@chaibuilder/sdk 3.0.18 → 3.0.19

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,10 +1,10 @@
1
1
  import { getRegisteredChaiBlock as Q } from "@chaibuilder/runtime";
2
- import { memoize as Y, get as u, cloneDeep as S, forEach as $, keys as A, isString as T, startsWith as v, isArray as N, isEmpty as g, includes as _, flatten as tt, flatMapDeep as et, set as k, has as C, filter as V, find as m, some as st, compact as at, map as nt, trim as rt, capitalize as ot, last as ct } from "lodash-es";
3
- import { twMerge as lt } from "tailwind-merge";
4
- import { g as pt, c as D } from "./common-functions-BGzDsf1z.js";
5
- import { parse as dt, stringify as E } from "himalaya";
6
- const f = "#styles:", It = "__ADD_BLOCK_INTERNAL_ROOT", Ct = "@", ut = "#", K = (e) => {
7
- if (e = e.replace(f, ""), !e) return { baseClasses: "", classes: "" };
2
+ import { memoize as Y, get as d, cloneDeep as R, forEach as D, keys as H, isString as B, startsWith as T, isArray as I, isEmpty as b, includes as k, flatten as tt, flatMapDeep as et, set as w, has as L, filter as V, find as y, some as at, compact as st, map as nt, trim as rt, capitalize as ot, last as lt } from "lodash-es";
3
+ import { twMerge as ct } from "tailwind-merge";
4
+ import { g as pt, c as S } from "./common-functions-BGzDsf1z.js";
5
+ import { parse as ut, stringify as C } from "himalaya";
6
+ const x = "#styles:", It = "__ADD_BLOCK_INTERNAL_ROOT", Dt = "@", dt = "#", K = (e) => {
7
+ if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
8
8
  const n = e.split(/,(?![^\[]*\])/);
9
9
  if (n.length === 1)
10
10
  return { baseClasses: "", classes: n[0].trim() };
@@ -41,36 +41,36 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
41
41
  }
42
42
  };
43
43
  for (let n in e) {
44
- const t = K(`${f}${n}`);
44
+ const t = K(`${x}${n}`);
45
45
  expect(t).toEqual(e[n]);
46
46
  }
47
47
  });
48
48
  });
