@chaibuilder/sdk 3.2.4 → 3.2.6

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.
@@ -1,14 +1,14 @@
1
1
  import { g as ct, c as P } from "./common-functions-D2lMFR6K.js";
2
- import { isEmpty as x, flatten as pt, flatMapDeep as ut, get as d, set as E, startsWith as k, find as m, startCase as dt, forEach as N, camelCase as ht, includes as w, has as A, filter as Q, some as yt, unset as H, map as st, compact as mt, trim as gt, capitalize as bt, memoize as xt, cloneDeep as M, keys as W, isString as $, isArray as I, each as ft, last as _t } from "lodash-es";
2
+ import { isEmpty as x, flatten as pt, flatMapDeep as ut, get as y, set as w, startsWith as k, find as m, startCase as dt, forEach as N, camelCase as yt, includes as T, has as A, filter as Q, some as ht, unset as H, map as st, compact as mt, trim as gt, capitalize as bt, memoize as xt, cloneDeep as M, keys as R, isString as $, isArray as I, each as ft, last as _t } from "lodash-es";
3
3
  import { parse as kt, stringify as D } from "himalaya";
4
4
  import { getRegisteredChaiBlock as vt } from "@chaibuilder/runtime";
5
5
  import { twMerge as wt } from "tailwind-merge";
6
- const f = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", Tt = "#", tt = "dt#", nt = (e) => {
6
+ const f = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", Tt = "#", tt = "dt#", at = (e) => {
7
7
  if (e = e.replace(f, ""), !e) return { baseClasses: "", classes: "" };
8
- const a = e.split(/,(?![^\[]*\])/);
9
- if (a.length === 1)
10
- return { baseClasses: "", classes: a[0].trim() };
11
- const [t, ...s] = a;
8
+ const n = e.split(/,(?![^\[]*\])/);
9
+ if (n.length === 1)
10
+ return { baseClasses: "", classes: n[0].trim() };
11
+ const [t, ...s] = n;
12
12
  return {
13
13
  baseClasses: t.trim(),
14
14
  classes: s.join(",").trim().replace(/ +(?= )/g, "")
@@ -40,20 +40,20 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
40
40
  classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
41
41
  }
42
42
  };
43
- for (let a in e) {
44
- const t = nt(`${f}${a}`);
45
- expect(t).toEqual(e[a]);
43
+ for (let n in e) {
44
+ const t = at(`${f}${n}`);
45
+ expect(t).toEqual(e[n]);
46
46
  }
47
47
  });
48
48
  });
