@chaibuilder/sdk 3.1.14 → 3.1.16

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,17 +1,18 @@
1
- import { g as rt, c as S } from "./common-functions-BGzDsf1z.js";
2
- import { isEmpty as f, flatten as ot, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as ct, forEach as $, camelCase as pt, includes as v, has as A, filter as Z, some as ut, map as Q, compact as dt, trim as ht, capitalize as gt, memoize as tt, cloneDeep as q, keys as M, isString as B, isArray as C, last as mt } from "lodash-es";
3
- import { parse as yt, stringify as N } from "himalaya";
4
- import { getRegisteredChaiBlock as bt } from "@chaibuilder/runtime";
5
- import { twMerge as ft } from "tailwind-merge";
6
- const x = "#styles:", Ht = "__ADD_BLOCK_INTERNAL_ROOT", jt = "@", xt = "#", et = (e) => {
1
+ import { g as ot, c as R } from "./common-functions-BGzDsf1z.js";
2
+ import { isEmpty as f, flatten as ct, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as pt, forEach as $, camelCase as ut, includes as v, has as A, filter as G, some as dt, map as tt, compact as ht, trim as gt, capitalize as mt, memoize as et, cloneDeep as M, keys as P, isString as B, isArray as C, last as yt } from "lodash-es";
3
+ import { parse as bt, stringify as N } from "himalaya";
4
+ import { unset as H } from "lodash";
5
+ import { getRegisteredChaiBlock as ft } from "@chaibuilder/runtime";
6
+ import { twMerge as xt } from "tailwind-merge";
7
+ const x = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", _t = "#", st = (e) => {
7
8
  if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
8
- const s = e.split(/,(?![^\[]*\])/);
9
- if (s.length === 1)
10
- return { baseClasses: "", classes: s[0].trim() };
11
- const [t, ...a] = s;
9
+ const a = e.split(/,(?![^\[]*\])/);
10
+ if (a.length === 1)
11
+ return { baseClasses: "", classes: a[0].trim() };
12
+ const [t, ...s] = a;
12
13
  return {
13
14
  baseClasses: t.trim(),
14
- classes: a.join(",").trim().replace(/ +(?= )/g, "")
15
+ classes: s.join(",").trim().replace(/ +(?= )/g, "")
15
16
  };
16
17
  };
17
18
  import.meta.vitest && describe("getSplitChaiClasses", () => {
@@ -40,20 +41,20 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
40
41
  classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
41
42
  }
42
43
  };
43
- for (let s in e) {
44
- const t = et(`${x}${s}`);
45
- expect(t).toEqual(e[s]);
44
+ for (let a in e) {
45
+ const t = st(`${x}${a}`);
46
+ expect(t).toEqual(e[a]);
46
47
  }
47
48
  });
48
49
  });
