@chaibuilder/sdk 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
- var U = Object.defineProperty;
2
- var V = (o, r, n) => r in o ? U(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
1
+ var H = Object.defineProperty;
2
+ var V = (o, r, n) => r in o ? H(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
3
  var F = (o, r, n) => V(o, typeof r != "symbol" ? r + "" : r, n);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
@@ -21,7 +21,7 @@ import { isObject } from "@rjsf/utils";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
22
22
  import { toast, Toaster } from "sonner";
23
23
  import { useTranslation, initReactI18next } from "react-i18next";
24
- import { useTranslation as Ue } from "react-i18next";
24
+ import { useTranslation as Ve } from "react-i18next";
25
25
  import Fuse from "fuse.js";
26
26
  import UndoManager from "undo-manager";
27
27
  import Link from "@tiptap/extension-link";
@@ -841,8 +841,8 @@ const undoRedoStateAtom = atom({
841
841
  return {
842
842
  moveBlocks: (x, y, b) => {
843
843
  const A = map(x, (B) => {
844
- const w = r.find((E) => E._id === B)._parent || null, S = r.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(B);
845
- return { _id: B, oldParent: w, oldPosition: S };
844
+ const w = r.find((E) => E._id === B)._parent || null, v = r.filter((E) => w ? E._parent === w : !E._parent).map((E) => E._id).indexOf(B);
845
+ return { _id: B, oldParent: w, oldPosition: v };
846
846
  }), _ = A.find(({ _id: B }) => B === x[0]);
847
847
  _ && _.oldParent === y && _.oldPosition === b || (i(x, y, b), o({
848
848
  undo: () => each(A, ({ _id: B, oldParent: N, oldPosition: w }) => {
@@ -2385,8 +2385,8 @@ const getBlockWithChildren = (o, r) => {
2385
2385
  }
2386
2386
  if (m === "styles") {
2387
2387
  const w = B.map((k) => {
2388
- for (const S in k)
2389
- S !== "_id" && (k[S] = `${STYLES_KEY},${k[S]}`);
2388
+ for (const v in k)
2389
+ v !== "_id" && (k[v] = `${STYLES_KEY},${k[v]}`);
2390
2390
  return k;
2391
2391
  });
2392
2392
  c(w);
@@ -3598,26 +3598,26 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3598
3598
  ({ block: o, children: r }) => {
3599
3599
  const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: A, blockType: _ } = useMemo(() => {
3600
3600
  var j;
3601
- const S = o._type;
3601
+ const v = o._type;
3602
3602
  let E = o[n];
3603
- const v = getRegisteredChaiBlock(o._type);
3604
- return f && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${f}`) && (E = get(o, `${n}-${f}`)), { blockContent: E, blockType: S };
3603
+ const S = getRegisteredChaiBlock(o._type);
3604
+ return f && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${f}`) && (E = get(o, `${n}-${f}`)), { blockContent: E, blockType: v };
3605
3605
  }, [o, f]), B = useCallback(
3606
- (S) => {
3607
- var v;
3608
- const E = S || ((v = g.current) == null ? void 0 : v.innerText);
3606
+ (v) => {
3607
+ var S;
3608
+ const E = v || ((S = g.current) == null ? void 0 : S.innerText);
3609
3609
  m([b], { [n]: E }), u(null), c(null), d(-1), x(b ? [b] : []);
3610
3610
  },
3611
3611
  [b, m, c, x, f]
3612
3612
  ), N = useDebouncedCallback(
3613
- (S) => {
3614
- m([b], { [n]: S });
3613
+ (v) => {
3614
+ m([b], { [n]: v });
3615
3615
  },
3616
3616
  [b, o, m, f],
3617
3617
  1e3
3618
3618
  ), w = useCallback(
3619
- (S) => {
3620
- S.preventDefault(), b && (y.current = b), B(), setTimeout(() => {
3619
+ (v) => {
3620
+ v.preventDefault(), b && (y.current = b), B(), setTimeout(() => {
3621
3621
  const E = y.current;
3622
3622
  y.current = null, x([E]);
3623
3623
  }, 100);
@@ -3627,8 +3627,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3627
3627
  useEffect(() => {
3628
3628
  var C;
3629
3629
  if (!b) return;
3630
- const S = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${S}${E}`);
3631
- v && ((C = v == null ? void 0 : v.classList) == null || C.add("sr-only"), u(v));
3630
+ const v = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${v}${E}`);
3631
+ S && ((C = S == null ? void 0 : S.classList) == null || C.add("sr-only"), u(S));
3632
3632
  }, [b, _, a, i]);
3633
3633
  const k = useMemo(() => p ? (h(), _ === "RichText" ? /* @__PURE__ */ jsx(
3634
3634
  RichTextEditor,
@@ -4220,11 +4220,11 @@ const DataBindingSelector = ({
4220
4220
  if (_ !== B)
4221
4221
  b.chain().deleteSelection().insertContent(A).run();
4222
4222
  else {
4223
- const { state: w } = b, k = w.selection.from, S = w.doc.textBetween(Math.max(0, k - 1), k), E = w.doc.textBetween(k, Math.min(k + 1, w.doc.content.size));
4224
- let v = "";
4225
- k > 0 && S !== " " && !m(S) && (v = " ");
4223
+ const { state: w } = b, k = w.selection.from, v = w.doc.textBetween(Math.max(0, k - 1), k), E = w.doc.textBetween(k, Math.min(k + 1, w.doc.content.size));
4224
+ let S = "";
4225
+ k > 0 && v !== " " && !m(v) && (S = " ");
4226
4226
  let C = "";
4227
- E && E !== " " && !m(E) && (C = " "), b.chain().insertContent(v + A + C).run();
4227
+ E && E !== " " && !m(E) && (C = " "), b.chain().insertContent(S + A + C).run();
4228
4228
  }
4229
4229
  setTimeout(() => r(b.getHTML(), {}, n), 100);
4230
4230
  return;
@@ -4232,12 +4232,12 @@ const DataBindingSelector = ({
4232
4232
  } else {
4233
4233
  const b = x, A = b.selectionStart || 0, _ = b.value || "", B = b.selectionEnd || A;
4234
4234
  if (B > A) {
4235
- const E = `{{${g}}}`, { text: v } = f(_, A, E), C = _.slice(0, A) + v + _.slice(B);
4235
+ const E = `{{${g}}}`, { text: S } = f(_, A, E), C = _.slice(0, A) + S + _.slice(B);
4236
4236
  r(C, {}, n);
4237
4237
  return;
4238
4238
  }
4239
- const w = `{{${g}}}`, { text: k } = f(_, A, w), S = _.slice(0, A) + k + _.slice(A);
4240
- r(S, {}, n);
4239
+ const w = `{{${g}}}`, { text: k } = f(_, A, w), v = _.slice(0, A) + k + _.slice(A);
4240
+ r(v, {}, n);
4241
4241
  }
4242
4242
  },
4243
4243
  [n, r, a, c == null ? void 0 : c._id, d]
@@ -4259,67 +4259,67 @@ const DataBindingSelector = ({
4259
4259
  onChange: n
4260
4260
  }) => {
4261
4261
  var E;
4262
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), A = useRef(null), _ = (E = r == null ? void 0 : r.find((v) => v.key === u)) == null ? void 0 : E.name;
4262
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), A = useRef(null), _ = (E = r == null ? void 0 : r.find((S) => S.key === u)) == null ? void 0 : E.name;
4263
4263
  useEffect(() => {
4264
4264
  if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4265
- const v = split(o, ":"), C = get(v, 1, "page") || "page";
4265
+ const S = split(o, ":"), C = get(S, 1, "page") || "page";
4266
4266
  g(C), (async () => {
4267
- const j = await l(C, [get(v, 2, "page")]);
4267
+ const j = await l(C, [get(S, 2, "page")]);
4268
4268
  j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4269
4269
  })();
4270
4270
  }, [o]);
4271
4271
  const B = useDebouncedCallback(
4272
- async (v) => {
4273
- if (isEmpty(v))
4272
+ async (S) => {
4273
+ if (isEmpty(S))
4274
4274
  x([]);
4275
4275
  else {
4276
- const C = await l(u, v);
4276
+ const C = await l(u, S);
4277
4277
  x(C);
4278
4278
  }
4279
4279
  c(!1), b(-1);
4280
4280
  },
4281
4281
  [u],
4282
4282
  300
4283
- ), N = (v) => {
4284
- const C = ["pageType", u, v.id];
4285
- C[1] && (n(C.join(":")), m(v.name), p(!1), x([]), b(-1));
4286
- }, w = (v) => {
4287
- switch (v.key) {
4283
+ ), N = (S) => {
4284
+ const C = ["pageType", u, S.id];
4285
+ C[1] && (n(C.join(":")), m(S.name), p(!1), x([]), b(-1));
4286
+ }, w = (S) => {
4287
+ switch (S.key) {
4288
4288
  case "ArrowDown":
4289
- v.preventDefault(), b((C) => C < f.length - 1 ? C + 1 : C);
4289
+ S.preventDefault(), b((C) => C < f.length - 1 ? C + 1 : C);
4290
4290
  break;
4291
4291
  case "ArrowUp":
4292
- v.preventDefault(), b((C) => C > 0 ? C - 1 : C);
4292
+ S.preventDefault(), b((C) => C > 0 ? C - 1 : C);
4293
4293
  break;
4294
4294
  case "Enter":
4295
- if (v.preventDefault(), f.length === 0) return;
4295
+ if (S.preventDefault(), f.length === 0) return;
4296
4296
  y >= 0 && N(f[y]);
4297
4297
  break;
4298
4298
  case "Escape":
4299
- v.preventDefault(), k();
4299
+ S.preventDefault(), k();
4300
4300
  break;
4301
4301
  }
4302
4302
  };
4303
4303
  useEffect(() => {
4304
4304
  if (y >= 0 && A.current) {
4305
- const v = A.current.children[y];
4306
- v == null || v.scrollIntoView({ block: "nearest" });
4305
+ const S = A.current.children[y];
4306
+ S == null || S.scrollIntoView({ block: "nearest" });
4307
4307
  }
4308
4308
  }, [y]);
4309
4309
  const k = () => {
4310
4310
  m(""), x([]), b(-1), p(!1), n("");
4311
- }, S = (v) => {
4312
- m(v), p(!isEmpty(v)), c(!0), B(v);
4311
+ }, v = (S) => {
4312
+ m(S), p(!isEmpty(S)), c(!0), B(S);
4313
4313
  };
4314
4314
  return /* @__PURE__ */ jsxs("div", { children: [
4315
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(r, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
4315
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (S) => g(S.target.value), children: map(r, (S) => /* @__PURE__ */ jsx("option", { value: S.key, children: S.name }, S.key)) }),
4316
4316
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4317
4317
  /* @__PURE__ */ jsx(
4318
4318
  "input",
4319
4319
  {
4320
4320
  type: "text",
4321
4321
  value: h,
4322
- onChange: (v) => S(v.target.value),
4322
+ onChange: (S) => v(S.target.value),
4323
4323
  onKeyDown: w,
4324
4324
  placeholder: a(`Search ${_ ?? ""}`),
4325
4325
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
@@ -4335,22 +4335,22 @@ const DataBindingSelector = ({
4335
4335
  ' "',
4336
4336
  h,
4337
4337
  '"'
4338
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, C) => /* @__PURE__ */ jsxs(
4338
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (S, C) => /* @__PURE__ */ jsxs(
4339
4339
  "li",
4340
4340
  {
4341
- onClick: () => N(v),
4342
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : C === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4341
+ onClick: () => N(S),
4342
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : C === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4343
4343
  children: [
4344
- v.name,
4344
+ S.name,
4345
4345
  " ",
4346
- v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4346
+ S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4347
4347
  "( ",
4348
- v.slug,
4348
+ S.slug,
4349
4349
  " )"
4350
4350
  ] })
4351
4351
  ]
4352
4352
  },
4353
- v.id
4353
+ S.id
4354
4354
  )) }) })
4355
4355
  ] });
4356
4356
  }, LinkField = ({ schema: o, formData: r, onChange: n, name: a }) => {
@@ -4965,7 +4965,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4965
4965
  if (c)
4966
4966
  return null;
4967
4967
  if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4968
- const S = B == null ? void 0 : B.includes(o.replace("root.", ""));
4968
+ const v = B == null ? void 0 : B.includes(o.replace("root.", ""));
4969
4969
  if (p.type === "array") {
4970
4970
  const E = N === o;
4971
4971
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
@@ -4986,8 +4986,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4986
4986
  Info,
4987
4987
  {
4988
4988
  className: "h-3 w-3 text-muted-foreground/70",
4989
- onClick: (v) => v.stopPropagation(),
4990
- onMouseDown: (v) => v.stopPropagation()
4989
+ onClick: (S) => S.stopPropagation(),
4990
+ onMouseDown: (S) => S.stopPropagation()
4991
4991
  }
4992
4992
  ) }),
4993
4993
  /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
@@ -5008,7 +5008,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5008
5008
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: p.type === "object" ? "pb-2" : "", children: [
5009
5009
  n,
5010
5010
  " ",
5011
- S && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5011
+ v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5012
5012
  " ",
5013
5013
  y
5014
5014
  ] }),
@@ -5130,11 +5130,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5130
5130
  }), a;
5131
5131
  };
5132
5132
  function BlockSettings() {
5133
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: w }, k, S) => {
5134
- k && (c == null ? void 0 : c._id) === r._id && a([r._id], { [k]: get(w, k) }, S);
5133
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: w }, k, v) => {
5134
+ k && (c == null ? void 0 : c._id) === r._id && a([r._id], { [k]: get(w, k) }, v);
5135
5135
  }, x = useCallback(
5136
- debounce(({ formData: w }, k, S) => {
5137
- f({ formData: w }, k, S), d(w);
5136
+ debounce(({ formData: w }, k, v) => {
5137
+ f({ formData: w }, k, v), d(w);
5138
5138
  }, 1500),
5139
5139
  [r == null ? void 0 : r._id, o]
5140
5140
  ), y = ({ formData: w }, k) => {
@@ -5146,20 +5146,20 @@ function BlockSettings() {
5146
5146
  if (!w)
5147
5147
  return { schema: {}, uiSchema: {} };
5148
5148
  try {
5149
- const { schema: k, uiSchema: S } = getBlockFormSchemas(w);
5149
+ const { schema: k, uiSchema: v } = getBlockFormSchemas(w);
5150
5150
  if (w === "Repeater") {
5151
5151
  const E = get(r, "repeaterItems", "");
5152
- startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(S, "filter", { "ui:widget": "collectionSelect" }), set(S, "sort", { "ui:widget": "collectionSelect" })) : (set(S, "filter", { "ui:widget": "hidden" }), set(S, "sort", { "ui:widget": "hidden" }));
5152
+ startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(v, "filter", { "ui:widget": "collectionSelect" }), set(v, "sort", { "ui:widget": "collectionSelect" })) : (set(v, "filter", { "ui:widget": "hidden" }), set(v, "sort", { "ui:widget": "hidden" }));
5153
5153
  }
5154
- return { schema: k, uiSchema: S };
5154
+ return { schema: k, uiSchema: v };
5155
5155
  } catch {
5156
5156
  return { schema: {}, uiSchema: {} };
5157
5157
  }
5158
5158
  }, [r]), { wrapperSchema: B, wrapperUiSchema: N } = useMemo(() => {
5159
5159
  if (!g || !(g != null && g._type))
5160
5160
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5161
- const w = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: S = {} } = getBlockFormSchemas(w);
5162
- return { wrapperSchema: k, wrapperUiSchema: S };
5161
+ const w = g == null ? void 0 : g._type, { schema: k = {}, uiSchema: v = {} } = getBlockFormSchemas(w);
5162
+ return { wrapperSchema: k, wrapperUiSchema: v };
5163
5163
  }, [g]);
5164
5164
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5165
5165
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -5412,15 +5412,15 @@ const BlockStylingProps = () => {
5412
5412
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5413
5413
  const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [A, _] = useState(!1), [B, N] = useState(!1);
5414
5414
  useEffect(() => {
5415
- const { value: v, unit: C } = getClassValueAndUnit(i);
5415
+ const { value: S, unit: C } = getClassValueAndUnit(i);
5416
5416
  if (C === "") {
5417
- l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5417
+ l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5418
5418
  return;
5419
5419
  }
5420
- m(C), l(C === "class" || isEmpty(v) ? "" : v);
5420
+ m(C), l(C === "class" || isEmpty(S) ? "" : S);
5421
5421
  }, [i, p, u]);
5422
- const w = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), k = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), S = useCallback(
5423
- (v = !1) => {
5422
+ const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), k = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), v = useCallback(
5423
+ (S = !1) => {
5424
5424
  const C = getUserInputValues(`${a}`, u);
5425
5425
  if (get(C, "error", !1)) {
5426
5426
  x(!0);
@@ -5433,25 +5433,25 @@ const BlockStylingProps = () => {
5433
5433
  }
5434
5434
  if (get(C, "value") === "")
5435
5435
  return;
5436
- const L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5437
- v ? k(L) : w(L);
5436
+ const T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5437
+ S ? k(T) : w(T);
5438
5438
  },
5439
5439
  [w, k, a, h, d, u]
5440
5440
  ), E = useCallback(
5441
- (v) => {
5441
+ (S) => {
5442
5442
  const C = getUserInputValues(`${a}`, u);
5443
5443
  if (get(C, "error", !1)) {
5444
5444
  x(!0);
5445
5445
  return;
5446
5446
  }
5447
- if (v === "auto" || v === "none") {
5448
- w(`${d}${v}`);
5447
+ if (S === "auto" || S === "none") {
5448
+ w(`${d}${S}`);
5449
5449
  return;
5450
5450
  }
5451
5451
  if (get(C, "value") === "")
5452
5452
  return;
5453
- const j = get(C, "unit") !== "" ? get(C, "unit") : v, L = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5454
- w(L);
5453
+ const j = get(C, "unit") !== "" ? get(C, "unit") : S, T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5454
+ w(T);
5455
5455
  },
5456
5456
  [w, a, d, u]
5457
5457
  );
@@ -5474,29 +5474,29 @@ const BlockStylingProps = () => {
5474
5474
  "input",
5475
5475
  {
5476
5476
  readOnly: h === "class",
5477
- onKeyPress: (v) => {
5478
- v.key === "Enter" && S();
5477
+ onKeyPress: (S) => {
5478
+ S.key === "Enter" && v();
5479
5479
  },
5480
- onKeyDown: (v) => {
5481
- if (v.keyCode !== 38 && v.keyCode !== 40)
5480
+ onKeyDown: (S) => {
5481
+ if (S.keyCode !== 38 && S.keyCode !== 40)
5482
5482
  return;
5483
- v.preventDefault(), N(!0);
5484
- const C = parseInt$1(v.target.value);
5483
+ S.preventDefault(), N(!0);
5484
+ const C = parseInt$1(S.target.value);
5485
5485
  let j = isNaN$1(C) ? 0 : C;
5486
- v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5486
+ S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5487
5487
  const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5488
5488
  k(R);
5489
5489
  },
5490
- onKeyUp: (v) => {
5491
- B && (v.preventDefault(), N(!1));
5490
+ onKeyUp: (S) => {
5491
+ B && (S.preventDefault(), N(!1));
5492
5492
  },
5493
- onBlur: () => S(),
5494
- onChange: (v) => {
5495
- x(!1), l(v.target.value);
5493
+ onBlur: () => v(),
5494
+ onChange: (S) => {
5495
+ x(!1), l(S.target.value);
5496
5496
  },
5497
- onClick: (v) => {
5497
+ onClick: (S) => {
5498
5498
  var C;
5499
- (C = v == null ? void 0 : v.target) == null || C.select(), n(!1);
5499
+ (C = S == null ? void 0 : S.target) == null || C.select(), n(!1);
5500
5500
  },
5501
5501
  value: A ? y : a,
5502
5502
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
@@ -5523,8 +5523,8 @@ const BlockStylingProps = () => {
5523
5523
  {
5524
5524
  units: u,
5525
5525
  current: h,
5526
- onSelect: (v) => {
5527
- n(!1), m(v), E(v);
5526
+ onSelect: (S) => {
5527
+ n(!1), m(S), E(S);
5528
5528
  }
5529
5529
  }
5530
5530
  ) })
@@ -5534,17 +5534,17 @@ const BlockStylingProps = () => {
5534
5534
  DragStyleButton,
5535
5535
  {
5536
5536
  onDragStart: () => _(!0),
5537
- onDragEnd: (v) => {
5538
- if (b(() => ""), _(!1), isEmpty(v))
5537
+ onDragEnd: (S) => {
5538
+ if (b(() => ""), _(!1), isEmpty(S))
5539
5539
  return;
5540
- const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5540
+ const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5541
5541
  w(I);
5542
5542
  },
5543
- onDrag: (v) => {
5544
- if (isEmpty(v))
5543
+ onDrag: (S) => {
5544
+ if (isEmpty(S))
5545
5545
  return;
5546
- b(v);
5547
- const C = `${v}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5546
+ b(S);
5547
+ const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5548
5548
  k(I);
5549
5549
  },
5550
5550
  currentValue: a,
@@ -6009,11 +6009,11 @@ const COLOR_PROP = {
6009
6009
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6010
6010
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
6011
6011
  }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
6012
- (k, S = !0) => {
6012
+ (k, v = !0) => {
6013
6013
  const E = { dark: p, mq: g, mod: u, cls: k, property: l, fullCls: "" };
6014
6014
  (p || u !== "") && (E.mq = "xs");
6015
- const v = generateFullClsName(E);
6016
- m(x, [v], S);
6015
+ const S = generateFullClsName(E);
6016
+ m(x, [S], v);
6017
6017
  },
6018
6018
  [x, p, g, u, l, m]
6019
6019
  ), A = useCallback(() => {
@@ -6456,24 +6456,24 @@ const AskAIStyles = ({ blockId: o }) => {
6456
6456
  };
6457
6457
  function ManualClasses() {
6458
6458
  var I;
6459
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), A = b.split(" ").filter((L) => !isEmpty(L)), _ = () => {
6460
- const L = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6461
- u(h, L, !0), x("");
6462
- }, [B, N] = useState([]), w = ({ value: L }) => {
6463
- const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
6459
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), A = b.split(" ").filter((T) => !isEmpty(T)), _ = () => {
6460
+ const T = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6461
+ u(h, T, !0), x("");
6462
+ }, [B, N] = useState([]), w = ({ value: T }) => {
6463
+ const R = T.trim().toLowerCase(), L = R.match(/.+:/g);
6464
6464
  let D = [];
6465
- if (T && T.length > 0) {
6466
- const [O] = T, P = R.replace(O, "");
6467
- D = i.search(P).map((M) => ({
6468
- ...M,
6469
- item: { ...M.item, name: O + M.item.name }
6465
+ if (L && L.length > 0) {
6466
+ const [P] = L, M = R.replace(P, "");
6467
+ D = i.search(M).map((O) => ({
6468
+ ...O,
6469
+ item: { ...O.item, name: P + O.item.name }
6470
6470
  }));
6471
6471
  } else
6472
6472
  D = i.search(R);
6473
6473
  return N(map(D, "item"));
6474
6474
  }, k = () => {
6475
6475
  N([]);
6476
- }, S = (L) => L.name, E = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), v = useMemo(
6476
+ }, v = (T) => T.name, E = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6477
6477
  () => ({
6478
6478
  ref: o,
6479
6479
  autoComplete: "off",
@@ -6482,22 +6482,22 @@ function ManualClasses() {
6482
6482
  spellCheck: !1,
6483
6483
  placeholder: c("Enter classes separated by space"),
6484
6484
  value: f,
6485
- onFocus: (L) => {
6485
+ onFocus: (T) => {
6486
6486
  setTimeout(() => {
6487
- L.target && L.target.select();
6487
+ T.target && T.target.select();
6488
6488
  }, 0);
6489
6489
  },
6490
- onKeyDown: (L) => {
6491
- L.key === "Enter" && f.trim() !== "" && _();
6490
+ onKeyDown: (T) => {
6491
+ T.key === "Enter" && f.trim() !== "" && _();
6492
6492
  },
6493
- onChange: (L, { newValue: R }) => x(R),
6493
+ onChange: (T, { newValue: R }) => x(R),
6494
6494
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6495
6495
  }),
6496
6496
  [f, c, o]
6497
- ), C = (L) => {
6497
+ ), C = (T) => {
6498
6498
  debugger;
6499
6499
  const R = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6500
- g(h, [L]), u(h, R, !0), n(""), l(-1);
6500
+ g(h, [T]), u(h, R, !0), n(""), l(-1);
6501
6501
  }, j = () => {
6502
6502
  if (navigator.clipboard === void 0) {
6503
6503
  toast.error(c("Clipboard not supported"));
@@ -6529,9 +6529,9 @@ function ManualClasses() {
6529
6529
  suggestions: B,
6530
6530
  onSuggestionsFetchRequested: w,
6531
6531
  onSuggestionsClearRequested: k,
6532
- getSuggestionValue: S,
6532
+ getSuggestionValue: v,
6533
6533
  renderSuggestion: E,
6534
- inputProps: v,
6534
+ inputProps: S,
6535
6535
  containerProps: {
6536
6536
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6537
6537
  },
@@ -6555,31 +6555,31 @@ function ManualClasses() {
6555
6555
  )
6556
6556
  ] }),
6557
6557
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
6558
- (L, R) => a === R ? /* @__PURE__ */ jsx(
6558
+ (T, R) => a === R ? /* @__PURE__ */ jsx(
6559
6559
  "input",
6560
6560
  {
6561
6561
  ref: o,
6562
6562
  value: r,
6563
- onChange: (T) => n(T.target.value),
6563
+ onChange: (L) => n(L.target.value),
6564
6564
  onBlur: () => {
6565
- C(L);
6565
+ C(T);
6566
6566
  },
6567
- onKeyDown: (T) => {
6568
- T.key === "Enter" && C(L);
6567
+ onKeyDown: (L) => {
6568
+ L.key === "Enter" && C(T);
6569
6569
  },
6570
- onFocus: (T) => {
6570
+ onFocus: (L) => {
6571
6571
  setTimeout(() => {
6572
- T.target.select();
6572
+ L.target.select();
6573
6573
  }, 0);
6574
6574
  },
6575
6575
  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"
6576
6576
  },
6577
- L
6577
+ T
6578
6578
  ) : /* @__PURE__ */ jsx("div", { className: "group relative flex max-w-[260px] items-center", children: /* @__PURE__ */ jsxs(
6579
6579
  "button",
6580
6580
  {
6581
6581
  onDoubleClick: () => {
6582
- x(L), g(h, [L]), setTimeout(() => {
6582
+ x(T), g(h, [T]), setTimeout(() => {
6583
6583
  o.current && o.current.focus();
6584
6584
  }, 10);
6585
6585
  },
@@ -6589,7 +6589,7 @@ function ManualClasses() {
6589
6589
  /* @__PURE__ */ jsx(
6590
6590
  Cross2Icon,
6591
6591
  {
6592
- onClick: () => g(h, [L], !0),
6592
+ onClick: () => g(h, [T], !0),
6593
6593
  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"
6594
6594
  }
6595
6595
  ),
@@ -6616,10 +6616,10 @@ function ManualClasses() {
6616
6616
  }
6617
6617
  )
6618
6618
  ] }),
6619
- /* @__PURE__ */ jsx("div", { children: L })
6619
+ /* @__PURE__ */ jsx("div", { children: T })
6620
6620
  ]
6621
6621
  }
6622
- ) }, L)
6622
+ ) }, T)
6623
6623
  ) })
6624
6624
  ] });
6625
6625
  }
@@ -7062,18 +7062,18 @@ const CoreBlock = ({
7062
7062
  }
7063
7063
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7064
7064
  delete a.styles_attrs;
7065
- const w = filter(n.children || [], (S) => (S == null ? void 0 : S.tagName) !== "span");
7065
+ const w = filter(n.children || [], (v) => (v == null ? void 0 : v.tagName) !== "span");
7066
7066
  a.content = getTextContent(w);
7067
7067
  const k = find(
7068
7068
  n.children || [],
7069
- (S) => (S == null ? void 0 : S.tagName) === "span" && some(S.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
7069
+ (v) => (v == null ? void 0 : v.tagName) === "span" && some(v.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg")
7070
7070
  );
7071
7071
  if (k) {
7072
- const S = find(k.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg");
7073
- if (S) {
7074
- a.icon = stringify([S]);
7075
- const { height: E, width: v } = getSvgDimensions(S, "16px", "16px");
7076
- a.iconHeight = E, a.iconWidth = v;
7072
+ const v = find(k.children || [], (E) => (E == null ? void 0 : E.tagName) === "svg");
7073
+ if (v) {
7074
+ a.icon = stringify([v]);
7075
+ const { height: E, width: S } = getSvgDimensions(v, "16px", "16px");
7076
+ a.iconHeight = E, a.iconWidth = S;
7077
7077
  }
7078
7078
  }
7079
7079
  return [a];
@@ -7085,12 +7085,12 @@ const CoreBlock = ({
7085
7085
  const w = stringify([n]);
7086
7086
  return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7087
7087
  } else if (n.tagName === "svg") {
7088
- const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: k, width: S } = getHeightAndWidthFromClass(w);
7089
- if (k && S)
7090
- a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${k}`, w)}`.trim(), a.height = k == null ? void 0 : k.replace("px", ""), a.width = S == null ? void 0 : S.replace("px", "");
7088
+ const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: k, width: v } = getHeightAndWidthFromClass(w);
7089
+ if (k && v)
7090
+ a.styles = `${STYLES_KEY}, ${cn$2(`w-${v} h-${k}`, w)}`.trim(), a.height = k == null ? void 0 : k.replace("px", ""), a.width = v == null ? void 0 : v.replace("px", "");
7091
7091
  else {
7092
- const E = (_ = find(n.attributes, { key: "height" })) == null ? void 0 : _.value, v = (B = find(n.attributes, { key: "width" })) == null ? void 0 : B.value;
7093
- E && v ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${v}px] h-[${E}px]`, w)}`.trim(), a.height = E, a.width = v) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
7092
+ const E = (_ = find(n.attributes, { key: "height" })) == null ? void 0 : _.value, S = (B = find(n.attributes, { key: "width" })) == null ? void 0 : B.value;
7093
+ E && S ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${S}px] h-[${E}px]`, w)}`.trim(), a.height = E, a.width = S) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
7094
7094
  }
7095
7095
  return n.attributes = filter(n.attributes, (E) => !includes(["style", "width", "height", "class"], E.key)), a.icon = stringify([n]), [a];
7096
7096
  } else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
@@ -7301,7 +7301,7 @@ const registerChaiLibrary = (o, r) => {
7301
7301
  }, 400);
7302
7302
  }, k = () => {
7303
7303
  i != null && i.id && p(i.id);
7304
- }, S = () => {
7304
+ }, v = () => {
7305
7305
  g("");
7306
7306
  };
7307
7307
  if (d)
@@ -7309,7 +7309,7 @@ const registerChaiLibrary = (o, r) => {
7309
7309
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7310
7310
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7311
7311
  ] });
7312
- const E = filter(_, (C, j) => j % 2 === 0), v = filter(_, (C, j) => j % 2 === 1);
7312
+ const E = filter(_, (C, j) => j % 2 === 0), S = filter(_, (C, j) => j % 2 === 1);
7313
7313
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7314
7314
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7315
7315
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7325,7 +7325,7 @@ const registerChaiLibrary = (o, r) => {
7325
7325
  u && /* @__PURE__ */ jsx(
7326
7326
  "button",
7327
7327
  {
7328
- onClick: S,
7328
+ onClick: v,
7329
7329
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7330
7330
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7331
7331
  }
@@ -7380,7 +7380,7 @@ const registerChaiLibrary = (o, r) => {
7380
7380
  },
7381
7381
  `block-${j}`
7382
7382
  )) }),
7383
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((C, j) => /* @__PURE__ */ jsx(
7383
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((C, j) => /* @__PURE__ */ jsx(
7384
7384
  BlockCard,
7385
7385
  {
7386
7386
  parentId: o,
@@ -7487,8 +7487,8 @@ const registerChaiLibrary = (o, r) => {
7487
7487
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
7488
7488
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7489
7489
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
7490
- var v;
7491
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (C) => C._id === n)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
7490
+ var S;
7491
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (C) => C._id === n)) == null ? void 0 : S._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
7492
7492
  useEffect(() => {
7493
7493
  const C = setTimeout(() => {
7494
7494
  var j;
@@ -7524,7 +7524,7 @@ const registerChaiLibrary = (o, r) => {
7524
7524
  ), k = useMemo(
7525
7525
  () => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
7526
7526
  [w]
7527
- ), S = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? k : [m], [k, m]);
7527
+ ), v = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? k : [m], [k, m]);
7528
7528
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7529
7529
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7530
7530
  Input$1,
@@ -7570,7 +7570,7 @@ const registerChaiLibrary = (o, r) => {
7570
7570
  ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((C) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7571
7571
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(C.toLowerCase())) }),
7572
7572
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7573
- m === "all" ? filter(values(S), { group: C }) : values(S),
7573
+ m === "all" ? filter(values(v), { group: C }) : values(v),
7574
7574
  { hidden: !0 }
7575
7575
  ).map((j) => /* @__PURE__ */ jsx(
7576
7576
  CoreBlock,
@@ -7935,35 +7935,35 @@ const Input = ({ node: o }) => {
7935
7935
  var R;
7936
7936
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7937
7937
  let p = null;
7938
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: A, handleClick: _ } = o, B = (T) => {
7939
- T.stopPropagation(), !l.includes(m) && o.toggle();
7940
- }, N = (T) => {
7941
- T.isInternal && (p = T.isOpen, T.isOpen && T.close());
7942
- }, w = (T) => {
7943
- T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
7944
- }, [k, S] = useAtom$1(currentAddSelection), E = () => {
7945
- var T;
7946
- v(), o.parent.isSelected || S((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7947
- }, v = () => {
7948
- S(null);
7949
- }, C = (T) => {
7950
- v(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), _(T);
7938
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: A, handleClick: _ } = o, B = (L) => {
7939
+ L.stopPropagation(), !l.includes(m) && o.toggle();
7940
+ }, N = (L) => {
7941
+ L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7942
+ }, w = (L) => {
7943
+ L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
7944
+ }, [k, v] = useAtom$1(currentAddSelection), E = () => {
7945
+ var L;
7946
+ S(), o.parent.isSelected || v((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7947
+ }, S = () => {
7948
+ v(null);
7949
+ }, C = (L) => {
7950
+ S(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), _(L);
7951
7951
  };
7952
7952
  useEffect(() => {
7953
- const T = setTimeout(() => {
7953
+ const L = setTimeout(() => {
7954
7954
  y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7955
7955
  }, 500);
7956
- return () => clearTimeout(T);
7956
+ return () => clearTimeout(L);
7957
7957
  }, [y, o, b]);
7958
- const j = (T, D) => {
7959
- const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7960
- P && P.setAttribute("data-drop", D);
7961
- const $ = P.getBoundingClientRect(), M = c.getBoundingClientRect();
7962
- $.top >= M.top && $.left >= M.left && $.bottom <= M.bottom && $.right <= M.right || (O.documentElement.scrollTop = P.offsetTop - M.top);
7963
- }, I = (T) => {
7964
- v();
7958
+ const j = (L, D) => {
7959
+ const P = c.contentDocument || c.contentWindow.document, M = P.querySelector(`[data-block-id=${L}]`);
7960
+ M && M.setAttribute("data-drop", D);
7961
+ const $ = M.getBoundingClientRect(), O = c.getBoundingClientRect();
7962
+ $.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (P.documentElement.scrollTop = M.offsetTop - O.top);
7963
+ }, I = (L) => {
7964
+ S();
7965
7965
  const D = get(o, "parent.id");
7966
- D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
7966
+ D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
7967
7967
  };
7968
7968
  if (m === ROOT_TEMP_KEY)
7969
7969
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
@@ -7983,7 +7983,7 @@ const Input = ({ node: o }) => {
7983
7983
  ),
7984
7984
  /* @__PURE__ */ jsx("br", {})
7985
7985
  ] });
7986
- const L = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]);
7986
+ const T = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (d(PERMISSIONS.CREATE_LIBRARY_BLOCK) || d(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, d]);
7987
7987
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7988
7988
  "div",
7989
7989
  {
@@ -7995,24 +7995,24 @@ const Input = ({ node: o }) => {
7995
7995
  ref: l.includes(m) ? null : n,
7996
7996
  onDragStart: () => N(o),
7997
7997
  onDragEnd: () => w(o),
7998
- onDragOver: (T) => {
7999
- T.preventDefault(), j(m, "yes");
7998
+ onDragOver: (L) => {
7999
+ L.preventDefault(), j(m, "yes");
8000
8000
  },
8001
- onDragLeave: (T) => {
8002
- T.preventDefault(), j(m, "no");
8001
+ onDragLeave: (L) => {
8002
+ L.preventDefault(), j(m, "no");
8003
8003
  },
8004
- onDrop: (T) => {
8005
- T.preventDefault(), j(m, "no");
8004
+ onDrop: (L) => {
8005
+ L.preventDefault(), j(m, "no");
8006
8006
  },
8007
8007
  children: [
8008
8008
  d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
8009
8009
  "div",
8010
8010
  {
8011
- onClick: (T) => {
8012
- T.stopPropagation(), I(o.childIndex);
8011
+ onClick: (L) => {
8012
+ L.stopPropagation(), I(o.childIndex);
8013
8013
  },
8014
8014
  onMouseEnter: E,
8015
- onMouseLeave: v,
8015
+ onMouseLeave: S,
8016
8016
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
8017
8017
  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 p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
8018
8018
  }
@@ -8027,7 +8027,7 @@ const Input = ({ node: o }) => {
8027
8027
  (o == null ? void 0 : o.id) === k ? "bg-primary/10" : "",
8028
8028
  b && "opacity-20",
8029
8029
  l.includes(m) ? "opacity-50" : "",
8030
- L && x && "bg-primary/20 text-primary"
8030
+ T && x && "bg-primary/20 text-primary"
8031
8031
  ),
8032
8032
  children: [
8033
8033
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -8043,8 +8043,8 @@ const Input = ({ node: o }) => {
8043
8043
  {
8044
8044
  className: cn(
8045
8045
  "leading-1 flex items-center",
8046
- L && "text-primary/60",
8047
- L && x && "text-primary/80"
8046
+ T && "text-primary/60",
8047
+ T && x && "text-primary/80"
8048
8048
  ),
8049
8049
  children: [
8050
8050
  /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
@@ -8052,8 +8052,8 @@ const Input = ({ node: o }) => {
8052
8052
  "div",
8053
8053
  {
8054
8054
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
8055
- onDoubleClick: (T) => {
8056
- T.stopPropagation(), o.edit(), o.deselect();
8055
+ onDoubleClick: (L) => {
8056
+ L.stopPropagation(), o.edit(), o.deselect();
8057
8057
  },
8058
8058
  children: /* @__PURE__ */ jsx("span", { children: getBlockDisplayName(f) })
8059
8059
  }
@@ -8079,8 +8079,8 @@ const Input = ({ node: o }) => {
8079
8079
  /* @__PURE__ */ jsx(
8080
8080
  TooltipTrigger,
8081
8081
  {
8082
- onClick: (T) => {
8083
- T.stopPropagation(), i(m), o.isOpen && o.toggle();
8082
+ onClick: (L) => {
8083
+ L.stopPropagation(), i(m), o.isOpen && o.toggle();
8084
8084
  },
8085
8085
  className: "cursor-pointer rounded bg-transparent",
8086
8086
  asChild: !0,
@@ -8418,12 +8418,12 @@ const Input = ({ node: o }) => {
8418
8418
  ), B = useDebouncedCallback(
8419
8419
  (w, k) => {
8420
8420
  h(() => {
8421
- const S = get(g, `colors.${w}`);
8422
- return r ? set(S, 1, k) : set(S, 0, k), {
8421
+ const v = get(g, `colors.${w}`);
8422
+ return r ? set(v, 1, k) : set(v, 0, k), {
8423
8423
  ...g,
8424
8424
  colors: {
8425
8425
  ...g.colors,
8426
- [w]: S
8426
+ [w]: v
8427
8427
  }
8428
8428
  };
8429
8429
  });
@@ -8431,12 +8431,12 @@ const Input = ({ node: o }) => {
8431
8431
  [g],
8432
8432
  200
8433
8433
  ), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([k]) => {
8434
- const S = get(g, `colors.${k}.${r ? 1 : 0}`);
8435
- return S ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8434
+ const v = get(g, `colors.${k}.${r ? 1 : 0}`);
8435
+ return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8436
8436
  /* @__PURE__ */ jsx(
8437
8437
  ColorPickerInput,
8438
8438
  {
8439
- value: S,
8439
+ value: v,
8440
8440
  onChange: (E) => B(k, E)
8441
8441
  }
8442
8442
  ),
@@ -8457,8 +8457,8 @@ const Input = ({ node: o }) => {
8457
8457
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8458
8458
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8459
8459
  /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8460
- const k = Object.keys(w)[0], S = k.replaceAll("_", " ");
8461
- return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(S) }, k);
8460
+ const k = Object.keys(w)[0], v = k.replaceAll("_", " ");
8461
+ return /* @__PURE__ */ jsx(SelectItem, { value: k, children: capitalize(v) }, k);
8462
8462
  }) })
8463
8463
  ] }) }),
8464
8464
  /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: f("Apply") }) })
@@ -8475,7 +8475,7 @@ const Input = ({ node: o }) => {
8475
8475
  {
8476
8476
  label: w,
8477
8477
  value: g.fontFamily[w.replace(/font-/g, "")] || k[Object.keys(k)[0]],
8478
- onChange: (S) => A(w, S)
8478
+ onChange: (v) => A(w, v)
8479
8479
  },
8480
8480
  w
8481
8481
  )) }),
@@ -9467,8 +9467,8 @@ const AiAssistant = () => {
9467
9467
  n(k), l(a), c(""), p(""), m("");
9468
9468
  }
9469
9469
  }, A = (k) => {
9470
- const S = a.filter((E, v) => v !== k);
9471
- n(S), l(S);
9470
+ const v = a.filter((E, S) => S !== k);
9471
+ n(v), l(v);
9472
9472
  }, _ = (k) => {
9473
9473
  g(k), c(a[k].key), p(a[k].value);
9474
9474
  }, B = () => {
@@ -9483,23 +9483,23 @@ const AiAssistant = () => {
9483
9483
  }, N = (k) => {
9484
9484
  k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? B() : b());
9485
9485
  }, w = useCallback((k) => {
9486
- const S = (C) => /[.,!?;:]/.test(C), E = (C, j, I) => {
9487
- let L = "", R = "";
9488
- const T = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
9489
- return j > 0 && (T === "." || !S(T) && T !== " ") && (L = " "), j < C.length && !S(D) && D !== " " && (R = " "), {
9490
- text: L + I + R,
9491
- prefixLength: L.length,
9486
+ const v = (C) => /[.,!?;:]/.test(C), E = (C, j, I) => {
9487
+ let T = "", R = "";
9488
+ const L = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
9489
+ return j > 0 && (L === "." || !v(L) && L !== " ") && (T = " "), j < C.length && !v(D) && D !== " " && (R = " "), {
9490
+ text: T + I + R,
9491
+ prefixLength: T.length,
9492
9492
  suffixLength: R.length
9493
9493
  };
9494
- }, v = x.current;
9495
- if (v) {
9496
- const C = v.selectionStart || 0, j = v.value || "", I = v.selectionEnd || C;
9494
+ }, S = x.current;
9495
+ if (S) {
9496
+ const C = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || C;
9497
9497
  if (I > C) {
9498
- const O = `{{${k}}}`, { text: P } = E(j, C, O), $ = j.slice(0, C) + P + j.slice(I);
9498
+ const P = `{{${k}}}`, { text: M } = E(j, C, P), $ = j.slice(0, C) + M + j.slice(I);
9499
9499
  p($);
9500
9500
  return;
9501
9501
  }
9502
- const R = `{{${k}}}`, { text: T } = E(j, C, R), D = j.slice(0, C) + T + j.slice(C);
9502
+ const R = `{{${k}}}`, { text: L } = E(j, C, R), D = j.slice(0, C) + L + j.slice(C);
9503
9503
  p(D);
9504
9504
  }
9505
9505
  }, []);
@@ -9558,16 +9558,16 @@ const AiAssistant = () => {
9558
9558
  ]
9559
9559
  }
9560
9560
  ),
9561
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, S) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9561
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((k, v) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9562
9562
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9563
9563
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: k.key }),
9564
9564
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
9565
9565
  ] }),
9566
9566
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9567
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(S), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9568
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(S), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9567
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(v), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9568
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(v), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9569
9569
  ] })
9570
- ] }, S)) })
9570
+ ] }, v)) })
9571
9571
  ] });
9572
9572
  }), BlockAttributesEditor = React.memo(() => {
9573
9573
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9774,7 +9774,7 @@ const RootLayout = () => {
9774
9774
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9775
9775
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9776
9776
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9777
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((k, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9777
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((k, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9778
9778
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9779
9779
  position: "top",
9780
9780
  panelId: k.id,
@@ -9782,9 +9782,9 @@ const RootLayout = () => {
9782
9782
  show: () => w(k.id)
9783
9783
  }) }),
9784
9784
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9785
- ] }, "button-top-" + S)) }),
9785
+ ] }, "button-top-" + v)) }),
9786
9786
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9787
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((k, S) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9787
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((k, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9788
9788
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9789
9789
  position: "bottom",
9790
9790
  panelId: k.id,
@@ -9792,7 +9792,7 @@ const RootLayout = () => {
9792
9792
  show: () => w(k.id)
9793
9793
  }) }),
9794
9794
  /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9795
- ] }, "button-bottom-" + S)) })
9795
+ ] }, "button-bottom-" + v)) })
9796
9796
  ] }),
9797
9797
  /* @__PURE__ */ jsx(
9798
9798
  motion.div,
@@ -9961,8 +9961,8 @@ const RootLayout = () => {
9961
9961
  });
9962
9962
  }, m = (x) => {
9963
9963
  if (!c) return;
9964
- const y = x.clientX - p.x, b = x.clientY - p.y, A = x.currentTarget, _ = A.offsetWidth, B = A.offsetHeight, N = window.innerWidth - _, w = window.innerHeight - B, k = Math.max(0, Math.min(y, N)), S = Math.max(0, Math.min(b, w));
9965
- n(k, S);
9964
+ const y = x.clientX - p.x, b = x.clientY - p.y, A = x.currentTarget, _ = A.offsetWidth, B = A.offsetHeight, N = window.innerWidth - _, w = window.innerHeight - B, k = Math.max(0, Math.min(y, N)), v = Math.max(0, Math.min(b, w));
9965
+ n(k, v);
9966
9966
  }, f = () => {
9967
9967
  d(!1);
9968
9968
  };
@@ -10093,23 +10093,22 @@ const RootLayout = () => {
10093
10093
  if ("e" in o)
10094
10094
  throw o.e;
10095
10095
  return o.v;
10096
- }, PROMISE_STATE = Symbol(), getPromiseState = (o) => o[PROMISE_STATE], isPendingPromise = (o) => {
10096
+ }, promiseStateMap = /* @__PURE__ */ new WeakMap(), isPendingPromise = (o) => {
10097
10097
  var r;
10098
- return isPromiseLike$1(o) && !((r = getPromiseState(o)) != null && r[1]);
10099
- }, cancelPromise = (o, r) => {
10100
- const n = getPromiseState(o);
10101
- n && (n[1] = !0, n[0].forEach((a) => a(r)));
10102
- }, patchPromiseForCancelability = (o) => {
10103
- if (getPromiseState(o))
10104
- return;
10105
- const r = [/* @__PURE__ */ new Set(), !1];
10106
- o[PROMISE_STATE] = r;
10107
- const n = () => {
10108
- r[1] = !0;
10109
- };
10110
- o.then(n, n), o.onCancel = (a) => {
10111
- r[0].add(a);
10112
- };
10098
+ return isPromiseLike$1(o) && !!((r = promiseStateMap.get(o)) != null && r[0]);
10099
+ }, abortPromise = (o) => {
10100
+ const r = promiseStateMap.get(o);
10101
+ r != null && r[0] && (r[0] = !1, r[1].forEach((n) => n()));
10102
+ }, registerAbortHandler = (o, r) => {
10103
+ let n = promiseStateMap.get(o);
10104
+ if (!n) {
10105
+ n = [!0, /* @__PURE__ */ new Set()], promiseStateMap.set(o, n);
10106
+ const a = () => {
10107
+ n[0] = !1;
10108
+ };
10109
+ o.then(a, a);
10110
+ }
10111
+ n[1].add(r);
10113
10112
  }, isPromiseLike$1 = (o) => typeof (o == null ? void 0 : o.then) == "function", addPendingPromiseToDependency = (o, r, n) => {
10114
10113
  n.p.has(o) || (n.p.add(o), r.then(
10115
10114
  () => {
@@ -10120,13 +10119,11 @@ const RootLayout = () => {
10120
10119
  }
10121
10120
  ));
10122
10121
  }, setAtomStateValueOrPromise = (o, r, n) => {
10123
- const a = n(o), l = "v" in a, i = a.v, c = isPendingPromise(a.v) ? a.v : null;
10124
- if (isPromiseLike$1(r)) {
10125
- patchPromiseForCancelability(r);
10126
- for (const d of a.d.keys())
10127
- addPendingPromiseToDependency(o, r, n(d));
10128
- }
10129
- a.v = r, delete a.e, (!l || !Object.is(i, a.v)) && (++a.n, c && cancelPromise(c, r));
10122
+ const a = n(o), l = "v" in a, i = a.v;
10123
+ if (isPromiseLike$1(r))
10124
+ for (const c of a.d.keys())
10125
+ addPendingPromiseToDependency(o, r, n(c));
10126
+ a.v = r, delete a.e, (!l || !Object.is(i, a.v)) && (++a.n, isPromiseLike$1(i) && abortPromise(i));
10130
10127
  }, getMountedOrPendingDependents = (o, r, n) => {
10131
10128
  var a;
10132
10129
  const l = /* @__PURE__ */ new Set();
@@ -10142,186 +10139,185 @@ const RootLayout = () => {
10142
10139
  var x;
10143
10140
  return (x = m.onMount) == null ? void 0 : x.call(m, f);
10144
10141
  }, ...h) => {
10145
- const m = h[0] || ((S) => {
10146
- let E = o.get(S);
10147
- return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(S, E), u == null || u(S, k)), E;
10142
+ const m = h[0] || ((v) => {
10143
+ let E = o.get(v);
10144
+ return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, E), u == null || u(v, k)), E;
10148
10145
  }), f = h[1] || (() => {
10149
- let S, E;
10150
- const v = (C) => {
10146
+ const v = [], E = (S) => {
10151
10147
  try {
10152
- C();
10153
- } catch (j) {
10154
- S || (S = !0, E = j);
10148
+ S();
10149
+ } catch (C) {
10150
+ v.push(C);
10155
10151
  }
10156
10152
  };
10157
10153
  do {
10158
- c.f && v(c.f);
10159
- const C = /* @__PURE__ */ new Set(), j = C.add.bind(C);
10160
- a.forEach((I) => {
10161
- var L;
10162
- return (L = r.get(I)) == null ? void 0 : L.l.forEach(j);
10163
- }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), C.forEach(v), a.size && x();
10154
+ c.f && E(c.f);
10155
+ const S = /* @__PURE__ */ new Set(), C = S.add.bind(S);
10156
+ a.forEach((j) => {
10157
+ var I;
10158
+ return (I = r.get(j)) == null ? void 0 : I.l.forEach(C);
10159
+ }), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(E), a.size && x();
10164
10160
  } while (a.size || i.size || l.size);
10165
- if (S)
10166
- throw E;
10161
+ if (v.length)
10162
+ throw new AggregateError(v);
10167
10163
  }), x = h[2] || (() => {
10168
- const S = [], E = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
10164
+ const v = [], E = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
10169
10165
  for (; C.length; ) {
10170
10166
  const j = C[C.length - 1], I = m(j);
10171
- if (v.has(j)) {
10167
+ if (S.has(j)) {
10172
10168
  C.pop();
10173
10169
  continue;
10174
10170
  }
10175
10171
  if (E.has(j)) {
10176
- n.get(j) === I.n && S.push([j, I]), v.add(j), C.pop();
10172
+ n.get(j) === I.n && v.push([j, I]), S.add(j), C.pop();
10177
10173
  continue;
10178
10174
  }
10179
10175
  E.add(j);
10180
- for (const L of getMountedOrPendingDependents(j, I, r))
10181
- E.has(L) || C.push(L);
10176
+ for (const T of getMountedOrPendingDependents(j, I, r))
10177
+ E.has(T) || C.push(T);
10182
10178
  }
10183
- for (let j = S.length - 1; j >= 0; --j) {
10184
- const [I, L] = S[j];
10179
+ for (let j = v.length - 1; j >= 0; --j) {
10180
+ const [I, T] = v[j];
10185
10181
  let R = !1;
10186
- for (const T of L.d.keys())
10187
- if (T !== I && a.has(T)) {
10182
+ for (const L of T.d.keys())
10183
+ if (L !== I && a.has(L)) {
10188
10184
  R = !0;
10189
10185
  break;
10190
10186
  }
10191
10187
  R && (y(I), _(I)), n.delete(I);
10192
10188
  }
10193
- }), y = h[3] || ((S) => {
10194
- var E, v;
10195
- const C = m(S);
10196
- if (isAtomStateInitialized(C) && (r.has(S) && n.get(S) !== C.n || Array.from(C.d).every(
10197
- ([P, $]) => (
10189
+ }), y = h[3] || ((v) => {
10190
+ var E;
10191
+ const S = m(v);
10192
+ if (isAtomStateInitialized(S) && (r.has(v) && n.get(v) !== S.n || Array.from(S.d).every(
10193
+ ([P, M]) => (
10198
10194
  // Recursively, read the atom state of the dependency, and
10199
10195
  // check if the atom epoch number is unchanged
10200
- y(P).n === $
10196
+ y(P).n === M
10201
10197
  )
10202
10198
  )))
10203
- return C;
10204
- C.d.clear();
10205
- let j = !0;
10206
- const I = () => {
10207
- r.has(S) && (_(S), x(), f());
10208
- }, L = (P) => {
10209
- var $;
10210
- if (isSelfAtom(S, P)) {
10211
- const H = m(P);
10212
- if (!isAtomStateInitialized(H))
10199
+ return S;
10200
+ S.d.clear();
10201
+ let C = !0;
10202
+ const j = () => {
10203
+ r.has(v) && (_(v), x(), f());
10204
+ }, I = (P) => {
10205
+ var M;
10206
+ if (isSelfAtom(v, P)) {
10207
+ const O = m(P);
10208
+ if (!isAtomStateInitialized(O))
10213
10209
  if (hasInitialValue(P))
10214
10210
  setAtomStateValueOrPromise(P, P.init, m);
10215
10211
  else
10216
10212
  throw new Error("no atom init");
10217
- return returnAtomValue(H);
10213
+ return returnAtomValue(O);
10218
10214
  }
10219
- const M = y(P);
10215
+ const $ = y(P);
10220
10216
  try {
10221
- return returnAtomValue(M);
10217
+ return returnAtomValue($);
10222
10218
  } finally {
10223
- C.d.set(P, M.n), isPendingPromise(C.v) && addPendingPromiseToDependency(S, C.v, M), ($ = r.get(P)) == null || $.t.add(S), j || I();
10219
+ S.d.set(P, $.n), isPendingPromise(S.v) && addPendingPromiseToDependency(v, S.v, $), (M = r.get(P)) == null || M.t.add(v), C || j();
10224
10220
  }
10225
10221
  };
10226
- let R, T;
10227
- const D = {
10222
+ let T, R;
10223
+ const L = {
10228
10224
  get signal() {
10229
- return R || (R = new AbortController()), R.signal;
10225
+ return T || (T = new AbortController()), T.signal;
10230
10226
  },
10231
10227
  get setSelf() {
10232
- return !T && isActuallyWritableAtom(S) && (T = (...P) => {
10233
- if (!j)
10228
+ return !R && isActuallyWritableAtom(v) && (R = (...P) => {
10229
+ if (!C)
10234
10230
  try {
10235
- return A(S, ...P);
10231
+ return A(v, ...P);
10236
10232
  } finally {
10237
10233
  x(), f();
10238
10234
  }
10239
- }), T;
10235
+ }), R;
10240
10236
  }
10241
- }, O = C.n;
10237
+ }, D = S.n;
10242
10238
  try {
10243
- const P = d(S, L, D);
10244
- return setAtomStateValueOrPromise(S, P, m), isPromiseLike$1(P) && ((E = P.onCancel) == null || E.call(P, () => R == null ? void 0 : R.abort()), P.then(
10245
- I,
10246
- I
10247
- )), C;
10239
+ const P = d(v, I, L);
10240
+ return setAtomStateValueOrPromise(v, P, m), isPromiseLike$1(P) && (registerAbortHandler(P, () => T == null ? void 0 : T.abort()), P.then(
10241
+ j,
10242
+ j
10243
+ )), S;
10248
10244
  } catch (P) {
10249
- return delete C.v, C.e = P, ++C.n, C;
10245
+ return delete S.v, S.e = P, ++S.n, S;
10250
10246
  } finally {
10251
- j = !1, O !== C.n && n.get(S) === O && (n.set(S, C.n), a.add(S), (v = c.c) == null || v.call(c, S));
10247
+ C = !1, D !== S.n && n.get(v) === D && (n.set(v, S.n), a.add(v), (E = c.c) == null || E.call(c, v));
10252
10248
  }
10253
- }), b = h[4] || ((S) => {
10254
- const E = [S];
10249
+ }), b = h[4] || ((v) => {
10250
+ const E = [v];
10255
10251
  for (; E.length; ) {
10256
- const v = E.pop(), C = m(v);
10257
- for (const j of getMountedOrPendingDependents(v, C, r)) {
10252
+ const S = E.pop(), C = m(S);
10253
+ for (const j of getMountedOrPendingDependents(S, C, r)) {
10258
10254
  const I = m(j);
10259
10255
  n.set(j, I.n), E.push(j);
10260
10256
  }
10261
10257
  }
10262
- }), A = h[5] || ((S, ...E) => {
10263
- let v = !0;
10264
- const C = (I) => returnAtomValue(y(I)), j = (I, ...L) => {
10258
+ }), A = h[5] || ((v, ...E) => {
10259
+ let S = !0;
10260
+ const C = (I) => returnAtomValue(y(I)), j = (I, ...T) => {
10265
10261
  var R;
10266
- const T = m(I);
10262
+ const L = m(I);
10267
10263
  try {
10268
- if (isSelfAtom(S, I)) {
10264
+ if (isSelfAtom(v, I)) {
10269
10265
  if (!hasInitialValue(I))
10270
10266
  throw new Error("atom not writable");
10271
- const D = T.n, O = L[0];
10272
- setAtomStateValueOrPromise(I, O, m), _(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
10267
+ const D = L.n, P = T[0];
10268
+ setAtomStateValueOrPromise(I, P, m), _(I), D !== L.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
10273
10269
  return;
10274
10270
  } else
10275
- return A(I, ...L);
10271
+ return A(I, ...T);
10276
10272
  } finally {
10277
- v || (x(), f());
10273
+ S || (x(), f());
10278
10274
  }
10279
10275
  };
10280
10276
  try {
10281
- return p(S, C, j, ...E);
10277
+ return p(v, C, j, ...E);
10282
10278
  } finally {
10283
- v = !1;
10279
+ S = !1;
10284
10280
  }
10285
- }), _ = h[6] || ((S) => {
10281
+ }), _ = h[6] || ((v) => {
10286
10282
  var E;
10287
- const v = m(S), C = r.get(S);
10288
- if (C && !isPendingPromise(v.v)) {
10289
- for (const [j, I] of v.d)
10283
+ const S = m(v), C = r.get(v);
10284
+ if (C && !isPendingPromise(S.v)) {
10285
+ for (const [j, I] of S.d)
10290
10286
  if (!C.d.has(j)) {
10291
- const L = m(j);
10292
- B(j).t.add(S), C.d.add(j), I !== L.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
10287
+ const T = m(j);
10288
+ B(j).t.add(v), C.d.add(j), I !== T.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
10293
10289
  }
10294
10290
  for (const j of C.d || [])
10295
- if (!v.d.has(j)) {
10291
+ if (!S.d.has(j)) {
10296
10292
  C.d.delete(j);
10297
10293
  const I = N(j);
10298
- I == null || I.t.delete(S);
10294
+ I == null || I.t.delete(v);
10299
10295
  }
10300
10296
  }
10301
- }), B = h[7] || ((S) => {
10297
+ }), B = h[7] || ((v) => {
10302
10298
  var E;
10303
- const v = m(S);
10304
- let C = r.get(S);
10299
+ const S = m(v);
10300
+ let C = r.get(v);
10305
10301
  if (!C) {
10306
- y(S);
10307
- for (const j of v.d.keys())
10308
- B(j).t.add(S);
10302
+ y(v);
10303
+ for (const j of S.d.keys())
10304
+ B(j).t.add(v);
10309
10305
  if (C = {
10310
10306
  l: /* @__PURE__ */ new Set(),
10311
- d: new Set(v.d.keys()),
10307
+ d: new Set(S.d.keys()),
10312
10308
  t: /* @__PURE__ */ new Set()
10313
- }, r.set(S, C), (E = c.m) == null || E.call(c, S), isActuallyWritableAtom(S)) {
10309
+ }, r.set(v, C), (E = c.m) == null || E.call(c, v), isActuallyWritableAtom(v)) {
10314
10310
  const j = () => {
10315
10311
  let I = !0;
10316
- const L = (...R) => {
10312
+ const T = (...R) => {
10317
10313
  try {
10318
- return A(S, ...R);
10314
+ return A(v, ...R);
10319
10315
  } finally {
10320
10316
  I || (x(), f());
10321
10317
  }
10322
10318
  };
10323
10319
  try {
10324
- const R = g(S, L);
10320
+ const R = g(v, T);
10325
10321
  R && (C.u = () => {
10326
10322
  I = !0;
10327
10323
  try {
@@ -10338,18 +10334,18 @@ const RootLayout = () => {
10338
10334
  }
10339
10335
  }
10340
10336
  return C;
10341
- }), N = h[8] || ((S) => {
10337
+ }), N = h[8] || ((v) => {
10342
10338
  var E;
10343
- const v = m(S);
10344
- let C = r.get(S);
10339
+ const S = m(v);
10340
+ let C = r.get(v);
10345
10341
  if (C && !C.l.size && !Array.from(C.t).some((j) => {
10346
10342
  var I;
10347
- return (I = r.get(j)) == null ? void 0 : I.d.has(S);
10343
+ return (I = r.get(j)) == null ? void 0 : I.d.has(v);
10348
10344
  })) {
10349
- C.u && i.add(C.u), C = void 0, r.delete(S), (E = c.u) == null || E.call(c, S);
10350
- for (const j of v.d.keys()) {
10345
+ C.u && i.add(C.u), C = void 0, r.delete(v), (E = c.u) == null || E.call(c, v);
10346
+ for (const j of S.d.keys()) {
10351
10347
  const I = N(j);
10352
- I == null || I.t.delete(S);
10348
+ I == null || I.t.delete(v);
10353
10349
  }
10354
10350
  return;
10355
10351
  }
@@ -10363,7 +10359,7 @@ const RootLayout = () => {
10363
10359
  l,
10364
10360
  i,
10365
10361
  c,
10366
- // atom intercepters
10362
+ // atom interceptors
10367
10363
  d,
10368
10364
  p,
10369
10365
  u,
@@ -10379,77 +10375,103 @@ const RootLayout = () => {
10379
10375
  B,
10380
10376
  N
10381
10377
  ], k = {
10382
- get: (S) => returnAtomValue(y(S)),
10383
- set: (S, ...E) => {
10378
+ get: (v) => returnAtomValue(y(v)),
10379
+ set: (v, ...E) => {
10384
10380
  try {
10385
- return A(S, ...E);
10381
+ return A(v, ...E);
10386
10382
  } finally {
10387
10383
  x(), f();
10388
10384
  }
10389
10385
  },
10390
- sub: (S, E) => {
10391
- const C = B(S).l;
10386
+ sub: (v, E) => {
10387
+ const C = B(v).l;
10392
10388
  return C.add(E), f(), () => {
10393
- C.delete(E), N(S), f();
10389
+ C.delete(E), N(v), f();
10394
10390
  };
10395
10391
  }
10396
10392
  };
10397
10393
  return Object.defineProperty(k, BUILDING_BLOCKS, { value: w }), k;
10398
- }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
10394
+ }, INTERNAL_buildStoreRev1 = buildStore, INTERNAL_registerAbortHandler = registerAbortHandler;
10395
+ function createStore() {
10396
+ return INTERNAL_buildStoreRev1();
10397
+ }
10399
10398
  let defaultStore;
10400
- const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
10399
+ function getDefaultStore() {
10400
+ return defaultStore || (defaultStore = createStore()), defaultStore;
10401
+ }
10402
+ const StoreContext = createContext(
10401
10403
  void 0
10402
- ), useStore = (o) => useContext(StoreContext) || getDefaultStore(), isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function", attachPromiseMeta = (o) => {
10403
- o.status = "pending", o.then(
10404
+ );
10405
+ function useStore(o) {
10406
+ return useContext(StoreContext) || getDefaultStore();
10407
+ }
10408
+ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function", attachPromiseStatus = (o) => {
10409
+ o.status || (o.status = "pending", o.then(
10404
10410
  (r) => {
10405
10411
  o.status = "fulfilled", o.value = r;
10406
10412
  },
10407
10413
  (r) => {
10408
10414
  o.status = "rejected", o.reason = r;
10409
10415
  }
10410
- );
10411
- }, use = React__default.use || ((o) => {
10416
+ ));
10417
+ }, use = React__default.use || // A shim for older React versions
10418
+ ((o) => {
10412
10419
  if (o.status === "pending")
10413
10420
  throw o;
10414
10421
  if (o.status === "fulfilled")
10415
10422
  return o.value;
10416
- throw o.status === "rejected" ? o.reason : (attachPromiseMeta(o), o);
10417
- }), continuablePromiseMap = /* @__PURE__ */ new WeakMap(), createContinuablePromise = (o) => {
10418
- let r = continuablePromiseMap.get(o);
10419
- return r || (r = new Promise((n, a) => {
10420
- let l = o;
10421
- const i = (p) => (u) => {
10422
- l === p && n(u);
10423
- }, c = (p) => (u) => {
10424
- l === p && a(u);
10425
- }, d = (p) => {
10426
- "onCancel" in p && typeof p.onCancel == "function" && p.onCancel((u) => {
10427
- isPromiseLike(u) ? (continuablePromiseMap.set(u, r), l = u, u.then(i(u), c(u)), d(u)) : n(u);
10428
- });
10423
+ throw o.status === "rejected" ? o.reason : (attachPromiseStatus(o), o);
10424
+ }), continuablePromiseMap = /* @__PURE__ */ new WeakMap(), createContinuablePromise = (o, r) => {
10425
+ let n = continuablePromiseMap.get(o);
10426
+ return n || (n = new Promise((a, l) => {
10427
+ let i = o;
10428
+ const c = (u) => (g) => {
10429
+ i === u && a(g);
10430
+ }, d = (u) => (g) => {
10431
+ i === u && l(g);
10432
+ }, p = () => {
10433
+ try {
10434
+ const u = r();
10435
+ isPromiseLike(u) ? (continuablePromiseMap.set(u, n), i = u, u.then(c(u), d(u)), INTERNAL_registerAbortHandler(u, p)) : a(u);
10436
+ } catch (u) {
10437
+ l(u);
10438
+ }
10429
10439
  };
10430
- o.then(i(o), c(o)), d(o);
10431
- }), continuablePromiseMap.set(o, r)), r;
10440
+ o.then(c(o), d(o)), INTERNAL_registerAbortHandler(o, p);
10441
+ }), continuablePromiseMap.set(o, n)), n;
10432
10442
  };
10433
10443
  function useAtomValue(o, r) {
10434
- const n = useStore(), [[a, l, i], c] = useReducer(
10435
- (u) => {
10436
- const g = n.get(o);
10437
- return Object.is(u[0], g) && u[1] === n && u[2] === o ? u : [g, n, o];
10444
+ const { delay: n, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
10445
+ (g) => {
10446
+ const h = l.get(o);
10447
+ return Object.is(g[0], h) && g[1] === l && g[2] === o ? g : [h, l, o];
10438
10448
  },
10439
10449
  void 0,
10440
- () => [n.get(o), n, o]
10450
+ () => [l.get(o), l, o]
10441
10451
  );
10442
- let d = a;
10443
- if ((l !== n || i !== o) && (c(), d = n.get(o)), useEffect(() => {
10444
- const u = n.sub(o, () => {
10445
- c();
10452
+ let u = i;
10453
+ if ((c !== l || d !== o) && (p(), u = l.get(o)), useEffect(() => {
10454
+ const g = l.sub(o, () => {
10455
+ if (a)
10456
+ try {
10457
+ const h = l.get(o);
10458
+ isPromiseLike(h) && attachPromiseStatus(
10459
+ createContinuablePromise(h, () => l.get(o))
10460
+ );
10461
+ } catch {
10462
+ }
10463
+ if (typeof n == "number") {
10464
+ setTimeout(p, n);
10465
+ return;
10466
+ }
10467
+ p();
10446
10468
  });
10447
- return c(), u;
10448
- }, [n, o, void 0]), useDebugValue(d), isPromiseLike(d)) {
10449
- const u = createContinuablePromise(d);
10450
- return use(u);
10469
+ return p(), g;
10470
+ }, [l, o, n, a]), useDebugValue(u), isPromiseLike(u)) {
10471
+ const g = createContinuablePromise(u, () => l.get(o));
10472
+ return a && attachPromiseStatus(g), use(g);
10451
10473
  }
10452
- return d;
10474
+ return u;
10453
10475
  }
10454
10476
  function useSetAtom(o, r) {
10455
10477
  const n = useStore();
@@ -10606,7 +10628,7 @@ export {
10606
10628
  useTheme,
10607
10629
  useThemeOptions,
10608
10630
  useToggleChaiFeatureFlag,
10609
- Ue as useTranslation,
10631
+ Ve as useTranslation,
10610
10632
  useUndoManager,
10611
10633
  useUpdateBlocksProps,
10612
10634
  useUpdateBlocksPropsRealtime,