article-content-renderer-vue2 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,43 +1,43 @@
1
- var j = Object.defineProperty, z = Object.defineProperties;
2
- var M = Object.getOwnPropertyDescriptors;
3
- var S = Object.getOwnPropertySymbols;
4
- var Y = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
5
- var E = (i, r, t) => r in i ? j(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t, m = (i, r) => {
1
+ var J = Object.defineProperty, Q = Object.defineProperties;
2
+ var Z = Object.getOwnPropertyDescriptors;
3
+ var D = Object.getOwnPropertySymbols;
4
+ var tt = Object.prototype.hasOwnProperty, et = Object.prototype.propertyIsEnumerable;
5
+ var P = (i, r, t) => r in i ? J(i, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[r] = t, k = (i, r) => {
6
6
  for (var t in r || (r = {}))
7
- Y.call(r, t) && E(i, t, r[t]);
8
- if (S)
9
- for (var t of S(r))
10
- F.call(r, t) && E(i, t, r[t]);
7
+ tt.call(r, t) && P(i, t, r[t]);
8
+ if (D)
9
+ for (var t of D(r))
10
+ et.call(r, t) && P(i, t, r[t]);
11
11
  return i;
12
- }, A = (i, r) => z(i, M(r));
13
- var B = (i, r, t) => E(i, typeof r != "symbol" ? r + "" : r, t);
14
- import K from "vue";
15
- const G = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), W = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]), H = "https://article-content-renderer.invalid/", N = "https://www.doitme.link/";
16
- function X(i, r) {
12
+ }, E = (i, r) => Q(i, Z(r));
13
+ var $ = (i, r, t) => P(i, typeof r != "symbol" ? r + "" : r, t);
14
+ import Y from "vue";
15
+ const rt = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), it = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]), nt = "https://article-content-renderer.invalid/", _ = "https://www.doitme.link/";
16
+ function st(i, r) {
17
17
  if (typeof i != "string") return i;
18
18
  const t = i.trim();
19
- if (!t.startsWith(N)) return t;
20
- const n = (r.trim() || N).replace(/\/+$/u, ""), s = t.slice(N.length).replace(/^\/+/, "");
19
+ if (!t.startsWith(_)) return t;
20
+ const n = (r.trim() || _).replace(/\/+$/u, ""), s = t.slice(_.length).replace(/^\/+/, "");
21
21
  return `${n}/${s}`;
22
22
  }
