@chaibuilder/sdk 3.1.16 → 3.1.18

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.
@@ -223,23 +223,23 @@ function insertBlocksAtPosition(o, n, r, a) {
223
223
  let i = [...o];
224
224
  if (r) {
225
225
  const u = o.find((g) => g._id === r);
226
- if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
226
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
227
227
  const f = {
228
228
  _id: generateUUID(),
229
229
  _parent: r,
230
230
  _type: "Text",
231
231
  content: u.content
232
232
  };
233
- Object.keys(u).forEach((m) => {
234
- m.startsWith("content-") && (f[m] = u[m]);
235
- }), l.unshift(f), i = i.map((m) => {
236
- if (m._id === r) {
237
- const x = { ...m, content: "" };
233
+ Object.keys(u).forEach((h) => {
234
+ h.startsWith("content-") && (f[h] = u[h]);
235
+ }), l.unshift(f), i = i.map((h) => {
236
+ if (h._id === r) {
237
+ const x = { ...h, content: "" };
238
238
  return Object.keys(x).forEach((b) => {
239
239
  b.startsWith("content-") && (x[b] = "");
240
240
  }), x;
241
241
  }
242
- return m;
242
+ return h;
243
243
  });
244
244
  }
245
245
  }
@@ -272,13 +272,13 @@ function moveNode(o, n, r, a) {
272
272
  const l = findNodeById(o, n), i = findNodeById(o, r);
273
273
  if (!l || !i) return !1;
274
274
  i.children || (i.model.children = []);
275
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
275
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
276
276
  l.drop(), c = Math.max(c, 0);
277
277
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
278
278
  try {
279
279
  i.addChildAtIndex(l, p);
280
- } catch (h) {
281
- return console.error("Error adding child to parent:", h), !1;
280
+ } catch (m) {
281
+ return console.error("Error adding child to parent:", m), !1;
282
282
  }
283
283
  return !0;
284
284
  }
@@ -319,8 +319,8 @@ function handleNewParentTextBlock(o, n, r) {
319
319
  const d = o.map((u) => {
320
320
  if (u._id === r) {
321
321
  const g = { ...u, content: "" };
322
- return Object.keys(g).forEach((h) => {
323
- h.startsWith("content-") && (g[h] = "");
322
+ return Object.keys(g).forEach((m) => {
323
+ m.startsWith("content-") && (g[m] = "");
324
324
  }), g;
325
325
  }
326
326
  return u;
@@ -337,7 +337,7 @@ function moveBlocksWithChildren(o, n, r, a) {
337
337
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
338
338
  if (moveNode(p, n, c, a)) {
339
339
  let u = flattenTree(p);
340
- const g = u.find((h) => h._id === n);
340
+ const g = u.find((m) => m._id === n);
341
341
  return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
342
342
  }
343
343
  return i;
@@ -361,22 +361,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
361
361
  }, removeNestedBlocks = (o, n) => {
362
362
  let r = [...o], a = [];
363
363
  n.forEach((d) => {
364
- const p = r.find((h) => h._id === d);
364
+ const p = r.find((m) => m._id === d);
365
365
  if (!p || !p._parent) return;
366
- const u = p._parent, g = r.filter((h) => h._parent === u);
366
+ const u = p._parent, g = r.filter((m) => m._parent === u);
367
367
  if (g.length === 2) {
368
- const h = g.find((f) => f._id !== d);
369
- if (h && h._type === "Text") {
370
- const f = r.find((m) => m._id === u);
371
- f && "content" in f && (r = r.map((m) => {
372
- if (m._id === u) {
373
- const x = { ...m, content: h.content };
374
- return Object.keys(h).forEach((b) => {
375
- b.startsWith("content-") && (x[b] = h[b]);
368
+ const m = g.find((f) => f._id !== d);
369
+ if (m && m._type === "Text") {
370
+ const f = r.find((h) => h._id === u);
371
+ f && "content" in f && (r = r.map((h) => {
372
+ if (h._id === u) {
373
+ const x = { ...h, content: m.content };
374
+ return Object.keys(m).forEach((b) => {
375
+ b.startsWith("content-") && (x[b] = m[b]);
376
376
  }), x;
377
377
  }
378
- return m;
379
- }), a.push(h._id));
378
+ return h;
379
+ }), a.push(m._id));
380
380
  }
381
381
  }
382
382
  });
@@ -458,34 +458,34 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
458
458
  status: "idle",
459
459
  props: {},
460
460
  error: void 0
461
- }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (m) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
461
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (h) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
462
462
  return useEffect(() => {
463
463
  if (n === "mock") {
464
464
  if (isFunction(a)) {
465
465
  i((x) => ({ ...x, status: "loading", props: {} }));
466
- const m = a({ block: o });
467
- if (!isObject(m))
466
+ const h = a({ block: o });
467
+ if (!isObject(h))
468
468
  throw new Error("mockDataProvider should return an object");
469
- i((x) => ({ ...x, status: "loaded", props: m }));
469
+ i((x) => ({ ...x, status: "loaded", props: h }));
470
470
  }
471
471
  return;
472
472
  }
473
- n === "live" && (!g && !h || (i((m) => ({ ...m, status: "loading", props: {} })), d({ block: o }).then((m = {}) => {
473
+ n === "live" && (!g && !m || (i((h) => ({ ...h, status: "loading", props: {} })), d({ block: o }).then((h = {}) => {
474
474
  g ? (p((x) => ({
475
475
  ...x,
476
476
  [o._id]: {
477
477
  status: "loaded",
478
- props: get(m, "items", []),
478
+ props: get(h, "items", []),
479
479
  repeaterItems: o.repeaterItems
480
480
  }
481
- })), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(m, "totalItems") } })), c([o._id], { totalItems: get(m, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(m) ? m : {} }));
482
- }).catch((m) => {
481
+ })), i((x) => ({ ...x, status: "loaded", props: { totalItems: get(h, "totalItems") } })), c([o._id], { totalItems: get(h, "totalItems") })) : i((x) => ({ ...x, status: "loaded", props: isObject(h) ? h : {} }));
482
+ }).catch((h) => {
483
483
  g ? (p((x) => ({
484
484
  ...x,
485
- [o._id]: { status: "error", error: m, props: [] }
486
- })), i((x) => ({ ...x, status: "error", error: m, props: {} }))) : i((x) => ({ ...x, status: "error", error: m, props: {} }));
485
+ [o._id]: { status: "error", error: h, props: [] }
486
+ })), i((x) => ({ ...x, status: "error", error: h, props: {} }))) : i((x) => ({ ...x, status: "error", error: h, props: {} }));
487
487
  })));
488
- }, [o == null ? void 0 : o._id, u, g, h, a, n]), {
488
+ }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
489
489
  $loading: get(l, "status") === "loading",
490
490
  ...o ? get(l, "props", {}) : {}
491
491
  };
@@ -638,19 +638,19 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
638
638
  return console.warn(`Failed to get block definition for type: ${r._type}`, a), !1;
639
639
  }
640
640
  }) : !1, useSavePage = () => {
641
- const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (m) => {
641
+ const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (h) => {
642
642
  }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
643
- const m = l();
644
- return !d || d === p ? !1 : checkMissingTranslations(m.blocks || [], d);
643
+ const h = l();
644
+ return !d || d === p ? !1 : checkMissingTranslations(h.blocks || [], d);
645
645
  };
646
646
  return { savePage: useThrottledCallback(
647
- async (m = !1, x = !1) => {
647
+ async (h = !1, x = !1) => {
648
648
  if (!x && (!c("save_page") || !u))
649
649
  return;
650
650
  n("SAVING"), a("SAVING");
651
651
  const b = l();
652
652
  return await r({
653
- autoSave: m,
653
+ autoSave: h,
654
654
  blocks: b.blocks,
655
655
  theme: i,
656
656
  needTranslations: g()
@@ -661,8 +661,8 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
661
661
  [l, n, i, r, a, u],
662
662
  3e3
663
663
  // save only every 5 seconds
664
- ), savePageAsync: async (m = !1) => {
665
- if (!m && (!c("save_page") || !u))
664
+ ), savePageAsync: async (h = !1) => {
665
+ if (!h && (!c("save_page") || !u))
666
666
  return;
667
667
  n("SAVING"), a("SAVING");
668
668
  const x = l();
@@ -727,13 +727,13 @@ const undoRedoStateAtom = atom({
727
727
  } = useBlocksStoreManager();
728
728
  return {
729
729
  moveBlocks: (x, b, y) => {
730
- const k = map(x, (v) => {
730
+ const S = map(x, (v) => {
731
731
  const E = n.find((A) => A._id === v)._parent || null, C = n.filter((A) => E ? A._parent === E : !A._parent).map((A) => A._id).indexOf(v);
732
732
  return { _id: v, oldParent: E, oldPosition: C };
733
- }), S = k.find(({ _id: v }) => v === x[0]);
734
- S && S.oldParent === b && S.oldPosition === y || (i(x, b, y), o({
735
- undo: () => each(k, ({ _id: v, oldParent: _, oldPosition: E }) => {
736
- i([v], _, E);
733
+ }), k = S.find(({ _id: v }) => v === x[0]);
734
+ k && k.oldParent === b && k.oldPosition === y || (i(x, b, y), o({
735
+ undo: () => each(S, ({ _id: v, oldParent: B, oldPosition: E }) => {
736
+ i([v], B, E);
737
737
  }),
738
738
  redo: () => i(x, b, y)
739
739
  }));
@@ -745,27 +745,27 @@ const undoRedoStateAtom = atom({
745
745
  });
746
746
  },
747
747
  removeBlocks: (x) => {
748
- var S;
749
- const b = (S = first(x)) == null ? void 0 : S._parent, k = n.filter((v) => b ? v._parent === b : !v._parent).indexOf(first(x));
748
+ var k;
749
+ const b = (k = first(x)) == null ? void 0 : k._parent, S = n.filter((v) => b ? v._parent === b : !v._parent).indexOf(first(x));
750
750
  l(map(x, "_id")), o({
751
- undo: () => a(x, b, k),
751
+ undo: () => a(x, b, S),
752
752
  redo: () => l(map(x, "_id"))
753
753
  });
754
754
  },
755
755
  updateBlocks: (x, b, y) => {
756
- let k = [];
756
+ let S = [];
757
757
  if (y)
758
- k = map(x, (S) => ({ _id: S, ...y }));
758
+ S = map(x, (k) => ({ _id: k, ...y }));
759
759
  else {
760
- const S = keys(b);
761
- k = map(x, (v) => {
762
- const _ = n.find((I) => I._id === v), E = { _id: v };
763
- return each(S, (I) => E[I] = _[I]), E;
760
+ const k = keys(b);
761
+ S = map(x, (v) => {
762
+ const B = n.find((I) => I._id === v), E = { _id: v };
763
+ return each(k, (I) => E[I] = B[I]), E;
764
764
  });
765
765
  }
766
- c(map(x, (S) => ({ _id: S, ...b }))), o({
767
- undo: () => c(k),
768
- redo: () => c(map(x, (S) => ({ _id: S, ...b })))
766
+ c(map(x, (k) => ({ _id: k, ...b }))), o({
767
+ undo: () => c(S),
768
+ redo: () => c(map(x, (k) => ({ _id: k, ...b })))
769
769
  });
770
770
  },
771
771
  updateBlocksRuntime: (x, b) => {
@@ -780,8 +780,8 @@ const undoRedoStateAtom = atom({
780
780
  updateMultipleBlocksProps: (x) => {
781
781
  let b = [];
782
782
  b = map(x, (y) => {
783
- const k = keys(y), S = n.find((_) => _._id === y._id), v = {};
784
- return each(k, (_) => v[_] = S[_]), v;
783
+ const S = keys(y), k = n.find((B) => B._id === y._id), v = {};
784
+ return each(S, (B) => v[B] = k[B]), v;
785
785
  }), c(x), o({
786
786
  undo: () => c(b),
787
787
  redo: () => c(x)
@@ -821,12 +821,12 @@ const useAddBlock = () => {
821
821
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
822
822
  (i, c, d) => {
823
823
  var f;
824
- for (let m = 0; m < i.length; m++) {
825
- const { _id: x } = i[m];
826
- i[m]._id = generateUUID();
824
+ for (let h = 0; h < i.length; h++) {
825
+ const { _id: x } = i[h];
826
+ i[h]._id = generateUUID();
827
827
  const b = filter(i, { _parent: x });
828
828
  for (let y = 0; y < b.length; y++)
829
- b[y]._parent = i[m]._id;
829
+ b[y]._parent = i[h]._id;
830
830
  }
831
831
  const p = first(i);
832
832
  let u, g;
@@ -847,8 +847,8 @@ const useAddBlock = () => {
847
847
  ...has(i, "_name") && { _name: i._name },
848
848
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
849
849
  };
850
- let h, f;
851
- return c && (h = find(o, { _id: c }), g._parent = c, f = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, f = h._parent), r([g], f, d), n([g._id]), g;
850
+ let m, f;
851
+ 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;
852
852
  },
853
853
  [r, a, o, n]
854
854
  ), addPredefinedBlock: a };
@@ -2273,19 +2273,19 @@ const getBlockWithChildren = (o, n) => {
2273
2273
  const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
2274
2274
  for (const u in a)
2275
2275
  if (!l.includes(u) && p.includes(u)) {
2276
- const g = get(a, `${u}-${n}`, ""), h = get(a, u, "");
2277
- d[u] = isString(g) && g.trim() || h, r && (d[u] = h);
2276
+ const g = get(a, `${u}-${n}`, ""), m = get(a, u, "");
2277
+ d[u] = isString(g) && g.trim() || m, r && (d[u] = m);
2278
2278
  }
2279
2279
  return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
2280
2280
  })
2281
2281
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2282
- 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, h = (f, m) => {
2283
- const x = cloneDeep(m.find((b) => b._id === f));
2282
+ 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) => {
2283
+ const x = cloneDeep(h.find((b) => b._id === f));
2284
2284
  for (const b in x) {
2285
2285
  const y = x[b];
2286
2286
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2287
- const { baseClasses: k, classes: S } = getSplitChaiClasses(y);
2288
- x[b] = compact(flattenDeep([k, S])).join(" ");
2287
+ const { baseClasses: S, classes: k } = getSplitChaiClasses(y);
2288
+ x[b] = compact(flattenDeep([S, k])).join(" ");
2289
2289
  } else
2290
2290
  b !== "_id" && delete x[b];
2291
2291
  }
@@ -2293,24 +2293,24 @@ const getBlockWithChildren = (o, n) => {
2293
2293
  };
2294
2294
  return {
2295
2295
  askAi: useCallback(
2296
- async (f, m, x, b) => {
2296
+ async (f, h, x, b) => {
2297
2297
  if (l) {
2298
2298
  n(!0), a(null);
2299
2299
  try {
2300
- const y = p === u ? "" : p, k = x.toLowerCase().includes("translate the content"), S = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(m, d)), p, k) : [h(m, d)], v = await l(f, addLangToPrompt(x, g, f), S, y), { blocks: _, error: E } = v;
2300
+ const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), k = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p, S) : [m(h, d)], v = await l(f, addLangToPrompt(x, g, f), k, y), { blocks: B, error: E } = v;
2301
2301
  if (E) {
2302
2302
  a(E);
2303
2303
  return;
2304
2304
  }
2305
2305
  if (f === "styles") {
2306
- const I = _.map((C) => {
2306
+ const I = B.map((C) => {
2307
2307
  for (const A in C)
2308
2308
  A !== "_id" && (C[A] = `${STYLES_KEY},${C[A]}`);
2309
2309
  return C;
2310
2310
  });
2311
2311
  c(I);
2312
2312
  } else
2313
- i(_);
2313
+ i(B);
2314
2314
  b && b(v);
2315
2315
  } catch (y) {
2316
2316
  a(y);
@@ -2388,7 +2388,7 @@ const getBlockWithChildren = (o, n) => {
2388
2388
  return [o, a];
2389
2389
  }, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
2390
2390
  const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useBuilderProp("flags.copyPaste", !0), c = useCallback(
2391
- (p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((h) => h._type === "PartialBlock" || h._type === "GlobalBlock")),
2391
+ (p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2392
2392
  [o]
2393
2393
  ), d = useCallback(
2394
2394
  async (p, u = !1) => {
@@ -2396,18 +2396,18 @@ const getBlockWithChildren = (o, n) => {
2396
2396
  if (isEmpty(p)) return;
2397
2397
  r(p), a([]);
2398
2398
  const g = {
2399
- _chai_copied_blocks: p.flatMap((h) => {
2400
- const f = getDuplicatedBlocks(o, h, null);
2399
+ _chai_copied_blocks: p.flatMap((m) => {
2400
+ const f = getDuplicatedBlocks(o, m, null);
2401
2401
  if (!u)
2402
2402
  return f;
2403
- let m = [];
2403
+ let h = [];
2404
2404
  for (const x of f)
2405
2405
  if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2406
2406
  let b = l(x.partialBlockId);
2407
- x._parent && (b == null ? void 0 : b.length) > 0 && (b = b.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), m = [...m, ...b];
2407
+ x._parent && (b == null ? void 0 : b.length) > 0 && (b = b.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), h = [...h, ...b];
2408
2408
  } else
2409
- m.push(x);
2410
- return m;
2409
+ h.push(x);
2410
+ return h;
2411
2411
  })
2412
2412
  };
2413
2413
  if (!i)
@@ -2454,8 +2454,8 @@ const getBlockWithChildren = (o, n) => {
2454
2454
  const g = filter(
2455
2455
  o,
2456
2456
  (f) => isString(l) ? f._parent === l : !f._parent
2457
- ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
2458
- r(h, l, g), i.push(get(h, "0._id", ""));
2457
+ ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
2458
+ r(m, l, g), i.push(get(m, "0._id", ""));
2459
2459
  }), n(i);
2460
2460
  },
2461
2461
  [o, n]
@@ -2584,14 +2584,14 @@ const getBlockWithChildren = (o, n) => {
2584
2584
  return map(i, (c) => {
2585
2585
  const d = o(c), p = a;
2586
2586
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2587
- return each(p, (h) => {
2588
- const f = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), m = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
2589
- u = u.replace(m, " ").replace(/\s+/g, " ").trim();
2590
- const x = first(h.split(":"));
2591
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
2592
- }), each(p, (h) => {
2593
- const f = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), m = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
2594
- g = g.replace(m, " ").replace(/\s+/g, " ").trim();
2587
+ return each(p, (m) => {
2588
+ const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
2589
+ u = u.replace(h, " ").replace(/\s+/g, " ").trim();
2590
+ const x = first(m.split(":"));
2591
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
2592
+ }), each(p, (m) => {
2593
+ const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
2594
+ g = g.replace(h, " ").replace(/\s+/g, " ").trim();
2595
2595
  }), {
2596
2596
  ids: [d._id],
2597
2597
  props: {
@@ -2747,9 +2747,9 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2747
2747
  o.tagName = d, o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
2748
2748
  const p = getRegisteredChaiBlock(c), u = n.find((g) => g._id === (l == null ? void 0 : l.value));
2749
2749
  if (u && o.attributes.push(
2750
- ...Object.entries(u).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, h]) => ({
2750
+ ...Object.entries(u).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
2751
2751
  key: g,
2752
- value: typeof h == "string" ? h : JSON.stringify(h)
2752
+ value: typeof m == "string" ? m : JSON.stringify(m)
2753
2753
  }))
2754
2754
  ), p && (p != null && p.description) && o.attributes.push({
2755
2755
  key: "about-this-component",
@@ -2783,7 +2783,7 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2783
2783
  if (!n) return "";
2784
2784
  const a = r != null && r.blockId ? `[data-block-id="${r.blockId}"]` : "#canvas", l = (g = (u = n.contentDocument) == null ? void 0 : u.querySelector(a)) == null ? void 0 : g[a === "#canvas" ? "innerHTML" : "outerHTML"];
2785
2785
  if (!l) return "";
2786
- const d = parse(l).map(cleanNode).filter((h) => h !== null).map((h) => transformNode(h, o, r));
2786
+ const d = parse(l).map(cleanNode).filter((m) => m !== null).map((m) => transformNode(m, o, r));
2787
2787
  let p = stringify(d);
2788
2788
  return p = p.replace(/#styles:,/g, "#styles:"), p.replace(/\s+/g, " ").trim();
2789
2789
  },
@@ -2797,13 +2797,13 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2797
2797
  const i = filter(n, { _type: r._type }), c = pick(r, l);
2798
2798
  return each(c, (d, p) => {
2799
2799
  const u = find(i, (g) => {
2800
- var m;
2801
- const h = typeof g[p] == "string" ? (m = g[p]) == null ? void 0 : m.trim().toLowerCase() : JSON.stringify(g[p]), f = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
2802
- return h === f;
2800
+ var h;
2801
+ const m = typeof g[p] == "string" ? (h = g[p]) == null ? void 0 : h.trim().toLowerCase() : JSON.stringify(g[p]), f = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
2802
+ return m === f;
2803
2803
  });
2804
2804
  if (u) {
2805
- const g = filter(Object.keys(u), (f) => startsWith(f, `${p}-`)), h = pick(u, g);
2806
- r = { ...r, ...h };
2805
+ const g = filter(Object.keys(u), (f) => startsWith(f, `${p}-`)), m = pick(u, g);
2806
+ r = { ...r, ...m };
2807
2807
  }
2808
2808
  }), r;
2809
2809
  }), useHtmlToBlocks = () => {
@@ -2885,7 +2885,7 @@ const getAllDescendantIds = (o, n) => {
2885
2885
  }, replaceBlock = (o, n, r) => {
2886
2886
  const a = find(o, { _id: n });
2887
2887
  if (!a) return o;
2888
- const l = o.findIndex((h) => h._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((h) => !c.has(h._id)), p = new Set(r.map((h) => h._id)), u = r.map((h) => !h._parent || !p.has(h._parent) ? { ...h, _parent: a._parent } : h);
2888
+ const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), u = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
2889
2889
  return [
2890
2890
  ...d.slice(0, l),
2891
2891
  ...u,
@@ -2980,12 +2980,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
2980
2980
  // Export Code
2981
2981
  OPEN_EXPORT_CODE: "OPEN_EXPORT_CODE"
2982
2982
  }, AddBlockDropdown = ({ block: o, children: n }) => {
2983
- const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (h) => {
2984
- if (h === "CHILD")
2983
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
2984
+ if (m === "CHILD")
2985
2985
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
2986
2986
  else {
2987
2987
  const f = { _id: c || "", position: d == null ? void 0 : d.length };
2988
- h === "BEFORE" ? f.position = Math.max(u, 0) : h === "AFTER" && (f.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, f);
2988
+ m === "BEFORE" ? f.position = Math.max(u, 0) : m === "AFTER" && (f.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, f);
2989
2989
  }
2990
2990
  };
2991
2991
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
@@ -3010,7 +3010,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
3010
3010
  let isDragging = !1;
3011
3011
  const setIsDragging = (o) => {
3012
3012
  isDragging = o;
3013
- };
3013
+ }, canvasRenderKeyAtom = atom(0);
3014
3014
  let lastDragHighlighted = null, floatingLabel = null;
3015
3015
  function createFloatingLabel(o, n) {
3016
3016
  const r = o.getAttribute("data-block-name"), a = o.getAttribute("data-block-type"), l = r || a || "Container", i = n.createElement("div");
@@ -3046,7 +3046,7 @@ const useDragParentHighlight = () => {
3046
3046
  lastDragHighlighted
3047
3047
  };
3048
3048
  }, useBlockDragEnd = () => {
3049
- const [, o] = useAtom$1(dragAndDropAtom), [, n] = useAtom$1(dropIndicatorAtom), [r] = useCanvasIframe(), { clearParentHighlight: a } = useDragParentHighlight(), l = r == null ? void 0 : r.contentDocument;
3049
+ const [, o] = useAtom$1(dragAndDropAtom), [, n] = useAtom$1(dropIndicatorAtom), [r] = useCanvasIframe(), { clearParentHighlight: a } = useDragParentHighlight(), [l, i] = useAtom$1(canvasRenderKeyAtom), c = r == null ? void 0 : r.contentDocument;
3050
3050
  return useCallback(() => {
3051
3051
  o(null), n({
3052
3052
  isVisible: !1,
@@ -3058,10 +3058,10 @@ const useDragParentHighlight = () => {
3058
3058
  left: 0,
3059
3059
  width: 0,
3060
3060
  height: 0
3061
- }), removeDropTargetAttributes$2(l), a(), l && l.querySelectorAll("[data-dragging]").forEach((c) => {
3062
- c.style.opacity = "", c.removeAttribute("data-dragging");
3063
- }), setIsDragging(!1);
3064
- }, [o, n, l, a]);
3061
+ }), removeDropTargetAttributes$2(c), a(), c && c.querySelectorAll("[data-dragging]").forEach((p) => {
3062
+ p.removeAttribute("data-dragging");
3063
+ }), setIsDragging(!1), i(l + 1);
3064
+ }, [o, n, c, a, l, i]);
3065
3065
  };
3066
3066
  function removeDropTargetAttributes$2(o) {
3067
3067
  if (!o) return;
@@ -3159,13 +3159,13 @@ function detectGapZone(o, n, r, a) {
3159
3159
  return a === "vertical" ? u.top - g.top : u.left - g.left;
3160
3160
  });
3161
3161
  for (let d = 0; d < c.length - 1; d++) {
3162
- const p = c[d], u = c[d + 1], g = p.getBoundingClientRect(), h = u.getBoundingClientRect();
3162
+ const p = c[d], u = c[d + 1], g = p.getBoundingClientRect(), m = u.getBoundingClientRect();
3163
3163
  if (a === "vertical") {
3164
- const f = g.bottom, m = h.top, x = m - f, b = r >= f && r <= m, y = n >= Math.min(g.left, h.left) && n <= Math.max(g.right, h.right);
3164
+ const f = g.bottom, h = m.top, x = h - f, b = r >= f && r <= h, y = n >= Math.min(g.left, m.left) && n <= Math.max(g.right, m.right);
3165
3165
  if (b && y && x >= ZONE_CONFIG.GAP_THRESHOLD)
3166
3166
  return { before: p, after: u };
3167
3167
  } else {
3168
- const f = g.right, m = h.left, x = m - f, b = n >= f && n <= m, y = r >= Math.min(g.top, h.top) && r <= Math.max(g.bottom, h.bottom);
3168
+ const f = g.right, h = m.left, x = h - f, b = n >= f && n <= h, y = r >= Math.min(g.top, m.top) && r <= Math.max(g.bottom, m.bottom);
3169
3169
  if (b && y && x >= ZONE_CONFIG.GAP_THRESHOLD)
3170
3170
  return { before: p, after: u };
3171
3171
  }
@@ -3174,12 +3174,12 @@ function detectGapZone(o, n, r, a) {
3174
3174
  for (let c = 0; c < l.length - 1; c++) {
3175
3175
  const d = l[c], p = l[c + 1], u = d.getBoundingClientRect(), g = p.getBoundingClientRect();
3176
3176
  if (a === "vertical") {
3177
- const h = u.bottom, f = g.top, m = f - h, x = r >= h && r <= f, b = n >= Math.min(u.left, g.left) && n <= Math.max(u.right, g.right);
3178
- if (x && b && m >= ZONE_CONFIG.GAP_THRESHOLD)
3177
+ const m = u.bottom, f = g.top, h = f - m, x = r >= m && r <= f, b = n >= Math.min(u.left, g.left) && n <= Math.max(u.right, g.right);
3178
+ if (x && b && h >= ZONE_CONFIG.GAP_THRESHOLD)
3179
3179
  return { before: d, after: p };
3180
3180
  } else {
3181
- const h = u.right, f = g.left, m = f - h, x = n >= h && n <= f, b = r >= Math.min(u.top, g.top) && r <= Math.max(u.bottom, g.bottom);
3182
- if (x && b && m >= ZONE_CONFIG.GAP_THRESHOLD)
3181
+ const m = u.right, f = g.left, h = f - m, x = n >= m && n <= f, b = r >= Math.min(u.top, g.top) && r <= Math.max(u.bottom, g.bottom);
3182
+ if (x && b && h >= ZONE_CONFIG.GAP_THRESHOLD)
3183
3183
  return { before: d, after: p };
3184
3184
  }
3185
3185
  }
@@ -3251,23 +3251,23 @@ function calculateElementZone(o, n, r, a, l) {
3251
3251
  }
3252
3252
  }
3253
3253
  function detectDropZone(o, n, r, a, l) {
3254
- var v, _, E, I;
3254
+ var v, B, E, I;
3255
3255
  const i = o.getAttribute("data-block-id"), c = o.getAttribute("data-block-type") || "Box";
3256
3256
  if (!i)
3257
3257
  return null;
3258
3258
  let d = o.parentElement;
3259
3259
  for (; d && !d.hasAttribute("data-block-id"); )
3260
3260
  d = d.parentElement;
3261
- const p = i === "canvas" ? i : d == null ? void 0 : d.getAttribute("data-block-id"), u = d ? getOrientation(d) : "vertical", g = getOrientation(o), h = isLeafBlock(c), f = !h && canAcceptChildBlock(c, a), m = ((v = l.defaultView) == null ? void 0 : v.scrollY) || 0, x = ((_ = l.defaultView) == null ? void 0 : _.scrollX) || 0;
3261
+ const p = i === "canvas" ? i : d == null ? void 0 : d.getAttribute("data-block-id"), u = d ? getOrientation(d) : "vertical", g = getOrientation(o), m = isLeafBlock(c), f = !m && canAcceptChildBlock(c, a), h = ((v = l.defaultView) == null ? void 0 : v.scrollY) || 0, x = ((B = l.defaultView) == null ? void 0 : B.scrollX) || 0;
3262
3262
  if (i === "canvas" && hasChildBlocks(o)) {
3263
3263
  const C = getChildBlocks(o), A = C[C.length - 1];
3264
3264
  if (A) {
3265
- const w = A.getBoundingClientRect(), B = o.getBoundingClientRect(), j = window.getComputedStyle(o), N = parseFloat(j.paddingLeft) || 0, L = parseFloat(j.paddingRight) || 0, D = B.width - N - L, P = B.left + x + N;
3265
+ const w = A.getBoundingClientRect(), j = o.getBoundingClientRect(), _ = window.getComputedStyle(o), N = parseFloat(_.paddingLeft) || 0, T = parseFloat(_.paddingRight) || 0, D = j.width - N - T, P = j.left + x + N;
3266
3266
  return {
3267
3267
  position: "after",
3268
3268
  placeholderOrientation: "horizontal",
3269
3269
  rect: {
3270
- top: w.bottom + m,
3270
+ top: w.bottom + h,
3271
3271
  left: P,
3272
3272
  width: D,
3273
3273
  height: 4
@@ -3280,22 +3280,22 @@ function detectDropZone(o, n, r, a, l) {
3280
3280
  };
3281
3281
  }
3282
3282
  }
3283
- if (f && !h && hasChildBlocks(o)) {
3283
+ if (f && !m && hasChildBlocks(o)) {
3284
3284
  const C = detectGapZone(o, n, r, g);
3285
3285
  if (C) {
3286
- const A = C.before.getBoundingClientRect(), w = C.after.getBoundingClientRect(), B = o.getBoundingClientRect(), j = window.getComputedStyle(o), N = parseFloat(j.paddingLeft) || 0, L = parseFloat(j.paddingRight) || 0, D = getChildBlocks(o), P = getSiblingsInSameRow(D, C.before, g);
3286
+ const A = C.before.getBoundingClientRect(), w = C.after.getBoundingClientRect(), j = o.getBoundingClientRect(), _ = window.getComputedStyle(o), N = parseFloat(_.paddingLeft) || 0, T = parseFloat(_.paddingRight) || 0, D = getChildBlocks(o), P = getSiblingsInSameRow(D, C.before, g);
3287
3287
  let R = 0;
3288
3288
  if (P.forEach((M) => {
3289
- const T = M.getBoundingClientRect();
3290
- T.height > R && (R = T.height);
3289
+ const L = M.getBoundingClientRect();
3290
+ L.height > R && (R = L.height);
3291
3291
  }), g === "vertical") {
3292
- const M = B.width - N - L, T = B.left + x + N;
3292
+ const M = j.width - N - T, L = j.left + x + N;
3293
3293
  return {
3294
3294
  position: "after",
3295
3295
  placeholderOrientation: "horizontal",
3296
3296
  rect: {
3297
- top: A.bottom + m,
3298
- left: T,
3297
+ top: A.bottom + h,
3298
+ left: L,
3299
3299
  width: M,
3300
3300
  height: 4
3301
3301
  },
@@ -3307,7 +3307,7 @@ function detectDropZone(o, n, r, a, l) {
3307
3307
  // High confidence for gap zones
3308
3308
  };
3309
3309
  } else {
3310
- const M = A.top + m, T = R > 0 ? R : Math.max(A.height, w.height);
3310
+ const M = A.top + h, L = R > 0 ? R : Math.max(A.height, w.height);
3311
3311
  return {
3312
3312
  position: "after",
3313
3313
  placeholderOrientation: "vertical",
@@ -3315,7 +3315,7 @@ function detectDropZone(o, n, r, a, l) {
3315
3315
  top: M,
3316
3316
  left: A.right + x,
3317
3317
  width: 4,
3318
- height: T
3318
+ height: L
3319
3319
  },
3320
3320
  targetElement: C.before,
3321
3321
  targetBlockId: C.before.getAttribute("data-block-id"),
@@ -3329,58 +3329,58 @@ function detectDropZone(o, n, r, a, l) {
3329
3329
  if (d && p) {
3330
3330
  const C = detectParentEdgeProximity(d, n, r, u);
3331
3331
  if (C) {
3332
- const A = d.getBoundingClientRect(), w = window.getComputedStyle(d), B = parseFloat(w.paddingLeft) || 0, j = parseFloat(w.paddingRight) || 0, N = parseFloat(w.paddingTop) || 0, L = parseFloat(w.paddingBottom) || 0, D = ((E = l.defaultView) == null ? void 0 : E.scrollY) || 0, P = ((I = l.defaultView) == null ? void 0 : I.scrollX) || 0, R = u === "vertical" ? "horizontal" : "vertical", M = getMaxSiblingDimensions(d);
3332
+ const A = d.getBoundingClientRect(), w = window.getComputedStyle(d), j = parseFloat(w.paddingLeft) || 0, _ = parseFloat(w.paddingRight) || 0, N = parseFloat(w.paddingTop) || 0, T = parseFloat(w.paddingBottom) || 0, D = ((E = l.defaultView) == null ? void 0 : E.scrollY) || 0, P = ((I = l.defaultView) == null ? void 0 : I.scrollX) || 0, R = u === "vertical" ? "horizontal" : "vertical", M = getMaxSiblingDimensions(d);
3333
3333
  if (C === "start") {
3334
- const T = getChildBlocks(d)[0];
3335
- if (T) {
3336
- const O = T.getBoundingClientRect();
3334
+ const L = getChildBlocks(d)[0];
3335
+ if (L) {
3336
+ const O = L.getBoundingClientRect();
3337
3337
  if (u === "vertical") {
3338
- const $ = A.width - B - j, H = A.left + P + B;
3338
+ const H = A.width - j - _, $ = A.left + P + j;
3339
3339
  return {
3340
3340
  position: "before",
3341
3341
  placeholderOrientation: R,
3342
3342
  rect: {
3343
3343
  top: O.top + D - 2,
3344
- left: H,
3345
- width: $,
3344
+ left: $,
3345
+ width: H,
3346
3346
  height: 4
3347
3347
  },
3348
- targetElement: T,
3349
- targetBlockId: T.getAttribute("data-block-id"),
3348
+ targetElement: L,
3349
+ targetBlockId: L.getAttribute("data-block-id"),
3350
3350
  targetParentId: p,
3351
3351
  confidence: 0.9
3352
3352
  };
3353
3353
  } else {
3354
- const $ = A.top + D + N, H = M.maxHeight > 0 ? M.maxHeight : A.height - N - L;
3354
+ const H = A.top + D + N, $ = M.maxHeight > 0 ? M.maxHeight : A.height - N - T;
3355
3355
  return {
3356
3356
  position: "before",
3357
3357
  placeholderOrientation: R,
3358
3358
  rect: {
3359
- top: $,
3359
+ top: H,
3360
3360
  left: O.left + P - 2,
3361
3361
  width: 4,
3362
- height: H
3362
+ height: $
3363
3363
  },
3364
- targetElement: T,
3365
- targetBlockId: T.getAttribute("data-block-id"),
3364
+ targetElement: L,
3365
+ targetBlockId: L.getAttribute("data-block-id"),
3366
3366
  targetParentId: p,
3367
3367
  confidence: 0.9
3368
3368
  };
3369
3369
  }
3370
3370
  }
3371
3371
  } else {
3372
- const T = getChildBlocks(d), O = T[T.length - 1];
3372
+ const L = getChildBlocks(d), O = L[L.length - 1];
3373
3373
  if (O) {
3374
- const $ = O.getBoundingClientRect();
3374
+ const H = O.getBoundingClientRect();
3375
3375
  if (u === "vertical") {
3376
- const H = A.width - B - j, F = A.left + P + B;
3376
+ const $ = A.width - j - _, F = A.left + P + j;
3377
3377
  return {
3378
3378
  position: "after",
3379
3379
  placeholderOrientation: R,
3380
3380
  rect: {
3381
- top: $.bottom + D - 2,
3381
+ top: H.bottom + D - 2,
3382
3382
  left: F,
3383
- width: H,
3383
+ width: $,
3384
3384
  height: 4
3385
3385
  },
3386
3386
  targetElement: O,
@@ -3389,13 +3389,13 @@ function detectDropZone(o, n, r, a, l) {
3389
3389
  confidence: 0.9
3390
3390
  };
3391
3391
  } else {
3392
- const H = A.top + D + N, F = M.maxHeight > 0 ? M.maxHeight : A.height - N - L;
3392
+ const $ = A.top + D + N, F = M.maxHeight > 0 ? M.maxHeight : A.height - N - T;
3393
3393
  return {
3394
3394
  position: "after",
3395
3395
  placeholderOrientation: R,
3396
3396
  rect: {
3397
- top: H,
3398
- left: $.right + P - 2,
3397
+ top: $,
3398
+ left: H.right + P - 2,
3399
3399
  width: 4,
3400
3400
  height: F
3401
3401
  },
@@ -3410,7 +3410,7 @@ function detectDropZone(o, n, r, a, l) {
3410
3410
  }
3411
3411
  }
3412
3412
  let b = calculateElementZone(o, n, r, f, u);
3413
- if (h && b.position === "inside") {
3413
+ if (m && b.position === "inside") {
3414
3414
  const C = o.getBoundingClientRect();
3415
3415
  u === "vertical" ? b = {
3416
3416
  position: (r - C.top) / C.height < 0.5 ? "before" : "after",
@@ -3422,20 +3422,20 @@ function detectDropZone(o, n, r, a, l) {
3422
3422
  }
3423
3423
  let y;
3424
3424
  b.position === "inside" ? y = g === "vertical" ? "horizontal" : "vertical" : y = u === "vertical" ? "horizontal" : "vertical";
3425
- const k = calculatePlaceholderRect(
3425
+ const S = calculatePlaceholderRect(
3426
3426
  o,
3427
3427
  d,
3428
3428
  b.position,
3429
3429
  y,
3430
3430
  l
3431
- ), S = b.position === "inside" ? i : p;
3431
+ ), k = b.position === "inside" ? i : p;
3432
3432
  return {
3433
3433
  position: b.position,
3434
3434
  placeholderOrientation: y,
3435
- rect: k,
3435
+ rect: S,
3436
3436
  targetElement: o,
3437
3437
  targetBlockId: i,
3438
- targetParentId: S,
3438
+ targetParentId: k,
3439
3439
  isEmpty: b.position === "inside" && !hasChildBlocks(o),
3440
3440
  confidence: b.confidence
3441
3441
  };
@@ -3449,20 +3449,20 @@ function findClosestSiblingInRow(o, n, r, a) {
3449
3449
  if (l.length === 0) {
3450
3450
  const d = /* @__PURE__ */ new Map();
3451
3451
  o.forEach((g) => {
3452
- const h = g.getBoundingClientRect(), f = Math.round(a === "vertical" ? h.top : h.left);
3452
+ const m = g.getBoundingClientRect(), f = Math.round(a === "vertical" ? m.top : m.left);
3453
3453
  d.has(f) || d.set(f, []), d.get(f).push(g);
3454
3454
  });
3455
3455
  let p = null, u = 1 / 0;
3456
- d.forEach((g, h) => {
3457
- const f = Math.abs(a === "vertical" ? r - h : n - h);
3456
+ d.forEach((g, m) => {
3457
+ const f = Math.abs(a === "vertical" ? r - m : n - m);
3458
3458
  f < u && (u = f, p = g);
3459
3459
  }), p && p.length > 0 && l.push(...p);
3460
3460
  }
3461
3461
  if (l.length === 0) return null;
3462
3462
  let i = l[0], c = 1 / 0;
3463
3463
  return l.forEach((d) => {
3464
- const p = d.getBoundingClientRect(), u = p.left + p.width / 2, g = p.top + p.height / 2, h = Math.sqrt(Math.pow(n - u, 2) + Math.pow(r - g, 2));
3465
- h < c && (c = h, i = d);
3464
+ const p = d.getBoundingClientRect(), u = p.left + p.width / 2, g = p.top + p.height / 2, m = Math.sqrt(Math.pow(n - u, 2) + Math.pow(r - g, 2));
3465
+ m < c && (c = m, i = d);
3466
3466
  }), i;
3467
3467
  }
3468
3468
  function getMaxSiblingDimensions(o) {
@@ -3483,15 +3483,15 @@ function getSiblingsInSameRow(o, n, r) {
3483
3483
  });
3484
3484
  }
3485
3485
  function calculatePlaceholderRect(o, n, r, a, l) {
3486
- var N, L;
3487
- const i = o.getBoundingClientRect(), c = window.getComputedStyle(o), d = ((N = l.defaultView) == null ? void 0 : N.scrollY) || 0, p = ((L = l.defaultView) == null ? void 0 : L.scrollX) || 0, u = parseFloat(c.marginTop) || 0, g = parseFloat(c.marginBottom) || 0, h = parseFloat(c.marginLeft) || 0, f = parseFloat(c.marginRight) || 0, m = parseFloat(c.paddingTop) || 0, x = parseFloat(c.paddingBottom) || 0, b = parseFloat(c.paddingLeft) || 0, y = parseFloat(c.paddingRight) || 0, k = n == null ? void 0 : n.getBoundingClientRect(), S = n && parseFloat(window.getComputedStyle(n).paddingLeft) || 0, v = n && parseFloat(window.getComputedStyle(n).paddingRight) || 0, _ = n && parseFloat(window.getComputedStyle(n).paddingTop) || 0, E = n && parseFloat(window.getComputedStyle(n).paddingBottom) || 0, I = n ? getMaxSiblingDimensions(n) : { maxWidth: 0, maxHeight: 0 }, C = n ? getOrientation(n) : "vertical", A = n ? getChildBlocks(n) : [], w = getSiblingsInSameRow(A, o, C);
3488
- let B = 0, j = 0;
3486
+ var N, T;
3487
+ const i = o.getBoundingClientRect(), c = window.getComputedStyle(o), d = ((N = l.defaultView) == null ? void 0 : N.scrollY) || 0, p = ((T = l.defaultView) == null ? void 0 : T.scrollX) || 0, u = parseFloat(c.marginTop) || 0, g = parseFloat(c.marginBottom) || 0, m = parseFloat(c.marginLeft) || 0, f = parseFloat(c.marginRight) || 0, h = parseFloat(c.paddingTop) || 0, x = parseFloat(c.paddingBottom) || 0, b = parseFloat(c.paddingLeft) || 0, y = parseFloat(c.paddingRight) || 0, S = n == null ? void 0 : n.getBoundingClientRect(), k = n && parseFloat(window.getComputedStyle(n).paddingLeft) || 0, v = n && parseFloat(window.getComputedStyle(n).paddingRight) || 0, B = n && parseFloat(window.getComputedStyle(n).paddingTop) || 0, E = n && parseFloat(window.getComputedStyle(n).paddingBottom) || 0, I = n ? getMaxSiblingDimensions(n) : { maxWidth: 0, maxHeight: 0 }, C = n ? getOrientation(n) : "vertical", A = n ? getChildBlocks(n) : [], w = getSiblingsInSameRow(A, o, C);
3488
+ let j = 0, _ = 0;
3489
3489
  if (w.forEach((D) => {
3490
3490
  const P = D.getBoundingClientRect();
3491
- P.height > B && (B = P.height), P.width > j && (j = P.width);
3491
+ P.height > j && (j = P.height), P.width > _ && (_ = P.width);
3492
3492
  }), r === "before")
3493
3493
  if (a === "horizontal") {
3494
- const D = k ? k.width - S - v : i.width, P = k ? k.left + p + S : i.left + p;
3494
+ const D = S ? S.width - k - v : i.width, P = S ? S.left + p + k : i.left + p;
3495
3495
  return {
3496
3496
  top: i.top + d - u - 2,
3497
3497
  left: P,
@@ -3499,17 +3499,17 @@ function calculatePlaceholderRect(o, n, r, a, l) {
3499
3499
  height: 4
3500
3500
  };
3501
3501
  } else {
3502
- const D = i.top + d, P = C === "horizontal" && B > 0 ? B : I.maxHeight > 0 ? I.maxHeight : k ? k.height - _ - E : i.height;
3502
+ const D = i.top + d, P = C === "horizontal" && j > 0 ? j : I.maxHeight > 0 ? I.maxHeight : S ? S.height - B - E : i.height;
3503
3503
  return {
3504
3504
  top: D,
3505
- left: i.left + p - h - 2,
3505
+ left: i.left + p - m - 2,
3506
3506
  width: 4,
3507
3507
  height: P
3508
3508
  };
3509
3509
  }
3510
3510
  else if (r === "after")
3511
3511
  if (a === "horizontal") {
3512
- const D = k ? k.width - S - v : i.width, P = k ? k.left + p + S : i.left + p;
3512
+ const D = S ? S.width - k - v : i.width, P = S ? S.left + p + k : i.left + p;
3513
3513
  return {
3514
3514
  top: i.bottom + d + g - 2,
3515
3515
  left: P,
@@ -3517,7 +3517,7 @@ function calculatePlaceholderRect(o, n, r, a, l) {
3517
3517
  height: 4
3518
3518
  };
3519
3519
  } else {
3520
- const D = i.top + d, P = C === "horizontal" && B > 0 ? B : I.maxHeight > 0 ? I.maxHeight : k ? k.height - _ - E : i.height;
3520
+ const D = i.top + d, P = C === "horizontal" && j > 0 ? j : I.maxHeight > 0 ? I.maxHeight : S ? S.height - B - E : i.height;
3521
3521
  return {
3522
3522
  top: D,
3523
3523
  left: i.right + p + f - 2,
@@ -3532,15 +3532,15 @@ function calculatePlaceholderRect(o, n, r, a, l) {
3532
3532
  width: i.width - b - y,
3533
3533
  height: 4
3534
3534
  } : {
3535
- top: i.top + d + m,
3535
+ top: i.top + d + h,
3536
3536
  left: i.right + p - y - 2,
3537
3537
  width: 4,
3538
- height: i.height - m - x
3538
+ height: i.height - h - x
3539
3539
  } : {
3540
- top: i.top + d + m,
3540
+ top: i.top + d + h,
3541
3541
  left: i.left + p + b,
3542
3542
  width: i.width - b - y,
3543
- height: Math.max(i.height - m - x, 20)
3543
+ height: Math.max(i.height - h - x, 20)
3544
3544
  };
3545
3545
  }
3546
3546
  function isDescendantOf(o, n, r) {
@@ -3583,64 +3583,105 @@ const LEAF_BLOCK_TYPES = [
3583
3583
  "Divider",
3584
3584
  "Repeater",
3585
3585
  "Video"
3586
- ], useBlockDragOver = () => {
3587
- const [o] = useAtom$1(dragAndDropAtom), [n] = useCanvasIframe(), [, r] = useAtom$1(dropIndicatorAtom), { clearParentHighlight: a, highlightParent: l } = useDragParentHighlight(), [i] = useBlocksStore(), c = n == null ? void 0 : n.contentDocument, d = useCallback(
3588
- throttle((p) => {
3586
+ ], AUTO_SCROLL_CONFIG = {
3587
+ /** Edge zone size in pixels where auto-scroll triggers */
3588
+ EDGE_ZONE: 50,
3589
+ /** Maximum scroll speed in pixels per frame */
3590
+ MAX_SCROLL_SPEED: 10,
3591
+ /** Minimum scroll speed in pixels per frame */
3592
+ MIN_SCROLL_SPEED: 10
3593
+ }, useBlockDragOver = () => {
3594
+ const [o] = useAtom$1(dragAndDropAtom), [n] = useCanvasIframe(), [, r] = useAtom$1(dropIndicatorAtom), { clearParentHighlight: a, highlightParent: l } = useDragParentHighlight(), [i] = useBlocksStore(), c = n == null ? void 0 : n.contentDocument, d = useRef(null), p = useRef(0), u = useCallback(
3595
+ (m) => {
3596
+ if (!(c != null && c.defaultView)) return;
3597
+ const f = c.defaultView, h = f.innerHeight, x = f.scrollY, b = c.documentElement.scrollHeight;
3598
+ p.current = m;
3599
+ const y = m, S = h - m;
3600
+ let k = !1, v = null, B = 0;
3601
+ if (y < AUTO_SCROLL_CONFIG.EDGE_ZONE && x > 0 ? (k = !0, v = "up", B = y) : S < AUTO_SCROLL_CONFIG.EDGE_ZONE && x + h < b && (k = !0, v = "down", B = S), !k && d.current !== null) {
3602
+ cancelAnimationFrame(d.current), d.current = null;
3603
+ return;
3604
+ }
3605
+ if (k && v) {
3606
+ const E = 1 - B / AUTO_SCROLL_CONFIG.EDGE_ZONE, I = AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED + (AUTO_SCROLL_CONFIG.MAX_SCROLL_SPEED - AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED) * E, C = () => {
3607
+ if (!isDragging || !f) {
3608
+ d.current = null;
3609
+ return;
3610
+ }
3611
+ const A = v === "up" ? -I : I;
3612
+ f.scrollBy(0, A);
3613
+ const w = f.scrollY, j = w > 0, _ = w + h < b, N = p.current, T = h - p.current;
3614
+ v === "up" && j && N < AUTO_SCROLL_CONFIG.EDGE_ZONE || v === "down" && _ && T < AUTO_SCROLL_CONFIG.EDGE_ZONE ? d.current = requestAnimationFrame(C) : d.current = null;
3615
+ };
3616
+ d.current === null && (d.current = requestAnimationFrame(C));
3617
+ }
3618
+ },
3619
+ [c]
3620
+ );
3621
+ useEffect(() => () => {
3622
+ d.current !== null && (cancelAnimationFrame(d.current), d.current = null);
3623
+ }, []), useEffect(() => {
3624
+ !isDragging && d.current !== null && (cancelAnimationFrame(d.current), d.current = null);
3625
+ }, [isDragging]);
3626
+ const g = useCallback(
3627
+ throttle((m) => {
3589
3628
  if (!isDragging || !o)
3590
3629
  return;
3591
3630
  a();
3592
- const u = getTargetDetail(p), { element: g, targetBlockId: h, targetParentId: f } = u;
3593
- if (!g || !h)
3631
+ const f = getTargetDetail(m), { element: h, targetBlockId: x, targetParentId: b } = f;
3632
+ if (!h || !x)
3594
3633
  return;
3595
- const m = o._id;
3596
- if (m && (h === m || isDescendantOf(h, m, i)))
3634
+ const y = o._id;
3635
+ if (y && (x === y || isDescendantOf(x, y, i)))
3597
3636
  return;
3598
- const x = o._type || o.type;
3599
- if (!x)
3637
+ const S = o._type || o.type;
3638
+ if (!S)
3600
3639
  return;
3601
- const b = p.clientX, y = p.clientY, k = detectDropZone(g, b, y, x, c);
3602
- if (!k)
3640
+ const k = m.clientX, v = m.clientY;
3641
+ u(v);
3642
+ const B = detectDropZone(h, k, v, S, c);
3643
+ if (!B)
3603
3644
  return;
3604
- const S = g.getAttribute("data-block-type") || "Box";
3605
- let v = !1;
3606
- const _ = LEAF_BLOCK_TYPES.includes(S);
3607
- if (k.position === "inside") {
3608
- if (_ || m && !canDropWithoutCircularReference(m, h, i))
3645
+ const E = h.getAttribute("data-block-type") || "Box";
3646
+ let I = !1;
3647
+ const C = LEAF_BLOCK_TYPES.includes(E);
3648
+ if (B.position === "inside") {
3649
+ if (C || y && !canDropWithoutCircularReference(y, x, i))
3609
3650
  return;
3610
- v = canAcceptChildBlock(S, x);
3651
+ I = canAcceptChildBlock(E, S);
3611
3652
  } else {
3612
- let I = g.parentElement, C = "Box";
3613
- for (; I && !I.hasAttribute("data-block-id"); )
3614
- I = I.parentElement;
3615
- if (I && (C = I.getAttribute("data-block-type") || "Box"), m && !canDropAsSiblingWithoutCircularReference(m, h, i))
3653
+ let w = h.parentElement, j = "Box";
3654
+ for (; w && !w.hasAttribute("data-block-id"); )
3655
+ w = w.parentElement;
3656
+ if (w && (j = w.getAttribute("data-block-type") || "Box"), y && !canDropAsSiblingWithoutCircularReference(y, x, i))
3616
3657
  return;
3617
- v = canAcceptChildBlock(C, x);
3658
+ I = canAcceptChildBlock(j, S);
3618
3659
  }
3619
- if (!v)
3660
+ if (!I)
3620
3661
  return;
3621
- l(k.targetParentId);
3622
- const E = k.targetParentId || f;
3662
+ l(B.targetParentId);
3663
+ const A = B.targetParentId || b;
3623
3664
  r({
3624
3665
  isVisible: !0,
3625
3666
  isValid: !0,
3626
- position: k.position,
3627
- placeholderOrientation: k.placeholderOrientation,
3628
- isEmpty: k.isEmpty,
3629
- top: k.rect.top,
3630
- left: k.rect.left,
3631
- width: k.rect.width,
3632
- height: k.rect.height,
3633
- targetBlockId: k.targetBlockId,
3634
- targetParentId: E
3635
- }), removeDropTargetAttributes$1(c), k.targetElement.setAttribute("data-drop-target", "true");
3667
+ position: B.position,
3668
+ placeholderOrientation: B.placeholderOrientation,
3669
+ isEmpty: B.isEmpty,
3670
+ top: B.rect.top,
3671
+ left: B.rect.left,
3672
+ width: B.rect.width,
3673
+ height: B.rect.height,
3674
+ targetBlockId: B.targetBlockId,
3675
+ targetParentId: A
3676
+ }), removeDropTargetAttributes$1(c), B.targetElement.setAttribute("data-drop-target", "true");
3636
3677
  }, 300),
3637
- [c, o, r, a, l, i]
3678
+ [c, o, r, a, l, i, u]
3638
3679
  );
3639
3680
  return useCallback(
3640
- (p) => {
3641
- p.preventDefault(), p.stopPropagation(), d(p);
3681
+ (m) => {
3682
+ m.preventDefault(), m.stopPropagation(), g(m);
3642
3683
  },
3643
- [d]
3684
+ [g]
3644
3685
  );
3645
3686
  };
3646
3687
  function getTargetDetail(o) {
@@ -3699,15 +3740,20 @@ const useBlockDragStart = () => {
3699
3740
  i.current && (cleanupDragImage(i.current), i.current = null);
3700
3741
  const u = p ? pick$1(d, ["type", "blocks"]) : d;
3701
3742
  if (a(u), c.dataTransfer.setData("text/plain", JSON.stringify({ block: u })), c.dataTransfer.effectAllowed = "move", !p && d._id) {
3702
- const h = (g = document.getElementById("canvas-iframe")) == null ? void 0 : g.contentDocument;
3703
- if (h) {
3704
- const f = h.querySelector(`[data-block-id="${d._id}"]`);
3705
- f && (f.style.opacity = "0.4", f.setAttribute("data-dragging", "true"));
3743
+ const m = (g = document.getElementById("canvas-iframe")) == null ? void 0 : g.contentDocument;
3744
+ if (m) {
3745
+ const f = m.querySelector(`[data-block-id="${d._id}"]`);
3746
+ f && setTimeout(() => {
3747
+ if (f) {
3748
+ const x = f.getBoundingClientRect().height;
3749
+ getOrientation(f == null ? void 0 : f.parentElement) === "vertical" && x > 200 && (f.style.height = "max-content", f.style.maxHeight = "max-content", f.style.minHeight = "0", f.style.overflow = "hidden", f.innerHTML = "<div class='flex items-center justify-center w-full h-full outline-[1px] outline-dashed font-medium outline-gray-500 bg-gray-500/10 py-4 text-transparent'>-</div>", f.style.opacity = "0.4"), f.style.opacity = "0.4", f.setAttribute("data-dragging", "true");
3750
+ }
3751
+ }, 0);
3706
3752
  }
3707
3753
  }
3708
3754
  if (d != null && d._type || d != null && d.type) {
3709
- const h = createCoreDragImage(d);
3710
- i.current = h, c.dataTransfer.setDragImage(h, 0, 0), setTimeout(() => {
3755
+ const m = createCoreDragImage(d);
3756
+ i.current = m, c.dataTransfer.setDragImage(m, 0, 0), setTimeout(() => {
3711
3757
  i.current && (cleanupDragImage(i.current), i.current = null);
3712
3758
  }, 50);
3713
3759
  }
@@ -3728,10 +3774,10 @@ const useBlockDragStart = () => {
3728
3774
  [o, r, a, l]
3729
3775
  );
3730
3776
  }, useBlockDrop = () => {
3731
- const [o, n] = useAtom$1(dragAndDropAtom), [r, a] = useAtom$1(dropIndicatorAtom), [l] = useBlocksStore(), [i] = useCanvasIframe(), { addCoreBlock: c } = useAddBlock(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [, p] = useSelectedBlockIds(), [, u] = useSelectedStylingBlocks(), { clearHighlight: g } = useBlockHighlight(), { clearParentHighlight: h } = useDragParentHighlight(), f = i == null ? void 0 : i.contentDocument;
3777
+ const [o, n] = useAtom$1(dragAndDropAtom), [r, a] = useAtom$1(dropIndicatorAtom), [l] = useBlocksStore(), [i] = useCanvasIframe(), { addCoreBlock: c } = useAddBlock(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [, p] = useSelectedBlockIds(), [, u] = useSelectedStylingBlocks(), { clearHighlight: g } = useBlockHighlight(), { clearParentHighlight: m } = useDragParentHighlight(), [f, h] = useAtom$1(canvasRenderKeyAtom), x = i == null ? void 0 : i.contentDocument;
3732
3778
  return useCallback(
3733
- (m) => {
3734
- if (m.preventDefault(), m.stopPropagation(), setIsDragging(!1), removeDropTargetAttributes(f), h(), a({
3779
+ (b) => {
3780
+ if (b.preventDefault(), b.stopPropagation(), setIsDragging(!1), restoreDraggedElementStyles(x), removeDropTargetAttributes(x), m(), a({
3735
3781
  isVisible: !1,
3736
3782
  isValid: !1,
3737
3783
  position: "inside",
@@ -3742,7 +3788,7 @@ const useBlockDragStart = () => {
3742
3788
  width: 0,
3743
3789
  height: 0
3744
3790
  }), setTimeout(() => {
3745
- h(), removeDropTargetAttributes(f), a({
3791
+ m(), removeDropTargetAttributes(x), a({
3746
3792
  isVisible: !1,
3747
3793
  isValid: !1,
3748
3794
  position: "inside",
@@ -3756,39 +3802,44 @@ const useBlockDragStart = () => {
3756
3802
  }, 50), !o)
3757
3803
  return;
3758
3804
  if (!r.isValid || !r.targetBlockId) {
3759
- h();
3805
+ m();
3760
3806
  return;
3761
3807
  }
3762
3808
  n(null);
3763
- const x = r.targetBlockId, b = r.targetParentId;
3764
- if (!x)
3809
+ const y = r.targetBlockId, S = r.targetParentId;
3810
+ if (!y)
3765
3811
  return;
3766
- const { parentId: y, index: k } = calculateInsertionIndex(
3812
+ const { parentId: k, index: v } = calculateInsertionIndex(
3767
3813
  l,
3768
- x,
3769
- b,
3814
+ y,
3815
+ S,
3770
3816
  r.position
3771
3817
  );
3772
3818
  if (o._id !== void 0)
3773
- d([o._id], y === null ? void 0 : y, k), g(), u([]), p([o._id]);
3819
+ d([o._id], k === null ? void 0 : k, v), g(), u([]), p([o._id]);
3774
3820
  else {
3775
- const v = o._type || o.type, _ = o != null && o.blocks ? isFunction$1(o == null ? void 0 : o.blocks) ? syncBlocksWithDefaults(o == null ? void 0 : o.blocks()) : o == null ? void 0 : o.blocks : null;
3776
- c((_ == null ? void 0 : _.length) > 0 ? { blocks: [..._] } : { type: v }, y, k);
3821
+ const E = o._type || o.type, I = o != null && o.blocks ? isFunction$1(o == null ? void 0 : o.blocks) ? syncBlocksWithDefaults(o == null ? void 0 : o.blocks()) : o == null ? void 0 : o.blocks : null;
3822
+ c((I == null ? void 0 : I.length) > 0 ? { blocks: [...I] } : { type: E }, k, v);
3777
3823
  }
3824
+ setTimeout(() => {
3825
+ h(f + 1);
3826
+ }, 50);
3778
3827
  },
3779
3828
  [
3780
3829
  o,
3781
3830
  r,
3782
3831
  l,
3783
- f,
3832
+ x,
3784
3833
  c,
3785
3834
  d,
3786
3835
  n,
3787
3836
  a,
3788
- h,
3837
+ m,
3789
3838
  g,
3790
3839
  p,
3791
- u
3840
+ u,
3841
+ f,
3842
+ h
3792
3843
  ]
3793
3844
  );
3794
3845
  };
@@ -3829,6 +3880,12 @@ function removeDropTargetAttributes(o) {
3829
3880
  if (!o) return;
3830
3881
  o.querySelectorAll("[data-drop-target]").forEach((r) => r.removeAttribute("data-drop-target"));
3831
3882
  }
3883
+ function restoreDraggedElementStyles(o) {
3884
+ if (!o) return;
3885
+ o.querySelectorAll("[data-dragging]").forEach((r) => {
3886
+ r.removeAttribute("data-dragging");
3887
+ });
3888
+ }
3832
3889
  const useDragAndDrop = () => {
3833
3890
  const o = useBlockDragStart(), n = useBlockDragOver(), r = useBlockDrop(), a = useBlockDragEnd();
3834
3891
  return {
@@ -3866,21 +3923,21 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
3866
3923
  return "VERTICAL";
3867
3924
  }
3868
3925
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3869
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), f = getParentBlockOrientation(c, i, a), m = useCallback(
3926
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), f = getParentBlockOrientation(c, i, a), h = useCallback(
3870
3927
  (x) => {
3871
- isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3928
+ isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3872
3929
  },
3873
- [g, h, p, u, i, c, n]
3930
+ [g, m, p, u, i, c, n]
3874
3931
  );
3875
3932
  return useHotkeys(
3876
3933
  "shift+up, shift+down, shift+left, shift+right",
3877
3934
  ({ key: x }) => {
3878
3935
  var b;
3879
- m((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3936
+ h((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
3880
3937
  },
3881
3938
  { document: a == null ? void 0 : a.contentDocument },
3882
- [m]
3883
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: m, orientation: f };
3939
+ [h]
3940
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: h, orientation: f };
3884
3941
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
3885
3942
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
3886
3943
  o,
@@ -3985,20 +4042,20 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3985
4042
  }
3986
4043
  );
3987
4044
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), BlockSelectionHighlighter = () => {
3988
- const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), { onDragStart: c, onDragEnd: d, isDragging: p } = useDragAndDrop(), [u, g] = useState(null), h = useIsDragAndDropEnabled(), f = (m, x = 0) => {
3989
- const { top: b } = m.getBoundingClientRect();
4045
+ const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), { onDragStart: c, onDragEnd: d, isDragging: p } = useDragAndDrop(), [u, g] = useState(null), m = useIsDragAndDropEnabled(), f = (h, x = 0) => {
4046
+ const { top: b } = h.getBoundingClientRect();
3990
4047
  return b + x >= 0 && b - x <= window.innerHeight;
3991
4048
  };
3992
4049
  return useEffect(() => {
3993
- var m;
4050
+ var h;
3994
4051
  if (o != null && o._id && o.type !== "Multiple" && n) {
3995
4052
  const x = getElementByDataBlockId(n, o._id);
3996
- x && (f(x) || (m = n.defaultView) == null || m.scrollTo({ top: x.offsetTop, behavior: "smooth" }), l([x]));
4053
+ x && (f(x) || (h = n.defaultView) == null || h.scrollTo({ top: x.offsetTop, behavior: "smooth" }), l([x]));
3997
4054
  }
3998
4055
  }, [o == null ? void 0 : o._id, o == null ? void 0 : o.type, n]), useEffect(() => {
3999
4056
  if (!isEmpty(r) && n) {
4000
- const m = getElementByStyleId(n, first(r).id);
4001
- i(m ? [m] : [null]);
4057
+ const h = getElementByStyleId(n, first(r).id);
4058
+ i(h ? [h] : [null]);
4002
4059
  } else
4003
4060
  i([null]);
4004
4061
  }, [r, n]), /* @__PURE__ */ jsx(
@@ -4007,9 +4064,9 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4007
4064
  onDragEnd: () => {
4008
4065
  g(null), d();
4009
4066
  },
4010
- draggable: h && !!o,
4011
- onDragStart: (m) => {
4012
- g(a == null ? void 0 : a[0]), c(m, o, !1);
4067
+ draggable: m && !!o,
4068
+ onDragStart: (h) => {
4069
+ g(a == null ? void 0 : a[0]), c(h, o, !1);
4013
4070
  },
4014
4071
  children: /* @__PURE__ */ jsx(
4015
4072
  BlockFloatingSelector,
@@ -4022,7 +4079,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4022
4079
  }
4023
4080
  );
4024
4081
  }, BlockFloatingSelector = ({ block: o, isDragging: n, selectedBlockElement: r }) => {
4025
- const a = useRemoveBlocks(), l = useDuplicateBlocks(), [, i] = useSelectedBlockIds(), [, c] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: p } = usePermissions(), { editingBlockId: u } = useInlineEditing(), { document: g } = useFrame(), h = useIsDragAndDropEnabled(), f = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: m, refs: x, update: b } = useFloating({
4082
+ const a = useRemoveBlocks(), l = useDuplicateBlocks(), [, i] = useSelectedBlockIds(), [, c] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: p } = usePermissions(), { editingBlockId: u } = useInlineEditing(), { document: g } = useFrame(), m = useIsDragAndDropEnabled(), f = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: h, refs: x, update: b } = useFloating({
4026
4083
  placement: "top-start",
4027
4084
  middleware: [
4028
4085
  shift({
@@ -4039,10 +4096,10 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4039
4096
  }),
4040
4097
  size({
4041
4098
  boundary: g == null ? void 0 : g.body,
4042
- apply({ availableWidth: v, availableHeight: _, elements: E }) {
4099
+ apply({ availableWidth: v, availableHeight: B, elements: E }) {
4043
4100
  Object.assign(E.floating.style, {
4044
4101
  maxWidth: `${Math.max(200, v)}px`,
4045
- maxHeight: `${Math.max(100, _)}px`
4102
+ maxHeight: `${Math.max(100, B)}px`
4046
4103
  });
4047
4104
  }
4048
4105
  })
@@ -4050,7 +4107,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4050
4107
  elements: { reference: r }
4051
4108
  });
4052
4109
  useResizeObserver(r, () => b(), r !== null), useResizeObserver(g == null ? void 0 : g.body, () => b(), (g == null ? void 0 : g.body) !== null);
4053
- const y = get(o, "_parent", null), k = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
4110
+ const y = get(o, "_parent", null), S = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
4054
4111
  useEffect(() => {
4055
4112
  if (r) {
4056
4113
  const v = setTimeout(() => b(), 500);
@@ -4058,14 +4115,14 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4058
4115
  } else
4059
4116
  b();
4060
4117
  }, [r]);
4061
- const [, S] = useSidebarActivePanel();
4118
+ const [, k] = useSidebarActivePanel();
4062
4119
  return !n && (!r || !o || u) ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4063
4120
  "div",
4064
4121
  {
4065
4122
  role: "button",
4066
4123
  tabIndex: 0,
4067
4124
  ref: x.setFloating,
4068
- style: m,
4125
+ style: h,
4069
4126
  onClick: (v) => {
4070
4127
  v.stopPropagation(), v.preventDefault();
4071
4128
  },
@@ -4076,7 +4133,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4076
4133
  className: `isolate z-[999] flex h-6 items-center justify-between bg-blue-500 py-2 text-xs text-white ${n ? "opacity-0" : ""}`,
4077
4134
  children: /* @__PURE__ */ jsxs(Fragment, { children: [
4078
4135
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
4079
- h && /* @__PURE__ */ jsx(DragHandleDots2Icon, { className: "flex-shrink-0 cursor-grab rounded p-0.5 hover:bg-white/20 active:cursor-grabbing" }),
4136
+ m && /* @__PURE__ */ jsx(DragHandleDots2Icon, { className: "flex-shrink-0 cursor-grab rounded p-0.5 hover:bg-white/20 active:cursor-grabbing" }),
4080
4137
  y && /* @__PURE__ */ jsx(
4081
4138
  ArrowUpIcon,
4082
4139
  {
@@ -4087,14 +4144,14 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4087
4144
  }
4088
4145
  )
4089
4146
  ] }),
4090
- /* @__PURE__ */ jsx("div", { className: `w-full ${h ? "cursor-grab active:cursor-grabbing" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "mr-10 w-full items-center space-x-1 px-1 leading-tight", children: k }) }),
4147
+ /* @__PURE__ */ jsx("div", { className: `w-full ${m ? "cursor-grab active:cursor-grabbing" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "mr-10 w-full items-center space-x-1 px-1 leading-tight", children: S }) }),
4091
4148
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pl-1 pr-1.5", children: [
4092
4149
  p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
4093
4150
  AiIcon,
4094
4151
  {
4095
4152
  className: "h-4 w-4 rounded hover:bg-white hover:text-blue-500",
4096
4153
  onClick: () => {
4097
- S("chai-chat-panel"), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_AI_PANEL);
4154
+ k("chai-chat-panel"), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_AI_PANEL);
4098
4155
  }
4099
4156
  }
4100
4157
  ),
@@ -4105,7 +4162,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4105
4162
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500"
4106
4163
  }
4107
4164
  ),
4108
- !h && /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500" }) }),
4165
+ !m && /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500" }) }),
4109
4166
  canDuplicateBlock(get(o, "_type", "")) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
4110
4167
  CopyIcon,
4111
4168
  {
@@ -4322,7 +4379,7 @@ V(Frame, "defaultProps", {
4322
4379
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
4323
4380
  });
4324
4381
  const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
4325
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), f = o ? { document: o } : {};
4382
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
4326
4383
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
4327
4384
  "ctrl+c,command+c",
4328
4385
  () => u(n),
@@ -4331,17 +4388,17 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4331
4388
  ), useHotkeys(
4332
4389
  "ctrl+v,command+v",
4333
4390
  () => {
4334
- g(n[0]) && h(n);
4391
+ g(n[0]) && m(n);
4335
4392
  },
4336
4393
  { ...f, enabled: !isEmpty(n), preventDefault: !0 },
4337
- [n, g, h]
4394
+ [n, g, m]
4338
4395
  ), useHotkeys("esc", () => r([]), f, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...f, enabled: !isEmpty(n), preventDefault: !0 }, [
4339
4396
  n,
4340
4397
  i
4341
4398
  ]), useHotkeys(
4342
4399
  "del, backspace",
4343
- (m) => {
4344
- m.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
4400
+ (h) => {
4401
+ h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
4345
4402
  },
4346
4403
  f,
4347
4404
  [n, l]
@@ -4472,9 +4529,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
4472
4529
  }, useDirectBlockDrag = () => {
4473
4530
  const [, o] = useSelectedBlockIds(), { onDragStart: n, onDragEnd: r } = useDragAndDrop(), [a] = useBlocksStore(), l = useRef(null), i = useCallback(
4474
4531
  (p) => {
4475
- var h;
4532
+ var m;
4476
4533
  if (p.button !== 0) return;
4477
- const g = (h = p.target.closest("[data-block-id]")) == null ? void 0 : h.getAttribute("data-block-id");
4534
+ const g = (m = p.target.closest("[data-block-id]")) == null ? void 0 : m.getAttribute("data-block-id");
4478
4535
  g && (o([g]), l.current = g);
4479
4536
  },
4480
4537
  [o]
@@ -4525,16 +4582,16 @@ const RteDropdownMenu = ({
4525
4582
  }) => {
4526
4583
  const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
4527
4584
  if (useEffect(() => {
4528
- var k, S;
4585
+ var S, k;
4529
4586
  if (!p) {
4530
4587
  d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
4531
4588
  return;
4532
4589
  }
4533
- const h = (k = g.current) == null ? void 0 : k.getBoundingClientRect(), f = (S = l.current) == null ? void 0 : S.getBoundingClientRect();
4534
- let m = h == null ? void 0 : h.left, x = (h == null ? void 0 : h.bottom) + 4, b, y;
4535
- (f == null ? void 0 : f.left) + (f == null ? void 0 : f.width) + 50 >= i.body.offsetWidth && (m = void 0, b = i.body.offsetWidth - (h == null ? void 0 : h.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (h == null ? void 0 : h.bottom) + (f == null ? void 0 : f.height)), d({ left: m, top: x, right: b, bottom: y });
4590
+ const m = (S = g.current) == null ? void 0 : S.getBoundingClientRect(), f = (k = l.current) == null ? void 0 : k.getBoundingClientRect();
4591
+ let h = m == null ? void 0 : m.left, x = (m == null ? void 0 : m.bottom) + 4, b, y;
4592
+ (f == null ? void 0 : f.left) + (f == null ? void 0 : f.width) + 50 >= i.body.offsetWidth && (h = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (f == null ? void 0 : f.height)), d({ left: h, top: x, right: b, bottom: y });
4536
4593
  }, [p]), a === "canvas") {
4537
- const h = () => {
4594
+ const m = () => {
4538
4595
  u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
4539
4596
  };
4540
4597
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4544,7 +4601,7 @@ const RteDropdownMenu = ({
4544
4601
  "div",
4545
4602
  {
4546
4603
  id: "chaibuilder-rte-dropdown-menu-content",
4547
- onClick: h,
4604
+ onClick: m,
4548
4605
  className: "fixed inset-0 left-0 top-0 z-[10001] h-full w-screen",
4549
4606
  children: /* @__PURE__ */ jsx(
4550
4607
  "div",
@@ -4555,7 +4612,7 @@ const RteDropdownMenu = ({
4555
4612
  {},
4556
4613
  { left: c.left, top: c.top, right: c.right, bottom: c.bottom }
4557
4614
  ),
4558
- children: typeof r == "function" ? r(h) : r
4615
+ children: typeof r == "function" ? r(m) : r
4559
4616
  }
4560
4617
  )
4561
4618
  }
@@ -4639,13 +4696,13 @@ const getActiveClasses$1 = (o, n, r) => {
4639
4696
  onRemoveHighlightColor: i,
4640
4697
  onClose: c
4641
4698
  }) => {
4642
- const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((m) => get(m, d ? "1" : "0")), [h, f] = useState("TEXT");
4699
+ const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((h) => get(h, d ? "1" : "0")), [m, f] = useState("TEXT");
4643
4700
  return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
4644
4701
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
4645
4702
  /* @__PURE__ */ jsx(
4646
4703
  "div",
4647
4704
  {
4648
- className: `w-full cursor-pointer rounded p-0.5 text-center ${h === "TEXT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
4705
+ className: `w-full cursor-pointer rounded p-0.5 text-center ${m === "TEXT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
4649
4706
  onClick: () => f("TEXT"),
4650
4707
  children: "Text Color"
4651
4708
  }
@@ -4653,13 +4710,13 @@ const getActiveClasses$1 = (o, n, r) => {
4653
4710
  /* @__PURE__ */ jsx(
4654
4711
  "div",
4655
4712
  {
4656
- className: `w-full cursor-pointer rounded p-0.5 text-center ${h === "HIGHLIGHT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
4713
+ className: `w-full cursor-pointer rounded p-0.5 text-center ${m === "HIGHLIGHT" ? "bg-blue-500 text-white" : "hover:bg-blue-100 hover:text-blue-500"}`,
4657
4714
  onClick: () => f("HIGHLIGHT"),
4658
4715
  children: "Highlight Color"
4659
4716
  }
4660
4717
  )
4661
4718
  ] }),
4662
- h === "TEXT" ? /* @__PURE__ */ jsx(
4719
+ m === "TEXT" ? /* @__PURE__ */ jsx(
4663
4720
  Commons,
4664
4721
  {
4665
4722
  themeColors: g,
@@ -4680,11 +4737,11 @@ const getActiveClasses$1 = (o, n, r) => {
4680
4737
  )
4681
4738
  ] });
4682
4739
  }, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
4683
- var S, v;
4684
- const a = (S = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : S.color, l = (v = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : v.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [h, f] = useDebouncedState(d, 150), m = (_, E) => {
4685
- E ? (c(_), g(_)) : (o == null || o.chain().setColor(_).run(), c(_));
4686
- }, x = (_, E) => {
4687
- E ? (p(_), f(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
4740
+ var k, v;
4741
+ const a = (k = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : k.color, l = (v = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : v.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [m, f] = useDebouncedState(d, 150), h = (B, E) => {
4742
+ E ? (c(B), g(B)) : (o == null || o.chain().setColor(B).run(), c(B));
4743
+ }, x = (B, E) => {
4744
+ E ? (p(B), f(B)) : (o == null || o.chain().setHighlight({ color: B }).run(), p(B));
4688
4745
  }, b = () => {
4689
4746
  o == null || o.chain().unsetColor().run(), c("#000000F2");
4690
4747
  }, y = () => {
@@ -4693,8 +4750,8 @@ const getActiveClasses$1 = (o, n, r) => {
4693
4750
  return useEffect(() => {
4694
4751
  l && p(l);
4695
4752
  }, [l]), useEffect(() => {
4696
- h != null && h.includes("#") && (h == null ? void 0 : h.length) >= 3 && (o == null || o.chain().setHighlight({ color: h }).run());
4697
- }, [h]), useEffect(() => {
4753
+ m != null && m.includes("#") && (m == null ? void 0 : m.length) >= 3 && (o == null || o.chain().setHighlight({ color: m }).run());
4754
+ }, [m]), useEffect(() => {
4698
4755
  u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
4699
4756
  }, [u]), /* @__PURE__ */ jsx(
4700
4757
  RteDropdownMenu,
@@ -4714,16 +4771,16 @@ const getActiveClasses$1 = (o, n, r) => {
4714
4771
  ),
4715
4772
  /* @__PURE__ */ jsx(CaretDownIcon, { className: "h-3 w-3 opacity-50" })
4716
4773
  ] }),
4717
- content: (_) => /* @__PURE__ */ jsx(
4774
+ content: (B) => /* @__PURE__ */ jsx(
4718
4775
  ColorPickerContent,
4719
4776
  {
4720
4777
  textColor: i,
4721
4778
  highlightColor: d,
4722
- onChangeTextColor: m,
4779
+ onChangeTextColor: h,
4723
4780
  onChangeHighlightColor: x,
4724
4781
  onRemoveTextColor: b,
4725
4782
  onRemoveHighlightColor: y,
4726
- onClose: _
4783
+ onClose: B
4727
4784
  }
4728
4785
  )
4729
4786
  }
@@ -5041,8 +5098,8 @@ const RichTextEditor = memo(
5041
5098
  placeholder: "Enter text here",
5042
5099
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
5043
5100
  onBlur: ({ editor: u, event: g }) => {
5044
- const h = g == null ? void 0 : g.relatedTarget, f = i.querySelector(".ProseMirror"), m = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = f == null ? void 0 : f.contains(h), y = m == null ? void 0 : m.contains(h), k = x == null ? void 0 : x.contains(h), S = window.document.getElementById("rte-widget-color-picker");
5045
- if (!b && !y && !k && !S) {
5101
+ const m = g == null ? void 0 : g.relatedTarget, f = i.querySelector(".ProseMirror"), h = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = f == null ? void 0 : f.contains(m), y = h == null ? void 0 : h.contains(m), S = x == null ? void 0 : x.contains(m), k = window.document.getElementById("rte-widget-color-picker");
5102
+ if (!b && !y && !S && !k) {
5046
5103
  const v = (u == null ? void 0 : u.getHTML()) || "";
5047
5104
  r(v);
5048
5105
  }
@@ -5050,19 +5107,19 @@ const RichTextEditor = memo(
5050
5107
  from: "canvas"
5051
5108
  });
5052
5109
  useEffect(() => {
5053
- var g, h;
5110
+ var g, m;
5054
5111
  const u = getInitialTextAlign(n);
5055
- u && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(u)), (h = c == null ? void 0 : c.commands) == null || h.focus(), c == null || c.emit("focus", {
5112
+ u && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(u)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
5056
5113
  editor: c,
5057
5114
  event: new FocusEvent("focus"),
5058
5115
  transaction: []
5059
5116
  });
5060
5117
  }, [c]);
5061
5118
  const d = useMemo(() => {
5062
- var h;
5119
+ var m;
5063
5120
  const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
5064
5121
  if (!n) return u;
5065
- const g = ((h = n == null ? void 0 : n.className) == null ? void 0 : h.replace("sr-only", "")) || "";
5122
+ const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
5066
5123
  return `${u} ${g}`;
5067
5124
  }, [n]), p = (u) => {
5068
5125
  u.key === "Escape" && l(u);
@@ -5094,14 +5151,14 @@ const RichTextEditor = memo(
5094
5151
  useEffect(() => {
5095
5152
  if (a.current) {
5096
5153
  a.current.innerHTML = n, a.current.focus();
5097
- const f = c.createRange(), m = d.getSelection();
5098
- f.selectNodeContents(a.current), f.collapse(!1), m == null || m.removeAllRanges(), m == null || m.addRange(f), a.current.focus();
5154
+ const f = c.createRange(), h = d.getSelection();
5155
+ f.selectNodeContents(a.current), f.collapse(!1), h == null || h.removeAllRanges(), h == null || h.addRange(f), a.current.focus();
5099
5156
  } else
5100
5157
  r();
5101
5158
  }, [c, d]);
5102
5159
  const p = useMemo(() => {
5103
- var m;
5104
- const f = ((m = o == null ? void 0 : o.tagName) == null ? void 0 : m.toLowerCase()) || "div";
5160
+ var h;
5161
+ const f = ((h = o == null ? void 0 : o.tagName) == null ? void 0 : h.toLowerCase()) || "div";
5105
5162
  return f === "button" ? "div" : f;
5106
5163
  }, [o]), u = useCallback(
5107
5164
  (f) => {
@@ -5110,19 +5167,19 @@ const RichTextEditor = memo(
5110
5167
  [i]
5111
5168
  ), g = useCallback(() => {
5112
5169
  r();
5113
- }, [r]), h = useMemo(() => {
5170
+ }, [r]), m = useMemo(() => {
5114
5171
  var f;
5115
5172
  return {
5116
5173
  id: "active-inline-editing-element",
5117
5174
  contentEditable: !0,
5118
5175
  className: `${((f = o == null ? void 0 : o.className) == null ? void 0 : f.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
5119
5176
  style: cloneDeep(o == null ? void 0 : o.style) || {},
5120
- onInput: (m) => {
5121
- const x = m.target;
5122
- x && (x.innerText.trim() === "" ? (x.setAttribute("data-placeholder", "Enter text here"), x.children.length > 0 && x.children[0].remove()) : m.target.removeAttribute("data-placeholder"), l(m.target.innerText));
5177
+ onInput: (h) => {
5178
+ const x = h.target;
5179
+ x && (x.innerText.trim() === "" ? (x.setAttribute("data-placeholder", "Enter text here"), x.children.length > 0 && x.children[0].remove()) : h.target.removeAttribute("data-placeholder"), l(h.target.innerText));
5123
5180
  },
5124
- onClick: (m) => {
5125
- m.stopPropagation(), m.preventDefault();
5181
+ onClick: (h) => {
5182
+ h.stopPropagation(), h.preventDefault();
5126
5183
  }
5127
5184
  };
5128
5185
  }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
@@ -5130,29 +5187,29 @@ const RichTextEditor = memo(
5130
5187
  ref: a,
5131
5188
  onBlur: g,
5132
5189
  onKeyDown: u,
5133
- ...h
5190
+ ...m
5134
5191
  }) });
5135
5192
  }
5136
5193
  ), WithBlockTextEditor = memo(
5137
5194
  ({ block: o, children: n }) => {
5138
- const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), f = useUpdateBlocksProps(), { selectedLang: m } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: k, blockType: S } = useMemo(() => {
5139
- var j;
5195
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), f = useUpdateBlocksProps(), { selectedLang: h } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: k } = useMemo(() => {
5196
+ var _;
5140
5197
  const C = o._type;
5141
5198
  let A = o[r];
5142
5199
  const w = getRegisteredChaiBlock(o._type);
5143
- return m && ((j = w == null ? void 0 : w.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${m}`) && (A = get(o, `${r}-${m}`)), { blockContent: A, blockType: C };
5144
- }, [o, m]), v = useCallback(
5200
+ return h && ((_ = w == null ? void 0 : w.i18nProps) == null ? void 0 : _.includes(r)) && has(o, `${r}-${h}`) && (A = get(o, `${r}-${h}`)), { blockContent: A, blockType: C };
5201
+ }, [o, h]), v = useCallback(
5145
5202
  (C) => {
5146
5203
  var w;
5147
5204
  const A = C || ((w = g.current) == null ? void 0 : w.innerText);
5148
5205
  f([y], { [r]: A }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
5149
5206
  },
5150
- [y, f, c, x, m]
5151
- ), _ = useDebouncedCallback(
5207
+ [y, f, c, x, h]
5208
+ ), B = useDebouncedCallback(
5152
5209
  (C) => {
5153
5210
  f([y], { [r]: C });
5154
5211
  },
5155
- [y, o, f, m],
5212
+ [y, o, f, h],
5156
5213
  1e3
5157
5214
  ), E = useCallback(
5158
5215
  (C) => {
@@ -5161,20 +5218,20 @@ const RichTextEditor = memo(
5161
5218
  b.current = null, x([A]);
5162
5219
  }, 100);
5163
5220
  },
5164
- [x, y, m]
5221
+ [x, y, h]
5165
5222
  );
5166
5223
  useEffect(() => {
5167
- var B;
5224
+ var j;
5168
5225
  if (!y) return;
5169
5226
  const C = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "", w = a.querySelector(`${C}${A}`);
5170
- w && ((B = w == null ? void 0 : w.classList) == null || B.add("sr-only"), u(w));
5171
- }, [y, S, a, i]);
5172
- const I = useMemo(() => p ? (h(), ["RichText", "Paragraph"].includes(S) ? /* @__PURE__ */ jsx(
5227
+ w && ((j = w == null ? void 0 : w.classList) == null || j.add("sr-only"), u(w));
5228
+ }, [y, k, a, i]);
5229
+ const I = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(k) ? /* @__PURE__ */ jsx(
5173
5230
  RichTextEditor,
5174
5231
  {
5175
- blockContent: k,
5232
+ blockContent: S,
5176
5233
  editingElement: p,
5177
- onChange: _,
5234
+ onChange: B,
5178
5235
  onClose: v,
5179
5236
  onEscape: E
5180
5237
  }
@@ -5182,13 +5239,13 @@ const RichTextEditor = memo(
5182
5239
  MemoizedEditor,
5183
5240
  {
5184
5241
  editorRef: g,
5185
- blockContent: k,
5242
+ blockContent: S,
5186
5243
  editingElement: p,
5187
5244
  onClose: v,
5188
- onChange: _,
5245
+ onChange: B,
5189
5246
  onEscape: E
5190
5247
  }
5191
- )) : null, [p, y, S, k, v, m]);
5248
+ )) : null, [p, y, k, S, v, h]);
5192
5249
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5193
5250
  I,
5194
5251
  n
@@ -5223,42 +5280,42 @@ const RichTextEditor = memo(
5223
5280
  blockAtom: n,
5224
5281
  children: r
5225
5282
  }) => {
5226
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: m, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useIsDragAndDropEnabled(), k = b === "edit", S = useDirectBlockDrag(), v = useMemo(
5227
- () => h ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
5228
- index: m,
5283
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), f = get(c, "component", null), { index: h, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useIsDragAndDropEnabled(), S = b === "edit", k = useDirectBlockDrag(), v = useMemo(
5284
+ () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
5285
+ index: h,
5229
5286
  key: x
5230
5287
  }) : applyLanguage(i, d, c),
5231
- [i, d, c, g, h, m, x]
5232
- ), _ = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
5288
+ [i, d, c, g, m, h, x]
5289
+ ), B = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
5233
5290
  () => u(i._id, getBlockRuntimeProps(i._type)),
5234
5291
  [i._id, i._type, u, getBlockRuntimeProps]
5235
5292
  ), I = useMemo(() => {
5236
5293
  const N = {
5237
5294
  "data-block-id": i._id,
5238
5295
  "data-block-type": i._type,
5239
- "data-block-index": m
5296
+ "data-block-index": h
5240
5297
  };
5241
- return k && y ? {
5298
+ return S && y ? {
5242
5299
  ...N,
5243
5300
  draggable: !0,
5244
- onMouseDown: S.onMouseDown,
5245
- onDragStart: S.onDragStart,
5246
- onDragEnd: S.onDragEnd
5301
+ onMouseDown: k.onMouseDown,
5302
+ onDragStart: k.onDragStart,
5303
+ onDragEnd: k.onDragEnd
5247
5304
  } : N;
5248
- }, [i._id, i._type, m, k, y, S]), C = useMemo(
5305
+ }, [i._id, i._type, h, S, y, k]), C = useMemo(
5249
5306
  () => ({
5250
5307
  blockProps: I,
5251
5308
  inBuilder: b === "edit",
5252
5309
  lang: d || p,
5253
5310
  ...v,
5254
- ..._,
5311
+ ...B,
5255
5312
  ...E,
5256
5313
  ...o
5257
5314
  }),
5258
- [b, I, d, p, v, _, E, o]
5315
+ [b, I, d, p, v, B, E, o]
5259
5316
  ), A = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), w = useMemo(() => get(i, "_show", !0), [i]);
5260
5317
  if (isNull(f) || !w) return null;
5261
- let B = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
5318
+ let j = /* @__PURE__ */ jsx(Suspense, { children: createElement(f, {
5262
5319
  ...C,
5263
5320
  children: r({
5264
5321
  _id: i._id,
@@ -5271,8 +5328,8 @@ const RichTextEditor = memo(
5271
5328
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
5272
5329
  })
5273
5330
  }) });
5274
- const j = a === i._id && (l === m || m < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: B }) : B;
5275
- return A ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: j }) : j;
5331
+ const _ = a === i._id && (l === h || h < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: j }) : j;
5332
+ return A ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: _ }) : _;
5276
5333
  }, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
5277
5334
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
5278
5335
  (d) => {
@@ -5315,24 +5372,24 @@ const RichTextEditor = memo(
5315
5372
  );
5316
5373
  return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
5317
5374
  const p = l(d._id);
5318
- return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: h, partialBlockId: f, repeaterItems: m, $repeaterItemsKey: x }) => h === "Repeater" ? isArray(m) && m.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: h }) }, `${g}-${y}`)) : h === "GlobalBlock" || h === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: f }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: h }) : null }) }, d._id) : null;
5375
+ return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: f, repeaterItems: h, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(h) && h.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: f }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
5319
5376
  });
5320
5377
  }, PageBlocksRenderer = () => {
5321
5378
  const [o] = useBlocksStore();
5322
5379
  return /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: pageBlocksAtomsAtom, blocks: o });
5323
5380
  }, StaticBlocksRenderer = () => {
5324
- const [o] = useBlocksStore(), n = isEmpty(o) ? null : /* @__PURE__ */ jsx(PageBlocksRenderer, {});
5325
- return /* @__PURE__ */ jsx(Fragment, { children: n });
5381
+ const [o] = useBlocksStore(), [n] = useAtom$1(canvasRenderKeyAtom), r = isEmpty(o) ? null : /* @__PURE__ */ jsx(PageBlocksRenderer, {}, n);
5382
+ return /* @__PURE__ */ jsx(Fragment, { children: r });
5326
5383
  }, useCanvasScale = (o) => {
5327
5384
  const [n] = useCanvasDisplayWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
5328
5385
  const { width: d, height: p } = o;
5329
5386
  if (d < n) {
5330
5387
  const u = parseFloat((d / n).toFixed(2).toString());
5331
5388
  let g = {};
5332
- const h = p * u, f = d * u;
5389
+ const m = p * u, f = d * u;
5333
5390
  p && (g = {
5334
5391
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
5335
- height: 100 + (p - h) / h * 100 + "%",
5392
+ height: 100 + (p - m) / m * 100 + "%",
5336
5393
  width: 100 + (d - f) / f * 100 + "%"
5337
5394
  }), i({
5338
5395
  position: "relative",
@@ -5374,16 +5431,16 @@ const RichTextEditor = memo(
5374
5431
  l(), o([]), r([]);
5375
5432
  }), null;
5376
5433
  }, StaticCanvas = () => {
5377
- const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), { onDragOver: g, onDrop: h, onDragEnd: f } = useDragAndDrop(), m = useDropIndicator(), x = useCallback(
5434
+ const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), { onDragOver: g, onDrop: m, onDragEnd: f } = useDragAndDrop(), h = useDropIndicator(), x = useCallback(
5378
5435
  (y) => {
5379
- i((k) => ({ ...k, width: y }));
5436
+ i((S) => ({ ...S, width: y }));
5380
5437
  },
5381
5438
  [i]
5382
5439
  );
5383
5440
  useEffect(() => {
5384
5441
  if (!a.current) return;
5385
- const { clientWidth: y, clientHeight: k } = a.current;
5386
- i({ width: y, height: k });
5442
+ const { clientWidth: y, clientHeight: S } = a.current;
5443
+ i({ width: y, height: S });
5387
5444
  }, [a, o]);
5388
5445
  const b = useMemo(() => {
5389
5446
  let y = IframeInitialContent;
@@ -5395,7 +5452,7 @@ const RichTextEditor = memo(
5395
5452
  onMouseLeave: () => setTimeout(() => n(""), 300),
5396
5453
  className: "relative mx-auto h-full w-full overflow-hidden",
5397
5454
  onDragOver: g,
5398
- onDrop: h,
5455
+ onDrop: m,
5399
5456
  onDragEnd: f,
5400
5457
  ref: a,
5401
5458
  children: /* @__PURE__ */ jsxs(
@@ -5418,16 +5475,16 @@ const RichTextEditor = memo(
5418
5475
  ] }),
5419
5476
  /* @__PURE__ */ jsx(CanvasEventsWatcher, {})
5420
5477
  ] }),
5421
- m.isVisible && /* @__PURE__ */ jsx(
5478
+ h.isVisible && /* @__PURE__ */ jsx(
5422
5479
  "div",
5423
5480
  {
5424
5481
  id: "placeholder",
5425
- className: `pointer-events-none absolute z-[99999] max-w-full transition-all duration-150 ${m.isEmpty ? "bg-purple-500/10 outline-dashed outline-2 -outline-offset-2 outline-purple-500" : "rounded-full bg-green-500"}`,
5482
+ className: `pointer-events-none absolute z-[99999] max-w-full transition-all duration-150 ${h.isEmpty ? "bg-purple-500/10 outline-dashed outline-2 -outline-offset-2 outline-purple-500" : "rounded-full bg-green-500"}`,
5426
5483
  style: {
5427
- top: m.top,
5428
- left: m.left,
5429
- width: m.width,
5430
- height: m.height
5484
+ top: h.top,
5485
+ left: h.left,
5486
+ width: h.width,
5487
+ height: h.height
5431
5488
  }
5432
5489
  }
5433
5490
  )
@@ -5442,7 +5499,7 @@ const RichTextEditor = memo(
5442
5499
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
5443
5500
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
5444
5501
  ] }) });
5445
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-SUsv-NS0.js")), CanvasArea = () => {
5502
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-Ds3Sj2G3.js")), CanvasArea = () => {
5446
5503
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
5447
5504
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
5448
5505
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -5511,8 +5568,8 @@ const RichTextEditor = memo(
5511
5568
  ] })
5512
5569
  ] });
5513
5570
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
5514
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (m) => {
5515
- if (!m.trim()) {
5571
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (h) => {
5572
+ if (!h.trim()) {
5516
5573
  p(!1), g("Please enter a URL");
5517
5574
  return;
5518
5575
  }
@@ -5536,8 +5593,8 @@ const RichTextEditor = memo(
5536
5593
  {
5537
5594
  placeholder: f(`Enter ${r} URL`),
5538
5595
  value: a,
5539
- onChange: (m) => l(m.target.value),
5540
- onKeyUp: () => h(a)
5596
+ onChange: (h) => l(h.target.value),
5597
+ onKeyUp: () => m(a)
5541
5598
  }
5542
5599
  ),
5543
5600
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
@@ -5581,18 +5638,18 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
5581
5638
  const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
5582
5639
  return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
5583
5640
  }, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
5584
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, h = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), f = get(c, g, h ? c == null ? void 0 : c.assetId : ""), m = useMemo(() => {
5641
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), f = get(c, g, m ? c == null ? void 0 : c.assetId : ""), h = useMemo(() => {
5585
5642
  if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
5586
- const v = { ...c, [u]: o }, _ = applyBindingToBlockProps(v, p, { index: -1, key: "" });
5587
- return get(_, u, o);
5588
- }, [o, c, p, u]), x = !!f || m !== PLACEHOLDER_IMAGE, b = (S) => {
5589
- const v = isArray(S) ? first(S) : S;
5643
+ const v = { ...c, [u]: o }, B = applyBindingToBlockProps(v, p, { index: -1, key: "" });
5644
+ return get(B, u, o);
5645
+ }, [o, c, p, u]), x = !!f || h !== PLACEHOLDER_IMAGE, b = (k) => {
5646
+ const v = isArray(k) ? first(k) : k;
5590
5647
  if (v) {
5591
5648
  n(v == null ? void 0 : v.url);
5592
- const _ = v == null ? void 0 : v.width, E = v == null ? void 0 : v.height, I = g.includes("mobile");
5649
+ const B = v == null ? void 0 : v.width, E = v == null ? void 0 : v.height, I = g.includes("mobile");
5593
5650
  if (c != null && c._id) {
5594
5651
  const C = {
5595
- ..._ && { [I ? "mobileWidth" : "width"]: _ },
5652
+ ...B && { [I ? "mobileWidth" : "width"]: B },
5596
5653
  ...E && { [I ? "mobileHeight" : "height"]: E },
5597
5654
  ...v.description && { alt: v.description }
5598
5655
  };
@@ -5602,16 +5659,16 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
5602
5659
  }
5603
5660
  }, y = useCallback(() => {
5604
5661
  if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
5605
- const S = {}, v = g.includes("mobile");
5606
- set(S, g, ""), set(S, v ? "mobileWidth" : "width", ""), set(S, v ? "mobileHeight" : "height", ""), d([c._id], S);
5662
+ const k = {}, v = g.includes("mobile");
5663
+ set(k, g, ""), set(k, v ? "mobileWidth" : "width", ""), set(k, v ? "mobileHeight" : "height", ""), d([c._id], k);
5607
5664
  }
5608
- }, [n, c == null ? void 0 : c._id, d, g]), k = getFileName(m);
5665
+ }, [n, c == null ? void 0 : c._id, d, g]), S = getFileName(h);
5609
5666
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
5610
- m ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
5667
+ h ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
5611
5668
  /* @__PURE__ */ jsx(
5612
5669
  "img",
5613
5670
  {
5614
- src: m,
5671
+ src: h,
5615
5672
  className: "h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (f && f !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
5616
5673
  alt: ""
5617
5674
  }
@@ -5636,8 +5693,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
5636
5693
  ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, mode: "image", assetId: f, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
5637
5694
  /* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
5638
5695
  /* @__PURE__ */ jsxs(Fragment, { children: [
5639
- /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: k }),
5640
- /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(m) && m !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) }),
5696
+ /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: S }),
5697
+ /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(h) && h !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) }),
5641
5698
  /* @__PURE__ */ jsx("div", { className: "text-center text-xs text-gray-400", children: "OR" })
5642
5699
  ] }),
5643
5700
  /* @__PURE__ */ jsx(
@@ -5651,25 +5708,25 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
5651
5708
  className: "h-6 text-xs",
5652
5709
  placeholder: l("Enter image URL"),
5653
5710
  value: o === PLACEHOLDER_IMAGE ? "" : o,
5654
- onBlur: ({ target: { value: S } }) => a(r, S),
5655
- onChange: (S) => n(S.target.value)
5711
+ onBlur: ({ target: { value: k } }) => a(r, k),
5712
+ onChange: (k) => n(k.target.value)
5656
5713
  }
5657
5714
  )
5658
5715
  ] })
5659
5716
  ] });
5660
5717
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
5661
- const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
5662
- (h) => {
5663
- const f = (m) => r === "value" ? m === "value" || m === "object" : r === "array" ? m === "array" : m === r;
5664
- h.type === "object" ? (l((m) => [...m, h.key]), c(h.value)) : f(h.type) && n([...a, h.key].join("."), r);
5718
+ const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
5719
+ (m) => {
5720
+ const f = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
5721
+ m.type === "object" ? (l((h) => [...h, m.key]), c(m.value)) : f(m.type) && n([...a, m.key].join("."), r);
5665
5722
  },
5666
5723
  [a, n, r]
5667
5724
  ), u = React__default.useCallback(() => {
5668
5725
  if (a.length > 0) {
5669
- const h = a.slice(0, -1);
5670
- l(h), c(h.reduce((f, m) => f[m], o));
5726
+ const m = a.slice(0, -1);
5727
+ l(m), c(m.reduce((f, h) => f[h], o));
5671
5728
  }
5672
- }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, f]) => ({ key: h, value: f, type: d(f) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0) : [], [i, r]);
5729
+ }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, f]) => ({ key: m, value: f, type: d(f) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
5673
5730
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
5674
5731
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
5675
5732
  /* @__PURE__ */ jsxs(CommandList, { children: [
@@ -5679,36 +5736,36 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
5679
5736
  /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
5680
5737
  t("Back")
5681
5738
  ] }),
5682
- g.map((h) => /* @__PURE__ */ jsxs(
5739
+ g.map((m) => /* @__PURE__ */ jsxs(
5683
5740
  CommandItem,
5684
5741
  {
5685
- value: h.key,
5742
+ value: m.key,
5686
5743
  disabled: !1,
5687
- onSelect: () => p(h),
5744
+ onSelect: () => p(m),
5688
5745
  className: "flex items-center justify-between",
5689
5746
  children: [
5690
5747
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
5691
- startsWith(h.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(h.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
5692
- startsWith(h.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(h.key, COLLECTION_PREFIX) ? h.key.replace(COLLECTION_PREFIX, "") : h.key
5748
+ startsWith(m.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(m.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(IdCardIcon, {}) : null,
5749
+ startsWith(m.key, REPEATER_PREFIX) ? t("Repeater Data") : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
5693
5750
  ] }),
5694
5751
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5695
- r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
5752
+ r === "object" && m.type === "object" && /* @__PURE__ */ jsx(
5696
5753
  Button,
5697
5754
  {
5698
5755
  size: "sm",
5699
5756
  variant: "ghost",
5700
5757
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
5701
5758
  onClick: (f) => {
5702
- f.stopPropagation(), n([...a, h.key].join("."), r);
5759
+ f.stopPropagation(), n([...a, m.key].join("."), r);
5703
5760
  },
5704
5761
  children: t("Select")
5705
5762
  }
5706
5763
  ),
5707
- h.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
5764
+ m.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 opacity-50" }) })
5708
5765
  ] })
5709
5766
  ]
5710
5767
  },
5711
- h.key
5768
+ m.key
5712
5769
  ))
5713
5770
  ] })
5714
5771
  ] })
@@ -5760,51 +5817,51 @@ const DataBindingSelector = ({
5760
5817
  }) => {
5761
5818
  const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), d = useSelectedBlock(), p = useMemo(() => {
5762
5819
  if (c.length === 1) return "";
5763
- const h = c.find((x) => x._type === "Repeater"), m = get(h, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
5764
- return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${h._id}` : m}`;
5820
+ const m = c.find((x) => x._type === "Repeater"), h = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
5821
+ return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${m._id}` : h}`;
5765
5822
  }, [c]), u = useMemo(() => first(get(l, p.replace(REPEATER_PREFIX, ""), [])), [p, l]), g = useCallback(
5766
- (h, f) => {
5767
- if (h = isEmpty(p) ? h : h.replace(`${p}`, "$index"), f === "array" || f === "object") {
5768
- n(`{{${h}}}`, {}, r);
5823
+ (m, f) => {
5824
+ if (m = isEmpty(p) ? m : m.replace(`${p}`, "$index"), f === "array" || f === "object") {
5825
+ n(`{{${m}}}`, {}, r);
5769
5826
  return;
5770
5827
  }
5771
- const m = (k) => /[.,!?;:]/.test(k), x = (k, S, v) => {
5772
- let _ = "", E = "";
5773
- const I = S > 0 ? k[S - 1] : "", C = S < k.length ? k[S] : "";
5774
- return S > 0 && (I === "." || !m(I) && I !== " ") && (_ = " "), S < k.length && !m(C) && C !== " " && (E = " "), {
5775
- text: _ + v + E,
5776
- prefixLength: _.length,
5828
+ const h = (S) => /[.,!?;:]/.test(S), x = (S, k, v) => {
5829
+ let B = "", E = "";
5830
+ const I = k > 0 ? S[k - 1] : "", C = k < S.length ? S[k] : "";
5831
+ return k > 0 && (I === "." || !h(I) && I !== " ") && (B = " "), k < S.length && !h(C) && C !== " " && (E = " "), {
5832
+ text: B + v + E,
5833
+ prefixLength: B.length,
5777
5834
  suffixLength: E.length
5778
5835
  };
5779
5836
  }, b = document.getElementById(r);
5780
5837
  if (!b) return;
5781
5838
  const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
5782
5839
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
5783
- const k = y.__chaiRTE;
5784
- if (k) {
5785
- const S = `{{${h}}}`;
5786
- k.commands.focus();
5787
- const { from: v, to: _ } = k.state.selection;
5788
- if (v !== _)
5789
- k.chain().deleteSelection().insertContent(S).run();
5840
+ const S = y.__chaiRTE;
5841
+ if (S) {
5842
+ const k = `{{${m}}}`;
5843
+ S.commands.focus();
5844
+ const { from: v, to: B } = S.state.selection;
5845
+ if (v !== B)
5846
+ S.chain().deleteSelection().insertContent(k).run();
5790
5847
  else {
5791
- const { state: I } = k, C = I.selection.from, A = I.doc.textBetween(Math.max(0, C - 1), C), w = I.doc.textBetween(C, Math.min(C + 1, I.doc.content.size));
5792
- let B = "";
5793
- C > 0 && A !== " " && !m(A) && (B = " ");
5848
+ const { state: I } = S, C = I.selection.from, A = I.doc.textBetween(Math.max(0, C - 1), C), w = I.doc.textBetween(C, Math.min(C + 1, I.doc.content.size));
5794
5849
  let j = "";
5795
- w && w !== " " && !m(w) && (j = " "), k.chain().insertContent(B + S + j).run();
5850
+ C > 0 && A !== " " && !h(A) && (j = " ");
5851
+ let _ = "";
5852
+ w && w !== " " && !h(w) && (_ = " "), S.chain().insertContent(j + k + _).run();
5796
5853
  }
5797
- setTimeout(() => n(k.getHTML(), {}, r), 100);
5854
+ setTimeout(() => n(S.getHTML(), {}, r), 100);
5798
5855
  return;
5799
5856
  }
5800
5857
  } else {
5801
- const k = b, S = k.selectionStart || 0, v = k.value || "", _ = k.selectionEnd || S;
5802
- if (_ > S) {
5803
- const w = `{{${h}}}`, { text: B } = x(v, S, w), j = v.slice(0, S) + B + v.slice(_);
5804
- n(j, {}, r);
5858
+ const S = b, k = S.selectionStart || 0, v = S.value || "", B = S.selectionEnd || k;
5859
+ if (B > k) {
5860
+ const w = `{{${m}}}`, { text: j } = x(v, k, w), _ = v.slice(0, k) + j + v.slice(B);
5861
+ n(_, {}, r);
5805
5862
  return;
5806
5863
  }
5807
- const I = `{{${h}}}`, { text: C } = x(v, S, I), A = v.slice(0, S) + C + v.slice(S);
5864
+ const I = `{{${m}}}`, { text: C } = x(v, k, I), A = v.slice(0, k) + C + v.slice(k);
5808
5865
  n(A, {}, r);
5809
5866
  }
5810
5867
  },
@@ -5827,13 +5884,13 @@ const DataBindingSelector = ({
5827
5884
  onChange: r
5828
5885
  }) => {
5829
5886
  var A;
5830
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (w, B) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, f] = useState(""), [m, x] = useState([]), [b, y] = useState(-1), k = useRef(null), S = (A = n == null ? void 0 : n.find((w) => w.key === u)) == null ? void 0 : A.name;
5887
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (w, j) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [h, x] = useState([]), [b, y] = useState(-1), S = useRef(null), k = (A = n == null ? void 0 : n.find((w) => w.key === u)) == null ? void 0 : A.name;
5831
5888
  useEffect(() => {
5832
5889
  if (f(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
5833
- const w = split(o, ":"), B = get(w, 1, "page") || "page";
5834
- g(B), (async () => {
5835
- const j = await l(B, [get(w, 2, "page")]);
5836
- j && Array.isArray(j) && f(get(j, [0, "name"], ""));
5890
+ const w = split(o, ":"), j = get(w, 1, "page") || "page";
5891
+ g(j), (async () => {
5892
+ const _ = await l(j, [get(w, 2, "page")]);
5893
+ _ && Array.isArray(_) && f(get(_, [0, "name"], ""));
5837
5894
  })();
5838
5895
  }, [o]);
5839
5896
  const v = useDebouncedCallback(
@@ -5841,27 +5898,27 @@ const DataBindingSelector = ({
5841
5898
  if (isEmpty(w))
5842
5899
  x([]);
5843
5900
  else {
5844
- const B = await l(u, w);
5845
- x(B);
5901
+ const j = await l(u, w);
5902
+ x(j);
5846
5903
  }
5847
5904
  c(!1), y(-1);
5848
5905
  },
5849
5906
  [u],
5850
5907
  300
5851
- ), _ = (w) => {
5852
- const B = ["pageType", u, w.id];
5853
- B[1] && (r(B.join(":")), f(w.name), p(!1), x([]), y(-1));
5908
+ ), B = (w) => {
5909
+ const j = ["pageType", u, w.id];
5910
+ j[1] && (r(j.join(":")), f(w.name), p(!1), x([]), y(-1));
5854
5911
  }, E = (w) => {
5855
5912
  switch (w.key) {
5856
5913
  case "ArrowDown":
5857
- w.preventDefault(), y((B) => B < m.length - 1 ? B + 1 : B);
5914
+ w.preventDefault(), y((j) => j < h.length - 1 ? j + 1 : j);
5858
5915
  break;
5859
5916
  case "ArrowUp":
5860
- w.preventDefault(), y((B) => B > 0 ? B - 1 : B);
5917
+ w.preventDefault(), y((j) => j > 0 ? j - 1 : j);
5861
5918
  break;
5862
5919
  case "Enter":
5863
- if (w.preventDefault(), m.length === 0) return;
5864
- b >= 0 && _(m[b]);
5920
+ if (w.preventDefault(), h.length === 0) return;
5921
+ b >= 0 && B(h[b]);
5865
5922
  break;
5866
5923
  case "Escape":
5867
5924
  w.preventDefault(), I();
@@ -5869,8 +5926,8 @@ const DataBindingSelector = ({
5869
5926
  }
5870
5927
  };
5871
5928
  useEffect(() => {
5872
- if (b >= 0 && k.current) {
5873
- const w = k.current.children[b];
5929
+ if (b >= 0 && S.current) {
5930
+ const w = S.current.children[b];
5874
5931
  w == null || w.scrollIntoView({ block: "nearest" });
5875
5932
  }
5876
5933
  }, [b]);
@@ -5886,28 +5943,28 @@ const DataBindingSelector = ({
5886
5943
  "input",
5887
5944
  {
5888
5945
  type: "text",
5889
- value: h,
5946
+ value: m,
5890
5947
  onChange: (w) => C(w.target.value),
5891
5948
  onKeyDown: E,
5892
- placeholder: a(`Search ${S ?? ""}`),
5949
+ placeholder: a(`Search ${k ?? ""}`),
5893
5950
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
5894
5951
  }
5895
5952
  ),
5896
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: I, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
5953
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: I, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
5897
5954
  ] }),
5898
- (i || !isEmpty(m) || d && isEmpty(m)) && /* @__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: [
5955
+ (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: [
5899
5956
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
5900
5957
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
5901
- ] }) : d && isEmpty(m) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5958
+ ] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5902
5959
  a("No results found for"),
5903
5960
  ' "',
5904
- h,
5961
+ m,
5905
5962
  '"'
5906
- ] }) : /* @__PURE__ */ jsx("ul", { ref: k, children: map(m == null ? void 0 : m.slice(0, 20), (w, B) => /* @__PURE__ */ jsxs(
5963
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(h == null ? void 0 : h.slice(0, 20), (w, j) => /* @__PURE__ */ jsxs(
5907
5964
  "li",
5908
5965
  {
5909
- onClick: () => _(w),
5910
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(w.id) ? "bg-blue-200" : B === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
5966
+ onClick: () => B(w),
5967
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(w.id) ? "bg-blue-200" : j === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
5911
5968
  children: [
5912
5969
  w.name,
5913
5970
  " ",
@@ -5922,15 +5979,15 @@ const DataBindingSelector = ({
5922
5979
  )) }) })
5923
5980
  ] });
5924
5981
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
5925
- const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: h } = useLanguages(), f = useMemo(
5926
- () => isEmpty(h) ? "" : isEmpty(u) ? g : u,
5927
- [h, u, g]
5928
- ), m = useMemo(() => get(LANGUAGES, f, f), [f]), x = i === "pageType" && isEmpty(p) ? "url" : i;
5982
+ const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), f = useMemo(
5983
+ () => isEmpty(m) ? "" : isEmpty(u) ? g : u,
5984
+ [m, u, g]
5985
+ ), h = useMemo(() => get(LANGUAGES, f, f), [f]), x = i === "pageType" && isEmpty(p) ? "url" : i;
5929
5986
  return /* @__PURE__ */ jsxs("div", { children: [
5930
5987
  /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
5931
5988
  /* @__PURE__ */ jsxs("span", { children: [
5932
5989
  (o == null ? void 0 : o.title) ?? "Link",
5933
- /* @__PURE__ */ jsx("span", { className: "pl-1 text-[9px] text-zinc-400", children: m })
5990
+ /* @__PURE__ */ jsx("span", { className: "pl-1 text-[9px] text-zinc-400", children: h })
5934
5991
  ] }),
5935
5992
  /* @__PURE__ */ jsx(
5936
5993
  DataBindingSelector,
@@ -6012,18 +6069,18 @@ const DataBindingSelector = ({
6012
6069
  ]
6013
6070
  }
6014
6071
  ) });
6015
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-BHGfvz4u.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
6072
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-ChFbdN-q.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
6016
6073
  const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
6017
6074
  blockId: o,
6018
6075
  value: a,
6019
6076
  placeholder: r,
6020
6077
  onBlur: ({ editor: f }) => {
6021
- const m = f == null ? void 0 : f.getHTML();
6022
- i(n, m);
6078
+ const h = f == null ? void 0 : f.getHTML();
6079
+ i(n, h);
6023
6080
  },
6024
6081
  onUpdate: ({ editor: f }) => {
6025
- const m = f == null ? void 0 : f.getHTML();
6026
- l(m);
6082
+ const h = f == null ? void 0 : f.getHTML();
6083
+ l(h);
6027
6084
  }
6028
6085
  });
6029
6086
  useEffect(() => {
@@ -6031,7 +6088,7 @@ const DataBindingSelector = ({
6031
6088
  }, [o, u]);
6032
6089
  const g = () => {
6033
6090
  p(!1);
6034
- }, h = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
6091
+ }, m = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
6035
6092
  /* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
6036
6093
  /* @__PURE__ */ jsx(
6037
6094
  EditorContent,
@@ -6045,8 +6102,8 @@ const DataBindingSelector = ({
6045
6102
  )
6046
6103
  ] });
6047
6104
  return /* @__PURE__ */ jsxs(Fragment, { children: [
6048
- d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: h }) }),
6049
- d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: h })
6105
+ d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: m }) }),
6106
+ d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
6050
6107
  ] });
6051
6108
  }, RichTextEditorField = (o) => {
6052
6109
  const { editingBlockId: n } = useInlineEditing(), [r, a] = useState(null), l = useSelectedBlock(), i = l == null ? void 0 : l._id;
@@ -6064,7 +6121,7 @@ const DataBindingSelector = ({
6064
6121
  }, [a]), useEffect(() => {
6065
6122
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
6066
6123
  }, [o, u]);
6067
- const h = () => {
6124
+ const m = () => {
6068
6125
  const x = findIndex(u, { _id: g });
6069
6126
  if (x > -1) {
6070
6127
  const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
@@ -6078,7 +6135,7 @@ const DataBindingSelector = ({
6078
6135
  if (!y) return;
6079
6136
  n({ ...o, currentSlide: y }), c([y]);
6080
6137
  }
6081
- }, m = () => {
6138
+ }, h = () => {
6082
6139
  const x = i(
6083
6140
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
6084
6141
  p == null ? void 0 : p._id
@@ -6096,11 +6153,11 @@ const DataBindingSelector = ({
6096
6153
  "/",
6097
6154
  u.length
6098
6155
  ] }) : "-" }),
6099
- /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
6156
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
6100
6157
  /* @__PURE__ */ jsxs(
6101
6158
  "button",
6102
6159
  {
6103
- onClick: m,
6160
+ onClick: h,
6104
6161
  className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
6105
6162
  children: [
6106
6163
  /* @__PURE__ */ jsx(PlusCircledIcon, { className: "h-3 w-3" }),
@@ -6174,7 +6231,7 @@ const DataBindingSelector = ({
6174
6231
  const r = get(o, "srcsets", []) || [], a = (c, d) => {
6175
6232
  const p = c.target.name, u = c.target.value;
6176
6233
  n({
6177
- srcsets: map(r, (g, h) => h === d ? { ...g, [p]: u } : g)
6234
+ srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
6178
6235
  });
6179
6236
  }, l = () => {
6180
6237
  n({ srcsets: [...r, {}] });
@@ -6258,28 +6315,28 @@ const DataBindingSelector = ({
6258
6315
  u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
6259
6316
  ] }) });
6260
6317
  }, JSONFormFieldTemplate = (o) => {
6261
- const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: h } = o, { selectedLang: f, fallbackLang: m, languages: x } = useLanguages(), b = useMemo(
6262
- () => isEmpty(x) ? "" : isEmpty(f) ? m : f,
6263
- [x, f, m]
6264
- ), y = useMemo(() => get(LANGUAGES, b, b), [b]), k = usePageExternalData(), S = useSelectedBlock(), v = useRegisteredChaiBlocks(), _ = useMemo(
6265
- () => get(v, [S == null ? void 0 : S._type, "i18nProps"], []),
6266
- [v, S == null ? void 0 : S._type]
6318
+ const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: f, fallbackLang: h, languages: x } = useLanguages(), b = useMemo(
6319
+ () => isEmpty(x) ? "" : isEmpty(f) ? h : f,
6320
+ [x, f, h]
6321
+ ), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), k = useSelectedBlock(), v = useRegisteredChaiBlocks(), B = useMemo(
6322
+ () => get(v, [k == null ? void 0 : k._type, "i18nProps"], []),
6323
+ [v, k == null ? void 0 : k._type]
6267
6324
  ), [E, I] = useState(null);
6268
6325
  if (d)
6269
6326
  return null;
6270
6327
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
6271
- const A = _ == null ? void 0 : _.includes(n.replace("root.", ""));
6328
+ const A = B == null ? void 0 : B.includes(n.replace("root.", ""));
6272
6329
  if (u.type === "array") {
6273
- const j = E === n;
6330
+ const _ = E === n;
6274
6331
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
6275
6332
  u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
6276
6333
  "label",
6277
6334
  {
6278
6335
  htmlFor: n,
6279
- onClick: () => I(j ? null : n),
6336
+ onClick: () => I(_ ? null : n),
6280
6337
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
6281
6338
  children: [
6282
- j ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
6339
+ _ ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }),
6283
6340
  /* @__PURE__ */ jsx(ListBulletIcon, { className: "h-3 w-3" }),
6284
6341
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
6285
6342
  " ",
@@ -6298,14 +6355,14 @@ const DataBindingSelector = ({
6298
6355
  ]
6299
6356
  }
6300
6357
  ) }),
6301
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: l }) : /* @__PURE__ */ jsxs("div", { className: `${j ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
6358
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: l }) : /* @__PURE__ */ jsxs("div", { className: `${_ ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
6302
6359
  l,
6303
6360
  i,
6304
6361
  c
6305
6362
  ] })
6306
6363
  ] });
6307
6364
  }
6308
- const w = n.replace("root.", ""), B = _.includes(w) && !isEmpty(f) && isEmpty(g);
6365
+ const w = n.replace("root.", ""), j = B.includes(w) && !isEmpty(f) && isEmpty(g);
6309
6366
  return /* @__PURE__ */ jsxs("div", { className: r, children: [
6310
6367
  u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
6311
6368
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
@@ -6323,8 +6380,8 @@ const DataBindingSelector = ({
6323
6380
  /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
6324
6381
  ] }) })
6325
6382
  ] }),
6326
- !u.enum && !u.oneOf && k && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
6327
- B ? /* @__PURE__ */ jsxs(Tooltip, { children: [
6383
+ !u.enum && !u.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
6384
+ j ? /* @__PURE__ */ jsxs(Tooltip, { children: [
6328
6385
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6329
6386
  "svg",
6330
6387
  {
@@ -6355,8 +6412,8 @@ const DataBindingSelector = ({
6355
6412
  DataBindingSelector,
6356
6413
  {
6357
6414
  schema: u,
6358
- onChange: (j) => {
6359
- h(j, g, n);
6415
+ onChange: (_) => {
6416
+ m(_, g, n);
6360
6417
  },
6361
6418
  id: n,
6362
6419
  formData: g
@@ -6406,8 +6463,8 @@ const DataBindingSelector = ({
6406
6463
  /* @__PURE__ */ jsx("span", { children: "Add" })
6407
6464
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
6408
6465
  const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
6409
- async ({ formData: g }, h) => {
6410
- get(g, h) === void 0 && set(g, h, ""), l({ formData: g }, h);
6466
+ async ({ formData: g }, m) => {
6467
+ get(g, m) === void 0 && set(g, m, ""), l({ formData: g }, m);
6411
6468
  },
6412
6469
  [l, i],
6413
6470
  400
@@ -6448,9 +6505,9 @@ const DataBindingSelector = ({
6448
6505
  uiSchema: r,
6449
6506
  schema: n,
6450
6507
  formData: a,
6451
- onChange: ({ formData: g }, h) => {
6452
- if (!h || o !== (g == null ? void 0 : g._id)) return;
6453
- const f = take(h.split("."), 2).join(".").replace("root.", "");
6508
+ onChange: ({ formData: g }, m) => {
6509
+ if (!m || o !== (g == null ? void 0 : g._id)) return;
6510
+ const f = take(m.split("."), 2).join(".").replace("root.", "");
6454
6511
  u({ formData: g }, f);
6455
6512
  }
6456
6513
  },
@@ -6463,18 +6520,18 @@ const DataBindingSelector = ({
6463
6520
  }), a;
6464
6521
  };
6465
6522
  function BlockSettings() {
6466
- 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(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, h), m = ({ formData: E }, I, C) => {
6523
+ 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: E }, I, C) => {
6467
6524
  I && (c == null ? void 0 : c._id) === n._id && a([n._id], { [I]: get(E, I) }, C);
6468
6525
  }, x = useCallback(
6469
6526
  debounce(({ formData: E }, I, C) => {
6470
- m({ formData: E }, I, C), d(E);
6527
+ h({ formData: E }, I, C), d(E);
6471
6528
  }, 1500),
6472
6529
  [n == null ? void 0 : n._id, o]
6473
6530
  ), b = ({ formData: E }, I) => {
6474
6531
  I && (r([n._id], { [I]: get(E, I) }), x({ formData: E }, I, { [I]: get(c, I) }));
6475
6532
  }, y = ({ formData: E }, I) => {
6476
6533
  I && (r([g._id], { [I]: get(E, I) }), x({ formData: E }, I, { [I]: get(c, I) }));
6477
- }, { schema: k, uiSchema: S } = useMemo(() => {
6534
+ }, { schema: S, uiSchema: k } = useMemo(() => {
6478
6535
  const E = n == null ? void 0 : n._type;
6479
6536
  if (!E)
6480
6537
  return { schema: {}, uiSchema: {} };
@@ -6488,7 +6545,7 @@ function BlockSettings() {
6488
6545
  } catch {
6489
6546
  return { schema: {}, uiSchema: {} };
6490
6547
  }
6491
- }, [n]), { wrapperSchema: v, wrapperUiSchema: _ } = useMemo(() => {
6548
+ }, [n]), { wrapperSchema: v, wrapperUiSchema: B } = useMemo(() => {
6492
6549
  if (!g || !(g != null && g._type))
6493
6550
  return { wrapperSchema: {}, wrapperUiSchema: {} };
6494
6551
  const E = g == null ? void 0 : g._type, { schema: I = {}, uiSchema: C = {} } = getBlockFormSchemas(E);
@@ -6521,29 +6578,29 @@ function BlockSettings() {
6521
6578
  onChange: y,
6522
6579
  formData: f,
6523
6580
  schema: v,
6524
- uiSchema: _
6581
+ uiSchema: B
6525
6582
  }
6526
6583
  ) })
6527
6584
  ] }),
6528
- isEmpty(k) ? null : /* @__PURE__ */ jsx(
6585
+ isEmpty(S) ? null : /* @__PURE__ */ jsx(
6529
6586
  JSONForm,
6530
6587
  {
6531
6588
  blockId: n == null ? void 0 : n._id,
6532
6589
  onChange: b,
6533
6590
  formData: i,
6534
- schema: k,
6535
- uiSchema: S
6591
+ schema: S,
6592
+ uiSchema: k
6536
6593
  }
6537
6594
  )
6538
6595
  ] });
6539
6596
  }
6540
6597
  const BlockStylingProps = () => {
6541
- var m;
6598
+ var h;
6542
6599
  const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), a = useRemoveClassesFromBlocks(), [l] = useSelectedBlockIds(), { t: i } = useTranslation();
6543
6600
  if (!o) return null;
6544
6601
  const c = Object.keys(o).filter(
6545
6602
  (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
6546
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (m = n[0]) == null ? void 0 : m.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], f = (x) => find(n, (b) => b.prop === x);
6603
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (h = n[0]) == null ? void 0 : h.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], f = (x) => find(n, (b) => b.prop === x);
6547
6604
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
6548
6605
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
6549
6606
  i("Style element"),
@@ -6585,7 +6642,7 @@ const BlockStylingProps = () => {
6585
6642
  {
6586
6643
  className: "text-xs",
6587
6644
  onClick: () => {
6588
- a(l, h, !0);
6645
+ a(l, m, !0);
6589
6646
  },
6590
6647
  children: i("Clear styles")
6591
6648
  }
@@ -6743,37 +6800,37 @@ const BlockStylingProps = () => {
6743
6800
  },
6744
6801
  a
6745
6802
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6746
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [m, x] = useState(!1), [b, y] = useState(""), [k, S] = useState(!1), [v, _] = useState(!1);
6803
+ 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, x] = useState(!1), [b, y] = useState(""), [S, k] = useState(!1), [v, B] = useState(!1);
6747
6804
  useEffect(() => {
6748
- const { value: w, unit: B } = getClassValueAndUnit(i);
6749
- if (B === "") {
6805
+ const { value: w, unit: j } = getClassValueAndUnit(i);
6806
+ if (j === "") {
6750
6807
  l(w), f(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6751
6808
  return;
6752
6809
  }
6753
- f(B), l(B === "class" || isEmpty(w) ? "" : w);
6810
+ f(j), l(j === "class" || isEmpty(w) ? "" : w);
6754
6811
  }, [i, p, u]);
6755
6812
  const E = useThrottledCallback((w) => c(w), [c], THROTTLE_TIME), I = useThrottledCallback((w) => c(w, !1), [c], THROTTLE_TIME), C = useCallback(
6756
6813
  (w = !1) => {
6757
- const B = getUserInputValues(`${a}`, u);
6758
- if (get(B, "error", !1)) {
6814
+ const j = getUserInputValues(`${a}`, u);
6815
+ if (get(j, "error", !1)) {
6759
6816
  x(!0);
6760
6817
  return;
6761
6818
  }
6762
- const j = get(B, "unit") !== "" ? get(B, "unit") : h;
6763
- if (j === "auto" || j === "none") {
6764
- E(`${d}${j}`);
6819
+ const _ = get(j, "unit") !== "" ? get(j, "unit") : m;
6820
+ if (_ === "auto" || _ === "none") {
6821
+ E(`${d}${_}`);
6765
6822
  return;
6766
6823
  }
6767
- if (get(B, "value") === "")
6824
+ if (get(j, "value") === "")
6768
6825
  return;
6769
- const L = `${get(B, "value", "").startsWith("-") ? "-" : ""}${d}[${get(B, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
6770
- w ? I(L) : E(L);
6826
+ const T = `${get(j, "value", "").startsWith("-") ? "-" : ""}${d}[${get(j, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
6827
+ w ? I(T) : E(T);
6771
6828
  },
6772
- [E, I, a, h, d, u]
6829
+ [E, I, a, m, d, u]
6773
6830
  ), A = useCallback(
6774
6831
  (w) => {
6775
- const B = getUserInputValues(`${a}`, u);
6776
- if (get(B, "error", !1)) {
6832
+ const j = getUserInputValues(`${a}`, u);
6833
+ if (get(j, "error", !1)) {
6777
6834
  x(!0);
6778
6835
  return;
6779
6836
  }
@@ -6781,14 +6838,14 @@ const BlockStylingProps = () => {
6781
6838
  E(`${d}${w}`);
6782
6839
  return;
6783
6840
  }
6784
- if (get(B, "value") === "")
6841
+ if (get(j, "value") === "")
6785
6842
  return;
6786
- const j = get(B, "unit") !== "" ? get(B, "unit") : w, L = `${get(B, "value", "").startsWith("-") ? "-" : ""}${d}[${get(B, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
6787
- E(L);
6843
+ const _ = get(j, "unit") !== "" ? get(j, "unit") : w, T = `${get(j, "value", "").startsWith("-") ? "-" : ""}${d}[${get(j, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
6844
+ E(T);
6788
6845
  },
6789
6846
  [E, a, d, u]
6790
6847
  );
6791
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6848
+ 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: [
6792
6849
  /* @__PURE__ */ jsx(
6793
6850
  "input",
6794
6851
  {
@@ -6801,40 +6858,40 @@ const BlockStylingProps = () => {
6801
6858
  /* @__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, {}) }) }),
6802
6859
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6803
6860
  ] })
6804
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${k ? "z-auto" : ""}`, children: [
6861
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
6805
6862
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6806
- ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
6863
+ ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6807
6864
  "input",
6808
6865
  {
6809
- readOnly: h === "class",
6866
+ readOnly: m === "class",
6810
6867
  onKeyPress: (w) => {
6811
6868
  w.key === "Enter" && C();
6812
6869
  },
6813
6870
  onKeyDown: (w) => {
6814
6871
  if (w.keyCode !== 38 && w.keyCode !== 40)
6815
6872
  return;
6816
- w.preventDefault(), _(!0);
6817
- const B = parseInt$1(w.target.value);
6818
- let j = isNaN$1(B) ? 0 : B;
6819
- w.keyCode === 38 && (j += 1), w.keyCode === 40 && (j -= 1);
6820
- const N = `${j}`, D = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${h === "-" ? "" : h}]`;
6873
+ w.preventDefault(), B(!0);
6874
+ const j = parseInt$1(w.target.value);
6875
+ let _ = isNaN$1(j) ? 0 : j;
6876
+ w.keyCode === 38 && (_ += 1), w.keyCode === 40 && (_ -= 1);
6877
+ const N = `${_}`, D = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
6821
6878
  I(D);
6822
6879
  },
6823
6880
  onKeyUp: (w) => {
6824
- v && (w.preventDefault(), _(!1));
6881
+ v && (w.preventDefault(), B(!1));
6825
6882
  },
6826
6883
  onBlur: () => C(),
6827
6884
  onChange: (w) => {
6828
6885
  x(!1), l(w.target.value);
6829
6886
  },
6830
6887
  onClick: (w) => {
6831
- var B;
6832
- (B = w == null ? void 0 : w.target) == null || B.select(), r(!1);
6888
+ var j;
6889
+ (j = w == null ? void 0 : w.target) == null || j.select(), r(!1);
6833
6890
  },
6834
- value: k ? b : a,
6891
+ value: S ? b : a,
6835
6892
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6836
6893
  " ",
6837
- m ? "border-red-500 text-red-500" : "border-foreground/20"
6894
+ h ? "border-red-500 text-red-500" : "border-foreground/20"
6838
6895
  )
6839
6896
  }
6840
6897
  ),
@@ -6846,7 +6903,7 @@ const BlockStylingProps = () => {
6846
6903
  onClick: () => r(!n),
6847
6904
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
6848
6905
  children: [
6849
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
6906
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
6850
6907
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
6851
6908
  ]
6852
6909
  }
@@ -6855,7 +6912,7 @@ const BlockStylingProps = () => {
6855
6912
  UnitSelection,
6856
6913
  {
6857
6914
  units: u,
6858
- current: h,
6915
+ current: m,
6859
6916
  onSelect: (w) => {
6860
6917
  r(!1), f(w), A(w);
6861
6918
  }
@@ -6863,25 +6920,25 @@ const BlockStylingProps = () => {
6863
6920
  ) })
6864
6921
  ] })
6865
6922
  ] }),
6866
- ["none", "auto"].indexOf(h) !== -1 || k ? null : /* @__PURE__ */ jsx(
6923
+ ["none", "auto"].indexOf(m) !== -1 || S ? null : /* @__PURE__ */ jsx(
6867
6924
  DragStyleButton,
6868
6925
  {
6869
- onDragStart: () => S(!0),
6926
+ onDragStart: () => k(!0),
6870
6927
  onDragEnd: (w) => {
6871
- if (y(() => ""), S(!1), isEmpty(w))
6928
+ if (y(() => ""), k(!1), isEmpty(w))
6872
6929
  return;
6873
- const B = `${w}`, N = `${B.startsWith("-") ? "-" : ""}${d}[${B.replace("-", "")}${h === "-" ? "" : h}]`;
6930
+ const j = `${w}`, N = `${j.startsWith("-") ? "-" : ""}${d}[${j.replace("-", "")}${m === "-" ? "" : m}]`;
6874
6931
  E(N);
6875
6932
  },
6876
6933
  onDrag: (w) => {
6877
6934
  if (isEmpty(w))
6878
6935
  return;
6879
6936
  y(w);
6880
- const B = `${w}`, N = `${B.startsWith("-") ? "-" : ""}${d}[${B.replace("-", "")}${h === "-" ? "" : h}]`;
6937
+ const j = `${w}`, N = `${j.startsWith("-") ? "-" : ""}${d}[${j.replace("-", "")}${m === "-" ? "" : m}]`;
6881
6938
  I(N);
6882
6939
  },
6883
6940
  currentValue: a,
6884
- unit: h,
6941
+ unit: m,
6885
6942
  negative: g,
6886
6943
  cssProperty: p
6887
6944
  }
@@ -6941,7 +6998,7 @@ const COLOR_PROP = {
6941
6998
  ringColor: "ring",
6942
6999
  ringOffsetColor: "ring-offset"
6943
7000
  }, ColorChoice = ({ property: o, onChange: n }) => {
6944
- 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", ""), h = get(u, "2", ""), f = useCallback(
7001
+ 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(
6945
7002
  // eslint-disable-next-line no-shadow
6946
7003
  (b) => {
6947
7004
  ["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" })));
@@ -6953,7 +7010,7 @@ const COLOR_PROP = {
6953
7010
  return c([]);
6954
7011
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
6955
7012
  }, [g]);
6956
- const m = useCallback(
7013
+ const h = useCallback(
6957
7014
  // eslint-disable-next-line no-shadow
6958
7015
  (b) => {
6959
7016
  p({ color: g, shade: b });
@@ -7007,7 +7064,7 @@ const COLOR_PROP = {
7007
7064
  ]
7008
7065
  }
7009
7066
  ) }),
7010
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: m, options: i }) })
7067
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: h, options: i }) })
7011
7068
  ] });
7012
7069
  }, EDITOR_ICONS = {
7013
7070
  "not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
@@ -7341,7 +7398,7 @@ const COLOR_PROP = {
7341
7398
  "2xl": "1536px"
7342
7399
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
7343
7400
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
7344
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(h, "fullCls", ""), [h]), y = useCallback(
7401
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
7345
7402
  (I, C = !0) => {
7346
7403
  const A = { dark: p, mq: g, mod: u, cls: I, property: l, fullCls: "" };
7347
7404
  (p || u !== "") && (A.mq = "xs");
@@ -7349,13 +7406,13 @@ const COLOR_PROP = {
7349
7406
  f(x, [w], C);
7350
7407
  },
7351
7408
  [x, p, g, u, l, f]
7352
- ), k = useCallback(() => {
7353
- m(x, [b], !0);
7354
- }, [x, b, m]), S = useMemo(() => canChangeClass(h, g), [h, g]);
7409
+ ), S = useCallback(() => {
7410
+ h(x, [b], !0);
7411
+ }, [x, b, h]), k = useMemo(() => canChangeClass(m, g), [m, g]);
7355
7412
  useEffect(() => {
7356
- i(S, h);
7357
- }, [S, i, h]);
7358
- const [, , v] = useScreenSizeWidth(), _ = useCallback(
7413
+ i(k, m);
7414
+ }, [k, i, m]);
7415
+ const [, , v] = useScreenSizeWidth(), B = useCallback(
7359
7416
  (I) => {
7360
7417
  v({
7361
7418
  xs: 400,
@@ -7367,15 +7424,15 @@ const COLOR_PROP = {
7367
7424
  }[I]);
7368
7425
  },
7369
7426
  [v]
7370
- ), E = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
7371
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: h && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
7372
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !E ? "text-foreground" : ""}`, children: n(a) }) }),
7427
+ ), E = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
7428
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: k, canReset: m && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
7429
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !E ? "text-foreground" : ""}`, children: n(a) }) }),
7373
7430
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
7374
7431
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
7375
7432
  r === "arbitrary" ? /* @__PURE__ */ jsx(
7376
7433
  AdvanceChoices,
7377
7434
  {
7378
- currentClass: get(h, "cls", ""),
7435
+ currentClass: get(m, "cls", ""),
7379
7436
  classPrefix: get(CLASS_PREFIXES, l, ""),
7380
7437
  units: c || [],
7381
7438
  onChange: y,
@@ -7388,7 +7445,7 @@ const COLOR_PROP = {
7388
7445
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
7389
7446
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
7390
7447
  ] }),
7391
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: E ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => k(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
7448
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: E ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : k && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
7392
7449
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
7393
7450
  "button",
7394
7451
  {
@@ -7400,19 +7457,19 @@ const COLOR_PROP = {
7400
7457
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
7401
7458
  "Current style is set at  ",
7402
7459
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
7403
- getBreakpoint(get(h, "mq")),
7404
- p && !h.dark ? "(Light mode)" : ""
7460
+ getBreakpoint(get(m, "mq")),
7461
+ p && !m.dark ? "(Light mode)" : ""
7405
7462
  ] }),
7406
7463
  /* @__PURE__ */ jsx("br", {}),
7407
7464
  /* @__PURE__ */ jsxs(
7408
7465
  "button",
7409
7466
  {
7410
7467
  type: "button",
7411
- onClick: () => _(get(h, "mq")),
7468
+ onClick: () => B(get(m, "mq")),
7412
7469
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
7413
7470
  children: [
7414
7471
  "Switch to ",
7415
- get(h, "mq").toUpperCase()
7472
+ get(m, "mq").toUpperCase()
7416
7473
  ]
7417
7474
  }
7418
7475
  )
@@ -7429,7 +7486,7 @@ const COLOR_PROP = {
7429
7486
  units: i = basicUnits,
7430
7487
  negative: c = !1
7431
7488
  }) => {
7432
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((f) => map(g, "property").includes(f), [g]);
7489
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
7433
7490
  return /* @__PURE__ */ jsxs(
7434
7491
  "div",
7435
7492
  {
@@ -7437,18 +7494,18 @@ const COLOR_PROP = {
7437
7494
  children: [
7438
7495
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
7439
7496
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
7440
- /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: f, key: m }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
7497
+ /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: f, key: h }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
7441
7498
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
7442
7499
  "button",
7443
7500
  {
7444
7501
  type: "button",
7445
- onClick: () => u(m),
7446
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${m === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
7502
+ onClick: () => u(h),
7503
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
7447
7504
  children: [
7448
7505
  React__default.createElement("div", {
7449
- className: h(m) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
7506
+ className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
7450
7507
  }),
7451
- React__default.createElement(get(EDITOR_ICONS, m, BoxIcon), { className: "text-inherit w-3 h-3" })
7508
+ React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
7452
7509
  ]
7453
7510
  }
7454
7511
  ) }),
@@ -7575,7 +7632,7 @@ const COLOR_PROP = {
7575
7632
  icon: p,
7576
7633
  onClick: u,
7577
7634
  buttonClass: g = "",
7578
- activeButtonClass: h = ""
7635
+ activeButtonClass: m = ""
7579
7636
  }) => {
7580
7637
  const { t: f } = useTranslation();
7581
7638
  return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
@@ -7584,7 +7641,7 @@ const COLOR_PROP = {
7584
7641
  {
7585
7642
  onClick: () => u(d),
7586
7643
  size: "sm",
7587
- className: cn$1("h-7 w-7 rounded-md p-1", c === i ? h : g),
7644
+ className: cn$1("h-7 w-7 rounded-md p-1", c === i ? m : g),
7588
7645
  variant: c === i ? "outline" : "ghost",
7589
7646
  children: p
7590
7647
  }
@@ -7610,33 +7667,33 @@ const COLOR_PROP = {
7610
7667
  buttonClass: a = "",
7611
7668
  activeButtonClass: l = ""
7612
7669
  }) => {
7613
- const [i, , c] = useScreenSizeWidth(), [d, p] = useCanvasDisplayWidth(), [u, g] = useSelectedBreakpoints(), h = u, f = g, { t: m } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (S) => {
7614
- h.includes(S) ? h.length > 2 && f(h.filter((v) => v !== S)) : f((v) => [...v, S]);
7615
- }, y = (S) => {
7616
- n || c(S), p(S);
7617
- }, k = getBreakpointValue(n ? d : i).toLowerCase();
7618
- return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (S) => /* @__PURE__ */ createElement(
7670
+ const [i, , c] = useScreenSizeWidth(), [d, p] = useCanvasDisplayWidth(), [u, g] = useSelectedBreakpoints(), m = u, f = g, { t: h } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (k) => {
7671
+ m.includes(k) ? m.length > 2 && f(m.filter((v) => v !== k)) : f((v) => [...v, k]);
7672
+ }, y = (k) => {
7673
+ n || c(k), p(k);
7674
+ }, S = getBreakpointValue(n ? d : i).toLowerCase();
7675
+ return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
7619
7676
  BreakpointCard,
7620
7677
  {
7621
7678
  canvas: n,
7622
- ...S,
7679
+ ...k,
7623
7680
  onClick: y,
7624
- key: S.breakpoint,
7625
- currentBreakpoint: k
7681
+ key: k.breakpoint,
7682
+ currentBreakpoint: S
7626
7683
  }
7627
7684
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
7628
7685
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
7629
- x.filter((S) => includes(h, toUpper(S.breakpoint))),
7630
- (S) => /* @__PURE__ */ createElement(
7686
+ x.filter((k) => includes(m, toUpper(k.breakpoint))),
7687
+ (k) => /* @__PURE__ */ createElement(
7631
7688
  BreakpointCard,
7632
7689
  {
7633
7690
  canvas: n,
7634
7691
  openDelay: o,
7635
7692
  tooltip: r,
7636
- ...S,
7693
+ ...k,
7637
7694
  onClick: y,
7638
- key: S.breakpoint,
7639
- currentBreakpoint: k,
7695
+ key: k.breakpoint,
7696
+ currentBreakpoint: S,
7640
7697
  buttonClass: a,
7641
7698
  activeButtonClass: l
7642
7699
  }
@@ -7645,18 +7702,18 @@ const COLOR_PROP = {
7645
7702
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
7646
7703
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer rounded-md p-1 hover:bg-background", children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "scale-90 transform" }) }) }),
7647
7704
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
7648
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
7705
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
7649
7706
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
7650
- map(x, (S) => /* @__PURE__ */ jsx(
7707
+ map(x, (k) => /* @__PURE__ */ jsx(
7651
7708
  DropdownMenuCheckboxItem,
7652
7709
  {
7653
- disabled: S.breakpoint === "xs",
7654
- onCheckedChange: () => b(toUpper(S.breakpoint)),
7655
- checked: includes(h, toUpper(S.breakpoint)),
7710
+ disabled: k.breakpoint === "xs",
7711
+ onCheckedChange: () => b(toUpper(k.breakpoint)),
7712
+ checked: includes(m, toUpper(k.breakpoint)),
7656
7713
  onSelect: (v) => v.preventDefault(),
7657
- children: m(S.title)
7714
+ children: h(k.title)
7658
7715
  },
7659
- S.breakpoint
7716
+ k.breakpoint
7660
7717
  ))
7661
7718
  ] })
7662
7719
  ] })
@@ -7681,24 +7738,24 @@ function BreakpointSelector() {
7681
7738
  }
7682
7739
  function ManualClasses() {
7683
7740
  var N;
7684
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), [f, m] = useState(""), x = (N = first(d)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((L) => !isEmpty(L)), k = useBuilderProp("flags.copyPaste", !0), S = () => {
7685
- const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
7686
- u(h, L, !0), m("");
7687
- }, [v, _] = useState([]), E = ({ value: L }) => {
7688
- const D = L.trim().toLowerCase(), P = D.match(/.+:/g);
7741
+ 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, h] = useState(""), x = (N = first(d)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((T) => !isEmpty(T)), S = useBuilderProp("flags.copyPaste", !0), k = () => {
7742
+ const T = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
7743
+ u(m, T, !0), h("");
7744
+ }, [v, B] = useState([]), E = ({ value: T }) => {
7745
+ const D = T.trim().toLowerCase(), P = D.match(/.+:/g);
7689
7746
  let R = [];
7690
7747
  if (P && P.length > 0) {
7691
- const [M] = P, T = D.replace(M, "");
7692
- R = i.search(T).map(($) => ({
7693
- ...$,
7694
- item: { ...$.item, name: M + $.item.name }
7748
+ const [M] = P, L = D.replace(M, "");
7749
+ R = i.search(L).map((H) => ({
7750
+ ...H,
7751
+ item: { ...H.item, name: M + H.item.name }
7695
7752
  }));
7696
7753
  } else
7697
7754
  R = i.search(D);
7698
- return _(map(R, "item"));
7755
+ return B(map(R, "item"));
7699
7756
  }, I = () => {
7700
- _([]);
7701
- }, C = (L) => L.name, A = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), w = useMemo(
7757
+ B([]);
7758
+ }, C = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), w = useMemo(
7702
7759
  () => ({
7703
7760
  ref: o,
7704
7761
  autoComplete: "off",
@@ -7707,23 +7764,23 @@ function ManualClasses() {
7707
7764
  spellCheck: !1,
7708
7765
  placeholder: c("Enter classes separated by space"),
7709
7766
  value: f,
7710
- onFocus: (L) => {
7767
+ onFocus: (T) => {
7711
7768
  setTimeout(() => {
7712
- L.target && L.target.select();
7769
+ T.target && T.target.select();
7713
7770
  }, 0);
7714
7771
  },
7715
- onKeyDown: (L) => {
7716
- L.key === "Enter" && f.trim() !== "" && S();
7772
+ onKeyDown: (T) => {
7773
+ T.key === "Enter" && f.trim() !== "" && k();
7717
7774
  },
7718
- onChange: (L, { newValue: D }) => m(D),
7775
+ onChange: (T, { newValue: D }) => h(D),
7719
7776
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
7720
7777
  }),
7721
7778
  [f, c, o]
7722
- ), B = (L) => {
7779
+ ), j = (T) => {
7723
7780
  debugger;
7724
7781
  const D = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
7725
- g(h, [L]), u(h, D, !0), r(""), l(-1);
7726
- }, j = () => {
7782
+ g(m, [T]), u(m, D, !0), r(""), l(-1);
7783
+ }, _ = () => {
7727
7784
  if (navigator.clipboard === void 0) {
7728
7785
  toast.error(c("Clipboard not supported"));
7729
7786
  return;
@@ -7733,8 +7790,8 @@ function ManualClasses() {
7733
7790
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
7734
7791
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
7735
7792
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
7736
- k && /* @__PURE__ */ jsxs(Tooltip, { children: [
7737
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
7793
+ S && /* @__PURE__ */ jsxs(Tooltip, { children: [
7794
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
7738
7795
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
7739
7796
  ] })
7740
7797
  ] }) }),
@@ -7763,7 +7820,7 @@ function ManualClasses() {
7763
7820
  {
7764
7821
  variant: "outline",
7765
7822
  className: "h-6 border-border",
7766
- onClick: S,
7823
+ onClick: k,
7767
7824
  disabled: f.trim() === "",
7768
7825
  size: "sm",
7769
7826
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -7771,17 +7828,17 @@ function ManualClasses() {
7771
7828
  )
7772
7829
  ] }),
7773
7830
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: y.map(
7774
- (L, D) => a === D ? /* @__PURE__ */ jsx(
7831
+ (T, D) => a === D ? /* @__PURE__ */ jsx(
7775
7832
  "input",
7776
7833
  {
7777
7834
  ref: o,
7778
7835
  value: n,
7779
7836
  onChange: (P) => r(P.target.value),
7780
7837
  onBlur: () => {
7781
- B(L);
7838
+ j(T);
7782
7839
  },
7783
7840
  onKeyDown: (P) => {
7784
- P.key === "Enter" && B(L);
7841
+ P.key === "Enter" && j(T);
7785
7842
  },
7786
7843
  onFocus: (P) => {
7787
7844
  setTimeout(() => {
@@ -7790,12 +7847,12 @@ function ManualClasses() {
7790
7847
  },
7791
7848
  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"
7792
7849
  },
7793
- L
7850
+ T
7794
7851
  ) : /* @__PURE__ */ jsx("div", { className: "group relative flex max-w-[260px] items-center", children: /* @__PURE__ */ jsxs(
7795
7852
  "button",
7796
7853
  {
7797
7854
  onDoubleClick: () => {
7798
- m(L), g(h, [L]), setTimeout(() => {
7855
+ h(T), g(m, [T]), setTimeout(() => {
7799
7856
  o.current && o.current.focus();
7800
7857
  }, 10);
7801
7858
  },
@@ -7805,7 +7862,7 @@ function ManualClasses() {
7805
7862
  /* @__PURE__ */ jsx(
7806
7863
  Cross2Icon,
7807
7864
  {
7808
- onClick: () => g(h, [L], !0),
7865
+ onClick: () => g(m, [T], !0),
7809
7866
  className: "hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"
7810
7867
  }
7811
7868
  ),
@@ -7832,10 +7889,10 @@ function ManualClasses() {
7832
7889
  }
7833
7890
  )
7834
7891
  ] }),
7835
- /* @__PURE__ */ jsx("div", { children: L })
7892
+ /* @__PURE__ */ jsx("div", { children: T })
7836
7893
  ]
7837
7894
  }
7838
- ) }, L)
7895
+ ) }, T)
7839
7896
  ) })
7840
7897
  ] });
7841
7898
  }
@@ -7948,13 +8005,13 @@ function BlockStyling() {
7948
8005
  cssProperty: ""
7949
8006
  }), d = useThrottledCallback(
7950
8007
  (u) => {
7951
- const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
8008
+ const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
7952
8009
  let f = parseFloat(i.dragStartValue);
7953
8010
  f = isNaN(f) ? 0 : f;
7954
- let m = MAPPER[i.dragUnit];
7955
- (startsWith(h, "scale") || h === "opacity") && (m = 10);
7956
- let b = (i.dragStartY - u.pageY) / m + f;
7957
- g && b < 0 && (b = 0), h === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
8011
+ let h = MAPPER[i.dragUnit];
8012
+ (startsWith(m, "scale") || m === "opacity") && (h = 10);
8013
+ let b = (i.dragStartY - u.pageY) / h + f;
8014
+ g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
7958
8015
  },
7959
8016
  [i],
7960
8017
  50
@@ -8002,7 +8059,7 @@ const CoreBlock = ({
8002
8059
  } else
8003
8060
  d(o, r || null, a);
8004
8061
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8005
- }, g = useIsDragAndDropEnabled(), { t: h } = useTranslation(), { onDragStart: f, onDragEnd: m } = useDragAndDrop();
8062
+ }, g = useIsDragAndDropEnabled(), { t: m } = useTranslation(), { onDragStart: f, onDragEnd: h } = useDragAndDrop();
8006
8063
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
8007
8064
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
8008
8065
  "button",
@@ -8011,16 +8068,16 @@ const CoreBlock = ({
8011
8068
  onClick: u,
8012
8069
  type: "button",
8013
8070
  onDragStart: (x) => f(x, { ...o, label: c, icon: i }),
8014
- onDragEnd: m,
8071
+ onDragEnd: h,
8015
8072
  draggable: g,
8016
8073
  className: `${kebabCase(`chai-block-${l}`)} ${g ? "cursor-grab active:cursor-grabbing" : "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 ${n ? "opacity-50" : ""}`,
8017
8074
  children: [
8018
8075
  createElement(i || BoxIcon, { className: "w-4 h-4 mx-auto", "data-add-core-block-icon": l }),
8019
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(h(c || l)) })
8076
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(m(c || l)) })
8020
8077
  ]
8021
8078
  }
8022
8079
  ) }),
8023
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(c || l) }) })
8080
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m(c || l) }) })
8024
8081
  ] }) });
8025
8082
  }, DefaultChaiBlocks = ({
8026
8083
  parentId: o,
@@ -8051,8 +8108,8 @@ const registerChaiPreImportHTMLHook = (o) => {
8051
8108
  }) => {
8052
8109
  const { t: a } = useTranslation(), [l, i] = useState(""), { addPredefinedBlock: c } = useAddBlock(), [d, p] = useState(!1), u = async () => {
8053
8110
  p(!0);
8054
- const g = await getPreImportHTML(l), h = getBlocksFromHTML(g);
8055
- c([...h], o, n), i(""), p(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8111
+ const g = await getPreImportHTML(l), m = getBlocksFromHTML(g);
8112
+ c([...m], o, n), i(""), p(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8056
8113
  };
8057
8114
  return /* @__PURE__ */ jsxs(Card, { className: `border-border/0 p-0 shadow-none ${r ? "w-full" : "max-w-full"}`, children: [
8058
8115
  /* @__PURE__ */ jsx(CardHeader, { className: r ? "p-0" : "p-3", children: /* @__PURE__ */ jsx(CardDescription, { className: r ? "text-xs" : "", children: a("Use HTML snippets from Tailwind CSS component libraries") }) }),
@@ -8141,50 +8198,50 @@ const registerChaiLibrary = (o, n) => {
8141
8198
  draggable: c,
8142
8199
  className: d = ""
8143
8200
  }) => {
8144
- const { onDragStart: p, onDragEnd: u } = useDragAndDrop(), g = useIsDragAndDropEnabled(), [, h] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = c !== void 0 ? c : g;
8201
+ const { onDragStart: p, onDragEnd: u } = useDragAndDrop(), g = useIsDragAndDropEnabled(), [, m] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), h = c !== void 0 ? c : g;
8145
8202
  return /* @__PURE__ */ jsx(
8146
8203
  "div",
8147
8204
  {
8148
- draggable: m,
8205
+ draggable: h,
8149
8206
  onDragStart: async (y) => {
8150
8207
  try {
8151
8208
  if (l) {
8152
8209
  l(y);
8153
8210
  return;
8154
8211
  }
8155
- let k = null;
8212
+ let S = null;
8156
8213
  if (n) {
8157
- const S = typeof n == "function" ? await n() : n, v = getBlocksFromHTML(S);
8214
+ const k = typeof n == "function" ? await n() : n, v = getBlocksFromHTML(k);
8158
8215
  if (isEmpty(v)) return;
8159
- k = {
8216
+ S = {
8160
8217
  type: "Box",
8161
8218
  blocks: v,
8162
8219
  name: get(v, "0._type", "Block")
8163
8220
  };
8164
8221
  } else if (r) {
8165
- const S = typeof r == "function" ? await r() : r;
8166
- if (isEmpty(S)) return;
8167
- k = {
8222
+ const k = typeof r == "function" ? await r() : r;
8223
+ if (isEmpty(k)) return;
8224
+ S = {
8168
8225
  type: "Box",
8169
- blocks: S,
8170
- name: get(S, "0._type", "Block")
8226
+ blocks: k,
8227
+ name: get(k, "0._type", "Block")
8171
8228
  };
8172
8229
  } else if (o) {
8173
- const S = typeof o == "function" ? await o() : o;
8174
- k = typeof S == "object" ? omit(S, ["component", "icon"]) : S;
8230
+ const k = typeof o == "function" ? await o() : o;
8231
+ S = typeof k == "object" ? omit(k, ["component", "icon"]) : k;
8175
8232
  }
8176
- if (!k) return;
8177
- p(y, k, !0), setTimeout(() => {
8178
- h([]), f();
8233
+ if (!S) return;
8234
+ p(y, S, !0), setTimeout(() => {
8235
+ m([]), f();
8179
8236
  }, 200);
8180
- } catch (k) {
8181
- console.error("Error in ChaiDraggableBlock drag start:", k);
8237
+ } catch (S) {
8238
+ console.error("Error in ChaiDraggableBlock drag start:", S);
8182
8239
  }
8183
8240
  },
8184
8241
  onDragEnd: (y) => {
8185
8242
  i ? i(y) : u();
8186
8243
  },
8187
- className: `${m ? "cursor-grab active:cursor-grabbing" : ""} ${d}`.trim(),
8244
+ className: `${h ? "cursor-grab active:cursor-grabbing" : ""} ${d}`.trim(),
8188
8245
  children: a
8189
8246
  }
8190
8247
  );
@@ -8220,23 +8277,23 @@ const BlockCard = ({
8220
8277
  parentId: r = void 0,
8221
8278
  position: a = -1
8222
8279
  }) => {
8223
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), u = get(o, "name", get(o, "label")), g = get(o, "description", ""), { onDragStart: h, onDragEnd: f } = useDragAndDrop(), m = useIsDragAndDropEnabled(), x = useCallback(
8280
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), u = get(o, "name", get(o, "label")), g = get(o, "description", ""), { onDragStart: m, onDragEnd: f } = useDragAndDrop(), h = useIsDragAndDropEnabled(), x = useCallback(
8224
8281
  async (y) => {
8225
8282
  if (y.stopPropagation(), has(o, "component")) {
8226
8283
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8227
8284
  return;
8228
8285
  }
8229
8286
  i(!0);
8230
- let k = await c({ library: n, block: o });
8231
- typeof k == "string" && (k = getBlocksFromHTML(k)), isEmpty(k) || p(syncBlocksWithDefaults(k), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK), setTimeout(() => i(!1), 1e3);
8287
+ let S = await c({ library: n, block: o });
8288
+ typeof S == "string" && (S = getBlocksFromHTML(S)), isEmpty(S) || p(syncBlocksWithDefaults(S), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK), setTimeout(() => i(!1), 1e3);
8232
8289
  },
8233
8290
  [d, p, o, c, n, r, a]
8234
8291
  );
8235
8292
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
8236
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(ChaiDraggableBlock, { draggable: m, onDragStart: async (y) => {
8237
- if (!m) return;
8238
- let k = await c({ library: n, block: o });
8239
- typeof k == "string" && (k = getBlocksFromHTML(k)), h(y, { type: "Box", blocks: k, name: u }, !0);
8293
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(ChaiDraggableBlock, { draggable: h, onDragStart: async (y) => {
8294
+ if (!h) return;
8295
+ let S = await c({ library: n, block: o });
8296
+ typeof S == "string" && (S = getBlocksFromHTML(S)), m(y, { type: "Box", blocks: S, name: u }, !0);
8240
8297
  }, onDragEnd: f, children: /* @__PURE__ */ jsxs(
8241
8298
  "div",
8242
8299
  {
@@ -8244,7 +8301,7 @@ const BlockCard = ({
8244
8301
  } : x,
8245
8302
  className: clsx$1(
8246
8303
  "relative mt-2 overflow-hidden rounded-md border border-border duration-200 hover:border-blue-500 hover:shadow-xl",
8247
- m ? "" : "cursor-pointer"
8304
+ h ? "" : "cursor-pointer"
8248
8305
  ),
8249
8306
  children: [
8250
8307
  l && /* @__PURE__ */ jsxs("div", { className: "absolute flex h-full w-full items-center justify-center bg-black/70", children: [
@@ -8265,7 +8322,7 @@ const BlockCard = ({
8265
8322
  position: n,
8266
8323
  fromSidebar: r
8267
8324
  }) => {
8268
- const [a, l] = useSelectedLibrary(), i = useChaiLibraries(), c = i.find((B) => B.id === a) || first(i), { data: d, isLoading: p, resetLibrary: u } = useLibraryBlocks(c), [g, h] = useState(""), [f, m] = useState([]), x = useRef(null);
8325
+ const [a, l] = useSelectedLibrary(), i = useChaiLibraries(), c = i.find((j) => j.id === a) || first(i), { data: d, isLoading: p, resetLibrary: u } = useLibraryBlocks(c), [g, m] = useState(""), [f, h] = useState([]), x = useRef(null);
8269
8326
  useEffect(() => {
8270
8327
  d && d.length > 0 && (x.current = new Fuse(d, {
8271
8328
  keys: ["name", "label", "description", "group"],
@@ -8274,26 +8331,26 @@ const BlockCard = ({
8274
8331
  }));
8275
8332
  }, [d]), useEffect(() => {
8276
8333
  if (!g.trim() || !x.current) {
8277
- m([]);
8334
+ h([]);
8278
8335
  return;
8279
8336
  }
8280
- const B = x.current.search(g).map((j) => j.item);
8281
- m(B);
8337
+ const j = x.current.search(g).map((_) => _.item);
8338
+ h(j);
8282
8339
  }, [g]);
8283
- const b = g.trim() && !isEmpty(f) ? f : d, y = groupBy(b, "group"), [k, S] = useState(null);
8340
+ const b = g.trim() && !isEmpty(f) ? f : d, y = groupBy(b, "group"), [S, k] = useState(null);
8284
8341
  useEffect(() => {
8285
8342
  if (isEmpty(keys(y))) {
8286
- S(null);
8343
+ k(null);
8287
8344
  return;
8288
8345
  }
8289
- if (!k || !y[k]) {
8290
- S(first(keys(y)));
8346
+ if (!S || !y[S]) {
8347
+ k(first(keys(y)));
8291
8348
  return;
8292
8349
  }
8293
- }, [y, k]);
8294
- const v = get(y, k, []), _ = useRef(null), { t: E } = useTranslation(), I = (B) => {
8295
- _.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
8296
- _.current && S(B);
8350
+ }, [y, S]);
8351
+ const v = get(y, S, []), B = useRef(null), { t: E } = useTranslation(), I = (j) => {
8352
+ B.current && (clearTimeout(B.current), B.current = null), B.current = setTimeout(() => {
8353
+ B.current && k(j);
8297
8354
  }, 400);
8298
8355
  }, C = () => {
8299
8356
  c != null && c.id && u(c.id);
@@ -8303,9 +8360,9 @@ const BlockCard = ({
8303
8360
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
8304
8361
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
8305
8362
  ] });
8306
- const A = filter(v, (B, j) => j % 2 === 0), w = filter(v, (B, j) => j % 2 === 1);
8363
+ const A = filter(v, (j, _) => _ % 2 === 0), w = filter(v, (j, _) => _ % 2 === 1);
8307
8364
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
8308
- /* @__PURE__ */ jsx(SearchInput, { value: g, setValue: h }),
8365
+ /* @__PURE__ */ jsx(SearchInput, { value: g, setValue: m }),
8309
8366
  /* @__PURE__ */ jsx("div", { className: "relative flex h-full max-h-full flex-1 overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: `flex h-full flex-1 pt-2 ${r ? "flex-col" : ""}`, children: [
8310
8367
  /* @__PURE__ */ jsxs(
8311
8368
  "div",
@@ -8326,26 +8383,26 @@ const BlockCard = ({
8326
8383
  /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
8327
8384
  E("Retry")
8328
8385
  ] })
8329
- ] }) }) : r ? /* @__PURE__ */ jsxs(Select$1, { value: k, onValueChange: S, children: [
8386
+ ] }) }) : r ? /* @__PURE__ */ jsxs(Select$1, { value: S, onValueChange: k, children: [
8330
8387
  /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: E("Select a group") }) }),
8331
- /* @__PURE__ */ jsx(SelectContent, { children: map(y, (B, j) => /* @__PURE__ */ jsx(SelectItem, { value: j, children: capitalize(E(j.toLowerCase())) }, j)) })
8332
- ] }) : map(y, (B, j) => /* @__PURE__ */ jsxs(
8388
+ /* @__PURE__ */ jsx(SelectContent, { children: map(y, (j, _) => /* @__PURE__ */ jsx(SelectItem, { value: _, children: capitalize(E(_.toLowerCase())) }, _)) })
8389
+ ] }) : map(y, (j, _) => /* @__PURE__ */ jsxs(
8333
8390
  "div",
8334
8391
  {
8335
- onMouseEnter: () => I(j),
8336
- onMouseLeave: () => clearTimeout(_.current),
8392
+ onMouseEnter: () => I(_),
8393
+ onMouseLeave: () => clearTimeout(B.current),
8337
8394
  role: "button",
8338
- onClick: () => S(j),
8395
+ onClick: () => k(_),
8339
8396
  className: cn$2(
8340
8397
  "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",
8341
- j === k ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
8398
+ _ === S ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
8342
8399
  ),
8343
8400
  children: [
8344
- /* @__PURE__ */ jsx("span", { children: capitalize(E(j.toLowerCase())) }),
8401
+ /* @__PURE__ */ jsx("span", { children: capitalize(E(_.toLowerCase())) }),
8345
8402
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
8346
8403
  ]
8347
8404
  },
8348
- j
8405
+ _
8349
8406
  ))
8350
8407
  }
8351
8408
  )
@@ -8356,29 +8413,29 @@ const BlockCard = ({
8356
8413
  /* @__PURE__ */ jsx("div", { className: `flex h-full max-h-full w-full flex-col border-border ${r ? "" : "border-l"}`, children: /* @__PURE__ */ jsxs(
8357
8414
  ScrollArea,
8358
8415
  {
8359
- onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
8416
+ onMouseEnter: () => B.current ? clearTimeout(B.current) : null,
8360
8417
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
8361
8418
  children: [
8362
8419
  isEmpty(v) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: `grid w-full gap-2 ${r ? "grid-cols-1 pb-20" : "grid-cols-2 px-2"}`, children: [
8363
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((B, j) => /* @__PURE__ */ jsx(
8420
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((j, _) => /* @__PURE__ */ jsx(
8364
8421
  BlockCard,
8365
8422
  {
8366
8423
  parentId: o,
8367
8424
  position: n,
8368
- block: B,
8425
+ block: j,
8369
8426
  library: c
8370
8427
  },
8371
- `block-${j}`
8428
+ `block-${_}`
8372
8429
  )) }),
8373
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: w.map((B, j) => /* @__PURE__ */ jsx(
8430
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: w.map((j, _) => /* @__PURE__ */ jsx(
8374
8431
  BlockCard,
8375
8432
  {
8376
8433
  parentId: o,
8377
8434
  position: n,
8378
- block: B,
8435
+ block: j,
8379
8436
  library: c
8380
8437
  },
8381
- `block-second-${j}`
8438
+ `block-second-${_}`
8382
8439
  )) })
8383
8440
  ] }),
8384
8441
  /* @__PURE__ */ jsx("br", {}),
@@ -8408,7 +8465,7 @@ const BlockCard = ({
8408
8465
  gridCols: r = "grid-cols-2",
8409
8466
  disableBlockGroupsSidebar: a = !1
8410
8467
  }) => {
8411
- const { data: l, isLoading: i, refetch: c, error: d } = usePartialBlocksList(), [p, u] = useAtom$1(partialBlocksDataAtom), [g, h] = useAtom$1(hasInitializedPartialBlocksAtom);
8468
+ const { data: l, isLoading: i, refetch: c, error: d } = usePartialBlocksList(), [p, u] = useAtom$1(partialBlocksDataAtom), [g, m] = useAtom$1(hasInitializedPartialBlocksAtom);
8412
8469
  useEffect(() => {
8413
8470
  if (!g || Object.keys(p.blocks).length === 0)
8414
8471
  if (d)
@@ -8417,47 +8474,47 @@ const BlockCard = ({
8417
8474
  groups: [],
8418
8475
  isLoading: !1,
8419
8476
  error: d
8420
- }), h(!0);
8477
+ }), m(!0);
8421
8478
  else if (!i && Object.keys(l || {}).length > 0) {
8422
- const m = Object.entries(l).map(([b, y]) => {
8423
- const k = y, S = k.type || "partial", v = formatReadableName(S);
8479
+ const h = Object.entries(l).map(([b, y]) => {
8480
+ const S = y, k = S.type || "partial", v = formatReadableName(k);
8424
8481
  return {
8425
8482
  type: "PartialBlock",
8426
8483
  // Set the type to PartialBlock
8427
- label: formatReadableName(k.name || b),
8428
- description: k.description || "",
8484
+ label: formatReadableName(S.name || b),
8485
+ description: S.description || "",
8429
8486
  icon: FrameIcon,
8430
8487
  group: v,
8431
8488
  // Use formatted type as group
8432
8489
  category: "partial",
8433
8490
  partialBlockId: b,
8434
8491
  // Store the original ID as partialBlockId
8435
- _name: k.name
8492
+ _name: S.name
8436
8493
  };
8437
- }), x = uniq(map(m, "group"));
8494
+ }), x = uniq(map(h, "group"));
8438
8495
  u({
8439
- blocks: m,
8496
+ blocks: h,
8440
8497
  groups: x,
8441
8498
  isLoading: !1,
8442
8499
  error: null
8443
- }), h(!0);
8444
- } else i ? u((m) => ({ ...m, isLoading: !0, error: null })) : !i && Object.keys(l || {}).length === 0 && (u({
8500
+ }), m(!0);
8501
+ } else i ? u((h) => ({ ...h, isLoading: !0, error: null })) : !i && Object.keys(l || {}).length === 0 && (u({
8445
8502
  blocks: [],
8446
8503
  groups: [],
8447
8504
  isLoading: !1,
8448
8505
  error: "No partial blocks available"
8449
- }), h(!0));
8506
+ }), m(!0));
8450
8507
  }, [
8451
8508
  i,
8452
8509
  l,
8453
8510
  g,
8454
- h,
8511
+ m,
8455
8512
  u,
8456
8513
  p.blocks,
8457
8514
  d
8458
8515
  ]);
8459
8516
  const f = () => {
8460
- u((m) => ({ ...m, isLoading: !0, error: null })), h(!1), c();
8517
+ u((h) => ({ ...h, isLoading: !0, error: null })), m(!1), c();
8461
8518
  };
8462
8519
  return p.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : p.error || p.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
8463
8520
  /* @__PURE__ */ jsx("p", { children: p.error || "No partial blocks available" }),
@@ -8490,44 +8547,44 @@ const BlockCard = ({
8490
8547
  gridCols: l = "grid-cols-4",
8491
8548
  disableBlockGroupsSidebar: i
8492
8549
  }) => {
8493
- var B;
8494
- const { t: c } = useTranslation(), [d] = useBlocksStore(), [p, u] = useState(""), g = useRef(null), [h] = useAtom$1(addBlockTabAtom), f = (B = find(d, (j) => j._id === r)) == null ? void 0 : B._type, [m, x] = useState("all"), [b, y] = useState(null), k = useRef(null);
8550
+ var j;
8551
+ const { t: c } = useTranslation(), [d] = useBlocksStore(), [p, u] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), f = (j = find(d, (_) => _._id === r)) == null ? void 0 : j._type, [h, x] = useState("all"), [b, y] = useState(null), S = useRef(null);
8495
8552
  useEffect(() => {
8496
- const j = setTimeout(() => {
8553
+ const _ = setTimeout(() => {
8497
8554
  var N;
8498
8555
  (N = g.current) == null || N.focus();
8499
8556
  }, 0);
8500
- return () => clearTimeout(j);
8501
- }, [h]), useEffect(() => {
8557
+ return () => clearTimeout(_);
8558
+ }, [m]), useEffect(() => {
8502
8559
  p && (x("all"), y(null));
8503
- }, [p]), useEffect(() => (k.current = debounce((j) => {
8504
- x(j);
8560
+ }, [p]), useEffect(() => (S.current = debounce((_) => {
8561
+ x(_);
8505
8562
  }, 500), () => {
8506
- k.current && k.current.cancel();
8563
+ S.current && S.current.cancel();
8507
8564
  }), []);
8508
- const S = useCallback((j) => {
8509
- y(j), k.current && k.current(j);
8565
+ const k = useCallback((_) => {
8566
+ y(_), S.current && S.current(_);
8510
8567
  }, []), v = useCallback(() => {
8511
- y(null), k.current && k.current.cancel();
8512
- }, []), _ = useCallback((j) => {
8513
- k.current && k.current.cancel(), x(j), y(null);
8568
+ y(null), S.current && S.current.cancel();
8569
+ }, []), B = useCallback((_) => {
8570
+ S.current && S.current.cancel(), x(_), y(null);
8514
8571
  }, []), E = useMemo(
8515
8572
  () => p ? values(n).filter(
8516
- (j) => {
8517
- var N, L;
8518
- return (((N = j.label) == null ? void 0 : N.toLowerCase()) + " " + ((L = j.type) == null ? void 0 : L.toLowerCase())).includes(p.toLowerCase());
8573
+ (_) => {
8574
+ var N, T;
8575
+ return (((N = _.label) == null ? void 0 : N.toLowerCase()) + " " + ((T = _.type) == null ? void 0 : T.toLowerCase())).includes(p.toLowerCase());
8519
8576
  }
8520
8577
  ) : n,
8521
8578
  [n, p]
8522
8579
  ), I = useMemo(
8523
8580
  () => p ? o.filter(
8524
- (j) => reject(filter(values(E), { group: j }), { hidden: !0 }).length > 0
8525
- ) : o.filter((j) => reject(filter(values(n), { group: j }), { hidden: !0 }).length > 0),
8581
+ (_) => reject(filter(values(E), { group: _ }), { hidden: !0 }).length > 0
8582
+ ) : o.filter((_) => reject(filter(values(n), { group: _ }), { hidden: !0 }).length > 0),
8526
8583
  [n, E, o, p]
8527
8584
  ), C = useMemo(
8528
- () => sortBy(I, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
8585
+ () => sortBy(I, (_) => CORE_GROUPS.indexOf(_) === -1 ? 99 : CORE_GROUPS.indexOf(_)),
8529
8586
  [I]
8530
- ), A = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), w = useMemo(() => m === "all" ? C : [m], [C, m]);
8587
+ ), A = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), w = useMemo(() => h === "all" ? C : [h], [C, h]);
8531
8588
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full flex-col", children: [
8532
8589
  /* @__PURE__ */ jsx(SearchInput, { value: p, setValue: u }),
8533
8590
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2", children: [
@@ -8535,24 +8592,24 @@ const BlockCard = ({
8535
8592
  /* @__PURE__ */ jsx(
8536
8593
  "button",
8537
8594
  {
8538
- onClick: () => _("all"),
8539
- onMouseEnter: () => S("all"),
8595
+ onClick: () => B("all"),
8596
+ onMouseEnter: () => k("all"),
8540
8597
  onMouseLeave: v,
8541
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || b === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
8598
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || b === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
8542
8599
  children: c("All")
8543
8600
  },
8544
8601
  "sidebar-all"
8545
8602
  ),
8546
- C.map((j) => /* @__PURE__ */ jsx(
8603
+ C.map((_) => /* @__PURE__ */ jsx(
8547
8604
  "button",
8548
8605
  {
8549
- onClick: () => _(j),
8550
- onMouseEnter: () => S(j),
8606
+ onClick: () => B(_),
8607
+ onMouseEnter: () => k(_),
8551
8608
  onMouseLeave: v,
8552
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === j || b === j ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
8553
- children: capitalize(c(j.toLowerCase()))
8609
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === _ || b === _ ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
8610
+ children: capitalize(c(_.toLowerCase()))
8554
8611
  },
8555
- `sidebar-${j}`
8612
+ `sidebar-${_}`
8556
8613
  ))
8557
8614
  ] }) }) }),
8558
8615
  /* @__PURE__ */ jsx(
@@ -8564,10 +8621,10 @@ const BlockCard = ({
8564
8621
  ' "',
8565
8622
  p,
8566
8623
  '"'
8567
- ] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: w.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
8568
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(j.toLowerCase())) }),
8624
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: w.map((_) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
8625
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(_.toLowerCase())) }),
8569
8626
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
8570
- m === "all" ? filter(values(A), { group: j }) : values(A),
8627
+ h === "all" ? filter(values(A), { group: _ }) : values(A),
8571
8628
  { hidden: !0 }
8572
8629
  ).map((N) => /* @__PURE__ */ jsx(
8573
8630
  CoreBlock,
@@ -8579,7 +8636,7 @@ const BlockCard = ({
8579
8636
  },
8580
8637
  N.type
8581
8638
  )) })
8582
- ] }, j)) }) })
8639
+ ] }, _)) }) })
8583
8640
  }
8584
8641
  )
8585
8642
  ] })
@@ -8591,16 +8648,16 @@ const BlockCard = ({
8591
8648
  position: a = -1,
8592
8649
  fromSidebar: l = !1
8593
8650
  }) => {
8594
- const { t: i } = useTranslation(), [c, d] = useAtom$1(addBlockTabAtom), [, p] = useAtom$1(showPredefinedBlockCategoryAtom), u = useBuilderProp("flags.importHtml", !0), { data: g } = usePartialBlocksList(), h = Object.keys(g || {}).length > 0, { hasPermission: f } = usePermissions();
8651
+ const { t: i } = useTranslation(), [c, d] = useAtom$1(addBlockTabAtom), [, p] = useAtom$1(showPredefinedBlockCategoryAtom), u = useBuilderProp("flags.importHtml", !0), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: f } = usePermissions();
8595
8652
  useEffect(() => {
8596
- c === "partials" && !h && d("library");
8597
- }, [c, h, d]);
8598
- const m = useCallback(() => {
8653
+ c === "partials" && !m && d("library");
8654
+ }, [c, m, d]);
8655
+ const h = useCallback(() => {
8599
8656
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
8600
- }, []), x = useChaiAddBlockTabs(), b = u && f(PERMISSIONS.IMPORT_HTML), k = useChaiLibraries().length > 0;
8657
+ }, []), x = useChaiAddBlockTabs(), b = u && f(PERMISSIONS.IMPORT_HTML), S = useChaiLibraries().length > 0;
8601
8658
  return useEffect(() => {
8602
- c === "library" && !k && d("core");
8603
- }, [c, k, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
8659
+ c === "library" && !S && d("core");
8660
+ }, [c, S, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
8604
8661
  n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
8605
8662
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: i("Add block") }),
8606
8663
  /* @__PURE__ */ jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: i(c === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
@@ -8608,25 +8665,25 @@ const BlockCard = ({
8608
8665
  /* @__PURE__ */ jsxs(
8609
8666
  Tabs,
8610
8667
  {
8611
- onValueChange: (S) => {
8612
- p(""), d(S);
8668
+ onValueChange: (k) => {
8669
+ p(""), d(k);
8613
8670
  },
8614
8671
  value: c,
8615
8672
  className: "flex h-full max-h-full flex-col overflow-hidden",
8616
8673
  children: [
8617
8674
  /* @__PURE__ */ jsxs(TabsList, { className: `flex items-center ${l ? "h-max w-max justify-start p-1" : "w-full"}`, children: [
8618
- k && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", className: l ? "h-5 px-2 text-xs" : "", children: i("Library") }),
8675
+ S && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", className: l ? "h-5 px-2 text-xs" : "", children: i("Library") }),
8619
8676
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", className: l ? "h-5 px-2 text-xs" : "", children: i("Blocks") }),
8620
- h && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", className: l ? "h-5 px-2 text-xs" : "", children: i("Partials") }),
8677
+ m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", className: l ? "h-5 px-2 text-xs" : "", children: i("Partials") }),
8621
8678
  b ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", className: l ? "h-5 px-2 text-xs" : "", children: i("Import") }) : null,
8622
- map(x, (S) => /* @__PURE__ */ jsx(
8679
+ map(x, (k) => /* @__PURE__ */ jsx(
8623
8680
  TabsTrigger,
8624
8681
  {
8625
- value: S.id,
8682
+ value: k.id,
8626
8683
  className: l ? "h-5 px-2 text-xs" : "",
8627
- children: React__default.createElement(S.tab)
8684
+ children: React__default.createElement(k.tab)
8628
8685
  },
8629
- `tab-add-block-${S.id}`
8686
+ `tab-add-block-${k.id}`
8630
8687
  ))
8631
8688
  ] }),
8632
8689
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(
@@ -8638,8 +8695,8 @@ const BlockCard = ({
8638
8695
  disableBlockGroupsSidebar: l
8639
8696
  }
8640
8697
  ) }) }) }),
8641
- k && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { fromSidebar: l, parentId: r, position: a }) }),
8642
- h && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(
8698
+ S && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { fromSidebar: l, parentId: r, position: a }) }),
8699
+ m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(
8643
8700
  PartialBlocks,
8644
8701
  {
8645
8702
  gridCols: l ? "grid-cols-2" : "grid-cols-4",
@@ -8649,7 +8706,7 @@ const BlockCard = ({
8649
8706
  }
8650
8707
  ) }) }) }),
8651
8708
  b ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20 ", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a, fromSidebar: l }) }) : null,
8652
- map(x, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: m, parentId: r, position: a }) }, `panel-add-block-${S.id}`))
8709
+ map(x, (k) => /* @__PURE__ */ jsx(TabsContent, { value: k.id, children: React__default.createElement(k.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${k.id}`))
8653
8710
  ]
8654
8711
  }
8655
8712
  )
@@ -8806,10 +8863,10 @@ const registerChaiSaveToLibrary = (o) => {
8806
8863
  }, CopyPasteBlocks = () => {
8807
8864
  const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
8808
8865
  const u = n.map((g) => {
8809
- const h = o.find((f) => f._id === g);
8866
+ const m = o.find((f) => f._id === g);
8810
8867
  return {
8811
8868
  id: g,
8812
- data: h
8869
+ data: m
8813
8870
  };
8814
8871
  });
8815
8872
  l(u.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
@@ -9028,35 +9085,35 @@ const Input = ({ node: o }) => {
9028
9085
  var M;
9029
9086
  const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
9030
9087
  let d = null;
9031
- const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), h = useIsDragAndDropEnabled(), { id: f, data: m, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: k, handleClick: S } = o, v = get(m, "_show", !0), _ = (T) => {
9032
- T.stopPropagation(), v && o.toggle();
9033
- }, E = (T) => {
9034
- T.isInternal && (d = T.isOpen, T.isOpen && T.close());
9035
- }, I = (T) => {
9036
- T.isInternal && d !== null && (d ? T.open() : T.close(), d = null);
9088
+ const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), m = useIsDragAndDropEnabled(), { id: f, data: h, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: S, handleClick: k } = o, v = get(h, "_show", !0), B = (L) => {
9089
+ L.stopPropagation(), v && o.toggle();
9090
+ }, E = (L) => {
9091
+ L.isInternal && (d = L.isOpen, L.isOpen && L.close());
9092
+ }, I = (L) => {
9093
+ L.isInternal && d !== null && (d ? L.open() : L.close(), d = null);
9037
9094
  }, [C, A] = useAtom$1(currentAddSelection), w = () => {
9038
- var T;
9039
- B(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
9040
- }, B = () => {
9095
+ var L;
9096
+ j(), o.parent.isSelected || A((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
9097
+ }, j = () => {
9041
9098
  A(null);
9042
- }, j = (T) => {
9043
- B(), T.stopPropagation(), !o.isOpen && v && o.toggle(), S(T);
9099
+ }, _ = (L) => {
9100
+ j(), L.stopPropagation(), !o.isOpen && v && o.toggle(), k(L);
9044
9101
  };
9045
9102
  useEffect(() => {
9046
- const T = setTimeout(() => {
9103
+ const L = setTimeout(() => {
9047
9104
  b && !o.isOpen && !y && v && o.toggle();
9048
9105
  }, 500);
9049
- return () => clearTimeout(T);
9106
+ return () => clearTimeout(L);
9050
9107
  }, [b, o, y]);
9051
- const N = (T, O) => {
9052
- const $ = i.contentDocument || i.contentWindow.document, H = $.querySelector(`[data-block-id=${T}]`);
9053
- H && H.setAttribute("data-drop", O);
9054
- const F = H.getBoundingClientRect(), U = i.getBoundingClientRect();
9055
- F.top >= U.top && F.left >= U.left && F.bottom <= U.bottom && F.right <= U.right || ($.documentElement.scrollTop = H.offsetTop - U.top);
9056
- }, L = (T) => {
9057
- B();
9108
+ const N = (L, O) => {
9109
+ const H = i.contentDocument || i.contentWindow.document, $ = H.querySelector(`[data-block-id=${L}]`);
9110
+ $ && $.setAttribute("data-drop", O);
9111
+ const F = $.getBoundingClientRect(), U = i.getBoundingClientRect();
9112
+ F.top >= U.top && F.left >= U.left && F.bottom <= U.bottom && F.right <= U.right || (H.documentElement.scrollTop = $.offsetTop - U.top);
9113
+ }, T = (L) => {
9114
+ j();
9058
9115
  const O = get(o, "parent.id");
9059
- O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
9116
+ O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
9060
9117
  };
9061
9118
  if (f === ROOT_TEMP_KEY)
9062
9119
  return /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 w-full cursor-pointer", children: [
@@ -9065,7 +9122,7 @@ const Input = ({ node: o }) => {
9065
9122
  "div",
9066
9123
  {
9067
9124
  role: "button",
9068
- onClick: () => L(-1),
9125
+ onClick: () => T(-1),
9069
9126
  className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
9070
9127
  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-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
9071
9128
  /* @__PURE__ */ jsx(PlusIcon, { className: "w-2.4 h-2.5 stroke-[5] text-white" }),
@@ -9076,36 +9133,36 @@ const Input = ({ node: o }) => {
9076
9133
  ),
9077
9134
  /* @__PURE__ */ jsx("br", {})
9078
9135
  ] });
9079
- const { librarySite: D } = useBuilderProp("flags", { librarySite: !1 }), P = useMemo(() => D && has(m, "_libBlockId") && !isEmpty(m._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [m, c, D]), R = useMemo(() => (m == null ? void 0 : m._type) === "PartialBlock" || (m == null ? void 0 : m._type) === "GlobalBlock", [m]);
9136
+ const { librarySite: D } = useBuilderProp("flags", { librarySite: !1 }), P = useMemo(() => D && has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, c, D]), R = useMemo(() => (h == null ? void 0 : h._type) === "PartialBlock" || (h == null ? void 0 : h._type) === "GlobalBlock", [h]);
9080
9137
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
9081
9138
  "div",
9082
9139
  {
9083
9140
  onMouseEnter: () => u(f),
9084
9141
  onMouseLeave: () => g(),
9085
- onClick: j,
9142
+ onClick: _,
9086
9143
  style: n,
9087
9144
  "data-node-id": f,
9088
9145
  ref: r,
9089
9146
  onDragStart: () => E(o),
9090
9147
  onDragEnd: () => I(o),
9091
- onDragOver: (T) => {
9092
- T.preventDefault(), N(f, "yes");
9148
+ onDragOver: (L) => {
9149
+ L.preventDefault(), N(f, "yes");
9093
9150
  },
9094
- onDragLeave: (T) => {
9095
- T.preventDefault(), N(f, "no");
9151
+ onDragLeave: (L) => {
9152
+ L.preventDefault(), N(f, "no");
9096
9153
  },
9097
- onDrop: (T) => {
9098
- T.preventDefault(), N(f, "no");
9154
+ onDrop: (L) => {
9155
+ L.preventDefault(), N(f, "no");
9099
9156
  },
9100
9157
  children: [
9101
- c(PERMISSIONS.ADD_BLOCK) && !h && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((M = o == null ? void 0 : o.parent) == null ? void 0 : M.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
9158
+ c(PERMISSIONS.ADD_BLOCK) && !m && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((M = o == null ? void 0 : o.parent) == null ? void 0 : M.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
9102
9159
  "div",
9103
9160
  {
9104
- onClick: (T) => {
9105
- T.stopPropagation(), L(o.childIndex);
9161
+ onClick: (L) => {
9162
+ L.stopPropagation(), T(o.childIndex);
9106
9163
  },
9107
9164
  onMouseEnter: w,
9108
- onMouseLeave: B,
9165
+ onMouseLeave: j,
9109
9166
  className: "absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",
9110
9167
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[2] text-white" }) })
9111
9168
  }
@@ -9116,7 +9173,7 @@ const Input = ({ node: o }) => {
9116
9173
  className: cn(
9117
9174
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
9118
9175
  x ? "bg-primary/20" : "hover:bg-primary/10",
9119
- b && canAcceptChildBlock(m._type, "Icon") ? "bg-green-200" : "",
9176
+ b && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
9120
9177
  (o == null ? void 0 : o.id) === C ? "bg-primary/10" : "",
9121
9178
  y && "opacity-20",
9122
9179
  v ? "" : "line-through opacity-50",
@@ -9128,7 +9185,7 @@ const Input = ({ node: o }) => {
9128
9185
  "div",
9129
9186
  {
9130
9187
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
9131
- children: p && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
9188
+ children: p && /* @__PURE__ */ jsx("button", { onClick: B, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
9132
9189
  }
9133
9190
  ),
9134
9191
  /* @__PURE__ */ jsxs(
@@ -9142,15 +9199,15 @@ const Input = ({ node: o }) => {
9142
9199
  R && x && "text-purple-800"
9143
9200
  ),
9144
9201
  children: [
9145
- /* @__PURE__ */ jsx(TypeIcon, { type: m == null ? void 0 : m._type }),
9146
- k ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
9202
+ /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
9203
+ S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
9147
9204
  "div",
9148
9205
  {
9149
9206
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
9150
- onDoubleClick: (T) => {
9151
- T.stopPropagation(), o.edit(), o.deselect();
9207
+ onDoubleClick: (L) => {
9208
+ L.stopPropagation(), o.edit(), o.deselect();
9152
9209
  },
9153
- children: /* @__PURE__ */ jsx("span", { title: getBlockDisplayName(m).length > 17 ? getBlockDisplayName(m) : "", children: truncateText(getBlockDisplayName(m), 17) })
9210
+ children: /* @__PURE__ */ jsx("span", { title: getBlockDisplayName(h).length > 17 ? getBlockDisplayName(h) : "", children: truncateText(getBlockDisplayName(h), 17) })
9154
9211
  }
9155
9212
  )
9156
9213
  ]
@@ -9158,7 +9215,7 @@ const Input = ({ node: o }) => {
9158
9215
  )
9159
9216
  ] }),
9160
9217
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
9161
- canAddChildBlock(m == null ? void 0 : m._type) && v && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
9218
+ canAddChildBlock(h == null ? void 0 : h._type) && v && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
9162
9219
  /* @__PURE__ */ jsx(
9163
9220
  TooltipTrigger,
9164
9221
  {
@@ -9174,8 +9231,8 @@ const Input = ({ node: o }) => {
9174
9231
  /* @__PURE__ */ jsx(
9175
9232
  TooltipTrigger,
9176
9233
  {
9177
- onClick: (T) => {
9178
- T.stopPropagation(), l([f], { _show: !v }), o.isOpen && o.toggle();
9234
+ onClick: (L) => {
9235
+ L.stopPropagation(), l([f], { _show: !v }), o.isOpen && o.toggle();
9179
9236
  },
9180
9237
  className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
9181
9238
  asChild: !0,
@@ -9627,7 +9684,7 @@ const Input = ({ node: o }) => {
9627
9684
  console.warn("Failed to clear previous theme from localStorage:", o);
9628
9685
  }
9629
9686
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
9630
- const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), h = useBuilderProp("flags.darkMode", !0);
9687
+ const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0);
9631
9688
  if (d) {
9632
9689
  const C = d.map((A) => Object.keys(A)[0]);
9633
9690
  DEFAULT_THEME_PRESET.forEach((A) => {
@@ -9635,36 +9692,36 @@ const Input = ({ node: o }) => {
9635
9692
  C.includes(w) || d.push(A);
9636
9693
  });
9637
9694
  }
9638
- const [f, m] = useTheme(), x = useThemeOptions(), { t: b } = useTranslation(), y = React.useCallback(
9695
+ const [f, h] = useTheme(), x = useThemeOptions(), { t: b } = useTranslation(), y = React.useCallback(
9639
9696
  (C) => {
9640
9697
  const A = { ...f };
9641
- setPreviousTheme(A), m(C), toast.success("Theme updated", {
9698
+ setPreviousTheme(A), h(C), toast.success("Theme updated", {
9642
9699
  action: {
9643
9700
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9644
9701
  /* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
9645
9702
  " Undo"
9646
9703
  ] }),
9647
9704
  onClick: () => {
9648
- m(A), clearPreviousTheme(), toast.dismiss();
9705
+ h(A), clearPreviousTheme(), toast.dismiss();
9649
9706
  }
9650
9707
  },
9651
9708
  closeButton: !0,
9652
9709
  duration: 15e3
9653
9710
  });
9654
9711
  },
9655
- [f, m]
9656
- ), k = () => {
9712
+ [f, h]
9713
+ ), S = () => {
9657
9714
  const C = d.find((A) => Object.keys(A)[0] === a);
9658
9715
  if (C) {
9659
9716
  const A = Object.values(C)[0];
9660
9717
  A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? (y(A), l("")) : console.error("Invalid preset structure:", A);
9661
9718
  } else
9662
9719
  console.error("Preset not found:", a);
9663
- }, S = (C) => {
9720
+ }, k = (C) => {
9664
9721
  y(C), l("");
9665
9722
  }, v = useDebouncedCallback(
9666
9723
  (C, A) => {
9667
- m(() => ({
9724
+ h(() => ({
9668
9725
  ...f,
9669
9726
  fontFamily: {
9670
9727
  ...f.fontFamily,
@@ -9674,9 +9731,9 @@ const Input = ({ node: o }) => {
9674
9731
  },
9675
9732
  [f],
9676
9733
  200
9677
- ), _ = React.useCallback(
9734
+ ), B = React.useCallback(
9678
9735
  (C) => {
9679
- m(() => ({
9736
+ h(() => ({
9680
9737
  ...f,
9681
9738
  borderRadius: `${C}px`
9682
9739
  }));
@@ -9684,7 +9741,7 @@ const Input = ({ node: o }) => {
9684
9741
  [f]
9685
9742
  ), E = useDebouncedCallback(
9686
9743
  (C, A) => {
9687
- m(() => {
9744
+ h(() => {
9688
9745
  const w = get(f, `colors.${C}`);
9689
9746
  return n ? set(w, 1, A) : set(w, 0, A), {
9690
9747
  ...f,
@@ -9704,10 +9761,10 @@ const Input = ({ node: o }) => {
9704
9761
  ColorPickerInput,
9705
9762
  {
9706
9763
  value: w,
9707
- onChange: (B) => E(A, B)
9764
+ onChange: (j) => E(A, j)
9708
9765
  }
9709
9766
  ),
9710
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
9767
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
9711
9768
  ] }, A) : null;
9712
9769
  }) });
9713
9770
  return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
@@ -9728,7 +9785,7 @@ const Input = ({ node: o }) => {
9728
9785
  return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(w) }, A);
9729
9786
  }) })
9730
9787
  ] }) }),
9731
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: b("Apply") }) })
9788
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: S, children: b("Apply") }) })
9732
9789
  ] })
9733
9790
  ] }),
9734
9791
  /* @__PURE__ */ jsx(Separator, {}),
@@ -9755,7 +9812,7 @@ const Input = ({ node: o }) => {
9755
9812
  ] }),
9756
9813
  /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: f.borderRadius })
9757
9814
  ] }),
9758
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: f.borderRadius, onChange: _ }) })
9815
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: f.borderRadius, onChange: B }) })
9759
9816
  ] }),
9760
9817
  /* @__PURE__ */ jsx(Separator, {}),
9761
9818
  (x == null ? void 0 : x.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
@@ -9764,7 +9821,7 @@ const Input = ({ node: o }) => {
9764
9821
  /* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "h-3 w-3 text-gray-600" }),
9765
9822
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: b("Colors") })
9766
9823
  ] }),
9767
- h && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9824
+ m && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9768
9825
  /* @__PURE__ */ jsx(SunIcon, { className: "h-4 w-4" }),
9769
9826
  /* @__PURE__ */ jsx(
9770
9827
  Switch,
@@ -9785,7 +9842,7 @@ const Input = ({ node: o }) => {
9785
9842
  {
9786
9843
  open: i,
9787
9844
  onOpenChange: c,
9788
- onImport: S
9845
+ onImport: k
9789
9846
  }
9790
9847
  ) })
9791
9848
  ] }),
@@ -10329,8 +10386,8 @@ function QuickPrompts({ onClick: o }) {
10329
10386
  const AIUserPrompt = ({ blockId: o }) => {
10330
10387
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
10331
10388
  useEffect(() => {
10332
- var h;
10333
- (h = d.current) == null || h.focus();
10389
+ var m;
10390
+ (m = d.current) == null || m.focus();
10334
10391
  }, []);
10335
10392
  const g = () => {
10336
10393
  l || c("");
@@ -10347,8 +10404,8 @@ const AIUserPrompt = ({ blockId: o }) => {
10347
10404
  /* @__PURE__ */ jsx("div", { className: "rounded border p-2 text-sm", children: /* @__PURE__ */ jsx(
10348
10405
  QuickPrompts,
10349
10406
  {
10350
- onClick: (h) => {
10351
- p.current && clearTimeout(p.current), r("content", o, h, g);
10407
+ onClick: (m) => {
10408
+ p.current && clearTimeout(p.current), r("content", o, m, g);
10352
10409
  }
10353
10410
  }
10354
10411
  ) }),
@@ -10360,12 +10417,12 @@ const AIUserPrompt = ({ blockId: o }) => {
10360
10417
  {
10361
10418
  ref: d,
10362
10419
  value: i,
10363
- onChange: (h) => c(h.target.value),
10420
+ onChange: (m) => c(m.target.value),
10364
10421
  placeholder: n("Ask AI to edit content"),
10365
10422
  className: "w-full resize-none border-none p-0 text-xs shadow-none outline-none",
10366
10423
  rows: 3,
10367
- onKeyDown: (h) => {
10368
- h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, g));
10424
+ onKeyDown: (m) => {
10425
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), r("content", o, i, g));
10369
10426
  }
10370
10427
  }
10371
10428
  ),
@@ -10470,11 +10527,11 @@ const UndoRedo = () => {
10470
10527
  preloadedAttributes: n = [],
10471
10528
  onAttributesChange: r
10472
10529
  }) {
10473
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, f] = useState(""), m = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
10530
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
10474
10531
  useEffect(() => {
10475
10532
  l(n);
10476
10533
  }, [n]);
10477
- const k = () => {
10534
+ const S = () => {
10478
10535
  if (i.startsWith("@")) {
10479
10536
  f("Attribute keys cannot start with '@'");
10480
10537
  return;
@@ -10483,12 +10540,12 @@ const UndoRedo = () => {
10483
10540
  const C = [...a, { key: i, value: d }];
10484
10541
  r(C), l(a), c(""), p(""), f("");
10485
10542
  }
10486
- }, S = (C) => {
10487
- const A = a.filter((w, B) => B !== C);
10543
+ }, k = (C) => {
10544
+ const A = a.filter((w, j) => j !== C);
10488
10545
  r(A), l(A);
10489
10546
  }, v = (C) => {
10490
10547
  g(C), c(a[C].key), p(a[C].value);
10491
- }, _ = () => {
10548
+ }, B = () => {
10492
10549
  if (i.startsWith("@")) {
10493
10550
  f("Attribute keys cannot start with '@'");
10494
10551
  return;
@@ -10498,25 +10555,25 @@ const UndoRedo = () => {
10498
10555
  C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), f("");
10499
10556
  }
10500
10557
  }, E = (C) => {
10501
- C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? _() : k());
10558
+ C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? B() : S());
10502
10559
  }, I = useCallback((C) => {
10503
- const A = (j) => /[.,!?;:]/.test(j), w = (j, N, L) => {
10560
+ const A = (_) => /[.,!?;:]/.test(_), w = (_, N, T) => {
10504
10561
  let D = "", P = "";
10505
- const R = N > 0 ? j[N - 1] : "", M = N < j.length ? j[N] : "";
10506
- return N > 0 && (R === "." || !A(R) && R !== " ") && (D = " "), N < j.length && !A(M) && M !== " " && (P = " "), {
10507
- text: D + L + P,
10562
+ const R = N > 0 ? _[N - 1] : "", M = N < _.length ? _[N] : "";
10563
+ return N > 0 && (R === "." || !A(R) && R !== " ") && (D = " "), N < _.length && !A(M) && M !== " " && (P = " "), {
10564
+ text: D + T + P,
10508
10565
  prefixLength: D.length,
10509
10566
  suffixLength: P.length
10510
10567
  };
10511
- }, B = x.current;
10512
- if (B) {
10513
- const j = B.selectionStart || 0, N = B.value || "", L = B.selectionEnd || j;
10514
- if (L > j) {
10515
- const T = `{{${C}}}`, { text: O } = w(N, j, T), $ = N.slice(0, j) + O + N.slice(L);
10516
- p($);
10568
+ }, j = x.current;
10569
+ if (j) {
10570
+ const _ = j.selectionStart || 0, N = j.value || "", T = j.selectionEnd || _;
10571
+ if (T > _) {
10572
+ const L = `{{${C}}}`, { text: O } = w(N, _, L), H = N.slice(0, _) + O + N.slice(T);
10573
+ p(H);
10517
10574
  return;
10518
10575
  }
10519
- const P = `{{${C}}}`, { text: R } = w(N, j, P), M = N.slice(0, j) + R + N.slice(j);
10576
+ const P = `{{${C}}}`, { text: R } = w(N, _, P), M = N.slice(0, _) + R + N.slice(_);
10520
10577
  p(M);
10521
10578
  }
10522
10579
  }, []);
@@ -10525,7 +10582,7 @@ const UndoRedo = () => {
10525
10582
  "form",
10526
10583
  {
10527
10584
  onSubmit: (C) => {
10528
- C.preventDefault(), u !== null ? _() : k();
10585
+ C.preventDefault(), u !== null ? B() : S();
10529
10586
  },
10530
10587
  className: "space-y-3",
10531
10588
  children: [
@@ -10539,7 +10596,7 @@ const UndoRedo = () => {
10539
10596
  autoCorrect: "off",
10540
10597
  spellCheck: "false",
10541
10598
  id: "attrKey",
10542
- ref: m,
10599
+ ref: h,
10543
10600
  value: i,
10544
10601
  onChange: (C) => c(C.target.value),
10545
10602
  placeholder: y("Enter Key"),
@@ -10571,7 +10628,7 @@ const UndoRedo = () => {
10571
10628
  ] })
10572
10629
  ] }),
10573
10630
  /* @__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" }) }),
10574
- h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
10631
+ m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
10575
10632
  ]
10576
10633
  }
10577
10634
  ),
@@ -10582,7 +10639,7 @@ const UndoRedo = () => {
10582
10639
  ] }),
10583
10640
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
10584
10641
  /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
10585
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
10642
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => k(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
10586
10643
  ] })
10587
10644
  ] }, A)) })
10588
10645
  ] });
@@ -10750,14 +10807,14 @@ registerChaiSidebarPanel("outline", {
10750
10807
  panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
10751
10808
  });
10752
10809
  const RootLayout = () => {
10753
- const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), h = useCallback((C) => {
10810
+ const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), m = useCallback((C) => {
10754
10811
  C.preventDefault();
10755
- }, []), f = useMemo(() => [p].flat(), [p]), m = useCallback(
10812
+ }, []), f = useMemo(() => [p].flat(), [p]), h = useCallback(
10756
10813
  (C) => {
10757
10814
  console.log("handleMenuItemClick", C, n), r(n === C ? null : C);
10758
10815
  },
10759
10816
  [n, r]
10760
- ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), k = find(b, { id: n }) ?? first(b), S = get(k, "width", DEFAULT_PANEL_WIDTH);
10817
+ ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), k = get(S, "width", DEFAULT_PANEL_WIDTH);
10761
10818
  useEffect(() => {
10762
10819
  if (n !== null) {
10763
10820
  const C = find(b, { id: n });
@@ -10767,8 +10824,8 @@ const RootLayout = () => {
10767
10824
  const v = useMemo(() => {
10768
10825
  if (n === null) return 0;
10769
10826
  const C = find(b, { id: n });
10770
- return get(C, "view", "standard") === "standard" ? S : l;
10771
- }, [n, S, l, b]), _ = useCallback(() => {
10827
+ return get(C, "view", "standard") === "standard" ? k : l;
10828
+ }, [n, k, l, b]), B = useCallback(() => {
10772
10829
  r(a.current);
10773
10830
  }, [r, n]), E = useCallback(() => {
10774
10831
  r("outline");
@@ -10778,15 +10835,15 @@ const RootLayout = () => {
10778
10835
  }, [n, b]);
10779
10836
  const I = useCallback(
10780
10837
  (C) => {
10781
- m(C);
10838
+ h(C);
10782
10839
  },
10783
- [m]
10840
+ [h]
10784
10841
  );
10785
10842
  return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
10786
10843
  /* @__PURE__ */ jsxs(
10787
10844
  "div",
10788
10845
  {
10789
- onContextMenu: h,
10846
+ onContextMenu: m,
10790
10847
  className: "flex h-full max-h-full flex-col bg-background text-foreground",
10791
10848
  children: [
10792
10849
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
@@ -10820,15 +10877,15 @@ const RootLayout = () => {
10820
10877
  initial: { width: v },
10821
10878
  animate: { width: v },
10822
10879
  transition: { duration: 0.3, ease: "easeInOut" },
10823
- children: n !== null && get(k, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
10880
+ children: n !== null && get(S, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
10824
10881
  /* @__PURE__ */ jsx(
10825
10882
  "div",
10826
10883
  {
10827
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(k, "isInternal", !1) ? "" : "w-64"}`,
10828
- children: /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
10884
+ className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(S, "isInternal", !1) ? "" : "w-64"}`,
10885
+ children: /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
10829
10886
  }
10830
10887
  ),
10831
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(k, "panel", NoopComponent), {}) }) })
10888
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {}) }) })
10832
10889
  ] })
10833
10890
  }
10834
10891
  ),
@@ -10874,34 +10931,34 @@ const RootLayout = () => {
10874
10931
  }
10875
10932
  ),
10876
10933
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
10877
- n !== null && get(k, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
10934
+ n !== null && get(S, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(
10878
10935
  SheetContent,
10879
10936
  {
10880
10937
  side: "left",
10881
10938
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
10882
- style: { width: `${S}px` },
10939
+ style: { width: `${k}px` },
10883
10940
  children: [
10884
10941
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
10885
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(k, "icon", null) }),
10886
- /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
10942
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
10943
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
10887
10944
  ] }) }),
10888
- /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(k, "panel", NoopComponent), {
10945
+ /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
10889
10946
  close: E
10890
10947
  }) }) })
10891
10948
  ]
10892
10949
  }
10893
10950
  ) }),
10894
10951
  " ",
10895
- n !== null && get(k, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${S}px` }, children: [
10952
+ n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${k}px` }, children: [
10896
10953
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
10897
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(k, "icon", null) }),
10898
- /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
10954
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
10955
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
10899
10956
  ] }) }),
10900
- /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(k, "panel", NoopComponent), {
10957
+ /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
10901
10958
  close: E
10902
10959
  }) }) })
10903
10960
  ] }) }),
10904
- n !== null && get(k, "view") === "overlay" && /* @__PURE__ */ jsx(
10961
+ n !== null && get(S, "view") === "overlay" && /* @__PURE__ */ jsx(
10905
10962
  motion.div,
10906
10963
  {
10907
10964
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -10920,12 +10977,12 @@ const RootLayout = () => {
10920
10977
  children: [
10921
10978
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
10922
10979
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
10923
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(k, "icon", null) }),
10924
- /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
10980
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(S, "icon", null) }),
10981
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
10925
10982
  ] }),
10926
- /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
10983
+ /* @__PURE__ */ jsx(Button, { onClick: () => B(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
10927
10984
  ] }),
10928
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(k, "panel", NoopComponent), {
10985
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
10929
10986
  close: E
10930
10987
  }) }) })
10931
10988
  ]
@@ -10986,20 +11043,20 @@ const RootLayout = () => {
10986
11043
  const x = l.toLowerCase();
10987
11044
  return Object.fromEntries(
10988
11045
  Object.entries(a).filter(([b, y]) => {
10989
- var k;
10990
- return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((k = y == null ? void 0 : y.description) == null ? void 0 : k.toLowerCase().includes(x));
11046
+ var S;
11047
+ return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((S = y == null ? void 0 : y.description) == null ? void 0 : S.toLowerCase().includes(x));
10991
11048
  })
10992
11049
  );
10993
- }, [a, l]), h = (x) => {
11050
+ }, [a, l]), m = (x) => {
10994
11051
  d(!0), u({
10995
11052
  x: x.clientX - n.x,
10996
11053
  y: x.clientY - n.y
10997
11054
  });
10998
11055
  }, f = (x) => {
10999
11056
  if (!c) return;
11000
- const b = x.clientX - p.x, y = x.clientY - p.y, k = x.currentTarget, S = k.offsetWidth, v = k.offsetHeight, _ = window.innerWidth - S, E = window.innerHeight - v, I = Math.max(0, Math.min(b, _)), C = Math.max(0, Math.min(y, E));
11057
+ const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, k = S.offsetWidth, v = S.offsetHeight, B = window.innerWidth - k, E = window.innerHeight - v, I = Math.max(0, Math.min(b, B)), C = Math.max(0, Math.min(y, E));
11001
11058
  r(I, C);
11002
- }, m = () => {
11059
+ }, h = () => {
11003
11060
  d(!1);
11004
11061
  };
11005
11062
  return useEffect(() => {
@@ -11010,9 +11067,9 @@ const RootLayout = () => {
11010
11067
  }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
11011
11068
  "div",
11012
11069
  {
11013
- onMouseDown: h,
11070
+ onMouseDown: m,
11014
11071
  onMouseMove: f,
11015
- onMouseUp: m,
11072
+ onMouseUp: h,
11016
11073
  className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
11017
11074
  style: {
11018
11075
  left: n.x,
@@ -11196,49 +11253,49 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
11196
11253
  const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (g) => {
11197
11254
  try {
11198
11255
  g();
11199
- } catch (h) {
11200
- p.push(h);
11256
+ } catch (m) {
11257
+ p.push(m);
11201
11258
  }
11202
11259
  };
11203
11260
  do {
11204
11261
  c.f && u(c.f);
11205
- const g = /* @__PURE__ */ new Set(), h = g.add.bind(g);
11262
+ const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
11206
11263
  a.forEach((f) => {
11207
- var m;
11208
- return (m = r.get(f)) == null ? void 0 : m.l.forEach(h);
11209
- }), a.clear(), i.forEach(h), i.clear(), l.forEach(h), l.clear(), g.forEach(u), a.size && d(o);
11264
+ var h;
11265
+ return (h = r.get(f)) == null ? void 0 : h.l.forEach(m);
11266
+ }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
11210
11267
  } while (a.size || i.size || l.size);
11211
11268
  if (p.length)
11212
11269
  throw new AggregateError(p);
11213
11270
  }, recomputeInvalidatedAtoms = (o) => {
11214
- const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), h = Array.from(l);
11215
- for (; h.length; ) {
11216
- const f = h[h.length - 1], m = i(o, f);
11271
+ const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
11272
+ for (; m.length; ) {
11273
+ const f = m[m.length - 1], h = i(o, f);
11217
11274
  if (g.has(f)) {
11218
- h.pop();
11275
+ m.pop();
11219
11276
  continue;
11220
11277
  }
11221
11278
  if (u.has(f)) {
11222
- a.get(f) === m.n && p.push([f, m]), g.add(f), h.pop();
11279
+ a.get(f) === h.n && p.push([f, h]), g.add(f), m.pop();
11223
11280
  continue;
11224
11281
  }
11225
11282
  u.add(f);
11226
- for (const x of getMountedOrPendingDependents(f, m, r))
11227
- u.has(x) || h.push(x);
11283
+ for (const x of getMountedOrPendingDependents(f, h, r))
11284
+ u.has(x) || m.push(x);
11228
11285
  }
11229
11286
  for (let f = p.length - 1; f >= 0; --f) {
11230
- const [m, x] = p[f];
11287
+ const [h, x] = p[f];
11231
11288
  let b = !1;
11232
11289
  for (const y of x.d.keys())
11233
- if (y !== m && l.has(y)) {
11290
+ if (y !== h && l.has(y)) {
11234
11291
  b = !0;
11235
11292
  break;
11236
11293
  }
11237
- b && (c(o, m), d(o, m)), a.delete(m);
11294
+ b && (c(o, h), d(o, h)), a.delete(h);
11238
11295
  }
11239
11296
  }, readAtomState = (o, n) => {
11240
11297
  var r;
11241
- const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], h = a[13], f = a[14], m = a[16], x = a[17], b = u(o, n);
11298
+ const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], f = a[14], h = a[16], x = a[17], b = u(o, n);
11242
11299
  if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
11243
11300
  ([C, A]) => (
11244
11301
  // Recursively, read the atom state of the dependency, and
@@ -11249,46 +11306,46 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
11249
11306
  return b;
11250
11307
  b.d.clear();
11251
11308
  let y = !0;
11252
- function k() {
11253
- l.has(n) && (x(o, n), h(o), g(o));
11309
+ function S() {
11310
+ l.has(n) && (x(o, n), m(o), g(o));
11254
11311
  }
11255
- function S(C) {
11312
+ function k(C) {
11256
11313
  var A;
11257
11314
  if (isSelfAtom(n, C)) {
11258
- const B = u(o, C);
11259
- if (!isAtomStateInitialized(B))
11315
+ const j = u(o, C);
11316
+ if (!isAtomStateInitialized(j))
11260
11317
  if (hasInitialValue(C))
11261
11318
  setAtomStateValueOrPromise(o, C, C.init);
11262
11319
  else
11263
11320
  throw new Error("no atom init");
11264
- return returnAtomValue(B);
11321
+ return returnAtomValue(j);
11265
11322
  }
11266
11323
  const w = f(o, C);
11267
11324
  try {
11268
11325
  return returnAtomValue(w);
11269
11326
  } finally {
11270
- b.d.set(C, w.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, w), (A = l.get(C)) == null || A.t.add(n), y || k();
11327
+ b.d.set(C, w.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, w), (A = l.get(C)) == null || A.t.add(n), y || S();
11271
11328
  }
11272
11329
  }
11273
- let v, _;
11330
+ let v, B;
11274
11331
  const E = {
11275
11332
  get signal() {
11276
11333
  return v || (v = new AbortController()), v.signal;
11277
11334
  },
11278
11335
  get setSelf() {
11279
- return !_ && isActuallyWritableAtom(n) && (_ = (...C) => {
11336
+ return !B && isActuallyWritableAtom(n) && (B = (...C) => {
11280
11337
  if (!y)
11281
11338
  try {
11282
- return m(o, n, ...C);
11339
+ return h(o, n, ...C);
11283
11340
  } finally {
11284
- h(o), g(o);
11341
+ m(o), g(o);
11285
11342
  }
11286
- }), _;
11343
+ }), B;
11287
11344
  }
11288
11345
  }, I = b.n;
11289
11346
  try {
11290
- const C = p(o, n, S, E);
11291
- return setAtomStateValueOrPromise(o, n, C), isPromiseLike$1(C) && (registerAbortHandler(C, () => v == null ? void 0 : v.abort()), C.then(k, k)), b;
11347
+ const C = p(o, n, k, E);
11348
+ return setAtomStateValueOrPromise(o, n, C), isPromiseLike$1(C) && (registerAbortHandler(C, () => v == null ? void 0 : v.abort()), C.then(S, S)), b;
11292
11349
  } catch (C) {
11293
11350
  return delete b.v, b.e = C, ++b.n, b;
11294
11351
  } finally {
@@ -11304,73 +11361,73 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
11304
11361
  }
11305
11362
  }
11306
11363
  }, writeAtomState = (o, n, ...r) => {
11307
- const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], h = a[15], f = a[17];
11308
- let m = !0;
11309
- const x = (y) => returnAtomValue(g(o, y)), b = (y, ...k) => {
11310
- var S;
11364
+ const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], f = a[17];
11365
+ let h = !0;
11366
+ const x = (y) => returnAtomValue(g(o, y)), b = (y, ...S) => {
11367
+ var k;
11311
11368
  const v = d(o, y);
11312
11369
  try {
11313
11370
  if (isSelfAtom(n, y)) {
11314
11371
  if (!hasInitialValue(y))
11315
11372
  throw new Error("atom not writable");
11316
- const _ = v.n, E = k[0];
11317
- setAtomStateValueOrPromise(o, y, E), f(o, y), _ !== v.n && (l.add(y), (S = i.c) == null || S.call(i, y), h(o, y));
11373
+ const B = v.n, E = S[0];
11374
+ setAtomStateValueOrPromise(o, y, E), f(o, y), B !== v.n && (l.add(y), (k = i.c) == null || k.call(i, y), m(o, y));
11318
11375
  return;
11319
11376
  } else
11320
- return writeAtomState(o, y, ...k);
11377
+ return writeAtomState(o, y, ...S);
11321
11378
  } finally {
11322
- m || (u(o), p(o));
11379
+ h || (u(o), p(o));
11323
11380
  }
11324
11381
  };
11325
11382
  try {
11326
11383
  return c(o, n, x, b, ...r);
11327
11384
  } finally {
11328
- m = !1;
11385
+ h = !1;
11329
11386
  }
11330
11387
  }, mountDependencies = (o, n) => {
11331
11388
  var r;
11332
- const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], h = d(o, n), f = l.get(n);
11333
- if (f && !isPendingPromise(h.v)) {
11334
- for (const [m, x] of h.d)
11335
- if (!f.d.has(m)) {
11336
- const b = d(o, m);
11337
- u(o, m).t.add(n), f.d.add(m), x !== b.n && (i.add(m), (r = c.c) == null || r.call(c, m), p(o, m));
11389
+ const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), f = l.get(n);
11390
+ if (f && !isPendingPromise(m.v)) {
11391
+ for (const [h, x] of m.d)
11392
+ if (!f.d.has(h)) {
11393
+ const b = d(o, h);
11394
+ u(o, h).t.add(n), f.d.add(h), x !== b.n && (i.add(h), (r = c.c) == null || r.call(c, h), p(o, h));
11338
11395
  }
11339
- for (const m of f.d || [])
11340
- if (!h.d.has(m)) {
11341
- f.d.delete(m);
11342
- const x = g(o, m);
11396
+ for (const h of f.d || [])
11397
+ if (!m.d.has(h)) {
11398
+ f.d.delete(h);
11399
+ const x = g(o, h);
11343
11400
  x == null || x.t.delete(n);
11344
11401
  }
11345
11402
  }
11346
11403
  }, mountAtom = (o, n) => {
11347
11404
  var r;
11348
- const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], h = a[14], f = a[16], m = p(o, n);
11405
+ const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], f = a[16], h = p(o, n);
11349
11406
  let x = l.get(n);
11350
11407
  if (!x) {
11351
- h(o, n);
11352
- for (const b of m.d.keys())
11408
+ m(o, n);
11409
+ for (const b of h.d.keys())
11353
11410
  mountAtom(o, b).t.add(n);
11354
11411
  if (x = {
11355
11412
  l: /* @__PURE__ */ new Set(),
11356
- d: new Set(m.d.keys()),
11413
+ d: new Set(h.d.keys()),
11357
11414
  t: /* @__PURE__ */ new Set()
11358
11415
  }, l.set(n, x), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
11359
11416
  const b = () => {
11360
11417
  let y = !0;
11361
- const k = (...S) => {
11418
+ const S = (...k) => {
11362
11419
  try {
11363
- return f(o, n, ...S);
11420
+ return f(o, n, ...k);
11364
11421
  } finally {
11365
11422
  y || (g(o), u(o));
11366
11423
  }
11367
11424
  };
11368
11425
  try {
11369
- const S = d(o, n, k);
11370
- S && (x.u = () => {
11426
+ const k = d(o, n, S);
11427
+ k && (x.u = () => {
11371
11428
  y = !0;
11372
11429
  try {
11373
- S();
11430
+ k();
11374
11431
  } finally {
11375
11432
  y = !1;
11376
11433
  }
@@ -11387,13 +11444,13 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
11387
11444
  var r;
11388
11445
  const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
11389
11446
  let g = l.get(n);
11390
- if (g && !g.l.size && !Array.from(g.t).some((h) => {
11447
+ if (g && !g.l.size && !Array.from(g.t).some((m) => {
11391
11448
  var f;
11392
- return (f = l.get(h)) == null ? void 0 : f.d.has(n);
11449
+ return (f = l.get(m)) == null ? void 0 : f.d.has(n);
11393
11450
  })) {
11394
11451
  g.u && i.add(g.u), g = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
11395
- for (const h of u.d.keys()) {
11396
- const f = p(o, h);
11452
+ for (const m of u.d.keys()) {
11453
+ const f = p(o, m);
11397
11454
  f == null || f.t.delete(n);
11398
11455
  }
11399
11456
  return;
@@ -11531,8 +11588,8 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
11531
11588
  function useAtomValue(o, n) {
11532
11589
  const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
11533
11590
  (g) => {
11534
- const h = l.get(o);
11535
- return Object.is(g[0], h) && g[1] === l && g[2] === o ? g : [h, l, o];
11591
+ const m = l.get(o);
11592
+ return Object.is(g[0], m) && g[1] === l && g[2] === o ? g : [m, l, o];
11536
11593
  },
11537
11594
  void 0,
11538
11595
  () => [l.get(o), l, o]
@@ -11542,9 +11599,9 @@ function useAtomValue(o, n) {
11542
11599
  const g = l.sub(o, () => {
11543
11600
  if (a)
11544
11601
  try {
11545
- const h = l.get(o);
11546
- isPromiseLike(h) && attachPromiseStatus(
11547
- createContinuablePromise(h, () => l.get(o))
11602
+ const m = l.get(o);
11603
+ isPromiseLike(m) && attachPromiseStatus(
11604
+ createContinuablePromise(m, () => l.get(o))
11548
11605
  );
11549
11606
  } catch {
11550
11607
  }
@@ -11684,12 +11741,12 @@ function domToJsx(o, n = 0) {
11684
11741
  if (o.length === 0) return "";
11685
11742
  if (o.length === 1) return domToJsx(o[0], n);
11686
11743
  const g = " ".repeat(n);
11687
- let h = `${g}<>
11744
+ let m = `${g}<>
11688
11745
  `;
11689
11746
  for (const f of o)
11690
- h += domToJsx(f, n + 1);
11691
- return h += `${g}</>
11692
- `, h;
11747
+ m += domToJsx(f, n + 1);
11748
+ return m += `${g}</>
11749
+ `, m;
11693
11750
  }
11694
11751
  const r = " ".repeat(n);
11695
11752
  if (o.nodeType === Node.TEXT_NODE) {
@@ -11718,57 +11775,57 @@ function domToJsx(o, n = 0) {
11718
11775
  const g = [];
11719
11776
  for (const f of o.attributes)
11720
11777
  if (f.name.startsWith("on") && f.name !== "on") {
11721
- const m = f.name.toLowerCase().replace(/on(\w)/, (x, b) => "on" + b.toUpperCase());
11722
- g.push(`${m}={${f.value}}`);
11778
+ const h = f.name.toLowerCase().replace(/on(\w)/, (x, b) => "on" + b.toUpperCase());
11779
+ g.push(`${h}={${f.value}}`);
11723
11780
  } else if (f.name === "style" && f.value) {
11724
- const m = f.value.split(";").reduce(
11781
+ const h = f.value.split(";").reduce(
11725
11782
  (x, b) => {
11726
- const [y, k] = b.split(":").map((S) => S.trim());
11727
- if (y && k) {
11728
- const S = y.replace(/-([a-z])/g, (v) => v[1].toUpperCase());
11729
- x[S] = k.replace(/['"]/g, "");
11783
+ const [y, S] = b.split(":").map((k) => k.trim());
11784
+ if (y && S) {
11785
+ const k = y.replace(/-([a-z])/g, (v) => v[1].toUpperCase());
11786
+ x[k] = S.replace(/['"]/g, "");
11730
11787
  }
11731
11788
  return x;
11732
11789
  },
11733
11790
  {}
11734
11791
  );
11735
- g.push(`style={${JSON.stringify(m)}}`);
11792
+ g.push(`style={${JSON.stringify(h)}}`);
11736
11793
  } else {
11737
- const m = convertAttributeName(f.name);
11738
- g.push(`${m}="${f.value}"`);
11794
+ const h = convertAttributeName(f.name);
11795
+ g.push(`${h}="${f.value}"`);
11739
11796
  }
11740
- const h = g.length > 0 ? ` ${g.join(" ")}` : "";
11741
- return `${r}<${a}${h} />
11797
+ const m = g.length > 0 ? ` ${g.join(" ")}` : "";
11798
+ return `${r}<${a}${m} />
11742
11799
  `;
11743
11800
  }
11744
11801
  let i = `${r}<${a}`;
11745
11802
  const c = [];
11746
11803
  for (const g of o.attributes)
11747
11804
  if (g.name.startsWith("on") && g.name !== "on") {
11748
- const h = g.name.toLowerCase().replace(/on(\w)/, (f, m) => "on" + m.toUpperCase());
11749
- c.push(`${h}={${g.value}}`);
11805
+ const m = g.name.toLowerCase().replace(/on(\w)/, (f, h) => "on" + h.toUpperCase());
11806
+ c.push(`${m}={${g.value}}`);
11750
11807
  } else if (g.name === "style" && g.value) {
11751
- const h = g.value.split(";").reduce(
11752
- (f, m) => {
11753
- const [x, b] = m.split(":").map((y) => y.trim());
11808
+ const m = g.value.split(";").reduce(
11809
+ (f, h) => {
11810
+ const [x, b] = h.split(":").map((y) => y.trim());
11754
11811
  if (x && b) {
11755
- const y = x.replace(/-([a-z])/g, (k) => k[1].toUpperCase());
11812
+ const y = x.replace(/-([a-z])/g, (S) => S[1].toUpperCase());
11756
11813
  f[y] = b.replace(/['"]/g, "");
11757
11814
  }
11758
11815
  return f;
11759
11816
  },
11760
11817
  {}
11761
11818
  );
11762
- c.push(`style={${JSON.stringify(h)}}`);
11819
+ c.push(`style={${JSON.stringify(m)}}`);
11763
11820
  } else {
11764
- const h = convertAttributeName(g.name);
11765
- c.push(`${h}="${g.value}"`);
11821
+ const m = convertAttributeName(g.name);
11822
+ c.push(`${m}="${g.value}"`);
11766
11823
  }
11767
11824
  c.length > 0 && (i += " " + c.join(" "));
11768
11825
  const d = Array.from(o.childNodes);
11769
11826
  if (!d.some((g) => {
11770
- var h;
11771
- return g.nodeType === Node.TEXT_NODE ? (h = g.textContent) == null ? void 0 : h.trim() : !0;
11827
+ var m;
11828
+ return g.nodeType === Node.TEXT_NODE ? (m = g.textContent) == null ? void 0 : m.trim() : !0;
11772
11829
  }))
11773
11830
  i += ` />
11774
11831
  `;
@@ -11825,7 +11882,7 @@ ${l}${l}${i == null ? void 0 : i.trimEnd()}
11825
11882
  ${l})
11826
11883
  }`, { jsx: i, html: formatHtml(c), componentName: a };
11827
11884
  }, ExportCodeModalContent = ({ tab: o }) => {
11828
- var k;
11885
+ var S;
11829
11886
  const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c, d] = useState(""), [p, u] = useState(!1), g = () => {
11830
11887
  switch (o) {
11831
11888
  case "js":
@@ -11837,7 +11894,7 @@ ${l})
11837
11894
  case "tailwind":
11838
11895
  return "tailwind.config.js";
11839
11896
  }
11840
- }, h = () => {
11897
+ }, m = () => {
11841
11898
  switch (o) {
11842
11899
  case "js":
11843
11900
  case "ts":
@@ -11850,18 +11907,18 @@ ${l})
11850
11907
  }, f = useCallback(async () => {
11851
11908
  try {
11852
11909
  u(!1);
11853
- let S = i({ blockId: l == null ? void 0 : l._id, additionalCoreBlocks: ["Icon"] });
11854
- S = S.replace(/\s*bid=["'][^"']*["']/g, "");
11910
+ let k = i({ blockId: l == null ? void 0 : l._id, additionalCoreBlocks: ["Icon"] });
11911
+ k = k.replace(/\s*bid=["'][^"']*["']/g, "");
11855
11912
  const v = o === "ts", {
11856
- jsx: _,
11913
+ jsx: B,
11857
11914
  html: E,
11858
11915
  componentName: I
11859
11916
  } = await getExportedCoded({
11860
11917
  selectedBlock: l,
11861
- html: S,
11918
+ html: k,
11862
11919
  isTypeScript: v
11863
11920
  });
11864
- a({ html: E, jsx: _ }), d(I), u(!0);
11921
+ a({ html: E, jsx: B }), d(I), u(!0);
11865
11922
  } catch {
11866
11923
  const v = "<div>Export failed. Close the modal and try again.</div>";
11867
11924
  a({ html: v, jsx: v }), toast.error(n("Failed to generate export HTML"));
@@ -11870,23 +11927,23 @@ ${l})
11870
11927
  useEffect(() => {
11871
11928
  f();
11872
11929
  }, [f, o]);
11873
- const m = useCallback(
11874
- async (S) => {
11930
+ const h = useCallback(
11931
+ async (k) => {
11875
11932
  try {
11876
- navigator.clipboard.writeText(S), toast.success(n("Export code copied!"));
11933
+ navigator.clipboard.writeText(k), toast.success(n("Export code copied!"));
11877
11934
  } catch {
11878
11935
  toast.error(n("Failed to copy export code"));
11879
11936
  }
11880
11937
  },
11881
11938
  [n]
11882
- ), x = (S) => {
11883
- const v = new Blob([S], { type: "text/jsx" }), _ = URL.createObjectURL(v), E = document.createElement("a");
11884
- E.href = _, E.download = g(), document.body.appendChild(E), E.click(), URL.revokeObjectURL(_), document.body.removeChild(E), toast.success(n("Export code downloaded successfully!"));
11939
+ ), x = (k) => {
11940
+ const v = new Blob([k], { type: "text/jsx" }), B = URL.createObjectURL(v), E = document.createElement("a");
11941
+ E.href = B, E.download = g(), document.body.appendChild(E), E.click(), URL.revokeObjectURL(B), document.body.removeChild(E), toast.success(n("Export code downloaded successfully!"));
11885
11942
  }, b = /* @__PURE__ */ jsxs("span", { children: [
11886
11943
  "Download ",
11887
11944
  /* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-light text-gray-300", children: g() })
11888
11945
  ] }), y = useMemo(() => {
11889
- const S = { extend: shadcnTheme() }, v = JSON.stringify(S, null, 2);
11946
+ const k = { extend: shadcnTheme() }, v = JSON.stringify(k, null, 2);
11890
11947
  return `{
11891
11948
  // Your tailwind config ...
11892
11949
 
@@ -11895,12 +11952,12 @@ ${l})
11895
11952
  `)},
11896
11953
  }`;
11897
11954
  }, []);
11898
- return ((k = r == null ? void 0 : r.jsx) == null ? void 0 : k.length) > 0 && p ? /* @__PURE__ */ jsx(
11955
+ return ((S = r == null ? void 0 : r.jsx) == null ? void 0 : S.length) > 0 && p ? /* @__PURE__ */ jsx(
11899
11956
  CodeDisplay,
11900
11957
  {
11901
- onCopy: m,
11958
+ onCopy: h,
11902
11959
  code: o === "tailwind" ? y : o === "html" ? r.html : r.jsx,
11903
- language: h(),
11960
+ language: m(),
11904
11961
  downloadText: b,
11905
11962
  onDownload: x
11906
11963
  },