49
49
  const Bt = (e) => {
50
- const a = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
51
- return a.test(e) || t.test(e);
50
+ const n = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
51
+ return n.test(e) || t.test(e);
52
52
  }, Et = (e) => {
53
53
  if (x(e)) return e;
54
- const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), o = s ? s[1] : n ? n[1] : null, l = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, i = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
55
- return o && (l.test(o) || i.test(o)) ? o : e;
56
- }, at = ["chai-name", "data-chai-name"], $t = {
54
+ const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(n), a = e.match(t), o = s ? s[1] : a ? a[1] : null, i = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
55
+ return o && (i.test(o) || l.test(o)) ? o : e;
56
+ }, nt = ["chai-name", "data-chai-name"], $t = {
57
57
  img: { alt: "alt", width: "width", height: "height", src: "image" },
58
58
  video: {
59
59
  src: "url",
@@ -89,58 +89,62 @@ const Bt = (e) => {
89
89
  form: {
90
90
  action: "action"
91
91
  }
92
- }, Nt = (e, a) => e.children.length === 1 && w(
92
+ }, Nt = (e, n) => e.children.length === 1 && T(
93
93
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
94
- a._type
95
- ), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : x(a.children) ? "" : j(a.children)).join(""), R = (e) => e === null ? "" : e, ot = (e) => {
96
- const a = mt(st(e.split(/\s+/), gt)), t = m(a, (i) => /^w-/.test(i)), s = m(a, (i) => /^h-/.test(i));
94
+ n._type
95
+ ), j = (e) => e.map((n) => n.type === "text" ? y(n, "content", "") : x(n.children) ? "" : j(n.children)).join(""), W = (e) => e === null ? "" : e, ot = (e) => {
96
+ const n = mt(st(e.split(/\s+/), gt)), t = m(n, (l) => /^w-/.test(l)), s = m(n, (l) => /^h-/.test(l));
97
97
  if (!s || !t) return { height: "", width: "" };
98
- const n = (i) => {
99
- if (!i) return;
100
- const h = i.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
101
- if (!h) return;
102
- if (h[1]) return h[1];
103
- const r = h[2];
104
- return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" || w(r, "%") ? r : "16px";
105
- }, o = n(t), l = n(s);
98
+ const a = (l) => {
99
+ if (!l) return;
100
+ const u = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
101
+ if (!u) return;
102
+ if (u[1]) return u[1];
103
+ const r = u[2];
104
+ return /^\d+(\.\d+)?$/.test(r) ? `${Number(r) * 4}px` : r === "auto" || T(r, "%") ? r : "16px";
105
+ }, o = a(t), i = a(s);
106
106
  return {
107
- width: w(o, "px") ? o : "16px",
108
- height: w(l, "px") ? l : "16px"
107
+ width: T(o, "px") ? o : "16px",
108
+ height: T(i, "px") ? i : "16px"
109
109
  };
110
110
  }, et = (e) => {
111
111
  if (e.tagName === "svg") return {};
112
- const a = {}, t = $t[e.tagName] || {}, s = e.attributes;
113
- return N(s, ({ key: n, value: o }) => {
114
- if (!w(at, n))
115
- if (n === "bid" && (a._bid = R(o)), t[n]) {
116
- if (e.tagName === "img" && n === "src" && !o.startsWith("http")) {
117
- const l = m(e.attributes, { key: "width" }), i = m(e.attributes, { key: "height" });
118
- l && i ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${i == null ? void 0 : i.value}` : o = "https://picsum.photos/150x150";
112
+ const n = {}, t = $t[e.tagName] || {}, s = e.attributes;
113
+ return N(s, ({ key: a, value: o }) => {
114
+ var i;
115
+ if (!T(nt, a))
116
+ if (a === "bid" && (n._bid = W(o)), t[a]) {
117
+ if (e.tagName === "img" && a === "src" && !o.startsWith("http")) {
118
+ const l = m(e.attributes, { key: "width" }), u = m(e.attributes, { key: "height" });
119
+ l && u ? o = `https://picsum.photos/${l == null ? void 0 : l.value}x${u == null ? void 0 : u.value}` : o = "https://picsum.photos/150x150";
120
+ } else if (e.tagName === "a") {
121
+ const l = m(e.attributes, { key: "href" });
122
+ l && typeof (l == null ? void 0 : l.value) == "string" && ((i = l == null ? void 0 : l.value) != null && i.startsWith("pageType:")) && w(n, "link.type", "pageType");
119
123
  }
120
- E(a, t[n], R(o));
121
- } else w(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), k(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = R(o));
122
- }), delete a.class, a;
123
- }, St = (e, a = "styles") => {
124
- if (!e.attributes) return { [a]: `${f},` };
124
+ w(n, t[a], W(o));
125
+ } else T(["style", "class", "srcset", "bid"], a) || (A(n, "styles_attrs") || (n.styles_attrs = {}), k(a, "@") && (a = a.replace("@", "x-on:")), n.styles_attrs[`${a}`] = W(o));
126
+ }), delete n.class, n;
127
+ }, St = (e, n = "styles") => {
128
+ if (!e.attributes) return { [n]: `${f},` };
125
129
  const t = m(e.attributes, { key: "class" });
126
130
  if (t) {
127
131
  const s = t.value;
128
- return { [a]: `${f},${s}` };
132
+ return { [n]: `${f},${s}` };
129
133
  }
130
- return { [a]: `${f},` };
134
+ return { [n]: `${f},` };
131
135
  }, It = (e) => {
132
- const a = d(e, "attributes", []), t = a.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), s = a.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), n = a.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = a.find(
136
+ const n = y(e, "attributes", []), t = n.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), s = n.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), a = n.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = n.find(
133
137
  (r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
134
- ), l = a.find(
138
+ ), i = n.find(
135
139
  (r) => r.key === "data-chai-dropdown-content" || r.key === "chai-dropdown-content"
136
- ), i = a.find((r) => r.key === "class"), h = i && i.value.split(/\s+/).includes("rte");
137
- if (n)
140
+ ), l = n.find((r) => r.key === "class"), u = l && l.value.split(/\s+/).includes("rte");
141
+ if (a)
138
142
  return { _type: "Dropdown" };
139
143
  if (o)
140
144
  return { _type: "DropdownButton" };
141
- if (l)
145
+ if (i)
142
146
  return { _type: "DropdownContent" };
143
- if (t || h)
147
+ if (t || u)
144
148
  return { _type: "Paragraph" };
145
149
  if (s)
146
150
  return { _type: "LightBoxLink" };