23
- function T(i, r) {
23
+ function V(i, r) {
24
24
  if (typeof i != "string") return null;
25
25
  const t = i.trim();
26
26
  if (!t || /[\u0000-\u001F\u007F]/u.test(t)) return null;
27
27
  try {
28
- const e = new URL(t, H);
29
- return (r === "link" ? G : W).has(e.protocol) ? t : null;
28
+ const e = new URL(t, nt);
29
+ return (r === "link" ? rt : it).has(e.protocol) ? t : null;
30
30
  } catch (e) {
31
31
  return null;
32
32
  }
33
33
  }
34
- function U(i, r) {
34
+ function O(i, r) {
35
35
  const t = new Set(
36
36
  typeof i == "string" ? i.trim().split(/\s+/u).filter(Boolean) : []
37
37
  );
38
38
  return r === "_blank" && (t.add("noopener"), t.add("noreferrer")), t.size > 0 ? [...t].join(" ") : void 0;
39
39
  }
40
- const J = /* @__PURE__ */ new Set([
40
+ const ot = /* @__PURE__ */ new Set([
41
41
  "paragraph",
42
42
  "heading",
43
43
  "blockquote",
@@ -49,89 +49,147 @@ const J = /* @__PURE__ */ new Set([
49
49
  "articleButton",
50
50
  "table"
51
51
  ]);
52
- function p(i) {
52
+ function y(i) {
53
53
  return typeof i == "object" && i !== null && !Array.isArray(i);
54
54
  }
55
- function _(i) {
56
- return p(i) ? i : {};
55
+ function C(i) {
56
+ return y(i) ? i : {};
57
57
  }
58
- function f(i, r, t, e) {
58
+ function p(i, r, t, e) {
59
59
  var c;
60
- const n = p(t) ? t : {}, s = p(t) ? e : t, o = {}, l = {};
61
- for (const [u, h] of Object.entries(n))
60
+ const n = y(t) ? t : {}, s = y(t) ? e : t, o = {}, a = {};
61
+ for (const [u, g] of Object.entries(n))
62
62
  if (u === "class")
63
- o.class = h;
63
+ o.class = g;
64
64
  else if (u === "style")
65
- o.style = h;
66
- else if (u.startsWith("on") && typeof h == "function") {
67
- const y = u.slice(2).toLowerCase();
68
- o.on = A(m({}, (c = o.on) != null ? c : {}), { [y]: h });
69
- } else h !== void 0 && h !== !1 && (l[u] = h);
70
- return Object.keys(l).length > 0 && (o.attrs = l), i.createElement(r, o, s);
71
- }
72
- function k(i) {
65
+ o.style = g;
66
+ else if (u.startsWith("on") && typeof g == "function") {
67
+ const f = u.slice(2).toLowerCase();
68
+ o.on = E(k({}, (c = o.on) != null ? c : {}), { [f]: g });
69
+ } else g !== void 0 && g !== !1 && (a[u] = g);
70
+ return Object.keys(a).length > 0 && (o.attrs = a), i.createElement(r, o, s);
71
+ }
72
+ function I(i) {
73
73
  return Array.isArray(i) ? i : [];
74
74
  }
75
- function g(i, ...r) {
75
+ function h(i, ...r) {
76
76
  return `${i}/${r.map(String).join("/")}`;
77
77
  }
78
- function w(i) {
78
+ function j(i) {
79
79
  return i === "left" || i === "center" || i === "right" || i === "justify";
80
80
  }
81
- function Q(i) {
81
+ function at(i) {
82
82
  return i === "left" || i === "center" || i === "right";
83
83
  }
84
- function R(i) {
84
+ function S(i) {
85
85
  return i === "_blank" || i === "_self";
86
86
  }
87
- function b(i, r) {
87
+ function L(i, r) {
88
88
  i.reportIssue(r);
89
89
  }
90
- function Z(i, r, t) {
91
- if (!p(i) || i.type !== "text" || typeof i.text != "string" || !i.text)
90
+ function lt(i, r, t) {
91
+ var s, o, a;
92
+ if (!y(i) || i.type !== "text" || typeof i.text != "string" || !i.text)
92
93
  return null;
93
94
  let e = i.text;
94
- const n = k(i.marks);
95
- for (let s = 0; s < n.length; s += 1) {
96
- const o = n[s];
97
- if (!p(o) || typeof o.type != "string") continue;
98
- const l = g(r, "marks", s);
99
- switch (o.type) {
95
+ const n = I(i.marks);
96
+ for (let c = 0; c < n.length; c += 1) {
97
+ const u = n[c];
98
+ if (!y(u) || typeof u.type != "string") continue;
99
+ const g = h(r, "marks", c);
100
+ switch (u.type) {
100
101
  case "bold":
101
- e = f(t, "strong", { class: "acp-mark acp-mark--bold" }, [e]);
102
+ e = p(t, "strong", { class: "acp-mark acp-mark--bold" }, [e]);
102
103
  break;
103
104
  case "italic":
104
- e = f(t, "em", { class: "acp-mark acp-mark--italic" }, [e]);
105
+ e = p(t, "em", { class: "acp-mark acp-mark--italic" }, [e]);
105
106
  break;
106
107
  case "strike":
107
- e = f(t, "s", { class: "acp-mark acp-mark--strike" }, [e]);
108
+ e = p(t, "s", { class: "acp-mark acp-mark--strike" }, [e]);
108
109
  break;
109
110
  case "underline":
110
- e = f(t, "u", { class: "acp-mark acp-mark--underline" }, [e]);
111
+ e = p(t, "u", { class: "acp-mark acp-mark--underline" }, [e]);
111
112
  break;
112
113
  case "code":
113
- e = f(t, "code", { class: "acp-mark acp-mark--code" }, [e]);
114
+ e = p(t, "code", { class: "acp-mark acp-mark--code" }, [e]);
114
115
  break;
115
116
  case "link": {
116
- const c = _(o.attrs), u = T(c.href, "link");
117
- if (!u) {
118
- b(t, {
117
+ const f = C(u.attrs), b = S(f.target) ? f.target : "_blank";
118
+ if (f.type === "custom") {
119
+ if (typeof f.id != "string" || !f.id || typeof f.title != "string" || !f.title)
120
+ break;
121
+ const T = Object.freeze(k({
122
+ type: "custom",
123
+ id: f.id,
124
+ title: f.title
125
+ }, S(f.target) ? { target: f.target } : {})), X = Object.freeze({
126
+ type: "link",
127
+ attrs: T
128
+ });
129
+ let m = null;
130
+ if (!t.resolveCustomLink)
131
+ L(t, {
132
+ code: "LINK_RESOLUTION_FAILED",
133
+ path: g,
134
+ message: "No resolveCustomLink callback was provided for a custom link mark.",
135
+ nodeType: "link"
136
+ });
137
+ else
138
+ try {
139
+ const A = t.resolveCustomLink(T, X);
140
+ m = B(A, b), m || L(t, {
141
+ code: typeof A == "string" || y(A) && typeof A.href == "string" ? "UNSAFE_URL" : "LINK_RESOLUTION_FAILED",
142
+ path: g,
143
+ message: "The custom link resolver returned no usable safe URL.",
144
+ nodeType: "link"
145
+ });
146
+ } catch (A) {
147
+ L(t, {
148
+ code: "LINK_RESOLUTION_FAILED",
149
+ path: g,
150
+ message: `The custom link resolver threw an error: ${A instanceof Error ? A.message : String(A)}`,
151
+ nodeType: "link"
152
+ });
153
+ }
154
+ const N = (s = m == null ? void 0 : m.href) != null ? s : null, v = (o = m == null ? void 0 : m.target) != null ? o : b;
155
+ e = p(
156
+ t,
157
+ "a",
158
+ {
159
+ class: `acp-link acp-link--custom${N ? "" : " acp-link--disabled"}`,
160
+ href: N != null ? N : void 0,
161
+ target: v,
162
+ rel: (a = m == null ? void 0 : m.rel) != null ? a : O(void 0, v),
163
+ title: T.title,
164
+ "data-link-type": "custom",
165
+ "data-link-id": T.id,
166
+ "aria-disabled": N ? void 0 : "true",
167
+ onClick: N ? void 0 : (A) => A.preventDefault()
168
+ },
169
+ [e]
170
+ );
171
+ break;
172
+ }
173
+ if (f.type !== void 0 && f.type !== "href") break;
174
+ const U = V(f.href, "link");
175
+ if (!U) {
176
+ L(t, {
119
177
  code: "UNSAFE_URL",
120
- path: g(l, "attrs", "href"),
178
+ path: h(g, "attrs", "href"),
121
179
  message: "The link URL is empty, malformed, or uses a disallowed protocol.",
122
180
  nodeType: "link"
123
181
  });
124
182
  break;
125
183
  }
126
- const h = R(c.target) ? c.target : "_blank";
127
- e = f(
184
+ e = p(
128
185
  t,
129
186
  "a",
130
187
  {
131
188
  class: "acp-link",
132
- href: u,
133
- target: h,
134
- rel: U(void 0, h)
189
+ href: U,
190
+ target: b,
191
+ rel: O(void 0, b),
192
+ "data-link-type": "href"
135
193
  },
136
194
  [e]
137
195
  );
@@ -141,70 +199,70 @@ function Z(i, r, t) {
141
199
  }
142
200
  return e;
143
201
  }
144
- function O(i, r, t) {
145
- return k(i).map((e, n) => Z(e, g(r, n), t)).filter((e) => e !== null);
202
+ function x(i, r, t) {
203
+ return I(i).map((e, n) => lt(e, h(r, n), t)).filter((e) => e !== null);
146
204
  }
147
- function V(i, r, t) {
148
- return !p(i) || i.type !== "listItem" ? null : f(
205
+ function z(i, r, t) {
206
+ return !y(i) || i.type !== "listItem" ? null : p(
149
207
  t,
150
208
  "li",
151
209
  { class: "acp-list-item", "data-node-type": "listItem" },
152
- P(i.content, g(r, "content"), t)
210
+ q(i.content, h(r, "content"), t)
153
211
  );
154
212
  }
155
- function tt(i, r, t) {
156
- return !p(i) || i.type !== "tableCell" ? null : f(
213
+ function ct(i, r, t) {
214
+ return !y(i) || i.type !== "tableCell" ? null : p(
157
215
  t,
158
216
  "td",
159
217
  { class: "acp-table-cell", "data-node-type": "tableCell" },
160
- P(i.content, g(r, "content"), t)
218
+ q(i.content, h(r, "content"), t)
161
219
  );
162
220
  }
163
- function et(i, r, t) {
164
- if (!p(i) || i.type !== "tableRow") return null;
165
- const e = k(i.content).map((n, s) => tt(n, g(r, "content", s), t)).filter((n) => n !== null);
166
- return f(t, "tr", { class: "acp-table-row", "data-node-type": "tableRow" }, e);
221
+ function dt(i, r, t) {
222
+ if (!y(i) || i.type !== "tableRow") return null;
223
+ const e = I(i.content).map((n, s) => ct(n, h(r, "content", s), t)).filter((n) => n !== null);
224
+ return p(t, "tr", { class: "acp-table-row", "data-node-type": "tableRow" }, e);
167
225
  }
168
- function q(i) {
169
- var n;
170
- if (p(i) && i.target !== void 0 && !R(i.target) || p(i) && i.rel !== void 0 && typeof i.rel != "string") return null;
171
- const r = typeof i == "string" ? { href: i } : p(i) && typeof i.href == "string" ? m(m({
226
+ function B(i, r = "_self") {
227
+ var s;
228
+ if (y(i) && i.target !== void 0 && !S(i.target) || y(i) && i.rel !== void 0 && typeof i.rel != "string") return null;
229
+ const t = typeof i == "string" ? { href: i } : y(i) && typeof i.href == "string" ? k(k({
172
230
  href: i.href
173
- }, R(i.target) ? { target: i.target } : {}), typeof i.rel == "string" ? { rel: i.rel } : {}) : null;
174
- if (!r) return null;
175
- const t = T(r.href, "link");
231
+ }, S(i.target) ? { target: i.target } : {}), typeof i.rel == "string" ? { rel: i.rel } : {}) : null;
176
232
  if (!t) return null;
177
- const e = (n = r.target) != null ? n : "_self";
233
+ const e = V(t.href, "link");
234
+ if (!e) return null;
235
+ const n = (s = t.target) != null ? s : r;
178
236
  return {
179
- href: t,
180
- target: e,
181
- rel: U(r.rel, e)
237
+ href: e,
238
+ target: n,
239
+ rel: O(t.rel, n)
182
240
  };
183
241
  }
184
- function rt(i, r, t) {
185
- var h;
186
- const e = _(i.attrs), n = e.style === "text" || e.style === "button", s = e.style === "link";
242
+ function ut(i, r, t) {
243
+ var g;
244
+ const e = C(i.attrs), n = e.style === "text" || e.style === "button", s = e.style === "link";
187
245
  if (typeof e.text != "string" || !e.text || !n && !s || n && (typeof e.id != "string" || !e.id) || s && e.id !== void 0 && (typeof e.id != "string" || !e.id))
188
246
  return null;
189
- const o = Object.freeze(s ? m(A(m(m({}, typeof e.id == "string" ? { id: e.id } : {}), typeof e.title == "string" ? { title: e.title } : {}), {
247
+ const o = Object.freeze(s ? k(E(k(k({}, typeof e.id == "string" ? { id: e.id } : {}), typeof e.title == "string" ? { title: e.title } : {}), {
190
248
  text: e.text,
191
249
  style: "link"
192
- }), typeof e.href == "string" ? { href: e.href } : {}) : A(m({
250
+ }), typeof e.href == "string" ? { href: e.href } : {}) : E(k({
193
251
  id: e.id
194
252
  }, typeof e.title == "string" ? { title: e.title } : {}), {
195
253
  text: e.text,
196
254
  style: e.style
197
- })), l = Object.freeze({ type: "articleButton", attrs: o });
255
+ })), a = Object.freeze({ type: "articleButton", attrs: o });
198
256
  let c = null;
199
257
  if (o.style === "link")
200
- o.href !== void 0 && (c = q(o.href), c || b(t, {
258
+ o.href !== void 0 && (c = B(o.href), c || L(t, {
201
259
  code: "UNSAFE_URL",
202
260
  path: `${r}/attrs/href`,
203
261
  message: "The articleButton link href is not a usable safe URL.",
204
262
  nodeType: "articleButton"
205
263
  }));
206
264
  else if (!t.resolveArticleButtonLink)
207
- b(t, {
265
+ L(t, {
208
266
  code: "LINK_RESOLUTION_FAILED",
209
267
  path: r,
210
268
  message: "No resolveArticleButtonLink callback was provided for an articleButton node.",
@@ -212,23 +270,23 @@ function rt(i, r, t) {
212
270
  });
213
271
  else
214
272
  try {
215
- const y = Object.freeze({ type: "articleButton", attrs: o }), L = t.resolveArticleButtonLink(o, y);
216
- c = q(L), c || b(t, {
217
- code: typeof L == "string" || p(L) && typeof L.href == "string" ? "UNSAFE_URL" : "LINK_RESOLUTION_FAILED",
273
+ const f = Object.freeze({ type: "articleButton", attrs: o }), b = t.resolveArticleButtonLink(o, f);
274
+ c = B(b), c || L(t, {
275
+ code: typeof b == "string" || y(b) && typeof b.href == "string" ? "UNSAFE_URL" : "LINK_RESOLUTION_FAILED",
218
276
  path: r,
219
277
  message: "The articleButton link resolver returned no usable safe URL.",
220
278
  nodeType: "articleButton"
221
279
  });
222
- } catch (y) {
223
- b(t, {
280
+ } catch (f) {
281
+ L(t, {
224
282
  code: "LINK_RESOLUTION_FAILED",
225
283
  path: r,
226
- message: `The articleButton link resolver threw an error: ${y instanceof Error ? y.message : String(y)}`,
284
+ message: `The articleButton link resolver threw an error: ${f instanceof Error ? f.message : String(f)}`,
227
285
  nodeType: "articleButton"
228
286
  });
229
287
  }
230
- const u = (h = c == null ? void 0 : c.href) != null ? h : null;
231
- return f(
288
+ const u = (g = c == null ? void 0 : c.href) != null ? g : null;
289
+ return p(
232
290
  t,
233
291
  "a",
234
292
  {
@@ -245,21 +303,21 @@ function rt(i, r, t) {
245
303
  "data-article-button-id": o.id,
246
304
  "data-article-button-style": o.style,
247
305
  "aria-disabled": u ? void 0 : "true",
248
- onClick: (y) => {
249
- u || y.preventDefault(), t.emitArticleButtonClick({ attrs: o, node: l, href: u, event: y });
306
+ onClick: (f) => {
307
+ u || f.preventDefault(), t.emitArticleButtonClick({ attrs: o, node: a, href: u, event: f });
250
308
  }
251
309
  },
252
310
  o.text
253
311
  );
254
312
  }
255
- function D(i, r, t) {
256
- if (!p(i) || typeof i.type != "string" || !J.has(i.type))
313
+ function K(i, r, t) {
314
+ if (!y(i) || typeof i.type != "string" || !ot.has(i.type))
257
315
  return null;
258
- const e = _(i.attrs);
316
+ const e = C(i.attrs);
259
317
  switch (i.type) {
260
318
  case "paragraph": {
261
- const n = w(e.textAlign) ? e.textAlign : void 0;
262
- return f(
319
+ const n = j(e.textAlign) ? e.textAlign : void 0;
320
+ return p(
263
321
  t,
264
322
  "p",
265
323
  {
@@ -267,12 +325,12 @@ function D(i, r, t) {
267
325
  "data-node-type": "paragraph",
268
326
  style: n ? { textAlign: n } : void 0
269
327
  },
270
- O(i.content, g(r, "content"), t)
328
+ x(i.content, h(r, "content"), t)
271
329
  );
272
330
  }
273
331
  case "heading": {
274
- const n = Number.isInteger(e.level) && Number(e.level) >= 1 && Number(e.level) <= 6 ? Number(e.level) : 1, s = w(e.textAlign) ? e.textAlign : void 0;
275
- return f(
332
+ const n = Number.isInteger(e.level) && Number(e.level) >= 1 && Number(e.level) <= 6 ? Number(e.level) : 1, s = j(e.textAlign) ? e.textAlign : void 0;
333
+ return p(
276
334
  t,
277
335
  `h${n}`,
278
336
  {
@@ -280,23 +338,23 @@ function D(i, r, t) {
280
338
  "data-node-type": "heading",
281
339
  style: s ? { textAlign: s } : void 0
282
340
  },
283
- O(i.content, g(r, "content"), t)
341
+ x(i.content, h(r, "content"), t)
284
342
  );
285
343
  }
286
344
  case "blockquote":
287
- return f(
345
+ return p(
288
346
  t,
289
347
  "blockquote",
290
348
  { class: "acp-blockquote", "data-node-type": "blockquote" },
291
- P(i.content, g(r, "content"), t)
349
+ q(i.content, h(r, "content"), t)
292
350
  );
293
351
  case "bulletList": {
294
- const n = k(i.content).map((s, o) => V(s, g(r, "content", o), t)).filter((s) => s !== null);
295
- return f(t, "ul", { class: "acp-list acp-list--bullet", "data-node-type": "bulletList" }, n);
352
+ const n = I(i.content).map((s, o) => z(s, h(r, "content", o), t)).filter((s) => s !== null);
353
+ return p(t, "ul", { class: "acp-list acp-list--bullet", "data-node-type": "bulletList" }, n);
296
354
  }
297
355
  case "orderedList": {
298
- const n = Number.isInteger(e.start) && Number(e.start) >= 1 ? Number(e.start) : 1, s = k(i.content).map((o, l) => V(o, g(r, "content", l), t)).filter((o) => o !== null);
299
- return f(
356
+ const n = Number.isInteger(e.start) && Number(e.start) >= 1 ? Number(e.start) : 1, s = I(i.content).map((o, a) => z(o, h(r, "content", a), t)).filter((o) => o !== null);
357
+ return p(
300
358
  t,
301
359
  "ol",
302
360
  {
@@ -308,8 +366,8 @@ function D(i, r, t) {
308
366
  );
309
367
  }
310
368
  case "codeBlock": {
311
- const n = typeof e.language == "string" && e.language ? e.language : void 0, s = k(i.content).filter((o) => p(o) && o.type === "text" && typeof o.text == "string").map((o) => o.text).join("");
312
- return f(
369
+ const n = typeof e.language == "string" && e.language ? e.language : void 0, s = I(i.content).filter((o) => y(o) && o.type === "text" && typeof o.text == "string").map((o) => o.text).join("");
370
+ return p(
313
371
  t,
314
372
  "pre",
315
373
  {
@@ -317,22 +375,22 @@ function D(i, r, t) {
317
375
  "data-node-type": "codeBlock",
318
376
  "data-language": n
319
377
  },
320
- [f(t, "code", { class: n ? `language-${n}` : void 0 }, s)]
378
+ [p(t, "code", { class: n ? `language-${n}` : void 0 }, s)]
321
379
  );
322
380
  }
323
381
  case "horizontalRule":
324
- return f(t, "hr", { class: "acp-horizontal-rule", "data-node-type": "horizontalRule" });
382
+ return p(t, "hr", { class: "acp-horizontal-rule", "data-node-type": "horizontalRule" });
325
383
  case "image": {
326
- const n = T(X(e.src, t.imageBaseUrl), "image");
384
+ const n = V(st(e.src, t.imageBaseUrl), "image");
327
385
  if (!n)
328
- return b(t, {
386
+ return L(t, {
329
387
  code: "UNSAFE_URL",
330
- path: g(r, "attrs", "src"),
388
+ path: h(r, "attrs", "src"),
331
389
  message: "The image URL is empty, malformed, or uses a disallowed protocol.",
332
390
  nodeType: "image"
333
391
  }), null;
334
- const s = Q(e.imageAlign) ? e.imageAlign : "center", o = Number.isInteger(e.width) && Number(e.width) >= 1 && Number(e.width) <= 1e4 ? Number(e.width) : void 0, l = Number.isInteger(e.height) && Number(e.height) >= 1 && Number(e.height) <= 1e4 ? Number(e.height) : void 0;
335
- return f(
392
+ const s = at(e.imageAlign) ? e.imageAlign : "center", o = Number.isInteger(e.width) && Number(e.width) >= 1 && Number(e.width) <= 1e4 ? Number(e.width) : void 0, a = Number.isInteger(e.height) && Number(e.height) >= 1 && Number(e.height) <= 1e4 ? Number(e.height) : void 0;
393
+ return p(
336
394
  t,
337
395
  "div",
338
396
  {
@@ -341,57 +399,57 @@ function D(i, r, t) {
341
399
  "data-image-align": s
342
400
  },
343
401
  [
344
- f(t, "img", {
402
+ p(t, "img", {
345
403
  class: "acp-image__element",
346
404
  src: n,
347
405
  alt: typeof e.alt == "string" ? e.alt : "",
348
406
  title: typeof e.title == "string" ? e.title : void 0,
349
407
  width: o,
350
- height: l,
408
+ height: a,
351
409
  "data-image-align": s
352
410
  })
353
411
  ]
354
412
  );
355
413
  }
356
414
  case "articleButton":
357
- return rt(i, r, t);
415
+ return ut(i, r, t);
358
416
  case "table": {
359
- const n = k(i.content).map((s, o) => et(s, g(r, "content", o), t)).filter((s) => s !== null);
360
- return f(
417
+ const n = I(i.content).map((s, o) => dt(s, h(r, "content", o), t)).filter((s) => s !== null);
418
+ return p(
361
419
  t,
362
420
  "div",
363
421
  { class: "acp-table-wrapper", "data-node-type": "table" },
364
- [f(t, "table", { class: "acp-table" }, [f(t, "tbody", n)])]
422
+ [p(t, "table", { class: "acp-table" }, [p(t, "tbody", n)])]
365
423
  );
366
424
  }
367
425
  }
368
426
  return null;
369
427
  }
370
- function P(i, r, t) {
371
- return k(i).map((e, n) => D(e, g(r, n), t)).filter((e) => e !== null);
428
+ function q(i, r, t) {
429
+ return I(i).map((e, n) => K(e, h(r, n), t)).filter((e) => e !== null);
372
430
  }
373
- function it(i, r) {
374
- const t = k(i.content), e = /* @__PURE__ */ new Map();
431
+ function ft(i, r) {
432
+ const t = I(i.content), e = /* @__PURE__ */ new Map();
375
433
  r.customSlots.forEach((s) => {
376
- var l;
434
+ var a;
377
435
  if (!Number.isInteger(s.location) || s.location < 1 || s.location > t.length)
378
436
  return;
379
- const o = (l = e.get(s.location)) != null ? l : [];
437
+ const o = (a = e.get(s.location)) != null ? a : [];
380
438
  o.push(s), e.set(s.location, o);
381
439
  });
382
440
  const n = [];
383
441
  return t.forEach((s, o) => {
384
442
  var u;
385
- const l = o + 1;
386
- (u = e.get(l)) == null || u.forEach((h) => n.push(...h.content));
387
- const c = D(s, g("/content", o), r);
443
+ const a = o + 1;
444
+ (u = e.get(a)) == null || u.forEach((g) => n.push(...g.content));
445
+ const c = K(s, h("/content", o), r);
388
446
  c && typeof c != "string" && n.push(c);
389
447
  }), n;
390
448
  }
391
- function nt(i, r) {
392
- return !p(i) || i.type !== "doc" ? [] : it(i, r);
449
+ function pt(i, r) {
450
+ return !y(i) || i.type !== "doc" ? [] : ft(i, r);
393
451
  }
394
- const st = /* @__PURE__ */ new Set([
452
+ const gt = /* @__PURE__ */ new Set([
395
453
  "paragraph",
396
454
  "heading",
397
455
  "blockquote",
@@ -402,28 +460,28 @@ const st = /* @__PURE__ */ new Set([
402
460
  "image",
403
461
  "articleButton",
404
462
  "table"
405
- ]), ot = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), at = /* @__PURE__ */ new Set(["left", "center", "right"]), lt = /* @__PURE__ */ new Set(["bold", "italic", "strike", "underline", "code"]);
406
- function I(i) {
463
+ ]), yt = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), ht = /* @__PURE__ */ new Set(["left", "center", "right"]), mt = /* @__PURE__ */ new Set(["bold", "italic", "strike", "underline", "code"]);
464
+ function R(i) {
407
465
  return typeof i == "object" && i !== null && !Array.isArray(i);
408
466
  }
409
- function a(i, r) {
467
+ function l(i, r) {
410
468
  return `${i}/${String(r).replaceAll("~", "~0").replaceAll("/", "~1")}`;
411
469
  }
412
470
  function d(i, ...r) {
413
471
  let t = i;
414
- for (const e of r) t = a(t, e);
472
+ for (const e of r) t = l(t, e);
415
473
  return t;
416
474
  }
417
- class ct {
475
+ class kt {
418
476
  constructor() {
419
- B(this, "issues", []);
477
+ $(this, "issues", []);
420
478
  }
421
479
  validate(r) {
422
- if (!I(r))
480
+ if (!R(r))
423
481
  return this.add("INVALID_ROOT", "", "The document must be an object."), this.result();
424
482
  this.checkProperties(r, "", ["type", "content"], ["type", "content"]), r.type !== "doc" && this.add("INVALID_ROOT", "/type", 'The root node type must be "doc".');
425
483
  const t = this.requireArray(r.content, "/content");
426
- return t == null || t.forEach((e, n) => this.validateBlock(e, a("/content", n))), this.result();
484
+ return t == null || t.forEach((e, n) => this.validateBlock(e, l("/content", n))), this.result();
427
485
  }
428
486
  result() {
429
487
  return {
@@ -432,22 +490,22 @@ class ct {
432
490
  };
433
491
  }
434
492
  add(r, t, e, n) {
435
- this.issues.push(m({ code: r, path: t, message: e }, n ? { nodeType: n } : {}));
493
+ this.issues.push(k({ code: r, path: t, message: e }, n ? { nodeType: n } : {}));
436
494
  }
437
495
  checkProperties(r, t, e, n = [], s) {
438
496
  const o = new Set(e);
439
- for (const l of Object.keys(r))
440
- o.has(l) || this.add(
497
+ for (const a of Object.keys(r))
498
+ o.has(a) || this.add(
441
499
  "UNKNOWN_PROPERTY",
442
- a(t, l),
443
- `Property "${l}" is not allowed.`,
500
+ l(t, a),
501
+ `Property "${a}" is not allowed.`,
444
502
  s
445
503
  );
446
- for (const l of n)
447
- l in r || this.add(
504
+ for (const a of n)
505
+ a in r || this.add(
448
506
  "MISSING_PROPERTY",
449
- a(t, l),
450
- `Required property "${l}" is missing.`,
507
+ l(t, a),
508
+ `Required property "${a}" is missing.`,
451
509
  s
452
510
  );
453
511
  }
@@ -467,7 +525,7 @@ class ct {
467
525
  ), n;
468
526
  }
469
527
  requireRecord(r, t, e) {
470
- return I(r) ? r : (this.add("INVALID_TYPE", t, "Expected an object.", e), null);
528
+ return R(r) ? r : (this.add("INVALID_TYPE", t, "Expected an object.", e), null);
471
529
  }
472
530
  optionalRecord(r, t, e) {
473
531
  return r === void 0 ? {} : this.requireRecord(r, t, e);
@@ -490,17 +548,17 @@ class ct {
490
548
  return n !== void 0 && o < n ? (this.add("INVALID_VALUE", t, `Value must be at least ${n}.`, e), !1) : s !== void 0 && o > s ? (this.add("INVALID_VALUE", t, `Value must be at most ${s}.`, e), !1) : !0;
491
549
  }
492
550
  validateBlock(r, t) {
493
- if (!I(r)) {
551
+ if (!R(r)) {
494
552
  this.add("INVALID_TYPE", t, "A block node must be an object.");
495
553
  return;
496
554
  }
497
555
  const e = r.type;
498
556
  if (typeof e != "string") {
499
- this.add("MISSING_PROPERTY", a(t, "type"), "A block node requires a type.");
557
+ this.add("MISSING_PROPERTY", l(t, "type"), "A block node requires a type.");
500
558
  return;
501
559
  }
502
- if (!st.has(e)) {
503
- this.add("UNKNOWN_NODE", a(t, "type"), `Unknown block node "${e}".`, e);
560
+ if (!gt.has(e)) {
561
+ this.add("UNKNOWN_NODE", l(t, "type"), `Unknown block node "${e}".`, e);
504
562
  return;
505
563
  }
506
564
  switch (e) {
@@ -538,115 +596,159 @@ class ct {
538
596
  }
539
597
  validateParagraph(r, t) {
540
598
  const e = "paragraph";
541
- this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e), this.validateTextAlignAttrs(r.attrs, a(t, "attrs"), e, !1), this.validateInlineContent(r.content, a(t, "content"), e);
599
+ this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e), this.validateTextAlignAttrs(r.attrs, l(t, "attrs"), e, !1), this.validateInlineContent(r.content, l(t, "content"), e);
542
600
  }
543
601
  validateHeading(r, t) {
544
602
  const e = "heading";
545
603
  this.checkProperties(r, t, ["type", "attrs", "content"], ["type", "attrs"], e);
546
- const n = this.requireRecord(r.attrs, a(t, "attrs"), e);
547
- n && (this.checkProperties(n, a(t, "attrs"), ["level", "textAlign"], ["level"], e), this.requireInteger(n.level, d(t, "attrs", "level"), e, 1, 6), this.validateTextAlign(n.textAlign, d(t, "attrs", "textAlign"), e)), this.validateInlineContent(r.content, a(t, "content"), e);
604
+ const n = this.requireRecord(r.attrs, l(t, "attrs"), e);
605
+ n && (this.checkProperties(n, l(t, "attrs"), ["level", "textAlign"], ["level"], e), this.requireInteger(n.level, d(t, "attrs", "level"), e, 1, 6), this.validateTextAlign(n.textAlign, d(t, "attrs", "textAlign"), e)), this.validateInlineContent(r.content, l(t, "content"), e);
548
606
  }
549
607
  validateTextAlignAttrs(r, t, e, n) {
550
608
  const s = n ? this.requireRecord(r, t, e) : this.optionalRecord(r, t, e);
551
- s && (this.checkProperties(s, t, ["textAlign"], [], e), this.validateTextAlign(s.textAlign, a(t, "textAlign"), e));
609
+ s && (this.checkProperties(s, t, ["textAlign"], [], e), this.validateTextAlign(s.textAlign, l(t, "textAlign"), e));
552
610
  }
553
611
  validateTextAlign(r, t, e) {
554
- r !== void 0 && (typeof r != "string" ? this.add("INVALID_TYPE", t, "Text alignment must be a string.", e) : ot.has(r) || this.add("INVALID_VALUE", t, `Unsupported text alignment "${r}".`, e));
612
+ r !== void 0 && (typeof r != "string" ? this.add("INVALID_TYPE", t, "Text alignment must be a string.", e) : yt.has(r) || this.add("INVALID_VALUE", t, `Unsupported text alignment "${r}".`, e));
555
613
  }
556
614
  validateInlineContent(r, t, e) {
557
615
  const n = this.optionalArray(r, t, e);
558
- n == null || n.forEach((s, o) => this.validateText(s, a(t, o), !0));
616
+ n == null || n.forEach((s, o) => this.validateText(s, l(t, o), !0));
559
617
  }
560
618
  validateText(r, t, e) {
561
- if (!I(r)) {
619
+ if (!R(r)) {
562
620
  this.add("INVALID_TYPE", t, "A text node must be an object.", "text");
563
621
  return;
564
622
  }
565
623
  const n = e ? ["type", "text", "marks"] : ["type", "text"];
566
- if (this.checkProperties(r, t, n, ["type", "text"], "text"), r.type !== "text" && this.add("INVALID_CONTENT", a(t, "type"), "Expected a text node.", "text"), this.requireString(r.text, a(t, "text"), "text"), e && r.marks !== void 0) {
567
- const s = this.requireArray(r.marks, a(t, "marks"), "text");
568
- s == null || s.forEach((o, l) => this.validateMark(o, d(t, "marks", l)));
624
+ if (this.checkProperties(r, t, n, ["type", "text"], "text"), r.type !== "text" && this.add("INVALID_CONTENT", l(t, "type"), "Expected a text node.", "text"), this.requireString(r.text, l(t, "text"), "text"), e && r.marks !== void 0) {
625
+ const s = this.requireArray(r.marks, l(t, "marks"), "text");
626
+ s == null || s.forEach((o, a) => this.validateMark(o, d(t, "marks", a)));
569
627
  }
570
628
  }
571
629
  validateMark(r, t) {
572
- if (!I(r)) {
630
+ var s;
631
+ if (!R(r)) {
573
632
  this.add("INVALID_TYPE", t, "A mark must be an object.");
574
633
  return;
575
634
  }
576
635
  if (typeof r.type != "string") {
577
- this.add("MISSING_PROPERTY", a(t, "type"), "A mark requires a type.");
636
+ this.add("MISSING_PROPERTY", l(t, "type"), "A mark requires a type.");
578
637
  return;
579
638
  }
580
- if (lt.has(r.type)) {
639
+ if (mt.has(r.type)) {
581
640
  this.checkProperties(r, t, ["type"], ["type"], r.type);
582
641
  return;
583
642
  }
584
643
  if (r.type !== "link") {
585
- this.add("UNKNOWN_MARK", a(t, "type"), `Unknown mark "${r.type}".`, r.type);
644
+ this.add("UNKNOWN_MARK", l(t, "type"), `Unknown mark "${r.type}".`, r.type);
586
645
  return;
587
646
  }
588
647
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], "link");
589
- const e = this.requireRecord(r.attrs, a(t, "attrs"), "link");
590
- e && (this.checkProperties(e, a(t, "attrs"), ["href", "target"], ["href"], "link"), this.requireString(e.href, d(t, "attrs", "href"), "link"), e.target !== void 0 && e.target !== "_blank" && e.target !== "_self" && this.add(
648
+ const e = this.requireRecord(r.attrs, l(t, "attrs"), "link");
649
+ if (!e) return;
650
+ this.checkProperties(
651
+ e,
652
+ l(t, "attrs"),
653
+ ["type", "href", "id", "title", "target"],
654
+ [],
655
+ "link"
656
+ ), e.type !== void 0 && e.type !== "href" && e.type !== "custom" && this.add(
657
+ "INVALID_VALUE",
658
+ d(t, "attrs", "type"),
659
+ 'Link type must be "href" or "custom".',
660
+ "link"
661
+ );
662
+ const n = (s = e.type) != null ? s : "href";
663
+ if (n === "custom") {
664
+ for (const o of ["id", "title"])
665
+ o in e ? this.requireString(e[o], d(t, "attrs", o), "link") : this.add(
666
+ "MISSING_PROPERTY",
667
+ d(t, "attrs", o),
668
+ `Required property "${o}" is missing for a custom link.`,
669
+ "link"
670
+ );
671
+ e.href !== void 0 && this.add(
672
+ "INVALID_VALUE",
673
+ d(t, "attrs", "href"),
674
+ "A custom link must not contain href.",
675
+ "link"
676
+ );
677
+ } else if (n === "href") {
678
+ "href" in e ? this.requireString(e.href, d(t, "attrs", "href"), "link") : this.add(
679
+ "MISSING_PROPERTY",
680
+ d(t, "attrs", "href"),
681
+ 'Required property "href" is missing for an href link.',
682
+ "link"
683
+ );
684
+ for (const o of ["id", "title"])
685
+ e[o] !== void 0 && this.add(
686
+ "INVALID_VALUE",
687
+ d(t, "attrs", o),
688
+ `An href link must not contain ${o}.`,
689
+ "link"
690
+ );
691
+ }
692
+ e.target !== void 0 && e.target !== "_blank" && e.target !== "_self" && this.add(
591
693
  "INVALID_VALUE",
592
694
  d(t, "attrs", "target"),
593
695
  'Link target must be "_blank" or "_self".',
594
696
  "link"
595
- ));
697
+ );
596
698
  }
597
699
  validateBlockquote(r, t) {
598
700
  const e = "blockquote";
599
701
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
600
- const n = this.requireNonEmptyArray(r.content, a(t, "content"), e);
702
+ const n = this.requireNonEmptyArray(r.content, l(t, "content"), e);
601
703
  n == null || n.forEach((s, o) => this.validateBlock(s, d(t, "content", o)));
602
704
  }
603
705
  validateBulletList(r, t) {
604
706
  const e = "bulletList";
605
707
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
606
- const n = this.requireNonEmptyArray(r.content, a(t, "content"), e);
708
+ const n = this.requireNonEmptyArray(r.content, l(t, "content"), e);
607
709
  n == null || n.forEach((s, o) => this.validateListItem(s, d(t, "content", o)));
608
710
  }
609
711
  validateOrderedList(r, t) {
610
712
  const e = "orderedList";
611
713
  this.checkProperties(r, t, ["type", "attrs", "content"], ["type", "content"], e);
612
- const n = this.optionalRecord(r.attrs, a(t, "attrs"), e);
613
- n && (this.checkProperties(n, a(t, "attrs"), ["start"], [], e), n.start !== void 0 && this.requireInteger(n.start, d(t, "attrs", "start"), e, 1));
614
- const s = this.requireNonEmptyArray(r.content, a(t, "content"), e);
615
- s == null || s.forEach((o, l) => this.validateListItem(o, d(t, "content", l)));
714
+ const n = this.optionalRecord(r.attrs, l(t, "attrs"), e);
715
+ n && (this.checkProperties(n, l(t, "attrs"), ["start"], [], e), n.start !== void 0 && this.requireInteger(n.start, d(t, "attrs", "start"), e, 1));
716
+ const s = this.requireNonEmptyArray(r.content, l(t, "content"), e);
717
+ s == null || s.forEach((o, a) => this.validateListItem(o, d(t, "content", a)));
616
718
  }
617
719
  validateListItem(r, t) {
618
720
  const e = "listItem", n = this.requireRecord(r, t, e);
619
721
  if (!n) return;
620
- this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", a(t, "type"), "Expected a listItem node.", e);
621
- const s = this.requireNonEmptyArray(n.content, a(t, "content"), e);
622
- s == null || s.forEach((o, l) => this.validateBlock(o, d(t, "content", l)));
722
+ this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", l(t, "type"), "Expected a listItem node.", e);
723
+ const s = this.requireNonEmptyArray(n.content, l(t, "content"), e);
724
+ s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
623
725
  }
624
726
  validateCodeBlock(r, t) {
625
727
  const e = "codeBlock";
626
728
  this.checkProperties(r, t, ["type", "attrs", "content"], ["type"], e);
627
- const n = this.optionalRecord(r.attrs, a(t, "attrs"), e);
628
- n && (this.checkProperties(n, a(t, "attrs"), ["language"], [], e), this.optionalString(n.language, d(t, "attrs", "language"), e, { maxLength: 32 }));
629
- const s = this.optionalArray(r.content, a(t, "content"), e);
729
+ const n = this.optionalRecord(r.attrs, l(t, "attrs"), e);
730
+ n && (this.checkProperties(n, l(t, "attrs"), ["language"], [], e), this.optionalString(n.language, d(t, "attrs", "language"), e, { maxLength: 32 }));
731
+ const s = this.optionalArray(r.content, l(t, "content"), e);
630
732
  s && (s.length > 1 && this.add(
631
733
  "INVALID_CONTENT",
632
- a(t, "content"),
734
+ l(t, "content"),
633
735
  "A codeBlock may contain at most one text node.",
634
736
  e
635
737
  ), s.forEach(
636
- (o, l) => this.validateText(o, d(t, "content", l), !1)
738
+ (o, a) => this.validateText(o, d(t, "content", a), !1)
637
739
  ));
638
740
  }
639
741
  validateImage(r, t) {
640
742
  const e = "image";
641
743
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
642
- const n = this.requireRecord(r.attrs, a(t, "attrs"), e);
744
+ const n = this.requireRecord(r.attrs, l(t, "attrs"), e);
643
745
  n && (this.checkProperties(
644
746
  n,
645
- a(t, "attrs"),
747
+ l(t, "attrs"),
646
748
  ["src", "alt", "title", "width", "height", "imageAlign"],
647
749
  ["src"],
648
750
  e
649
- ), this.requireString(n.src, d(t, "attrs", "src"), e), this.optionalString(n.alt, d(t, "attrs", "alt"), e, { allowEmpty: !0 }), this.optionalString(n.title, d(t, "attrs", "title"), e, { allowEmpty: !0 }), n.width !== void 0 && this.requireInteger(n.width, d(t, "attrs", "width"), e, 1, 1e4), n.height !== void 0 && this.requireInteger(n.height, d(t, "attrs", "height"), e, 1, 1e4), n.imageAlign !== void 0 && (typeof n.imageAlign != "string" ? this.add("INVALID_TYPE", d(t, "attrs", "imageAlign"), "Image alignment must be a string.", e) : at.has(n.imageAlign) || this.add(
751
+ ), this.requireString(n.src, d(t, "attrs", "src"), e), this.optionalString(n.alt, d(t, "attrs", "alt"), e, { allowEmpty: !0 }), this.optionalString(n.title, d(t, "attrs", "title"), e, { allowEmpty: !0 }), n.width !== void 0 && this.requireInteger(n.width, d(t, "attrs", "width"), e, 1, 1e4), n.height !== void 0 && this.requireInteger(n.height, d(t, "attrs", "height"), e, 1, 1e4), n.imageAlign !== void 0 && (typeof n.imageAlign != "string" ? this.add("INVALID_TYPE", d(t, "attrs", "imageAlign"), "Image alignment must be a string.", e) : ht.has(n.imageAlign) || this.add(
650
752
  "INVALID_VALUE",
651
753
  d(t, "attrs", "imageAlign"),
652
754
  `Unsupported image alignment "${n.imageAlign}".`,
@@ -656,10 +758,10 @@ class ct {
656
758
  validateArticleButton(r, t) {
657
759
  const e = "articleButton";
658
760
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
659
- const n = this.requireRecord(r.attrs, a(t, "attrs"), e);
761
+ const n = this.requireRecord(r.attrs, l(t, "attrs"), e);
660
762
  n && (this.checkProperties(
661
763
  n,
662
- a(t, "attrs"),
764
+ l(t, "attrs"),
663
765
  ["id", "title", "text", "style", "href"],
664
766
  ["text", "style"],
665
767
  e
@@ -683,14 +785,14 @@ class ct {
683
785
  validateTable(r, t) {
684
786
  const e = "table";
685
787
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
686
- const n = this.requireNonEmptyArray(r.content, a(t, "content"), e);
788
+ const n = this.requireNonEmptyArray(r.content, l(t, "content"), e);
687
789
  if (!n) return;
688
790
  let s = null;
689
- n.forEach((o, l) => {
690
- const c = d(t, "content", l), u = this.validateTableRow(o, c);
791
+ n.forEach((o, a) => {
792
+ const c = d(t, "content", a), u = this.validateTableRow(o, c);
691
793
  u !== null && (s === null ? s = u : u !== s && this.add(
692
794
  "TABLE_COLUMN_MISMATCH",
693
- a(c, "content"),
795
+ l(c, "content"),
694
796
  `Expected ${s} table cells but received ${u}.`,
695
797
  "tableRow"
696
798
  ));
@@ -700,46 +802,98 @@ class ct {
700
802
  var o;
701
803
  const e = "tableRow", n = this.requireRecord(r, t, e);
702
804
  if (!n) return null;
703
- this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", a(t, "type"), "Expected a tableRow node.", e);
704
- const s = this.requireNonEmptyArray(n.content, a(t, "content"), e);
705
- return s == null || s.forEach((l, c) => this.validateTableCell(l, d(t, "content", c))), (o = s == null ? void 0 : s.length) != null ? o : null;
805
+ this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", l(t, "type"), "Expected a tableRow node.", e);
806
+ const s = this.requireNonEmptyArray(n.content, l(t, "content"), e);
807
+ return s == null || s.forEach((a, c) => this.validateTableCell(a, d(t, "content", c))), (o = s == null ? void 0 : s.length) != null ? o : null;
706
808
  }
707
809
  validateTableCell(r, t) {
708
810
  const e = "tableCell", n = this.requireRecord(r, t, e);
709
811
  if (!n) return;
710
- this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", a(t, "type"), "Expected a tableCell node.", e);
711
- const s = this.requireNonEmptyArray(n.content, a(t, "content"), e);
712
- s == null || s.forEach((o, l) => this.validateBlock(o, d(t, "content", l)));
812
+ this.checkProperties(n, t, ["type", "content"], ["type", "content"], e), n.type !== e && this.add("INVALID_CONTENT", l(t, "type"), "Expected a tableCell node.", e);
813
+ const s = this.requireNonEmptyArray(n.content, l(t, "content"), e);
814
+ s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
713
815
  }
714
816
  }
715
- function dt(i) {
716
- return new ct().validate(i);
817
+ function At(i) {
818
+ return new kt().validate(i);
717
819
  }
718
- const C = Object.freeze({
820
+ const F = Object.freeze({
719
821
  version: 1,
720
- validate: dt,
721
- render: nt
722
- }), $ = /* @__PURE__ */ new Map([[C.version, C]]), At = Object.freeze([...$.keys()]), v = 1;
723
- function x(i) {
724
- return $.get(i);
822
+ validate: At,
823
+ render: pt
824
+ }), G = /* @__PURE__ */ new Map([[F.version, F]]), wt = Object.freeze([...G.keys()]), W = 1;
825
+ function H(i) {
826
+ return G.get(i);
725
827
  }
726
- function ut(i, r = {}) {
828
+ function bt(i, r = {}) {
727
829
  var s;
728
- const t = (s = r.protocolVersion) != null ? s : v, e = x(t);
830
+ const t = (s = r.protocolVersion) != null ? s : W, e = H(t);
729
831
  return e ? e.validate(i) : { valid: !1, issues: [{
730
832
  code: "UNSUPPORTED_PROTOCOL",
731
833
  path: "",
732
834
  message: `Article Content Protocol version ${t} is not supported.`
733
835
  }] };
734
836
  }
735
- function ft() {
837
+ function It() {
736
838
  return [];
737
839
  }
738
- function ht(i) {
840
+ function w(i) {
739
841
  return `${i.code}:${i.path}:${i.message}`;
740
842
  }
741
- const gt = K.extend({
843
+ function Lt(i) {
844
+ const r = i.slots();
845
+ return i.props.customSlots.map((t) => {
846
+ var s, o, a, c;
847
+ const e = { id: t.id, location: t.location }, n = (c = (a = (o = (s = i.scopedSlots)[t.id]) == null ? void 0 : o.call(s, e)) != null ? a : r[t.id]) != null ? c : [];
848
+ return E(k({}, t), { content: n });
849
+ });
850
+ }
851
+ function Nt(i, r) {
852
+ Array.isArray(i) ? i.forEach((t) => t(r)) : i == null || i(r);
853
+ }
854
+ const Et = Y.extend({
855
+ name: "ArticleContentRenderIssueReporter",
856
+ props: {
857
+ issues: {
858
+ type: Array,
859
+ required: !0
860
+ }
861
+ },
862
+ data() {
863
+ return {
864
+ reportedFingerprint: ""
865
+ };
866
+ },
867
+ watch: {
868
+ issues: {
869
+ immediate: !0,
870
+ deep: !0,
871
+ handler(i) {
872
+ const r = i.map(w).join("|");
873
+ r !== this.reportedFingerprint && (this.reportedFingerprint = r, this.$nextTick(() => i.forEach((t) => this.$emit("render-error", t))));
874
+ }
875
+ }
876
+ },
877
+ render(i) {
878
+ var r, t;
879
+ return (t = (r = this.$slots.default) == null ? void 0 : r[0]) != null ? t : i();
880
+ }
881
+ });
882
+ function M(i, r, t, e) {
883
+ var a;
884
+ const n = (a = t[0]) != null ? a : i(), s = r.listeners["render-error"], o = i(
885
+ Et,
886
+ {
887
+ props: { issues: e },
888
+ on: s ? { "render-error": s } : void 0
889
+ },
890
+ [n]
891
+ );
892
+ return t.length > 1 ? [o, ...t.slice(1)] : o;
893
+ }
894
+ const Rt = {
742
895
  name: "ArticleContentRenderer",
896
+ functional: !0,
743
897
  props: {
744
898
  document: {
745
899
  type: null,
@@ -747,7 +901,7 @@ const gt = K.extend({
747
901
  },
748
902
  protocolVersion: {
749
903
  type: Number,
750
- default: v
904
+ default: W
751
905
  },
752
906
  strict: {
753
907
  type: Boolean,
@@ -755,68 +909,27 @@ const gt = K.extend({
755
909
  },
756
910
  customSlots: {
757
911
  type: Array,
758
- default: ft
912
+ default: It
759
913
  },
760
914
  imageBaseUrl: {
761
915
  type: String,
762
- default: N
916
+ default: _
763
917
  },
764
918
  resolveArticleButtonLink: {
765
919
  type: Function,
766
920
  default: void 0
767
- }
768
- },
769
- data() {
770
- return {
771
- reportedRuntimeIssues: /* @__PURE__ */ new Set()
772
- };
773
- },
774
- computed: {
775
- validation() {
776
- return ut(this.document, { protocolVersion: this.protocolVersion });
777
- }
778
- },
779
- watch: {
780
- validation: {
781
- immediate: !0,
782
- deep: !0,
783
- handler(i) {
784
- i.issues.forEach((r) => this.$emit("render-error", r));
785
- }
786
- },
787
- document: {
788
- deep: !0,
789
- handler() {
790
- this.reportedRuntimeIssues.clear();
791
- }
792
- },
793
- protocolVersion() {
794
- this.reportedRuntimeIssues.clear();
795
- },
796
- resolveArticleButtonLink() {
797
- this.reportedRuntimeIssues.clear();
798
- },
799
- imageBaseUrl() {
800
- this.reportedRuntimeIssues.clear();
801
- }
802
- },
803
- methods: {
804
- resolveCustomSlots() {
805
- return this.customSlots.map((i) => {
806
- var e, n, s, o;
807
- const r = { id: i.id, location: i.location }, t = (o = (s = (n = (e = this.$scopedSlots)[i.id]) == null ? void 0 : n.call(e, r)) != null ? s : this.$slots[i.id]) != null ? o : [];
808
- return A(m({}, i), { content: t });
809
- });
810
921
  },
811
- reportRuntimeIssue(i) {
812
- const r = ht(i);
813
- this.reportedRuntimeIssues.has(r) || (this.reportedRuntimeIssues.add(r), this.$nextTick(() => this.$emit("render-error", i)));
922
+ resolveCustomLink: {
923
+ type: Function,
924
+ default: void 0
814
925
  }
815
926
  },
816
- render(i) {
817
- const r = x(this.protocolVersion);
818
- if (!r || this.strict && !this.validation.valid)
819
- return i(
927
+ render(i, r) {
928
+ const { props: t } = r, e = bt(t.document, {
929
+ protocolVersion: t.protocolVersion
930
+ }), n = H(t.protocolVersion), s = [];
931
+ if (!n || t.strict && !e.valid) {
932
+ const a = i(
820
933
  "div",
821
934
  {
822
935
  class: "acp-render-error",
@@ -827,38 +940,36 @@ const gt = K.extend({
827
940
  },
828
941
  "Invalid article content"
829
942
  );
830
- const t = r.render(this.document, {
943
+ return M(i, r, [a], e.issues);
944
+ }
945
+ const o = n.render(t.document, {
831
946
  createElement: i,
832
- customSlots: this.resolveCustomSlots(),
833
- imageBaseUrl: this.imageBaseUrl,
834
- resolveArticleButtonLink: this.resolveArticleButtonLink,
835
- emitArticleButtonClick: (e) => this.$emit("article-button-click", e),
836
- reportIssue: this.reportRuntimeIssue
947
+ customSlots: Lt(r),
948
+ imageBaseUrl: t.imageBaseUrl,
949
+ resolveArticleButtonLink: t.resolveArticleButtonLink,
950
+ resolveCustomLink: t.resolveCustomLink,
951
+ emitArticleButtonClick: (a) => Nt(r.listeners["article-button-click"], a),
952
+ reportIssue: (a) => s.push(a)
837
953
  });
838
- return i(
839
- "div",
840
- {
841
- class: "acp-document",
842
- attrs: {
843
- "data-node-type": "doc",
844
- "data-protocol-version": this.protocolVersion
845
- }
846
- },
847
- t
848
- );
849
- }
850
- });
851
- function pt(i, r, t, e, n, s, o, l) {
954
+ return M(i, r, o, [
955
+ ...e.issues,
956
+ ...s.filter(
957
+ (a, c, u) => u.findIndex((g) => w(g) === w(a)) === c
958
+ )
959
+ ]);
960
+ }
961
+ }, Tt = Y.extend(Rt);
962
+ function _t(i, r, t, e, n, s, o, a) {
852
963
  var c = typeof i == "function" ? i.options : i;
853
964
  return {
854
965
  exports: i,
855
966
  options: c
856
967
  };
857
968
  }
858
- var yt = /* @__PURE__ */ pt(
859
- gt
969
+ var St = /* @__PURE__ */ _t(
970
+ Tt
860
971
  );
861
- const mt = yt.exports, It = Object.freeze({
972
+ const Pt = St.exports, Vt = Object.freeze({
862
973
  fileFormat: "article-content-protocol",
863
974
  fileFormatVersion: 1,
864
975
  mediaType: "application/vnd.article-content-protocol+json",
@@ -885,17 +996,17 @@ const mt = yt.exports, It = Object.freeze({
885
996
  "text"
886
997
  ]),
887
998
  markTypes: Object.freeze(["bold", "italic", "strike", "underline", "code", "link"])
888
- }), Lt = {
999
+ }), Ct = {
889
1000
  install(i) {
890
- i.component("ArticleContentRenderer", mt);
1001
+ i.component("ArticleContentRenderer", Pt);
891
1002
  }
892
1003
  };
893
1004
  export {
894
- It as ARTICLE_CONTENT_PROTOCOL_V1,
895
- mt as ArticleContentRenderer,
896
- Lt as ArticleContentRendererPlugin,
897
- v as CURRENT_PROTOCOL_VERSION,
898
- At as SUPPORTED_PROTOCOL_VERSIONS,
899
- mt as default,
900
- ut as validateArticleDocument
1005
+ Vt as ARTICLE_CONTENT_PROTOCOL_V1,
1006
+ Pt as ArticleContentRenderer,
1007
+ Ct as ArticleContentRendererPlugin,
1008
+ W as CURRENT_PROTOCOL_VERSION,
1009
+ wt as SUPPORTED_PROTOCOL_VERSIONS,
1010
+ Pt as default,
1011
+ bt as validateArticleDocument
901
1012
  };