49
- function Nt(e, n, t) {
50
- const a = u(t, "i18nProps", []);
51
- if (g(n) || g(a)) return e;
52
- const s = S(e);
53
- return $(A(s), (o) => {
54
- if (_(a, o) && !g(n)) {
55
- const c = u(s, o), r = u(s, `${o}-${n}`, "");
56
- T(c) ? s[o] = T(r) && !g(r.trim()) && r.trimStart() || c : s[o] = g(r) ? c : r;
49
+ function Ct(e, n, t) {
50
+ const a = d(t, "i18nProps", []);
51
+ if (b(n) || b(a)) return e;
52
+ const s = R(e);
53
+ return D(H(s), (o) => {
54
+ if (k(a, o) && !b(n)) {
55
+ const i = d(s, o), r = d(s, `${o}-${n}`, "");
56
+ B(i) ? s[o] = B(r) && !b(r.trim()) && r.trimStart() || i : s[o] = b(r) ? i : r;
57
57
  }
58
58
  }), s;
59
59
  }
60
60
  const ht = Y((e) => {
61
61
  const { baseClasses: n, classes: t } = K(e);
62
- return lt(n, t);
62
+ return ct(n, t);
63
63
  });
64
- function yt(e, n) {
65
- return u(e, `${n}_attrs`, {});
64
+ function gt(e, n) {
65
+ return d(e, `${n}_attrs`, {});
66
66
  }
67
- function Dt(e, n = !0) {
67
+ function Nt(e, n = !0) {
68
68
  const t = {};
69
69
  return Object.keys(e).forEach((a) => {
70
- if (T(e[a]) && e[a].startsWith(f)) {
71
- const s = ht(e[a]), o = yt(e, a);
70
+ if (B(e[a]) && e[a].startsWith(x)) {
71
+ const s = ht(e[a]), o = gt(e, a);
72
72
  t[a] = {
73
- ...!g(s) && { className: s },
73
+ ...!b(s) && { className: s },
74
74
  ...o,
75
75
  ...n ? {
76
76
  "data-style-prop": a,
@@ -82,33 +82,33 @@ function Dt(e, n = !0) {
82
82
  }), t;
83
83
  }
84
84
  const Lt = Y((e) => {
85
- const n = Q(e), t = u(n, "schema.properties", {});
86
- return Object.fromEntries(Object.entries(t).filter(([, a]) => u(a, "runtime", !1)));
85
+ const n = Q(e), t = d(n, "schema.properties", {});
86
+ return Object.fromEntries(Object.entries(t).filter(([, a]) => d(a, "runtime", !1)));
87
87
  }), St = (e, n) => {
88
- if (!N(e)) return e;
88
+ if (!I(e)) return e;
89
89
  let t = e, a;
90
90
  return typeof n.limit == "number" && n.limit > 0 && (a = n.limit), a !== void 0 && (t = t.slice(0, a)), t;
91
91
  }, At = (e, n) => {
92
- const t = S(e);
93
- return $(A(t), (a) => {
94
- if (T(t[a]) && !v(a, "_")) {
92
+ const t = R(e);
93
+ return D(H(t), (a) => {
94
+ if (B(t[a]) && !T(a, "_")) {
95
95
  let s = t[a];
96
96
  a === "repeaterItems" && (t.repeaterItemsBinding = s);
97
- const o = /\{\{(.*?)\}\}/g, c = s.match(o);
98
- c && c.forEach((r) => {
99
- let p = r.slice(2, -2);
100
- const h = u(n, p, r);
101
- s = N(h) ? h : s.replace(r, h);
97
+ const o = /\{\{(.*?)\}\}/g, i = s.match(o);
98
+ i && i.forEach((r) => {
99
+ let m = r.slice(2, -2);
100
+ const p = d(n, m, r);
101
+ s = I(p) ? p : s.replace(r, p);
102
102
  }), t[a] = s;
103
103
  }
104
104
  }), t;
105
105
  }, mt = (e) => {
106
106
  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/;
107
107
  return n.test(e) || t.test(e);
108
- }, gt = (e) => {
109
- if (g(e)) return e;
110
- const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = e.match(n), s = e.match(t), o = a ? a[1] : s ? s[1] : null, c = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, r = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
111
- return o && (c.test(o) || r.test(o)) ? o : e;
108
+ }, yt = (e) => {
109
+ if (b(e)) return e;
110
+ const n = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = e.match(n), s = e.match(t), o = a ? a[1] : s ? s[1] : null, i = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, r = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
111
+ return o && (i.test(o) || r.test(o)) ? o : e;
112
112
  }, X = ["chai-name", "data-chai-name"], bt = {
113
113
  img: { alt: "alt", width: "width", height: "height", src: "image" },
114
114
  video: {
@@ -145,56 +145,56 @@ const Lt = Y((e) => {
145
145
  form: {
146
146
  action: "action"
147
147
  }
148
- }, ft = (e, n) => e.children.length === 1 && _(
148
+ }, xt = (e, n) => e.children.length === 1 && k(
149
149
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
150
150
  n._type
151
- ), L = (e) => e.map((n) => n.type === "text" ? u(n, "content", "") : g(n.children) ? "" : L(n.children)).join(""), W = (e) => e === null ? "" : e, Z = (e) => {
152
- const n = at(nt(e.split(/\s+/), rt)), t = m(n, (r) => /^w-/.test(r)), a = m(n, (r) => /^h-/.test(r));
151
+ ), A = (e) => e.map((n) => n.type === "text" ? d(n, "content", "") : b(n.children) ? "" : A(n.children)).join(""), W = (e) => e === null ? "" : e, Z = (e) => {
152
+ const n = st(nt(e.split(/\s+/), rt)), t = y(n, (r) => /^w-/.test(r)), a = y(n, (r) => /^h-/.test(r));
153
153
  if (!a || !t) return { height: "", width: "" };
154
154
  const s = (r) => {
155
155
  if (!r) return;
156
- const p = r.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
157
- if (!p) return;
158
- if (p[1]) return p[1];
159
- const h = p[2];
160
- return /^\d+(\.\d+)?$/.test(h) ? `${Number(h) * 4}px` : h === "auto" || _(h, "%") ? h : "16px";
161
- }, o = s(t), c = s(a);
156
+ const m = r.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
157
+ if (!m) return;
158
+ if (m[1]) return m[1];
159
+ const p = m[2];
160
+ return /^\d+(\.\d+)?$/.test(p) ? `${Number(p) * 4}px` : p === "auto" || k(p, "%") ? p : "16px";
161
+ }, o = s(t), i = s(a);
162
162
  return {
163
- width: _(o, "px") ? o : "16px",
164
- height: _(c, "px") ? c : "16px"
163
+ width: k(o, "px") ? o : "16px",
164
+ height: k(i, "px") ? i : "16px"
165
165
  };
166
166
  }, U = (e) => {
167
167
  if (e.tagName === "svg") return {};
168
168
  const n = {}, t = bt[e.tagName] || {}, a = e.attributes;
169
- return $(a, ({ key: s, value: o }) => {
170
- if (!_(X, s))
169
+ return D(a, ({ key: s, value: o }) => {
170
+ if (!k(X, s))
171
171
  if (t[s]) {
172
172
  if (e.tagName === "img" && s === "src" && !o.startsWith("http")) {
173
- const c = m(e.attributes, { key: "width" }), r = m(e.attributes, { key: "height" });
174
- c && r ? o = `https://via.placeholder.com/${c == null ? void 0 : c.value}x${r == null ? void 0 : r.value}` : o = "https://via.placeholder.com/150x150";
173
+ const i = y(e.attributes, { key: "width" }), r = y(e.attributes, { key: "height" });
174
+ i && r ? o = `https://via.placeholder.com/${i == null ? void 0 : i.value}x${r == null ? void 0 : r.value}` : o = "https://via.placeholder.com/150x150";
175
175
  }
176
- k(n, t[s], W(o));
177
- } else _(["style", "class", "srcset"], s) || (C(n, "styles_attrs") || (n.styles_attrs = {}), v(s, "@") && (s = s.replace("@", "x-on:")), n.styles_attrs[`${s}`] = W(o));
176
+ w(n, t[s], W(o));
177
+ } else k(["style", "class", "srcset"], s) || (L(n, "styles_attrs") || (n.styles_attrs = {}), T(s, "@") && (s = s.replace("@", "x-on:")), n.styles_attrs[`${s}`] = W(o));
178
178
  }), delete n.class, n;
179
- }, xt = (e, n = "styles") => {
180
- if (!e.attributes) return { [n]: `${f},` };
181
- const t = m(e.attributes, { key: "class" });
179
+ }, ft = (e, n = "styles") => {
180
+ if (!e.attributes) return { [n]: `${x},` };
181
+ const t = y(e.attributes, { key: "class" });
182
182
  if (t) {
183
183
  const a = t.value;
184
- return { [n]: `${f},${a}` };
184
+ return { [n]: `${x},${a}` };
185
185
  }
186
- return { [n]: `${f},` };
186
+ return { [n]: `${x},` };
187
187
  }, _t = (e) => {
188
- const n = u(e, "attributes", []), t = n.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), a = n.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), s = n.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = n.find(
188
+ const n = d(e, "attributes", []), t = n.find((r) => r.key === "data-chai-richtext" || r.key === "chai-richtext"), a = n.find((r) => r.key === "data-chai-lightbox" || r.key === "chai-lightbox"), s = n.find((r) => r.key === "data-chai-dropdown" || r.key === "chai-dropdown"), o = n.find(
189
189
  (r) => r.key === "data-chai-dropdown-button" || r.key === "chai-dropdown-button"
190
- ), c = n.find(
190
+ ), i = n.find(
191
191
  (r) => r.key === "data-chai-dropdown-content" || r.key === "chai-dropdown-content"
192
192
  );
193
193
  if (s)
194
194
  return { _type: "Dropdown" };
195
195
  if (o)
196
196
  return { _type: "DropdownButton" };
197
- if (c)
197
+ if (i)
198
198
  return { _type: "DropdownContent" };
199
199
  if (t)
200
200
  return { _type: "RichText" };
@@ -278,7 +278,7 @@ const Lt = Y((e) => {
278
278
  case "tfoot":
279
279
  return { _type: "TableFooter" };
280
280
  default: {
281
- const r = u(e, "children", []).length > 0 ? "Box" : "EmptyBox";
281
+ const r = d(e, "children", []).length > 0 ? "Box" : "EmptyBox";
282
282
  return {
283
283
  _type: r,
284
284
  tag: e.tagName,
@@ -287,35 +287,35 @@ const Lt = Y((e) => {
287
287
  }
288
288
  }
289
289
  }, G = (e, n = null) => et(e, (t) => {
290
- var R, H, M, q, P, O, j, z, F, J;
290
+ var E, f, j, q, M, P, J, O, z, F;
291
291
  if (t.type === "comment") return [];
292
292
  let a = { _id: pt() };
293
293
  if (n && (a._parent = n.block._id), t.type === "text")
294
- return g(u(t, "content", "")) ? [] : n && ft(n.node, n.block) ? (k(n, "block.content", u(t, "content", "")), []) : { ...a, _type: "Text", content: u(t, "content", "") };
295
- const s = u(t, "attributes", []), o = s.find(
296
- (i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"
297
- ), c = s.find(
298
- (i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"
294
+ return b(d(t, "content", "")) ? [] : n && xt(n.node, n.block) ? (w(n, "block.content", d(t, "content", "")), []) : { ...a, _type: "Text", content: d(t, "content", "") };
295
+ const s = d(t, "attributes", []), o = s.find(
296
+ (l) => l.key === "data-chai-richtext" || l.key === "chai-richtext"
297
+ ), i = s.find(
298
+ (l) => l.key === "data-chai-lightbox" || l.key === "chai-lightbox"
299
299
  ), r = s.find(
300
- (i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"
300
+ (l) => l.key === "data-chai-dropdown" || l.key === "chai-dropdown"
301
+ ), m = s.find(
302
+ (l) => l.key === "data-chai-dropdown-button" || l.key === "chai-dropdown-button"
301
303
  ), p = s.find(
302
- (i) => i.key === "data-chai-dropdown-button" || i.key === "chai-dropdown-button"
303
- ), h = s.find(
304
- (i) => i.key === "data-chai-dropdown-content" || i.key === "chai-dropdown-content"
304
+ (l) => l.key === "data-chai-dropdown-content" || l.key === "chai-dropdown-content"
305
305
  );
306
306
  if (a = {
307
307
  ...a,
308
308
  ..._t(t),
309
309
  ...U(t),
310
- ...xt(t)
310
+ ...ft(t)
311
311
  }, t.attributes) {
312
- const i = t.attributes.find((l) => _(X, l.key));
313
- i && (a._name = i.value);
312
+ const l = t.attributes.find((c) => k(X, c.key));
313
+ l && (a._name = l.value);
314
314
  }
315
315
  if (o)
316
- return a.content = E(t.children), C(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], C(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
317
- if (c) {
318
- const i = [
316
+ return a.content = C(t.children), L(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], L(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
317
+ if (i) {
318
+ const l = [
319
319
  "data-chai-lightbox",
320
320
  "chai-lightbox",
321
321
  "data-vbtype",
@@ -327,87 +327,87 @@ const Lt = Y((e) => {
327
327
  ];
328
328
  a = {
329
329
  ...a,
330
- href: ((R = s.find((l) => l.key === "href")) == null ? void 0 : R.value) || "",
331
- hrefType: ((H = s.find((l) => l.key === "data-vbtype")) == null ? void 0 : H.value) || "video",
332
- autoplay: ((M = s.find((l) => l.key === "data-autoplay")) == null ? void 0 : M.value) === "true" ? "true" : "false",
333
- maxWidth: ((P = (q = s.find((l) => l.key === "data-maxwidth")) == null ? void 0 : q.value) == null ? void 0 : P.replace("px", "")) || "",
334
- backdropColor: ((O = s.find((l) => l.key === "data-overlay")) == null ? void 0 : O.value) || "",
335
- galleryName: ((j = s.find((l) => l.key === "data-gall")) == null ? void 0 : j.value) || ""
336
- }, $(i, (l) => {
337
- C(a, `styles_attrs.${l}`) && delete a.styles_attrs[l];
330
+ href: ((E = s.find((c) => c.key === "href")) == null ? void 0 : E.value) || "",
331
+ hrefType: ((f = s.find((c) => c.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
332
+ autoplay: ((j = s.find((c) => c.key === "data-autoplay")) == null ? void 0 : j.value) === "true" ? "true" : "false",
333
+ maxWidth: ((M = (q = s.find((c) => c.key === "data-maxwidth")) == null ? void 0 : q.value) == null ? void 0 : M.replace("px", "")) || "",
334
+ backdropColor: ((P = s.find((c) => c.key === "data-overlay")) == null ? void 0 : P.value) || "",
335
+ galleryName: ((J = s.find((c) => c.key === "data-gall")) == null ? void 0 : J.value) || ""
336
+ }, D(l, (c) => {
337
+ L(a, `styles_attrs.${c}`) && delete a.styles_attrs[c];
338
338
  });
339
339
  }
340
- if (r && (delete a.styles_attrs, a.showDropdown = !1), h && delete a.styles_attrs, p) {
340
+ if (r && (delete a.styles_attrs, a.showDropdown = !1), p && delete a.styles_attrs, m) {
341
341
  delete a.styles_attrs;
342
- const i = V(t.children || [], (d) => (d == null ? void 0 : d.tagName) !== "span");
343
- a.content = L(i);
344
- const l = m(
342
+ const l = V(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
343
+ a.content = A(l);
344
+ const c = y(
345
345
  t.children || [],
346
- (d) => (d == null ? void 0 : d.tagName) === "span" && st(d.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg")
346
+ (u) => (u == null ? void 0 : u.tagName) === "span" && at(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
347
347
  );
348
- if (l) {
349
- const d = m(l.children || [], (y) => (y == null ? void 0 : y.tagName) === "svg");
350
- if (d) {
351
- a.icon = E([d]);
352
- const { height: y, width: B } = kt(d, "16px", "16px");
353
- a.iconHeight = y, a.iconWidth = B;
348
+ if (c) {
349
+ const u = y(c.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
350
+ if (u) {
351
+ a.icon = C([u]);
352
+ const { height: h, width: $ } = kt(u, "16px", "16px");
353
+ a.iconHeight = h, a.iconWidth = $;
354
354
  }
355
355
  }
356
356
  return [a];
357
357
  }
358
358
  if (a._type === "Input") {
359
- const i = a.inputType || "text";
360
- i === "checkbox" ? k(a, "_type", "Checkbox") : i === "radio" && k(a, "_type", "Radio");
359
+ const l = a.inputType || "text";
360
+ l === "checkbox" ? w(a, "_type", "Checkbox") : l === "radio" && w(a, "_type", "Radio");
361
361
  } else if (t.tagName === "video" || t.tagName === "iframe") {
362
- const i = E([t]);
363
- return mt(i) && (k(a, "_type", "Video"), k(a, "url", gt(i)), k(a, "styles", `${f},`), k(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = i, [a];
362
+ const l = C([t]);
363
+ return mt(l) && (w(a, "_type", "Video"), w(a, "url", yt(l)), w(a, "styles", `${x},`), w(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = l, [a];
364
364
  } else if (t.tagName === "svg") {
365
- const i = u(m(t.attributes, { key: "class" }), "value", ""), { height: l, width: d } = Z(i);
366
- if (l && d)
367
- a.styles = `${f}, ${D(`w-${d} h-${l}`, i)}`.trim(), a.height = l == null ? void 0 : l.replace("px", ""), a.width = d == null ? void 0 : d.replace("px", "");
365
+ const l = d(y(t.attributes, { key: "class" }), "value", ""), { height: c, width: u } = Z(l);
366
+ if (c && u)
367
+ a.styles = `${x}, ${S(`w-${u} h-${c}`, l)}`.trim(), a.height = c == null ? void 0 : c.replace("px", ""), a.width = u == null ? void 0 : u.replace("px", "");
368
368
  else {
369
- const y = (z = m(t.attributes, { key: "height" })) == null ? void 0 : z.value, B = (F = m(t.attributes, { key: "width" })) == null ? void 0 : F.value;
370
- y && B ? (a.styles = `${f}, ${D(`w-[${B}px] h-[${y}px]`, i)}`.trim(), a.height = y, a.width = B) : a.styles = `${f}, ${D("w-full h-full", i)}`.trim();
369
+ const h = (O = y(t.attributes, { key: "height" })) == null ? void 0 : O.value, $ = (z = y(t.attributes, { key: "width" })) == null ? void 0 : z.value;
370
+ h && $ ? (a.styles = `${x}, ${S(`w-[${$}px] h-[${h}px]`, l)}`.trim(), a.height = h, a.width = $) : a.styles = `${x}, ${S("w-full h-full", l)}`.trim();
371
371
  }
372
- return t.attributes = V(t.attributes, (y) => !_(["style", "width", "height", "class"], y.key)), a.icon = E([t]), [a];
373
- } else if (t.tagName == "option" && n && ((J = n.block) == null ? void 0 : J._type) === "Select")
372
+ return t.attributes = V(t.attributes, (h) => !k(["style", "width", "height", "class"], h.key)), a.icon = C([t]), [a];
373
+ } else if (t.tagName == "option" && n && ((F = n.block) == null ? void 0 : F._type) === "Select")
374
374
  return n.block.options.push({
375
- label: L(t.children),
375
+ label: A(t.children),
376
376
  ...U(t)
377
377
  }), [];
378
- const w = G(t.children, { block: a, node: t });
379
- return [a, ...w];
378
+ const v = G(t.children, { block: a, node: t });
379
+ return [a, ...v];
380
380
  }), kt = (e, n, t) => {
381
- var p, h;
382
- const a = u(e, "attributes", []), { height: s, width: o } = Z(
383
- u(m(a, { key: "class" }), "value", "")
381
+ var m, p;
382
+ const a = d(e, "attributes", []), { height: s, width: o } = Z(
383
+ d(y(a, { key: "class" }), "value", "")
384
384
  );
385
385
  if (s && o)
386
386
  return {
387
387
  height: `[${s}px]`,
388
388
  width: `[${o}px]`
389
389
  };
390
- const c = (p = m(a, { key: "height" })) == null ? void 0 : p.value, r = (h = m(a, { key: "width" })) == null ? void 0 : h.value;
390
+ const i = (m = y(a, { key: "height" })) == null ? void 0 : m.value, r = (p = y(a, { key: "width" })) == null ? void 0 : p.value;
391
391
  return {
392
- height: c ? `[${c}px]` : t,
392
+ height: i ? `[${i}px]` : t,
393
393
  width: r ? `[${r}px]` : n
394
394
  };
395
395
  }, vt = (e) => {
396
396
  e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, s, o) => {
397
- let c = o.replace(/\\"/g, '"');
398
- return c = c.replace(/{([^}]+)}/g, (r) => r.replace(/"/g, '\\"')), `${s}="${c.replace(/\\"/g, '"')}"`;
397
+ let i = o.replace(/\\"/g, '"');
398
+ return i = i.replace(/{([^}]+)}/g, (r) => r.replace(/"/g, '\\"')), `${s}="${i.replace(/\\"/g, '"')}"`;
399
399
  }), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
400
400
  const n = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
401
401
  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();
402
402
  }, Rt = (e) => {
403
- const n = dt(vt(e));
404
- return g(e) ? [] : tt(G(n));
405
- }, x = (e) => {
406
- const n = ct(e);
403
+ const n = ut(vt(e));
404
+ return b(e) ? [] : tt(G(n));
405
+ }, _ = (e) => {
406
+ const n = lt(e);
407
407
  return e.map((t) => {
408
408
  const a = Object.keys(t);
409
409
  for (let s = 0; s < a.length; s++)
410
- if (T(t[a[s]]) && v(a[s], "content")) {
410
+ if (B(t[a[s]]) && T(a[s], "content")) {
411
411
  const o = t === n ? "" : " ";
412
412
  t[a[s]] = `${t[a[s]].trim()}${o}`;
413
413
  }
@@ -418,50 +418,50 @@ if (import.meta.vitest) {
418
418
  const { describe: e, it: n, expect: t } = import.meta.vitest;
419
419
  e("adjustSpacingInContentBlocks", () => {
420
420
  n("should add space after content fields except for the last block", () => {
421
- const s = x([
421
+ const s = _([
422
422
  { _id: "1", _type: "Text", content: "First" },
423
423
  { _id: "2", _type: "Text", content: "Second" },
424
424
  { _id: "3", _type: "Text", content: "Third" }
425
425
  ]);
426
426
  t(s[0].content).toBe("First "), t(s[1].content).toBe("Second "), t(s[2].content).toBe("Third");
427
427
  }), n("should trim whitespace from content before adding space", () => {
428
- const s = x([
428
+ const s = _([
429
429
  { _id: "1", _type: "Text", content: " First " },
430
430
  { _id: "2", _type: "Text", content: " Second " }
431
431
  ]);
432
432
  t(s[0].content).toBe("First "), t(s[1].content).toBe("Second");
433
433
  }), n("should handle multiple content fields in a single block", () => {
434
- const s = x([
434
+ const s = _([
435
435
  { _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
436
436
  { _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
437
437
  ]);
438
438
  t(s[0].content).toBe("Main "), t(s[0].contentAlt).toBe("Alt "), t(s[1].content).toBe("Last"), t(s[1].contentSecondary).toBe("Secondary");
439
439
  }), n("should only process fields that start with 'content'", () => {
440
- const s = x([
440
+ const s = _([
441
441
  { _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
442
442
  { _id: "2", _type: "Text", content: "Last" }
443
443
  ]);
444
444
  t(s[0].content).toBe("Text "), t(s[0].title).toBe("Title"), t(s[0].text).toBe("Text"), t(s[1].content).toBe("Last");
445
445
  }), n("should handle empty array", () => {
446
- const s = x([]);
446
+ const s = _([]);
447
447
  t(s).toEqual([]);
448
448
  }), n("should handle single block", () => {
449
- const s = x([{ _id: "1", _type: "Text", content: "Only" }]);
449
+ const s = _([{ _id: "1", _type: "Text", content: "Only" }]);
450
450
  t(s[0].content).toBe("Only");
451
451
  }), n("should handle blocks without content fields", () => {
452
- const s = x([
452
+ const s = _([
453
453
  { _id: "1", _type: "Container", title: "Title" },
454
454
  { _id: "2", _type: "Container", name: "Name" }
455
455
  ]);
456
456
  t(s[0].title).toBe("Title"), t(s[1].name).toBe("Name");
457
457
  }), n("should handle blocks with non-string content fields", () => {
458
- const s = x([
458
+ const s = _([
459
459
  { _id: "1", _type: "Text", content: "Text", contentNum: 123 },
460
460
  { _id: "2", _type: "Text", content: "Last", contentBool: !0 }
461
461
  ]);
462
462
  t(s[0].content).toBe("Text "), t(s[0].contentNum).toBe(123), t(s[1].content).toBe("Last"), t(s[1].contentBool).toBe(!0);
463
463
  }), n("should handle empty string content", () => {
464
- const s = x([
464
+ const s = _([
465
465
  { _id: "1", _type: "Text", content: "" },
466
466
  { _id: "2", _type: "Text", content: "Last" }
467
467
  ]);
@@ -469,36 +469,40 @@ if (import.meta.vitest) {
469
469
  });
470
470
  });
471
471
  }
472
- const b = (e, n, { index: t, key: a }) => {
473
- if (T(e)) {
474
- let s = e;
475
- const o = /\{\{(.*?)\}\}/g, c = e.match(o);
476
- return c && c.forEach((r) => {
477
- let p = r.slice(2, -2).trim(), h = a.slice(2, -2).trim();
478
- t !== -1 && v(p, "$index.") ? p = `${h}.${t}.${p.slice(7)}` : t !== -1 && v(p, "$index") && (p = `${h}.${t}`);
479
- const w = u(n, p);
480
- w === void 0 ? s = s.replace(r, "") : s = N(w) ? w : s.replace(r, w);
481
- }), s;
472
+ const g = (e, n, { index: t, key: a }, s) => {
473
+ if (B(e)) {
474
+ let o = e;
475
+ const i = /\{\{(.*?)\}\}/g, r = e.match(i);
476
+ if (r) {
477
+ const m = s === "image" || s === "mobileImage";
478
+ r.forEach((p) => {
479
+ let v = p.slice(2, -2).trim(), E = a.slice(2, -2).trim();
480
+ t !== -1 && T(v, "$index.") ? v = `${E}.${t}.${v.slice(7)}` : t !== -1 && T(v, "$index") && (v = `${E}.${t}`);
481
+ const f = d(n, v);
482
+ f === void 0 ? o = o.replace(p, "") : m && !I(f) ? o = f : o = I(f) ? f : o.replace(p, f);
483
+ });
484
+ }
485
+ return o;
482
486
  }
483
- if (N(e))
484
- return e.map((s) => b(s, n, { index: t, key: a }));
487
+ if (I(e))
488
+ return e.map((o) => g(o, n, { index: t, key: a }, s));
485
489
  if (e && typeof e == "object") {
486
- const s = {};
487
- return $(A(e), (o) => {
488
- !v(o, "_") && o !== "$repeaterItemsKey" ? s[o] = b(e[o], n, { index: t, key: a }) : s[o] = e[o];
489
- }), s;
490
+ const o = {};
491
+ return D(H(e), (i) => {
492
+ !T(i, "_") && i !== "$repeaterItemsKey" ? o[i] = g(e[i], n, { index: t, key: a }, i) : o[i] = e[i];
493
+ }), o;
490
494
  }
491
495
  return e;
492
- }, I = (e, n, { index: t, key: a }) => {
493
- let s = S(e);
494
- return s.repeaterItems && (s.$repeaterItemsKey = s.repeaterItems, v(s.repeaterItems, `{{${ut}`) && (s.$repeaterItemsKey = s.repeaterItems = `${s.repeaterItems.replace("}}", `/${s._id}}}`)}`), !g(s.repeaterItems) && s.pagination && (s.repeaterTotalItems = `${s.repeaterItems.replace("}}", `/${s._id}/totalItems}}`)}`)), b(s, n, { index: t, key: a });
496
+ }, N = (e, n, { index: t, key: a }) => {
497
+ let s = R(e);
498
+ return s.repeaterItems && (s.$repeaterItemsKey = s.repeaterItems, T(s.repeaterItems, `{{${dt}`) && (s.$repeaterItemsKey = s.repeaterItems = `${s.repeaterItems.replace("}}", `/${s._id}}}`)}`), !b(s.repeaterItems) && s.pagination && (s.repeaterTotalItems = `${s.repeaterItems.replace("}}", `/${s._id}/totalItems}}`)}`)), g(s, n, { index: t, key: a });
495
499
  };
496
500
  import.meta.vitest && (describe("applyBindingToValue", () => {
497
501
  it("should handle string values with bindings", () => {
498
- const t = b("Hello {{user.name}}", { user: { name: "John" } }, { index: -1, key: "" });
502
+ const t = g("Hello {{user.name}}", { user: { name: "John" } }, { index: -1, key: "" });
499
503
  expect(t).toBe("Hello John");
500
504
  }), it("should handle nested object properties", () => {
501
- const t = b({
505
+ const t = g({
502
506
  name: "John",
503
507
  address: {
504
508
  city: "{{user.city}}",
@@ -513,19 +517,19 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
513
517
  }
514
518
  });
515
519
  }), it("should handle arrays of values", () => {
516
- const t = b(["Hello {{user.name}}", "Welcome {{user.role}}"], { user: { name: "John", role: "Admin" } }, { index: -1, key: "" });
520
+ const t = g(["Hello {{user.name}}", "Welcome {{user.role}}"], { user: { name: "John", role: "Admin" } }, { index: -1, key: "" });
517
521
  expect(t).toEqual(["Hello John", "Welcome Admin"]);
518
522
  }), it("should handle $index binding in repeater context", () => {
519
- const t = b("Item {{$index}}", { items: ["a", "b", "c"] }, { index: 1, key: "{{items}}" });
523
+ const t = g("Item {{$index}}", { items: ["a", "b", "c"] }, { index: 1, key: "{{items}}" });
520
524
  expect(t).toBe("Item b");
521
525
  }), it("should handle $index binding with dot notation", () => {
522
- const t = b("Item {{$index.value}}", { items: [{ value: "apple" }, { value: "banana" }, { value: "cherry" }] }, { index: 1, key: "{{items}}" });
526
+ const t = g("Item {{$index.value}}", { items: [{ value: "apple" }, { value: "banana" }, { value: "cherry" }] }, { index: 1, key: "{{items}}" });
523
527
  expect(t).toBe("Item banana");
524
528
  }), it("should return an empty string for non-existing bindings", () => {
525
- const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
529
+ const t = g("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
526
530
  expect(t).toBe("Hello ");
527
531
  }), it("should preserve private properties starting with _", () => {
528
- const n = b({
532
+ const n = g({
529
533
  name: "John",
530
534
  _private: "secret"
531
535
  }, {}, { index: -1, key: "" });
@@ -533,10 +537,50 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
533
537
  name: "John",
534
538
  _private: "secret"
535
539
  });
540
+ }), it("should completely replace image property value when binding exists", () => {
541
+ const t = g({
542
+ image: "https://default.jpg{{user.avatar}}",
543
+ title: "Hello {{user.name}}"
544
+ }, { user: { avatar: "https://avatar.jpg", name: "John" } }, { index: -1, key: "" });
545
+ expect(t).toEqual({
546
+ image: "https://avatar.jpg",
547
+ // Completely replaced, not concatenated
548
+ title: "Hello John"
549
+ // Normal replacement
550
+ });
551
+ }), it("should completely replace mobileImage property value when binding exists", () => {
552
+ const t = g({
553
+ mobileImage: "https://default-mobile.jpg{{user.mobileAvatar}}",
554
+ alt: "Avatar for {{user.name}}"
555
+ }, { user: { mobileAvatar: "https://mobile-avatar.jpg", name: "John" } }, { index: -1, key: "" });
556
+ expect(t).toEqual({
557
+ mobileImage: "https://mobile-avatar.jpg",
558
+ // Completely replaced
559
+ alt: "Avatar for John"
560
+ // Normal replacement
561
+ });
562
+ }), it("should handle image binding with only binding syntax", () => {
563
+ const t = g({
564
+ image: "{{product.thumbnail}}"
565
+ }, { product: { thumbnail: "https://product.jpg" } }, { index: -1, key: "" });
566
+ expect(t).toEqual({
567
+ image: "https://product.jpg"
568
+ });
569
+ }), it("should not affect non-image properties with similar bindings", () => {
570
+ const t = g({
571
+ url: "https://default.com{{page.slug}}",
572
+ link: "https://example.com/{{page.id}}"
573
+ }, { page: { slug: "/about", id: "123" } }, { index: -1, key: "" });
574
+ expect(t).toEqual({
575
+ url: "https://default.com/about",
576
+ // Concatenated normally
577
+ link: "https://example.com/123"
578
+ // Concatenated normally
579
+ });
536
580
  });
537
581
  }), describe("applyBindingToBlockProps", () => {
538
582
  it("should handle basic block with bindings", () => {
539
- const t = I({
583
+ const t = N({
540
584
  _id: "test-block",
541
585
  _type: "text",
542
586
  type: "text",
@@ -555,7 +599,7 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
555
599
  }
556
600
  });
557
601
  }), it("should handle repeaterItems and repeaterItemsBinding", () => {
558
- const t = I({
602
+ const t = N({
559
603
  _id: "test-block",
560
604
  _type: "repeater",
561
605
  type: "repeater",
@@ -571,7 +615,7 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
571
615
  items: ["a", "b", "c"]
572
616
  });
573
617
  }), it("should handle nested blocks with bindings", () => {
574
- const t = I({
618
+ const t = N({
575
619
  _id: "test-block",
576
620
  _type: "container",
577
621
  type: "container",
@@ -604,7 +648,7 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
604
648
  ]
605
649
  });
606
650
  }), it("should handle arrays of blocks", () => {
607
- const t = I({
651
+ const t = N({
608
652
  _id: "test-block",
609
653
  _type: "list",
610
654
  type: "list",
@@ -625,16 +669,16 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
625
669
  });
626
670
  }));
627
671
  export {
628
- ut as C,
629
- Ct as R,
630
- f as S,
631
- I as a,
632
- Nt as b,
672
+ dt as C,
673
+ Dt as R,
674
+ x as S,
675
+ N as a,
676
+ Ct as b,
633
677
  Lt as c,
634
678
  St as d,
635
- x as e,
679
+ _ as e,
636
680
  At as f,
637
- Dt as g,
681
+ Nt as g,
638
682
  Rt as h,
639
683
  K as i,
640
684
  It as j