@@ -222,7 +226,7 @@ const Bt = (e) => {
222
226
  case "tfoot":
223
227
  return { _type: "TableFooter" };
224
228
  default: {
225
- const r = d(e, "children", []).length > 0 ? "Box" : "EmptyBox";
229
+ const r = y(e, "children", []).length > 0 ? "Box" : "EmptyBox";
226
230
  return {
227
231
  _type: r,
228
232
  tag: e.tagName,
@@ -230,34 +234,34 @@ const Bt = (e) => {
230
234
  };
231
235
  }
232
236
  }
233
- }, q = (e, a = null) => ut(e, (t) => {
237
+ }, q = (e, n = null) => ut(e, (t) => {
234
238
  var O, V, J, z, F, U, Y, K, X, Z;
235
239
  if (t.type === "comment") return [];
236
240
  let s = { _id: ct() };
237
- if (a && (s._parent = a.block._id), t.type === "text")
238
- return x(d(t, "content", "")) ? [] : a && Nt(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
241
+ if (n && (s._parent = n.block._id), t.type === "text")
242
+ return x(y(t, "content", "")) ? [] : n && Nt(n.node, n.block) ? (w(n, "block.content", y(t, "content", "")), []) : { ...s, _type: "Text", content: y(t, "content", "") };
239
243
  if (k(t.tagName, "chai-")) {
240
- const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || dt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
241
- s._type = u, N(c, ({ key: g, value: G }) => {
244
+ const c = t.attributes, p = m(c, { key: "chai-type" }), d = (p == null ? void 0 : p.value) || dt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
245
+ s._type = d, N(c, ({ key: g, value: G }) => {
242
246
  if (g === "about-this-component" || g === "chai-type" || g === "can-move" || g === "can-delete") return;
243
247
  if (g === "id") {
244
248
  s._id = G;
245
249
  return;
246
250
  }
247
- const rt = k(g, "_") ? g : ht(g);
248
- let S = R(G);
251
+ const rt = k(g, "_") ? g : yt(g);
252
+ let S = W(G);
249
253
  typeof S == "string" && k(S, "#styles:") && (S = S.replace("#styles:", "#styles:,")), s[rt] = S;
250
254
  });
251
- const y = q(t.children, { block: s, node: t });
252
- return [s, ...y];
255
+ const h = q(t.children, { block: s, node: t });
256
+ return [s, ...h];
253
257
  }
254
- const n = d(t, "attributes", []), o = t.tagName === "p" || n.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), l = n.find((c) => c.key === "class"), i = l && l.value.split(/\s+/).includes("rte"), h = n.find(
258
+ const a = y(t, "attributes", []), o = t.tagName === "p" || a.find((c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"), i = a.find((c) => c.key === "class"), l = i && i.value.split(/\s+/).includes("rte"), u = a.find(
255
259
  (c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
256
- ), r = n.find(
260
+ ), r = a.find(
257
261
  (c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
258
- ), T = n.find(
262
+ ), B = a.find(
259
263
  (c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
260
- ), C = n.find(
264
+ ), C = a.find(
261
265
  (c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
262
266
  );
263
267
  if (s = {
@@ -266,12 +270,12 @@ const Bt = (e) => {
266
270
  ...et(t),
267
271
  ...St(t)
268
272
  }, t.attributes) {
269
- const c = t.attributes.find((p) => w(at, p.key));
273
+ const c = t.attributes.find((p) => T(nt, p.key));
270
274
  c && (s._name = c.value);
271
275
  }
272
- if (o || i)
276
+ if (o || l)
273
277
  return s.content = `<p>${D(t.children || [])}</p>`, A(s, "styles_attrs.data-chai-richtext") && delete s.styles_attrs["data-chai-richtext"], A(s, "styles_attrs.chai-richtext") && delete s.styles_attrs["chai-richtext"], [s];
274
- if (h) {
278
+ if (u) {
275
279
  const c = [
276
280
  "data-chai-lightbox",
277
281
  "chai-lightbox",
@@ -284,153 +288,153 @@ const Bt = (e) => {
284
288
  ];
285
289
  s = {
286
290
  ...s,
287
- href: ((O = n.find((p) => p.key === "href")) == null ? void 0 : O.value) || "",
288
- hrefType: ((V = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : V.value) || "video",
289
- autoplay: ((J = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : J.value) === "true" ? "true" : "false",
290
- maxWidth: ((F = (z = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : F.replace("px", "")) || "",
291
- backdropColor: ((U = n.find((p) => p.key === "data-overlay")) == null ? void 0 : U.value) || "",
292
- galleryName: ((Y = n.find((p) => p.key === "data-gall")) == null ? void 0 : Y.value) || ""
291
+ href: ((O = a.find((p) => p.key === "href")) == null ? void 0 : O.value) || "",
292
+ hrefType: ((V = a.find((p) => p.key === "data-vbtype")) == null ? void 0 : V.value) || "video",
293
+ autoplay: ((J = a.find((p) => p.key === "data-autoplay")) == null ? void 0 : J.value) === "true" ? "true" : "false",
294
+ maxWidth: ((F = (z = a.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : F.replace("px", "")) || "",
295
+ backdropColor: ((U = a.find((p) => p.key === "data-overlay")) == null ? void 0 : U.value) || "",
296
+ galleryName: ((Y = a.find((p) => p.key === "data-gall")) == null ? void 0 : Y.value) || ""
293
297
  }, N(c, (p) => {
294
298
  A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
295
299
  });
296
300
  }
297
- if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs, T) {
301
+ if (r && (delete s.styles_attrs, s.showDropdown = !1), C && delete s.styles_attrs, B) {
298
302
  delete s.styles_attrs;
299
- const c = Q(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
303
+ const c = Q(t.children || [], (d) => (d == null ? void 0 : d.tagName) !== "span");
300
304
  s.content = j(c);
301
305
  const p = m(
302
306
  t.children || [],
303
- (u) => (u == null ? void 0 : u.tagName) === "span" && yt(u.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg")
307
+ (d) => (d == null ? void 0 : d.tagName) === "span" && ht(d.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
304
308
  );
305
309
  if (p) {
306
- const u = m(p.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg");
307
- if (u) {
308
- s.icon = D([u]);
309
- const { height: y, width: g } = Ct(u, "16px", "16px");
310
- s.iconHeight = y, s.iconWidth = g;
310
+ const d = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
311
+ if (d) {
312
+ s.icon = D([d]);
313
+ const { height: h, width: g } = Ct(d, "16px", "16px");
314
+ s.iconHeight = h, s.iconWidth = g;
311
315
  }
312
316
  }
313
317
  return [s];
314
318
  }
315
319
  if (s._type === "Input") {
316
320
  const c = s.inputType || "text";
317
- c === "checkbox" ? E(s, "_type", "Checkbox") : c === "radio" && E(s, "_type", "Radio");
321
+ c === "checkbox" ? w(s, "_type", "Checkbox") : c === "radio" && w(s, "_type", "Radio");
318
322
  } else if (t.tagName === "video" || t.tagName === "iframe") {
319
323
  const c = D([t]);
320
- return Bt(c) && (E(s, "_type", "Video"), E(s, "url", Et(c)), E(s, "styles", `${f},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
324
+ return Bt(c) && (w(s, "_type", "Video"), w(s, "url", Et(c)), w(s, "styles", `${f},`), w(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
321
325
  } else if (t.tagName === "svg") {
322
- const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = ot(c);
323
- if (p && u)
324
- s.styles = `${f}, ${P(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
326
+ const c = y(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: d } = ot(c);
327
+ if (p && d)
328
+ s.styles = `${f}, ${P(`w-${d} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = d == null ? void 0 : d.replace("px", "");
325
329
  else {
326
- const y = (K = m(t.attributes, { key: "height" })) == null ? void 0 : K.value, g = (X = m(t.attributes, { key: "width" })) == null ? void 0 : X.value;
327
- y && g ? (s.styles = `${f}, ${P(`w-[${g}px] h-[${y}px]`, c)}`.trim(), s.height = y, s.width = g) : s.styles = `${f}, ${P("w-full h-full", c)}`.trim();
330
+ const h = (K = m(t.attributes, { key: "height" })) == null ? void 0 : K.value, g = (X = m(t.attributes, { key: "width" })) == null ? void 0 : X.value;
331
+ h && g ? (s.styles = `${f}, ${P(`w-[${g}px] h-[${h}px]`, c)}`.trim(), s.height = h, s.width = g) : s.styles = `${f}, ${P("w-full h-full", c)}`.trim();
328
332
  }
329
- return t.attributes = Q(t.attributes, (y) => !w(["style", "width", "height", "class"], y.key)), s.icon = D([t]), [s];
330
- } else if (t.tagName == "option" && a && ((Z = a.block) == null ? void 0 : Z._type) === "Select")
331
- return a.block.options.push({
333
+ return t.attributes = Q(t.attributes, (h) => !T(["style", "width", "height", "class"], h.key)), s.icon = D([t]), [s];
334
+ } else if (t.tagName == "option" && n && ((Z = n.block) == null ? void 0 : Z._type) === "Select")
335
+ return n.block.options.push({
332
336
  label: j(t.children),
333
337
  ...et(t)
334
338
  }), [];
335
- const B = q(t.children, { block: s, node: t });
336
- return [s, ...B];
337
- }), Ct = (e, a, t) => {
338
- var h, r;
339
- const s = d(e, "attributes", []), { height: n, width: o } = ot(
340
- d(m(s, { key: "class" }), "value", "")
339
+ const E = q(t.children, { block: s, node: t });
340
+ return [s, ...E];
341
+ }), Ct = (e, n, t) => {
342
+ var u, r;
343
+ const s = y(e, "attributes", []), { height: a, width: o } = ot(
344
+ y(m(s, { key: "class" }), "value", "")
341
345
  );
342
- if (n && o)
346
+ if (a && o)
343
347
  return {
344
- height: `[${n}px]`,
348
+ height: `[${a}px]`,
345
349
  width: `[${o}px]`
346
350
  };
347
- const l = (h = m(s, { key: "height" })) == null ? void 0 : h.value, i = (r = m(s, { key: "width" })) == null ? void 0 : r.value;
351
+ const i = (u = m(s, { key: "height" })) == null ? void 0 : u.value, l = (r = m(s, { key: "width" })) == null ? void 0 : r.value;
348
352
  return {
349
- height: l ? `[${l}px]` : t,
350
- width: i ? `[${i}px]` : a
353
+ height: i ? `[${i}px]` : t,
354
+ width: l ? `[${l}px]` : n
351
355
  };
352
356
  }, Dt = (e) => {
353
- e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, o) => {
354
- let l = o.replace(/\\"/g, '"');
355
- return l = l.replace(/{([^}]+)}/g, (i) => i.replace(/"/g, '\\"')), `${n}="${l.replace(/\\"/g, '"')}"`;
357
+ e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, a, o) => {
358
+ let i = o.replace(/\\"/g, '"');
359
+ return i = i.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${a}="${i.replace(/\\"/g, '"')}"`;
356
360
  }), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
357
- const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
358
- return (a && a.length > 0 ? a[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
359
- }, Lt = (e, a) => m(e, { _id: a }), Ot = (e, a) => x(a) ? e.map((t) => (H(t, "_bid"), t)) : st(e, (t) => {
360
- const s = x(t._bid) ? void 0 : Lt(a, t._bid);
361
+ const n = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
362
+ return (n && n.length > 0 ? n[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
363
+ }, Lt = (e, n) => m(e, { _id: n }), Ot = (e, n) => x(n) ? e.map((t) => (H(t, "_bid"), t)) : st(e, (t) => {
364
+ const s = x(t._bid) ? void 0 : Lt(n, t._bid);
361
365
  if (s) {
362
- s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
363
- const n = { ...s, ...t };
364
- return H(n, "_bid"), n;
366
+ s._type === "Icon" && y(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
367
+ const a = { ...s, ...t };
368
+ return H(a, "_bid"), a;
365
369
  }
366
370
  return H(t, "_bid"), t;
367
371
  }), Vt = (e) => {
368
- const a = kt(Dt(e));
369
- return x(e) ? [] : pt(q(a));
372
+ const n = kt(Dt(e));
373
+ return x(e) ? [] : pt(q(n));
370
374
  };
371
- function Jt(e, a, t) {
372
- const s = d(t, "i18nProps", []);
373
- if (x(a) || x(s)) return e;
374
- const n = M(e);
375
- return N(W(n), (o) => {
376
- if (w(s, o) && !x(a)) {
377
- const l = d(n, o), i = d(n, `${o}-${a}`, "");
378
- $(l) ? n[o] = $(i) && !x(i.trim()) && i.trimStart() || l : n[o] = x(i) ? l : i;
375
+ function Jt(e, n, t) {
376
+ const s = y(t, "i18nProps", []);
377
+ if (x(n) || x(s)) return e;
378
+ const a = M(e);
379
+ return N(R(a), (o) => {
380
+ if (T(s, o) && !x(n)) {
381
+ const i = y(a, o), l = y(a, `${o}-${n}`, "");
382
+ $(i) ? a[o] = $(l) && !x(l.trim()) && l.trimStart() || i : a[o] = x(l) ? i : l;
379
383
  }
380
- }), n;
384
+ }), a;
381
385
  }
382
- const lt = (e, a) => {
383
- const { baseClasses: t, classes: s } = nt(e), o = s.split(" ").filter((i) => i.startsWith(tt)).map((i) => {
384
- var h;
385
- return (h = a[i]) == null ? void 0 : h.value;
386
- }), l = s.split(" ").filter((i) => !i.startsWith(tt)).join(" ");
387
- return wt.apply(null, [t, ...o, l]);
386
+ const lt = (e, n) => {
387
+ const { baseClasses: t, classes: s } = at(e), o = s.split(" ").filter((l) => l.startsWith(tt)).map((l) => {
388
+ var u;
389
+ return (u = n[l]) == null ? void 0 : u.value;
390
+ }), i = s.split(" ").filter((l) => !l.startsWith(tt)).join(" ");
391
+ return wt.apply(null, [t, ...o, i]);
388
392
  };
389
- function At(e, a) {
390
- return d(e, `${a}_attrs`, {});
393
+ function At(e, n) {
394
+ return y(e, `${n}_attrs`, {});
391
395
  }
392
- function zt(e, a = !0, t = {}) {
396
+ function zt(e, n = !0, t = {}) {
393
397
  const s = {};
394
- return Object.keys(e).forEach((n) => {
395
- if ($(e[n]) && e[n].startsWith(f)) {
396
- const o = lt(e[n], t), l = At(e, n);
397
- s[n] = {
398
+ return Object.keys(e).forEach((a) => {
399
+ if ($(e[a]) && e[a].startsWith(f)) {
400
+ const o = lt(e[a], t), i = At(e, a);
401
+ s[a] = {
398
402
  ...!x(o) && { className: o },
399
- ...l,
400
- ...a ? {
401
- "data-style-prop": n,
403
+ ...i,
404
+ ...n ? {
405
+ "data-style-prop": a,
402
406
  "data-block-parent": e._id,
403
- "data-style-id": `${n}-${e._id}`
407
+ "data-style-id": `${a}-${e._id}`
404
408
  } : {}
405
409
  };
406
410
  }
407
411
  }), s;
408
412
  }
409
413
  const Ft = xt((e) => {
410
- const a = vt(e), t = d(a, "schema.properties", {});
411
- return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
412
- }), Ut = (e, a) => {
414
+ const n = vt(e), t = y(n, "schema.properties", {});
415
+ return Object.fromEntries(Object.entries(t).filter(([, s]) => y(s, "runtime", !1)));
416
+ }), Ut = (e, n) => {
413
417
  if (!I(e)) return e;
414
418
  let t = e, s;
415
- return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
416
- }, Yt = (e, a) => {
419
+ return typeof n.limit == "number" && n.limit > 0 && (s = n.limit), s !== void 0 && (t = t.slice(0, s)), t;
420
+ }, Yt = (e, n) => {
417
421
  const t = M(e);
418
- return N(W(t), (s) => {
422
+ return N(R(t), (s) => {
419
423
  if ($(t[s]) && !k(s, "_")) {
420
- let n = t[s];
421
- s === "repeaterItems" && (t.repeaterItemsBinding = n);
422
- const o = /\{\{(.*?)\}\}/g, l = n.match(o);
423
- l && l.forEach((i) => {
424
- let h = i.slice(2, -2);
425
- const r = d(a, h, i);
426
- n = I(r) ? r : n.replace(i, r);
427
- }), t[s] = n;
424
+ let a = t[s];
425
+ s === "repeaterItems" && (t.repeaterItemsBinding = a);
426
+ const o = /\{\{(.*?)\}\}/g, i = a.match(o);
427
+ i && i.forEach((l) => {
428
+ let u = l.slice(2, -2);
429
+ const r = y(n, u, l);
430
+ a = I(r) ? r : a.replace(l, r);
431
+ }), t[s] = a;
428
432
  }
429
433
  }), t;
430
- }, _ = (e, a) => e.map((t) => {
431
- const s = W(t).filter((n) => $(t[n]) && t[n].startsWith(f));
432
- return ft(s, (n) => {
433
- t[n] = `${f},${lt(t[n], a)}`;
434
+ }, _ = (e, n) => e.map((t) => {
435
+ const s = R(t).filter((a) => $(t[a]) && t[a].startsWith(f));
436
+ return ft(s, (a) => {
437
+ t[a] = `${f},${lt(t[a], n)}`;
434
438
  }), t;
435
439
  });
436
440
  import.meta.vitest && describe("applyDesignTokens", () => {
@@ -438,7 +442,7 @@ import.meta.vitest && describe("applyDesignTokens", () => {
438
442
  "dt#token1": { name: "primary-color", value: "bg-blue-500" },
439
443
  "dt#token2": { name: "text-size", value: "text-lg" },
440
444
  "dt#token3": { name: "spacing", value: "p-4" }
441
- }, a = [
445
+ }, n = [
442
446
  {
443
447
  _id: "block1",
444
448
  _type: "div",
@@ -462,16 +466,16 @@ import.meta.vitest && describe("applyDesignTokens", () => {
462
466
  }
463
467
  ];
464
468
  it("should process blocks and replace style properties with generated class names", () => {
465
- const t = _(a, e);
469
+ const t = _(n, e);
466
470
  expect(t).toHaveLength(3), expect(t[0].styles).toBe("#styles:,bg-white text-sm"), expect(t[0].className).toBe("#styles:,text-lg p-4"), expect(t[0].otherProp).toBe("not-a-style"), expect(t[0]._id).toBe("block1"), expect(t[0]._type).toBe("div");
467
471
  }), it("should handle blocks with no style properties", () => {
468
- const t = _(a, e);
472
+ const t = _(n, e);
469
473
  expect(t[2].noStyles).toBe("regular-string"), expect(t[2]._id).toBe("block3");
470
474
  }), it("should handle empty blocks array", () => {
471
475
  const t = _([], e);
472
476
  expect(t).toEqual([]);
473
477
  }), it("should handle empty design tokens", () => {
474
- const t = _(a, {});
478
+ const t = _(n, {});
475
479
  expect(t[0].styles).toBe("#styles:,bg-white text-sm");
476
480
  }), it("should handle blocks with only style prefix", () => {
477
481
  const s = _([
@@ -520,11 +524,11 @@ import.meta.vitest && describe("applyDesignTokens", () => {
520
524
  ], e);
521
525
  expect(s[0].styles).toBe("#styles:,bg-white"), expect(s[0].nullStyles).toBeNull(), expect(s[0].undefinedStyles).toBeUndefined();
522
526
  }), it("should preserve block structure and non-style properties", () => {
523
- _(a, e).forEach((s, n) => {
524
- expect(s._id).toBe(a[n]._id), expect(s._type).toBe(a[n]._type), expect(s._name).toBe(a[n]._name);
527
+ _(n, e).forEach((s, a) => {
528
+ expect(s._id).toBe(n[a]._id), expect(s._type).toBe(n[a]._type), expect(s._name).toBe(n[a]._name);
525
529
  });
526
530
  }), it("should handle complex design token values", () => {
527
- const n = _([
531
+ const a = _([
528
532
  {
529
533
  _id: "block1",
530
534
  _type: "div",
@@ -535,9 +539,9 @@ import.meta.vitest && describe("applyDesignTokens", () => {
535
539
  "dt#complex1": { name: "complex-token", value: "hover:bg-blue-600 focus:outline-none transition-colors" },
536
540
  "dt#complex2": { name: "spacing-token", value: "px-6 py-3 m-2" }
537
541
  });
538
- expect(n[0].styles).toBe("#styles:,hover:bg-blue-600 focus:outline-none transition-colors bg-white");
542
+ expect(a[0].styles).toBe("#styles:,hover:bg-blue-600 focus:outline-none transition-colors bg-white");
539
543
  }), it("should handle tokens with empty values", () => {
540
- const n = _([
544
+ const a = _([
541
545
  {
542
546
  _id: "block1",
543
547
  _type: "div",
@@ -548,103 +552,103 @@ import.meta.vitest && describe("applyDesignTokens", () => {
548
552
  "dt#empty1": { name: "empty-token", value: "" },
549
553
  "dt#valid1": { name: "valid-token", value: "bg-green-500" }
550
554
  });
551
- expect(n[0].styles).toBe("#styles:,bg-white");
555
+ expect(a[0].styles).toBe("#styles:,bg-white");
552
556
  });
553
557
  });
554
558
  const v = (e) => {
555
- const a = _t(e);
559
+ const n = _t(e);
556
560
  return e.map((t) => {
557
561
  const s = Object.keys(t);
558
- for (let n = 0; n < s.length; n++)
559
- if ($(t[s[n]]) && k(s[n], "content")) {
560
- const o = t === a ? "" : " ";
561
- t[s[n]] = `${t[s[n]].trim()}${o}`;
562
+ for (let a = 0; a < s.length; a++)
563
+ if ($(t[s[a]]) && k(s[a], "content")) {
564
+ const o = t === n ? "" : " ";
565
+ t[s[a]] = `${t[s[a]].trim()}${o}`;
562
566
  }
563
567
  return t;
564
568
  });
565
569
  };
566
570
  if (import.meta.vitest) {
567
- const { describe: e, it: a, expect: t } = import.meta.vitest;
571
+ const { describe: e, it: n, expect: t } = import.meta.vitest;
568
572
  e("adjustSpacingInContentBlocks", () => {
569
- a("should add space after content fields except for the last block", () => {
570
- const n = v([
573
+ n("should add space after content fields except for the last block", () => {
574
+ const a = v([
571
575
  { _id: "1", _type: "Text", content: "First" },
572
576
  { _id: "2", _type: "Text", content: "Second" },
573
577
  { _id: "3", _type: "Text", content: "Third" }
574
578
  ]);
575
- t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
576
- }), a("should trim whitespace from content before adding space", () => {
577
- const n = v([
579
+ t(a[0].content).toBe("First "), t(a[1].content).toBe("Second "), t(a[2].content).toBe("Third");
580
+ }), n("should trim whitespace from content before adding space", () => {
581
+ const a = v([
578
582
  { _id: "1", _type: "Text", content: " First " },
579
583
  { _id: "2", _type: "Text", content: " Second " }
580
584
  ]);
581
- t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
582
- }), a("should handle multiple content fields in a single block", () => {
583
- const n = v([
585
+ t(a[0].content).toBe("First "), t(a[1].content).toBe("Second");
586
+ }), n("should handle multiple content fields in a single block", () => {
587
+ const a = v([
584
588
  { _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
585
589
  { _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
586
590
  ]);
587
- t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
588
- }), a("should only process fields that start with 'content'", () => {
589
- const n = v([
591
+ t(a[0].content).toBe("Main "), t(a[0].contentAlt).toBe("Alt "), t(a[1].content).toBe("Last"), t(a[1].contentSecondary).toBe("Secondary");
592
+ }), n("should only process fields that start with 'content'", () => {
593
+ const a = v([
590
594
  { _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
591
595
  { _id: "2", _type: "Text", content: "Last" }
592
596
  ]);
593
- t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
594
- }), a("should handle empty array", () => {
595
- const n = v([]);
596
- t(n).toEqual([]);
597
- }), a("should handle single block", () => {
598
- const n = v([{ _id: "1", _type: "Text", content: "Only" }]);
599
- t(n[0].content).toBe("Only");
600
- }), a("should handle blocks without content fields", () => {
601
- const n = v([
597
+ t(a[0].content).toBe("Text "), t(a[0].title).toBe("Title"), t(a[0].text).toBe("Text"), t(a[1].content).toBe("Last");
598
+ }), n("should handle empty array", () => {
599
+ const a = v([]);
600
+ t(a).toEqual([]);
601
+ }), n("should handle single block", () => {
602
+ const a = v([{ _id: "1", _type: "Text", content: "Only" }]);
603
+ t(a[0].content).toBe("Only");
604
+ }), n("should handle blocks without content fields", () => {
605
+ const a = v([
602
606
  { _id: "1", _type: "Container", title: "Title" },
603
607
  { _id: "2", _type: "Container", name: "Name" }
604
608
  ]);
605
- t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
606
- }), a("should handle blocks with non-string content fields", () => {
607
- const n = v([
609
+ t(a[0].title).toBe("Title"), t(a[1].name).toBe("Name");
610
+ }), n("should handle blocks with non-string content fields", () => {
611
+ const a = v([
608
612
  { _id: "1", _type: "Text", content: "Text", contentNum: 123 },
609
613
  { _id: "2", _type: "Text", content: "Last", contentBool: !0 }
610
614
  ]);
611
- t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
612
- }), a("should handle empty string content", () => {
613
- const n = v([
615
+ t(a[0].content).toBe("Text "), t(a[0].contentNum).toBe(123), t(a[1].content).toBe("Last"), t(a[1].contentBool).toBe(!0);
616
+ }), n("should handle empty string content", () => {
617
+ const a = v([
614
618
  { _id: "1", _type: "Text", content: "" },
615
619
  { _id: "2", _type: "Text", content: "Last" }
616
620
  ]);
617
- t(n[0].content).toBe(" "), t(n[1].content).toBe("Last");
621
+ t(a[0].content).toBe(" "), t(a[1].content).toBe("Last");
618
622
  });
619
623
  });
620
624
  }
621
- const b = (e, a, { index: t, key: s }, n) => {
625
+ const b = (e, n, { index: t, key: s }, a) => {
622
626
  if ($(e)) {
623
627
  let o = e;
624
- const l = /\{\{(.*?)\}\}/g, i = e.match(l);
625
- if (i) {
626
- const h = n === "image" || n === "mobileImage";
627
- i.forEach((r) => {
628
- let T = r.slice(2, -2).trim(), C = s.slice(2, -2).trim();
629
- t !== -1 && k(T, "$index.") ? T = `${C}.${t}.${T.slice(7)}` : t !== -1 && k(T, "$index") && (T = `${C}.${t}`);
630
- const B = d(a, T);
631
- B === void 0 ? o = o.replace(r, "") : h && !I(B) ? o = B : o = I(B) ? B : o.replace(r, B);
628
+ const i = /\{\{(.*?)\}\}/g, l = e.match(i);
629
+ if (l) {
630
+ const u = a === "image" || a === "mobileImage";
631
+ l.forEach((r) => {
632
+ let B = r.slice(2, -2).trim(), C = s.slice(2, -2).trim();
633
+ t !== -1 && k(B, "$index.") ? B = `${C}.${t}.${B.slice(7)}` : t !== -1 && k(B, "$index") && (B = `${C}.${t}`);
634
+ const E = y(n, B);
635
+ E === void 0 ? o = o.replace(r, "") : u && !I(E) ? o = E : o = I(E) ? E : o.replace(r, E);
632
636
  });
633
637
  }
634
638
  return o;
635
639
  }
636
640
  if (I(e))
637
- return e.map((o) => b(o, a, { index: t, key: s }, n));
641
+ return e.map((o) => b(o, n, { index: t, key: s }, a));
638
642
  if (e && typeof e == "object") {
639
643
  const o = {};
640
- return N(W(e), (l) => {
641
- !k(l, "_") && l !== "$repeaterItemsKey" ? o[l] = b(e[l], a, { index: t, key: s }, l) : o[l] = e[l];
644
+ return N(R(e), (i) => {
645
+ !k(i, "_") && i !== "$repeaterItemsKey" ? o[i] = b(e[i], n, { index: t, key: s }, i) : o[i] = e[i];
642
646
  }), o;
643
647
  }
644
648
  return e;
645
- }, L = (e, a, { index: t, key: s }) => {
646
- let n = M(e);
647
- return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, k(n.repeaterItems, `{{${Tt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !x(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
649
+ }, L = (e, n, { index: t, key: s }) => {
650
+ let a = M(e);
651
+ return a.repeaterItems && (a.$repeaterItemsKey = a.repeaterItems, k(a.repeaterItems, `{{${Tt}`) && (a.$repeaterItemsKey = a.repeaterItems = `${a.repeaterItems.replace("}}", `/${a._id}}}`)}`), !x(a.repeaterItems) && a.pagination && (a.repeaterTotalItems = `${a.repeaterItems.replace("}}", `/${a._id}/totalItems}}`)}`)), b(a, n, { index: t, key: s });
648
652
  };
649
653
  import.meta.vitest && (describe("applyBindingToValue", () => {
650
654
  it("should handle string values with bindings", () => {
@@ -678,11 +682,11 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
678
682
  const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
679
683
  expect(t).toBe("Hello ");
680
684
  }), it("should preserve private properties starting with _", () => {
681
- const a = b({
685
+ const n = b({
682
686
  name: "John",
683
687
  _private: "secret"
684
688
  }, {}, { index: -1, key: "" });
685
- expect(a).toEqual({
689
+ expect(n).toEqual({
686
690
  name: "John",
687
691
  _private: "secret"
688
692
  });
@@ -831,7 +835,7 @@ export {
831
835
  zt as g,
832
836
  Vt as h,
833
837
  _ as i,
834
- nt as j,
838
+ at as j,
835
839
  qt as k,
836
840
  Ot as m
837
841
  };