49
- const _t = (e) => {
50
- const s = /(?: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 s.test(e) || t.test(e);
52
- }, kt = (e) => {
50
+ const kt = (e) => {
51
+ 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/;
52
+ return a.test(e) || t.test(e);
53
+ }, vt = (e) => {
53
54
  if (f(e)) return e;
54
- const s = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = e.match(s), n = e.match(t), r = a ? a[1] : n ? n[1] : null, o = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, c = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
55
- return r && (o.test(r) || c.test(r)) ? r : e;
56
- }, at = ["chai-name", "data-chai-name"], vt = {
55
+ const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), r = s ? s[1] : n ? n[1] : null, o = /(?: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/;
56
+ return r && (o.test(r) || l.test(r)) ? r : e;
57
+ }, at = ["chai-name", "data-chai-name"], wt = {
57
58
  img: { alt: "alt", width: "width", height: "height", src: "image" },
58
59
  video: {
59
60
  src: "url",
@@ -89,51 +90,51 @@ const _t = (e) => {
89
90
  form: {
90
91
  action: "action"
91
92
  }
92
- }, wt = (e, s) => e.children.length === 1 && v(
93
+ }, Tt = (e, a) => e.children.length === 1 && v(
93
94
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
94
- s._type
95
- ), R = (e) => e.map((s) => s.type === "text" ? d(s, "content", "") : f(s.children) ? "" : R(s.children)).join(""), H = (e) => e === null ? "" : e, st = (e) => {
96
- const s = dt(Q(e.split(/\s+/), ht)), t = m(s, (c) => /^w-/.test(c)), a = m(s, (c) => /^h-/.test(c));
97
- if (!a || !t) return { height: "", width: "" };
98
- const n = (c) => {
99
- if (!c) return;
100
- const g = c.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
95
+ a._type
96
+ ), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : f(a.children) ? "" : j(a.children)).join(""), S = (e) => e === null ? "" : e, nt = (e) => {
97
+ const a = ht(tt(e.split(/\s+/), gt)), t = m(a, (l) => /^w-/.test(l)), s = m(a, (l) => /^h-/.test(l));
98
+ if (!s || !t) return { height: "", width: "" };
99
+ const n = (l) => {
100
+ if (!l) return;
101
+ const g = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
101
102
  if (!g) return;
102
103
  if (g[1]) return g[1];
103
104
  const i = g[2];
104
105
  return /^\d+(\.\d+)?$/.test(i) ? `${Number(i) * 4}px` : i === "auto" || v(i, "%") ? i : "16px";
105
- }, r = n(t), o = n(a);
106
+ }, r = n(t), o = n(s);
106
107
  return {
107
108
  width: v(r, "px") ? r : "16px",
108
109
  height: v(o, "px") ? o : "16px"
109
110
  };
110
- }, G = (e) => {
111
+ }, Q = (e) => {
111
112
  if (e.tagName === "svg") return {};
112
- const s = {}, t = vt[e.tagName] || {}, a = e.attributes;
113
- return $(a, ({ key: n, value: r }) => {
113
+ const a = {}, t = wt[e.tagName] || {}, s = e.attributes;
114
+ return $(s, ({ key: n, value: r }) => {
114
115
  if (!v(at, n))
115
- if (t[n]) {
116
+ if (n === "bid" && (a._bid = S(r)), t[n]) {
116
117
  if (e.tagName === "img" && n === "src" && !r.startsWith("http")) {
117
- const o = m(e.attributes, { key: "width" }), c = m(e.attributes, { key: "height" });
118
- o && c ? r = `https://via.placeholder.com/${o == null ? void 0 : o.value}x${c == null ? void 0 : c.value}` : r = "https://via.placeholder.com/150x150";
118
+ const o = m(e.attributes, { key: "width" }), l = m(e.attributes, { key: "height" });
119
+ o && l ? r = `https://picsum.photos/${o == null ? void 0 : o.value}x${l == null ? void 0 : l.value}` : r = "https://picsum.photos/150x150";
119
120
  }
120
- E(s, t[n], H(r));
121
- } else v(["style", "class", "srcset"], n) || (A(s, "styles_attrs") || (s.styles_attrs = {}), _(n, "@") && (n = n.replace("@", "x-on:")), s.styles_attrs[`${n}`] = H(r));
122
- }), delete s.class, s;
123
- }, Tt = (e, s = "styles") => {
124
- if (!e.attributes) return { [s]: `${x},` };
121
+ E(a, t[n], S(r));
122
+ } else v(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), _(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = S(r));
123
+ }), delete a.class, a;
124
+ }, Et = (e, a = "styles") => {
125
+ if (!e.attributes) return { [a]: `${x},` };
125
126
  const t = m(e.attributes, { key: "class" });
126
127
  if (t) {
127
- const a = t.value;
128
- return { [s]: `${x},${a}` };
128
+ const s = t.value;
129
+ return { [a]: `${x},${s}` };
129
130
  }
130
- return { [s]: `${x},` };
131
- }, Et = (e) => {
132
- const s = d(e, "attributes", []), t = s.find((i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"), a = s.find((i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"), n = s.find((i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"), r = s.find(
131
+ return { [a]: `${x},` };
132
+ }, $t = (e) => {
133
+ const a = d(e, "attributes", []), t = a.find((i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"), s = a.find((i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"), n = a.find((i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"), r = a.find(
133
134
  (i) => i.key === "data-chai-dropdown-button" || i.key === "chai-dropdown-button"
134
- ), o = s.find(
135
+ ), o = a.find(
135
136
  (i) => i.key === "data-chai-dropdown-content" || i.key === "chai-dropdown-content"
136
- ), c = s.find((i) => i.key === "class"), g = c && c.value.split(/\s+/).includes("rte");
137
+ ), l = a.find((i) => i.key === "class"), g = l && l.value.split(/\s+/).includes("rte");
137
138
  if (n)
138
139
  return { _type: "Dropdown" };
139
140
  if (r)
@@ -142,7 +143,7 @@ const _t = (e) => {
142
143
  return { _type: "DropdownContent" };
143
144
  if (t || g)
144
145
  return { _type: "Paragraph" };
145
- if (a)
146
+ if (s)
146
147
  return { _type: "LightBoxLink" };
147
148
  switch (e.tagName) {
148
149
  // self closing tags
@@ -226,55 +227,55 @@ const _t = (e) => {
226
227
  return {
227
228
  _type: i,
228
229
  tag: e.tagName,
229
- _name: i == "EmptyBox" || e.tagName === "div" ? i : gt(e.tagName)
230
+ _name: i == "EmptyBox" || e.tagName === "div" ? i : mt(e.tagName)
230
231
  };
231
232
  }
232
233
  }
233
- }, j = (e, s = null) => lt(e, (t) => {
234
- var P, J, O, z, V, W, F, U, Y, K;
234
+ }, q = (e, a = null) => lt(e, (t) => {
235
+ var J, O, z, V, W, F, U, Y, K, X;
235
236
  if (t.type === "comment") return [];
236
- let a = { _id: rt() };
237
- if (s && (a._parent = s.block._id), t.type === "text")
238
- return f(d(t, "content", "")) ? [] : s && wt(s.node, s.block) ? (E(s, "block.content", d(t, "content", "")), []) : { ...a, _type: "Text", content: d(t, "content", "") };
237
+ let s = { _id: ot() };
238
+ if (a && (s._parent = a.block._id), t.type === "text")
239
+ return f(d(t, "content", "")) ? [] : a && Tt(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
239
240
  if (_(t.tagName, "chai-")) {
240
- const l = t.attributes, p = m(l, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || ct(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
241
- a._type = u, $(l, ({ key: y, value: X }) => {
241
+ const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || pt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
242
+ s._type = u, $(c, ({ key: y, value: Z }) => {
242
243
  if (y === "about-this-component" || y === "chai-type" || y === "can-move" || y === "can-delete") return;
243
244
  if (y === "id") {
244
- a._id = X;
245
+ s._id = Z;
245
246
  return;
246
247
  }
247
- const nt = _(y, "_") ? y : pt(y);
248
- let I = H(X);
249
- typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), a[nt] = I;
248
+ const rt = _(y, "_") ? y : ut(y);
249
+ let I = S(Z);
250
+ typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), s[rt] = I;
250
251
  });
251
- const h = j(t.children, { block: a, node: t });
252
- return [a, ...h];
252
+ const h = q(t.children, { block: s, node: t });
253
+ return [s, ...h];
253
254
  }
254
255
  const n = d(t, "attributes", []), r = n.find(
255
- (l) => l.key === "data-chai-richtext" || l.key === "chai-richtext"
256
- ), o = n.find((l) => l.key === "class"), c = o && o.value.split(/\s+/).includes("rte"), g = n.find(
257
- (l) => l.key === "data-chai-lightbox" || l.key === "chai-lightbox"
256
+ (c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"
257
+ ), o = n.find((c) => c.key === "class"), l = o && o.value.split(/\s+/).includes("rte"), g = n.find(
258
+ (c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
258
259
  ), i = n.find(
259
- (l) => l.key === "data-chai-dropdown" || l.key === "chai-dropdown"
260
+ (c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
260
261
  ), w = n.find(
261
- (l) => l.key === "data-chai-dropdown-button" || l.key === "chai-dropdown-button"
262
+ (c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
262
263
  ), D = n.find(
263
- (l) => l.key === "data-chai-dropdown-content" || l.key === "chai-dropdown-content"
264
+ (c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
264
265
  );
265
- if (a = {
266
- ...a,
267
- ...Et(t),
268
- ...G(t),
269
- ...Tt(t)
266
+ if (s = {
267
+ ...s,
268
+ ...$t(t),
269
+ ...Q(t),
270
+ ...Et(t)
270
271
  }, t.attributes) {
271
- const l = t.attributes.find((p) => v(at, p.key));
272
- l && (a._name = l.value);
272
+ const c = t.attributes.find((p) => v(at, p.key));
273
+ c && (s._name = c.value);
273
274
  }
274
- if (r || c)
275
- return a.content = N(t.children), A(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], A(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
275
+ if (r || l)
276
+ return s.content = N(t.children), 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];
276
277
  if (g) {
277
- const l = [
278
+ const c = [
278
279
  "data-chai-lightbox",
279
280
  "chai-lightbox",
280
281
  "data-vbtype",
@@ -284,202 +285,207 @@ const _t = (e) => {
284
285
  "data-gall",
285
286
  "href"
286
287
  ];
287
- a = {
288
- ...a,
289
- href: ((P = n.find((p) => p.key === "href")) == null ? void 0 : P.value) || "",
290
- hrefType: ((J = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : J.value) || "video",
291
- autoplay: ((O = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : O.value) === "true" ? "true" : "false",
292
- maxWidth: ((V = (z = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : z.value) == null ? void 0 : V.replace("px", "")) || "",
293
- backdropColor: ((W = n.find((p) => p.key === "data-overlay")) == null ? void 0 : W.value) || "",
294
- galleryName: ((F = n.find((p) => p.key === "data-gall")) == null ? void 0 : F.value) || ""
295
- }, $(l, (p) => {
296
- A(a, `styles_attrs.${p}`) && delete a.styles_attrs[p];
288
+ s = {
289
+ ...s,
290
+ href: ((J = n.find((p) => p.key === "href")) == null ? void 0 : J.value) || "",
291
+ hrefType: ((O = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : O.value) || "video",
292
+ autoplay: ((z = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : z.value) === "true" ? "true" : "false",
293
+ maxWidth: ((W = (V = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : V.value) == null ? void 0 : W.replace("px", "")) || "",
294
+ backdropColor: ((F = n.find((p) => p.key === "data-overlay")) == null ? void 0 : F.value) || "",
295
+ galleryName: ((U = n.find((p) => p.key === "data-gall")) == null ? void 0 : U.value) || ""
296
+ }, $(c, (p) => {
297
+ A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
297
298
  });
298
299
  }
299
- if (i && (delete a.styles_attrs, a.showDropdown = !1), D && delete a.styles_attrs, w) {
300
- delete a.styles_attrs;
301
- const l = Z(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
302
- a.content = R(l);
300
+ if (i && (delete s.styles_attrs, s.showDropdown = !1), D && delete s.styles_attrs, w) {
301
+ delete s.styles_attrs;
302
+ const c = G(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
303
+ s.content = j(c);
303
304
  const p = m(
304
305
  t.children || [],
305
- (u) => (u == null ? void 0 : u.tagName) === "span" && ut(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
306
+ (u) => (u == null ? void 0 : u.tagName) === "span" && dt(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
306
307
  );
307
308
  if (p) {
308
309
  const u = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
309
310
  if (u) {
310
- a.icon = N([u]);
311
- const { height: h, width: y } = $t(u, "16px", "16px");
312
- a.iconHeight = h, a.iconWidth = y;
311
+ s.icon = N([u]);
312
+ const { height: h, width: y } = Bt(u, "16px", "16px");
313
+ s.iconHeight = h, s.iconWidth = y;
313
314
  }
314
315
  }
315
- return [a];
316
+ return [s];
316
317
  }
317
- if (a._type === "Input") {
318
- const l = a.inputType || "text";
319
- l === "checkbox" ? E(a, "_type", "Checkbox") : l === "radio" && E(a, "_type", "Radio");
318
+ if (s._type === "Input") {
319
+ const c = s.inputType || "text";
320
+ c === "checkbox" ? E(s, "_type", "Checkbox") : c === "radio" && E(s, "_type", "Radio");
320
321
  } else if (t.tagName === "video" || t.tagName === "iframe") {
321
- const l = N([t]);
322
- return _t(l) && (E(a, "_type", "Video"), E(a, "url", kt(l)), E(a, "styles", `${x},`), E(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = l, [a];
322
+ const c = N([t]);
323
+ return kt(c) && (E(s, "_type", "Video"), E(s, "url", vt(c)), E(s, "styles", `${x},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
323
324
  } else if (t.tagName === "svg") {
324
- const l = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = st(l);
325
+ const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = nt(c);
325
326
  if (p && u)
326
- a.styles = `${x}, ${S(`w-${u} h-${p}`, l)}`.trim(), a.height = p == null ? void 0 : p.replace("px", ""), a.width = u == null ? void 0 : u.replace("px", "");
327
+ s.styles = `${x}, ${R(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
327
328
  else {
328
- const h = (U = m(t.attributes, { key: "height" })) == null ? void 0 : U.value, y = (Y = m(t.attributes, { key: "width" })) == null ? void 0 : Y.value;
329
- h && y ? (a.styles = `${x}, ${S(`w-[${y}px] h-[${h}px]`, l)}`.trim(), a.height = h, a.width = y) : a.styles = `${x}, ${S("w-full h-full", l)}`.trim();
329
+ const h = (Y = m(t.attributes, { key: "height" })) == null ? void 0 : Y.value, y = (K = m(t.attributes, { key: "width" })) == null ? void 0 : K.value;
330
+ h && y ? (s.styles = `${x}, ${R(`w-[${y}px] h-[${h}px]`, c)}`.trim(), s.height = h, s.width = y) : s.styles = `${x}, ${R("w-full h-full", c)}`.trim();
330
331
  }
331
- return t.attributes = Z(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), a.icon = N([t]), [a];
332
- } else if (t.tagName == "option" && s && ((K = s.block) == null ? void 0 : K._type) === "Select")
333
- return s.block.options.push({
334
- label: R(t.children),
335
- ...G(t)
332
+ return t.attributes = G(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), s.icon = N([t]), [s];
333
+ } else if (t.tagName == "option" && a && ((X = a.block) == null ? void 0 : X._type) === "Select")
334
+ return a.block.options.push({
335
+ label: j(t.children),
336
+ ...Q(t)
336
337
  }), [];
337
- const T = j(t.children, { block: a, node: t });
338
- return [a, ...T];
339
- }), $t = (e, s, t) => {
338
+ const T = q(t.children, { block: s, node: t });
339
+ return [s, ...T];
340
+ }), Bt = (e, a, t) => {
340
341
  var g, i;
341
- const a = d(e, "attributes", []), { height: n, width: r } = st(
342
- d(m(a, { key: "class" }), "value", "")
342
+ const s = d(e, "attributes", []), { height: n, width: r } = nt(
343
+ d(m(s, { key: "class" }), "value", "")
343
344
  );
344
345
  if (n && r)
345
346
  return {
346
347
  height: `[${n}px]`,
347
348
  width: `[${r}px]`
348
349
  };
349
- const o = (g = m(a, { key: "height" })) == null ? void 0 : g.value, c = (i = m(a, { key: "width" })) == null ? void 0 : i.value;
350
+ const o = (g = m(s, { key: "height" })) == null ? void 0 : g.value, l = (i = m(s, { key: "width" })) == null ? void 0 : i.value;
350
351
  return {
351
352
  height: o ? `[${o}px]` : t,
352
- width: c ? `[${c}px]` : s
353
+ width: l ? `[${l}px]` : a
353
354
  };
354
- }, Bt = (e) => {
355
- e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, n, r) => {
355
+ }, It = (e) => {
356
+ e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, r) => {
356
357
  let o = r.replace(/\\"/g, '"');
357
- return o = o.replace(/{([^}]+)}/g, (c) => c.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
358
+ return o = o.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
358
359
  }), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
359
- const s = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
360
- return (s && s.length > 0 ? s[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
361
- }, It = (e, s) => m(e, { _id: s }), qt = (e, s) => f(s) ? e : Q(e, (t) => {
362
- const a = It(s, t._id);
363
- return a ? (a._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon, { ...a, ...t }) : t;
364
- }), Mt = (e) => {
365
- const s = yt(Bt(e));
366
- return f(e) ? [] : ot(j(s));
360
+ const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
361
+ 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();
362
+ }, Ct = (e, a) => m(e, { _id: a }), Pt = (e, a) => f(a) ? e.map((t) => (H(t, "_bid"), t)) : tt(e, (t) => {
363
+ const s = f(t._bid) ? void 0 : Ct(a, t._bid);
364
+ if (s) {
365
+ s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
366
+ const n = { ...s, ...t };
367
+ return H(n, "_bid"), n;
368
+ }
369
+ return H(t, "_bid"), t;
370
+ }), Jt = (e) => {
371
+ const a = bt(It(e));
372
+ return f(e) ? [] : ct(q(a));
367
373
  };
368
- function Pt(e, s, t) {
369
- const a = d(t, "i18nProps", []);
370
- if (f(s) || f(a)) return e;
371
- const n = q(e);
372
- return $(M(n), (r) => {
373
- if (v(a, r) && !f(s)) {
374
- const o = d(n, r), c = d(n, `${r}-${s}`, "");
375
- B(o) ? n[r] = B(c) && !f(c.trim()) && c.trimStart() || o : n[r] = f(c) ? o : c;
374
+ function Ot(e, a, t) {
375
+ const s = d(t, "i18nProps", []);
376
+ if (f(a) || f(s)) return e;
377
+ const n = M(e);
378
+ return $(P(n), (r) => {
379
+ if (v(s, r) && !f(a)) {
380
+ const o = d(n, r), l = d(n, `${r}-${a}`, "");
381
+ B(o) ? n[r] = B(l) && !f(l.trim()) && l.trimStart() || o : n[r] = f(l) ? o : l;
376
382
  }
377
383
  }), n;
378
384
  }
379
- const Ct = tt((e) => {
380
- const { baseClasses: s, classes: t } = et(e);
381
- return ft(s, t);
385
+ const Dt = et((e) => {
386
+ const { baseClasses: a, classes: t } = st(e);
387
+ return xt(a, t);
382
388
  });
383
- function Dt(e, s) {
384
- return d(e, `${s}_attrs`, {});
389
+ function Nt(e, a) {
390
+ return d(e, `${a}_attrs`, {});
385
391
  }
386
- function Jt(e, s = !0) {
392
+ function zt(e, a = !0) {
387
393
  const t = {};
388
- return Object.keys(e).forEach((a) => {
389
- if (B(e[a]) && e[a].startsWith(x)) {
390
- const n = Ct(e[a]), r = Dt(e, a);
391
- t[a] = {
394
+ return Object.keys(e).forEach((s) => {
395
+ if (B(e[s]) && e[s].startsWith(x)) {
396
+ const n = Dt(e[s]), r = Nt(e, s);
397
+ t[s] = {
392
398
  ...!f(n) && { className: n },
393
399
  ...r,
394
- ...s ? {
395
- "data-style-prop": a,
400
+ ...a ? {
401
+ "data-style-prop": s,
396
402
  "data-block-parent": e._id,
397
- "data-style-id": `${a}-${e._id}`
403
+ "data-style-id": `${s}-${e._id}`
398
404
  } : {}
399
405
  };
400
406
  }
401
407
  }), t;
402
408
  }
403
- const Ot = tt((e) => {
404
- const s = bt(e), t = d(s, "schema.properties", {});
405
- return Object.fromEntries(Object.entries(t).filter(([, a]) => d(a, "runtime", !1)));
406
- }), zt = (e, s) => {
409
+ const Vt = et((e) => {
410
+ const a = ft(e), t = d(a, "schema.properties", {});
411
+ return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
412
+ }), Wt = (e, a) => {
407
413
  if (!C(e)) return e;
408
- let t = e, a;
409
- return typeof s.limit == "number" && s.limit > 0 && (a = s.limit), a !== void 0 && (t = t.slice(0, a)), t;
410
- }, Vt = (e, s) => {
411
- const t = q(e);
412
- return $(M(t), (a) => {
413
- if (B(t[a]) && !_(a, "_")) {
414
- let n = t[a];
415
- a === "repeaterItems" && (t.repeaterItemsBinding = n);
414
+ 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
+ }, Ft = (e, a) => {
417
+ const t = M(e);
418
+ return $(P(t), (s) => {
419
+ if (B(t[s]) && !_(s, "_")) {
420
+ let n = t[s];
421
+ s === "repeaterItems" && (t.repeaterItemsBinding = n);
416
422
  const r = /\{\{(.*?)\}\}/g, o = n.match(r);
417
- o && o.forEach((c) => {
418
- let g = c.slice(2, -2);
419
- const i = d(s, g, c);
420
- n = C(i) ? i : n.replace(c, i);
421
- }), t[a] = n;
423
+ o && o.forEach((l) => {
424
+ let g = l.slice(2, -2);
425
+ const i = d(a, g, l);
426
+ n = C(i) ? i : n.replace(l, i);
427
+ }), t[s] = n;
422
428
  }
423
429
  }), t;
424
430
  }, k = (e) => {
425
- const s = mt(e);
431
+ const a = yt(e);
426
432
  return e.map((t) => {
427
- const a = Object.keys(t);
428
- for (let n = 0; n < a.length; n++)
429
- if (B(t[a[n]]) && _(a[n], "content")) {
430
- const r = t === s ? "" : " ";
431
- t[a[n]] = `${t[a[n]].trim()}${r}`;
433
+ const s = Object.keys(t);
434
+ for (let n = 0; n < s.length; n++)
435
+ if (B(t[s[n]]) && _(s[n], "content")) {
436
+ const r = t === a ? "" : " ";
437
+ t[s[n]] = `${t[s[n]].trim()}${r}`;
432
438
  }
433
439
  return t;
434
440
  });
435
441
  };
436
442
  if (import.meta.vitest) {
437
- const { describe: e, it: s, expect: t } = import.meta.vitest;
443
+ const { describe: e, it: a, expect: t } = import.meta.vitest;
438
444
  e("adjustSpacingInContentBlocks", () => {
439
- s("should add space after content fields except for the last block", () => {
445
+ a("should add space after content fields except for the last block", () => {
440
446
  const n = k([
441
447
  { _id: "1", _type: "Text", content: "First" },
442
448
  { _id: "2", _type: "Text", content: "Second" },
443
449
  { _id: "3", _type: "Text", content: "Third" }
444
450
  ]);
445
451
  t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
446
- }), s("should trim whitespace from content before adding space", () => {
452
+ }), a("should trim whitespace from content before adding space", () => {
447
453
  const n = k([
448
454
  { _id: "1", _type: "Text", content: " First " },
449
455
  { _id: "2", _type: "Text", content: " Second " }
450
456
  ]);
451
457
  t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
452
- }), s("should handle multiple content fields in a single block", () => {
458
+ }), a("should handle multiple content fields in a single block", () => {
453
459
  const n = k([
454
460
  { _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
455
461
  { _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
456
462
  ]);
457
463
  t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
458
- }), s("should only process fields that start with 'content'", () => {
464
+ }), a("should only process fields that start with 'content'", () => {
459
465
  const n = k([
460
466
  { _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
461
467
  { _id: "2", _type: "Text", content: "Last" }
462
468
  ]);
463
469
  t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
464
- }), s("should handle empty array", () => {
470
+ }), a("should handle empty array", () => {
465
471
  const n = k([]);
466
472
  t(n).toEqual([]);
467
- }), s("should handle single block", () => {
473
+ }), a("should handle single block", () => {
468
474
  const n = k([{ _id: "1", _type: "Text", content: "Only" }]);
469
475
  t(n[0].content).toBe("Only");
470
- }), s("should handle blocks without content fields", () => {
476
+ }), a("should handle blocks without content fields", () => {
471
477
  const n = k([
472
478
  { _id: "1", _type: "Container", title: "Title" },
473
479
  { _id: "2", _type: "Container", name: "Name" }
474
480
  ]);
475
481
  t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
476
- }), s("should handle blocks with non-string content fields", () => {
482
+ }), a("should handle blocks with non-string content fields", () => {
477
483
  const n = k([
478
484
  { _id: "1", _type: "Text", content: "Text", contentNum: 123 },
479
485
  { _id: "2", _type: "Text", content: "Last", contentBool: !0 }
480
486
  ]);
481
487
  t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
482
- }), s("should handle empty string content", () => {
488
+ }), a("should handle empty string content", () => {
483
489
  const n = k([
484
490
  { _id: "1", _type: "Text", content: "" },
485
491
  { _id: "2", _type: "Text", content: "Last" }
@@ -488,33 +494,33 @@ if (import.meta.vitest) {
488
494
  });
489
495
  });
490
496
  }
491
- const b = (e, s, { index: t, key: a }, n) => {
497
+ const b = (e, a, { index: t, key: s }, n) => {
492
498
  if (B(e)) {
493
499
  let r = e;
494
- const o = /\{\{(.*?)\}\}/g, c = e.match(o);
495
- if (c) {
500
+ const o = /\{\{(.*?)\}\}/g, l = e.match(o);
501
+ if (l) {
496
502
  const g = n === "image" || n === "mobileImage";
497
- c.forEach((i) => {
498
- let w = i.slice(2, -2).trim(), D = a.slice(2, -2).trim();
503
+ l.forEach((i) => {
504
+ let w = i.slice(2, -2).trim(), D = s.slice(2, -2).trim();
499
505
  t !== -1 && _(w, "$index.") ? w = `${D}.${t}.${w.slice(7)}` : t !== -1 && _(w, "$index") && (w = `${D}.${t}`);
500
- const T = d(s, w);
506
+ const T = d(a, w);
501
507
  T === void 0 ? r = r.replace(i, "") : g && !C(T) ? r = T : r = C(T) ? T : r.replace(i, T);
502
508
  });
503
509
  }
504
510
  return r;
505
511
  }
506
512
  if (C(e))
507
- return e.map((r) => b(r, s, { index: t, key: a }, n));
513
+ return e.map((r) => b(r, a, { index: t, key: s }, n));
508
514
  if (e && typeof e == "object") {
509
515
  const r = {};
510
- return $(M(e), (o) => {
511
- !_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o], s, { index: t, key: a }, o) : r[o] = e[o];
516
+ return $(P(e), (o) => {
517
+ !_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o], a, { index: t, key: s }, o) : r[o] = e[o];
512
518
  }), r;
513
519
  }
514
520
  return e;
515
- }, L = (e, s, { index: t, key: a }) => {
516
- let n = q(e);
517
- return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${xt}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, s, { index: t, key: a });
521
+ }, L = (e, a, { index: t, key: s }) => {
522
+ let n = M(e);
523
+ return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${_t}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
518
524
  };
519
525
  import.meta.vitest && (describe("applyBindingToValue", () => {
520
526
  it("should handle string values with bindings", () => {
@@ -548,11 +554,11 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
548
554
  const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
549
555
  expect(t).toBe("Hello ");
550
556
  }), it("should preserve private properties starting with _", () => {
551
- const s = b({
557
+ const a = b({
552
558
  name: "John",
553
559
  _private: "secret"
554
560
  }, {}, { index: -1, key: "" });
555
- expect(s).toEqual({
561
+ expect(a).toEqual({
556
562
  name: "John",
557
563
  _private: "secret"
558
564
  });
@@ -688,18 +694,18 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
688
694
  });
689
695
  }));
690
696
  export {
691
- xt as C,
692
- jt as R,
697
+ _t as C,
698
+ Mt as R,
693
699
  x as S,
694
700
  L as a,
695
- Pt as b,
696
- Ot as c,
697
- zt as d,
701
+ Ot as b,
702
+ Vt as c,
703
+ Wt as d,
698
704
  k as e,
699
- Vt as f,
700
- Jt as g,
701
- Mt as h,
702
- et as i,
703
- Ht as j,
704
- qt as m
705
+ Ft as f,
706
+ zt as g,
707
+ Jt as h,
708
+ st as i,
709
+ qt as j,
710
+ Pt as m
705
711
  };