article-content-renderer-vue2 0.3.1 → 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 F = Object.defineProperty, Y = Object.defineProperties;
2
- var K = Object.getOwnPropertyDescriptors;
3
- var B = Object.getOwnPropertySymbols;
4
- var G = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
5
- var E = (n, r, t) => r in n ? F(n, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[r] = t, m = (n, 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
- G.call(r, t) && E(n, t, r[t]);
8
- if (B)
9
- for (var t of B(r))
10
- W.call(r, t) && E(n, t, r[t]);
11
- return n;
12
- }, A = (n, r) => Y(n, K(r));
13
- var O = (n, r, t) => E(n, typeof r != "symbol" ? r + "" : r, t);
14
- import $ from "vue";
15
- const H = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:"]), X = /* @__PURE__ */ new Set(["http:", "https:", "blob:"]), J = "https://article-content-renderer.invalid/", N = "https://www.doitme.link/";
16
- function Q(n, r) {
17
- if (typeof n != "string") return n;
18
- const t = n.trim();
19
- if (!t.startsWith(N)) return t;
20
- const i = (r.trim() || N).replace(/\/+$/u, ""), s = t.slice(N.length).replace(/^\/+/, "");
21
- return `${i}/${s}`;
22
- }
23
- function _(n, r) {
24
- if (typeof n != "string") return null;
25
- const t = n.trim();
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
+ return i;
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
+ if (typeof i != "string") return i;
18
+ const t = i.trim();
19
+ if (!t.startsWith(_)) return t;
20
+ const n = (r.trim() || _).replace(/\/+$/u, ""), s = t.slice(_.length).replace(/^\/+/, "");
21
+ return `${n}/${s}`;
22
+ }
23
+ function V(i, r) {
24
+ if (typeof i != "string") return null;
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, J);
29
- return (r === "link" ? H : X).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 x(n, r) {
34
+ function O(i, r) {
35
35
  const t = new Set(
36
- typeof n == "string" ? n.trim().split(/\s+/u).filter(Boolean) : []
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 Z = /* @__PURE__ */ new Set([
40
+ const ot = /* @__PURE__ */ new Set([
41
41
  "paragraph",
42
42
  "heading",
43
43
  "blockquote",
@@ -49,89 +49,147 @@ const Z = /* @__PURE__ */ new Set([
49
49
  "articleButton",
50
50
  "table"
51
51
  ]);
52
- function h(n) {
53
- return typeof n == "object" && n !== null && !Array.isArray(n);
52
+ function y(i) {
53
+ return typeof i == "object" && i !== null && !Array.isArray(i);
54
54
  }
55
- function P(n) {
56
- return h(n) ? n : {};
55
+ function C(i) {
56
+ return y(i) ? i : {};
57
57
  }
58
- function f(n, r, t, e) {
59
- var l;
60
- const i = h(t) ? t : {}, s = h(t) ? e : t, o = {}, a = {};
61
- for (const [u, g] of Object.entries(i))
58
+ function p(i, r, t, e) {
59
+ var c;
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
63
  o.class = g;
64
64
  else if (u === "style")
65
65
  o.style = g;
66
66
  else if (u.startsWith("on") && typeof g == "function") {
67
- const y = u.slice(2).toLowerCase();
68
- o.on = A(m({}, (l = o.on) != null ? l : {}), { [y]: g });
67
+ const f = u.slice(2).toLowerCase();
68
+ o.on = E(k({}, (c = o.on) != null ? c : {}), { [f]: g });
69
69
  } else g !== void 0 && g !== !1 && (a[u] = g);
70
- return Object.keys(a).length > 0 && (o.attrs = a), n.createElement(r, o, s);
70
+ return Object.keys(a).length > 0 && (o.attrs = a), i.createElement(r, o, s);
71
71
  }
72
- function k(n) {
73
- return Array.isArray(n) ? n : [];
72
+ function I(i) {
73
+ return Array.isArray(i) ? i : [];
74
74
  }
75
- function p(n, ...r) {
76
- return `${n}/${r.map(String).join("/")}`;
75
+ function h(i, ...r) {
76
+ return `${i}/${r.map(String).join("/")}`;
77
77
  }
78
- function w(n) {
79
- return n === "left" || n === "center" || n === "right" || n === "justify";
78
+ function j(i) {
79
+ return i === "left" || i === "center" || i === "right" || i === "justify";
80
80
  }
81
- function tt(n) {
82
- return n === "left" || n === "center" || n === "right";
81
+ function at(i) {
82
+ return i === "left" || i === "center" || i === "right";
83
83
  }
84
- function R(n) {
85
- return n === "_blank" || n === "_self";
84
+ function S(i) {
85
+ return i === "_blank" || i === "_self";
86
86
  }
87
- function b(n, r) {
88
- n.reportIssue(r);
87
+ function L(i, r) {
88
+ i.reportIssue(r);
89
89
  }
90
- function et(n, r, t) {
91
- if (!h(n) || n.type !== "text" || typeof n.text != "string" || !n.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
- let e = n.text;
94
- const i = k(n.marks);
95
- for (let s = 0; s < i.length; s += 1) {
96
- const o = i[s];
97
- if (!h(o) || typeof o.type != "string") continue;
98
- const a = p(r, "marks", s);
99
- switch (o.type) {
94
+ let e = i.text;
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 l = P(o.attrs), u = _(l.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: p(a, "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 g = R(l.target) ? l.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: g,
134
- rel: x(void 0, g)
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 et(n, r, t) {
141
199
  }
142
200
  return e;
143
201
  }
144
- function V(n, r, t) {
145
- return k(n).map((e, i) => et(e, p(r, i), 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 q(n, r, t) {
148
- return !h(n) || n.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
- S(n.content, p(r, "content"), t)
210
+ q(i.content, h(r, "content"), t)
153
211
  );
154
212
  }
155
- function rt(n, r, t) {
156
- return !h(n) || n.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
- S(n.content, p(r, "content"), t)
218
+ q(i.content, h(r, "content"), t)
161
219
  );
162
220
  }
163
- function nt(n, r, t) {
164
- if (!h(n) || n.type !== "tableRow") return null;
165
- const e = k(n.content).map((i, s) => rt(i, p(r, "content", s), t)).filter((i) => i !== null);
166
- return f(t, "tr", { class: "acp-table-row", "data-node-type": "tableRow" }, e);
167
- }
168
- function C(n) {
169
- var i;
170
- if (h(n) && n.target !== void 0 && !R(n.target) || h(n) && n.rel !== void 0 && typeof n.rel != "string") return null;
171
- const r = typeof n == "string" ? { href: n } : h(n) && typeof n.href == "string" ? m(m({
172
- href: n.href
173
- }, R(n.target) ? { target: n.target } : {}), typeof n.rel == "string" ? { rel: n.rel } : {}) : null;
174
- if (!r) return null;
175
- const t = _(r.href, "link");
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);
225
+ }
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({
230
+ href: i.href
231
+ }, S(i.target) ? { target: i.target } : {}), typeof i.rel == "string" ? { rel: i.rel } : {}) : null;
176
232
  if (!t) return null;
177
- const e = (i = r.target) != null ? i : "_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: x(r.rel, e)
237
+ href: e,
238
+ target: n,
239
+ rel: O(t.rel, n)
182
240
  };
183
241
  }
184
- function it(n, r, t) {
242
+ function ut(i, r, t) {
185
243
  var g;
186
- const e = P(n.attrs), i = e.style === "text" || e.style === "button", s = e.style === "link";
187
- if (typeof e.text != "string" || !e.text || !i && !s || i && (typeof e.id != "string" || !e.id) || s && e.id !== void 0 && (typeof e.id != "string" || !e.id))
244
+ const e = C(i.attrs), n = e.style === "text" || e.style === "button", s = e.style === "link";
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
255
  })), a = Object.freeze({ type: "articleButton", attrs: o });
198
- let l = null;
256
+ let c = null;
199
257
  if (o.style === "link")
200
- o.href !== void 0 && (l = C(o.href), l || 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 it(n, 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
- l = C(L), l || b(t, {
217
- code: typeof L == "string" || h(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 = (g = l == null ? void 0 : l.href) != null ? g : 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
  {
@@ -238,101 +296,101 @@ function it(n, r, t) {
238
296
  !u && "acp-article-button--disabled"
239
297
  ],
240
298
  href: u != null ? u : void 0,
241
- target: l == null ? void 0 : l.target,
242
- rel: l == null ? void 0 : l.rel,
299
+ target: c == null ? void 0 : c.target,
300
+ rel: c == null ? void 0 : c.rel,
243
301
  title: o.title,
244
302
  "data-node-type": "articleButton",
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: a, 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 v(n, r, t) {
256
- if (!h(n) || typeof n.type != "string" || !Z.has(n.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 = P(n.attrs);
259
- switch (n.type) {
316
+ const e = C(i.attrs);
317
+ switch (i.type) {
260
318
  case "paragraph": {
261
- const i = 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
  {
266
324
  class: "acp-paragraph",
267
325
  "data-node-type": "paragraph",
268
- style: i ? { textAlign: i } : void 0
326
+ style: n ? { textAlign: n } : void 0
269
327
  },
270
- V(n.content, p(r, "content"), t)
328
+ x(i.content, h(r, "content"), t)
271
329
  );
272
330
  }
273
331
  case "heading": {
274
- const i = 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
- `h${i}`,
335
+ `h${n}`,
278
336
  {
279
- class: ["acp-heading", `acp-heading--${i}`],
337
+ class: ["acp-heading", `acp-heading--${n}`],
280
338
  "data-node-type": "heading",
281
339
  style: s ? { textAlign: s } : void 0
282
340
  },
283
- V(n.content, p(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
- S(n.content, p(r, "content"), t)
349
+ q(i.content, h(r, "content"), t)
292
350
  );
293
351
  case "bulletList": {
294
- const i = k(n.content).map((s, o) => q(s, p(r, "content", o), t)).filter((s) => s !== null);
295
- return f(t, "ul", { class: "acp-list acp-list--bullet", "data-node-type": "bulletList" }, i);
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 i = Number.isInteger(e.start) && Number(e.start) >= 1 ? Number(e.start) : 1, s = k(n.content).map((o, a) => q(o, p(r, "content", a), 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
  {
303
361
  class: "acp-list acp-list--ordered",
304
362
  "data-node-type": "orderedList",
305
- start: i
363
+ start: n
306
364
  },
307
365
  s
308
366
  );
309
367
  }
310
368
  case "codeBlock": {
311
- const i = typeof e.language == "string" && e.language ? e.language : void 0, s = k(n.content).filter((o) => h(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
  {
316
374
  class: "acp-code-block",
317
375
  "data-node-type": "codeBlock",
318
- "data-language": i
376
+ "data-language": n
319
377
  },
320
- [f(t, "code", { class: i ? `language-${i}` : 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 i = _(Q(e.src, t.imageBaseUrl), "image");
327
- if (!i)
328
- return b(t, {
384
+ const n = V(st(e.src, t.imageBaseUrl), "image");
385
+ if (!n)
386
+ return L(t, {
329
387
  code: "UNSAFE_URL",
330
- path: p(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 = tt(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;
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,9 +399,9 @@ function v(n, 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
- src: i,
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,
@@ -354,24 +412,24 @@ function v(n, r, t) {
354
412
  );
355
413
  }
356
414
  case "articleButton":
357
- return it(n, r, t);
415
+ return ut(i, r, t);
358
416
  case "table": {
359
- const i = k(n.content).map((s, o) => nt(s, p(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", i)])]
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 S(n, r, t) {
371
- return k(n).map((e, i) => v(e, p(r, i), 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 st(n, r) {
374
- const t = k(n.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
434
  var a;
377
435
  if (!Number.isInteger(s.location) || s.location < 1 || s.location > t.length)
@@ -379,19 +437,19 @@ function st(n, r) {
379
437
  const o = (a = e.get(s.location)) != null ? a : [];
380
438
  o.push(s), e.set(s.location, o);
381
439
  });
382
- const i = [];
440
+ const n = [];
383
441
  return t.forEach((s, o) => {
384
442
  var u;
385
443
  const a = o + 1;
386
- (u = e.get(a)) == null || u.forEach((g) => i.push(...g.content));
387
- const l = v(s, p("/content", o), r);
388
- l && typeof l != "string" && i.push(l);
389
- }), i;
444
+ (u = e.get(a)) == null || u.forEach((g) => n.push(...g.content));
445
+ const c = K(s, h("/content", o), r);
446
+ c && typeof c != "string" && n.push(c);
447
+ }), n;
390
448
  }
391
- function ot(n, r) {
392
- return !h(n) || n.type !== "doc" ? [] : st(n, r);
449
+ function pt(i, r) {
450
+ return !y(i) || i.type !== "doc" ? [] : ft(i, r);
393
451
  }
394
- const at = /* @__PURE__ */ new Set([
452
+ const gt = /* @__PURE__ */ new Set([
395
453
  "paragraph",
396
454
  "heading",
397
455
  "blockquote",
@@ -402,28 +460,28 @@ const at = /* @__PURE__ */ new Set([
402
460
  "image",
403
461
  "articleButton",
404
462
  "table"
405
- ]), ct = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), lt = /* @__PURE__ */ new Set(["left", "center", "right"]), dt = /* @__PURE__ */ new Set(["bold", "italic", "strike", "underline", "code"]);
406
- function I(n) {
407
- return typeof n == "object" && n !== null && !Array.isArray(n);
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) {
465
+ return typeof i == "object" && i !== null && !Array.isArray(i);
408
466
  }
409
- function c(n, r) {
410
- return `${n}/${String(r).replaceAll("~", "~0").replaceAll("/", "~1")}`;
467
+ function l(i, r) {
468
+ return `${i}/${String(r).replaceAll("~", "~0").replaceAll("/", "~1")}`;
411
469
  }
412
- function d(n, ...r) {
413
- let t = n;
414
- for (const e of r) t = c(t, e);
470
+ function d(i, ...r) {
471
+ let t = i;
472
+ for (const e of r) t = l(t, e);
415
473
  return t;
416
474
  }
417
- class ut {
475
+ class kt {
418
476
  constructor() {
419
- O(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, i) => this.validateBlock(e, c("/content", i))), 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 {
@@ -431,22 +489,22 @@ class ut {
431
489
  issues: this.issues
432
490
  };
433
491
  }
434
- add(r, t, e, i) {
435
- this.issues.push(m({ code: r, path: t, message: e }, i ? { nodeType: i } : {}));
492
+ add(r, t, e, n) {
493
+ this.issues.push(k({ code: r, path: t, message: e }, n ? { nodeType: n } : {}));
436
494
  }
437
- checkProperties(r, t, e, i = [], s) {
495
+ checkProperties(r, t, e, n = [], s) {
438
496
  const o = new Set(e);
439
497
  for (const a of Object.keys(r))
440
498
  o.has(a) || this.add(
441
499
  "UNKNOWN_PROPERTY",
442
- c(t, a),
500
+ l(t, a),
443
501
  `Property "${a}" is not allowed.`,
444
502
  s
445
503
  );
446
- for (const a of i)
504
+ for (const a of n)
447
505
  a in r || this.add(
448
506
  "MISSING_PROPERTY",
449
- c(t, a),
507
+ l(t, a),
450
508
  `Required property "${a}" is missing.`,
451
509
  s
452
510
  );
@@ -458,49 +516,49 @@ class ut {
458
516
  return r === void 0 ? [] : this.requireArray(r, t, e);
459
517
  }
460
518
  requireNonEmptyArray(r, t, e) {
461
- const i = this.requireArray(r, t, e);
462
- return i && i.length === 0 && this.add(
519
+ const n = this.requireArray(r, t, e);
520
+ return n && n.length === 0 && this.add(
463
521
  "INVALID_CONTENT",
464
522
  t,
465
523
  `Node "${e}" must contain at least one child.`,
466
524
  e
467
- ), i;
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);
474
532
  }
475
- requireString(r, t, e, i = {}) {
476
- return typeof r != "string" ? (this.add("INVALID_TYPE", t, "Expected a string.", e), !1) : !i.allowEmpty && r.length === 0 ? (this.add("INVALID_VALUE", t, "The string must not be empty.", e), !1) : i.maxLength !== void 0 && r.length > i.maxLength ? (this.add(
533
+ requireString(r, t, e, n = {}) {
534
+ return typeof r != "string" ? (this.add("INVALID_TYPE", t, "Expected a string.", e), !1) : !n.allowEmpty && r.length === 0 ? (this.add("INVALID_VALUE", t, "The string must not be empty.", e), !1) : n.maxLength !== void 0 && r.length > n.maxLength ? (this.add(
477
535
  "INVALID_VALUE",
478
536
  t,
479
- `The string must contain at most ${i.maxLength} characters.`,
537
+ `The string must contain at most ${n.maxLength} characters.`,
480
538
  e
481
539
  ), !1) : !0;
482
540
  }
483
- optionalString(r, t, e, i = {}) {
484
- r !== void 0 && this.requireString(r, t, e, i);
541
+ optionalString(r, t, e, n = {}) {
542
+ r !== void 0 && this.requireString(r, t, e, n);
485
543
  }
486
- requireInteger(r, t, e, i, s) {
544
+ requireInteger(r, t, e, n, s) {
487
545
  if (!Number.isInteger(r))
488
546
  return this.add("INVALID_TYPE", t, "Expected an integer.", e), !1;
489
547
  const o = r;
490
- return i !== void 0 && o < i ? (this.add("INVALID_VALUE", t, `Value must be at least ${i}.`, e), !1) : s !== void 0 && o > s ? (this.add("INVALID_VALUE", t, `Value must be at most ${s}.`, e), !1) : !0;
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", c(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 (!at.has(e)) {
503
- this.add("UNKNOWN_NODE", c(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,98 +596,142 @@ class ut {
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, c(t, "attrs"), e, !1), this.validateInlineContent(r.content, c(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 i = this.requireRecord(r.attrs, c(t, "attrs"), e);
547
- i && (this.checkProperties(i, c(t, "attrs"), ["level", "textAlign"], ["level"], e), this.requireInteger(i.level, d(t, "attrs", "level"), e, 1, 6), this.validateTextAlign(i.textAlign, d(t, "attrs", "textAlign"), e)), this.validateInlineContent(r.content, c(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
- validateTextAlignAttrs(r, t, e, i) {
550
- const s = i ? this.requireRecord(r, t, e) : this.optionalRecord(r, t, e);
551
- s && (this.checkProperties(s, t, ["textAlign"], [], e), this.validateTextAlign(s.textAlign, c(t, "textAlign"), e));
607
+ validateTextAlignAttrs(r, t, e, n) {
608
+ const s = n ? this.requireRecord(r, t, e) : this.optionalRecord(r, t, 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) : ct.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
- const i = this.optionalArray(r, t, e);
558
- i == null || i.forEach((s, o) => this.validateText(s, c(t, o), !0));
615
+ const n = this.optionalArray(r, t, e);
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
- const i = e ? ["type", "text", "marks"] : ["type", "text"];
566
- if (this.checkProperties(r, t, i, ["type", "text"], "text"), r.type !== "text" && this.add("INVALID_CONTENT", c(t, "type"), "Expected a text node.", "text"), this.requireString(r.text, c(t, "text"), "text"), e && r.marks !== void 0) {
567
- const s = this.requireArray(r.marks, c(t, "marks"), "text");
623
+ const n = e ? ["type", "text", "marks"] : ["type", "text"];
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");
568
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", c(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 (dt.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", c(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, c(t, "attrs"), "link");
590
- e && (this.checkProperties(e, c(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 i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
601
- i == null || i.forEach((s, o) => this.validateBlock(s, d(t, "content", o)));
702
+ const n = this.requireNonEmptyArray(r.content, l(t, "content"), e);
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 i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
607
- i == null || i.forEach((s, o) => this.validateListItem(s, d(t, "content", o)));
708
+ const n = this.requireNonEmptyArray(r.content, l(t, "content"), e);
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 i = this.optionalRecord(r.attrs, c(t, "attrs"), e);
613
- i && (this.checkProperties(i, c(t, "attrs"), ["start"], [], e), i.start !== void 0 && this.requireInteger(i.start, d(t, "attrs", "start"), e, 1));
614
- const s = this.requireNonEmptyArray(r.content, c(t, "content"), e);
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);
615
717
  s == null || s.forEach((o, a) => this.validateListItem(o, d(t, "content", a)));
616
718
  }
617
719
  validateListItem(r, t) {
618
- const e = "listItem", i = this.requireRecord(r, t, e);
619
- if (!i) return;
620
- this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a listItem node.", e);
621
- const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
720
+ const e = "listItem", n = this.requireRecord(r, t, e);
721
+ if (!n) return;
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);
622
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 i = this.optionalRecord(r.attrs, c(t, "attrs"), e);
628
- i && (this.checkProperties(i, c(t, "attrs"), ["language"], [], e), this.optionalString(i.language, d(t, "attrs", "language"), e, { maxLength: 32 }));
629
- const s = this.optionalArray(r.content, c(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
- c(t, "content"),
734
+ l(t, "content"),
633
735
  "A codeBlock may contain at most one text node.",
634
736
  e
635
737
  ), s.forEach(
@@ -639,41 +741,41 @@ class ut {
639
741
  validateImage(r, t) {
640
742
  const e = "image";
641
743
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
642
- const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
643
- i && (this.checkProperties(
644
- i,
645
- c(t, "attrs"),
744
+ const n = this.requireRecord(r.attrs, l(t, "attrs"), e);
745
+ n && (this.checkProperties(
746
+ n,
747
+ l(t, "attrs"),
646
748
  ["src", "alt", "title", "width", "height", "imageAlign"],
647
749
  ["src"],
648
750
  e
649
- ), this.requireString(i.src, d(t, "attrs", "src"), e), this.optionalString(i.alt, d(t, "attrs", "alt"), e, { allowEmpty: !0 }), this.optionalString(i.title, d(t, "attrs", "title"), e, { allowEmpty: !0 }), i.width !== void 0 && this.requireInteger(i.width, d(t, "attrs", "width"), e, 1, 1e4), i.height !== void 0 && this.requireInteger(i.height, d(t, "attrs", "height"), e, 1, 1e4), i.imageAlign !== void 0 && (typeof i.imageAlign != "string" ? this.add("INVALID_TYPE", d(t, "attrs", "imageAlign"), "Image alignment must be a string.", e) : lt.has(i.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
- `Unsupported image alignment "${i.imageAlign}".`,
754
+ `Unsupported image alignment "${n.imageAlign}".`,
653
755
  e
654
756
  )));
655
757
  }
656
758
  validateArticleButton(r, t) {
657
759
  const e = "articleButton";
658
760
  this.checkProperties(r, t, ["type", "attrs"], ["type", "attrs"], e);
659
- const i = this.requireRecord(r.attrs, c(t, "attrs"), e);
660
- i && (this.checkProperties(
661
- i,
662
- c(t, "attrs"),
761
+ const n = this.requireRecord(r.attrs, l(t, "attrs"), e);
762
+ n && (this.checkProperties(
763
+ n,
764
+ l(t, "attrs"),
663
765
  ["id", "title", "text", "style", "href"],
664
766
  ["text", "style"],
665
767
  e
666
- ), i.style === "text" || i.style === "button" ? "id" in i ? this.requireString(i.id, d(t, "attrs", "id"), e) : this.add(
768
+ ), n.style === "text" || n.style === "button" ? "id" in n ? this.requireString(n.id, d(t, "attrs", "id"), e) : this.add(
667
769
  "MISSING_PROPERTY",
668
770
  d(t, "attrs", "id"),
669
771
  'Required property "id" is missing for an articleButton with text or button style.',
670
772
  e
671
- ) : this.optionalString(i.id, d(t, "attrs", "id"), e), this.optionalString(i.title, d(t, "attrs", "title"), e), this.requireString(i.text, d(t, "attrs", "text"), e), this.optionalString(i.href, d(t, "attrs", "href"), e), i.style !== "text" && i.style !== "button" && i.style !== "link" && this.add(
773
+ ) : this.optionalString(n.id, d(t, "attrs", "id"), e), this.optionalString(n.title, d(t, "attrs", "title"), e), this.requireString(n.text, d(t, "attrs", "text"), e), this.optionalString(n.href, d(t, "attrs", "href"), e), n.style !== "text" && n.style !== "button" && n.style !== "link" && this.add(
672
774
  "INVALID_VALUE",
673
775
  d(t, "attrs", "style"),
674
776
  'Article button style must be "text", "button", or "link".',
675
777
  e
676
- ), i.href !== void 0 && i.style !== "link" && this.add(
778
+ ), n.href !== void 0 && n.style !== "link" && this.add(
677
779
  "INVALID_VALUE",
678
780
  d(t, "attrs", "href"),
679
781
  'Article button href may only be present when style is "link".',
@@ -683,14 +785,14 @@ class ut {
683
785
  validateTable(r, t) {
684
786
  const e = "table";
685
787
  this.checkProperties(r, t, ["type", "content"], ["type", "content"], e);
686
- const i = this.requireNonEmptyArray(r.content, c(t, "content"), e);
687
- if (!i) return;
788
+ const n = this.requireNonEmptyArray(r.content, l(t, "content"), e);
789
+ if (!n) return;
688
790
  let s = null;
689
- i.forEach((o, a) => {
690
- const l = d(t, "content", a), u = this.validateTableRow(o, l);
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
- c(l, "content"),
795
+ l(c, "content"),
694
796
  `Expected ${s} table cells but received ${u}.`,
695
797
  "tableRow"
696
798
  ));
@@ -698,58 +800,58 @@ class ut {
698
800
  }
699
801
  validateTableRow(r, t) {
700
802
  var o;
701
- const e = "tableRow", i = this.requireRecord(r, t, e);
702
- if (!i) return null;
703
- this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a tableRow node.", e);
704
- const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
705
- return s == null || s.forEach((a, l) => this.validateTableCell(a, d(t, "content", l))), (o = s == null ? void 0 : s.length) != null ? o : null;
803
+ const e = "tableRow", n = this.requireRecord(r, t, e);
804
+ if (!n) return 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
- const e = "tableCell", i = this.requireRecord(r, t, e);
709
- if (!i) return;
710
- this.checkProperties(i, t, ["type", "content"], ["type", "content"], e), i.type !== e && this.add("INVALID_CONTENT", c(t, "type"), "Expected a tableCell node.", e);
711
- const s = this.requireNonEmptyArray(i.content, c(t, "content"), e);
810
+ const e = "tableCell", n = this.requireRecord(r, t, e);
811
+ if (!n) return;
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);
712
814
  s == null || s.forEach((o, a) => this.validateBlock(o, d(t, "content", a)));
713
815
  }
714
816
  }
715
- function ft(n) {
716
- return new ut().validate(n);
817
+ function At(i) {
818
+ return new kt().validate(i);
717
819
  }
718
- const U = Object.freeze({
820
+ const F = Object.freeze({
719
821
  version: 1,
720
- validate: ft,
721
- render: ot
722
- }), j = /* @__PURE__ */ new Map([[U.version, U]]), Rt = Object.freeze([...j.keys()]), z = 1;
723
- function M(n) {
724
- return j.get(n);
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 gt(n, r = {}) {
828
+ function bt(i, r = {}) {
727
829
  var s;
728
- const t = (s = r.protocolVersion) != null ? s : z, e = M(t);
729
- return e ? e.validate(n) : { valid: !1, issues: [{
830
+ const t = (s = r.protocolVersion) != null ? s : W, e = H(t);
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 pt() {
837
+ function It() {
736
838
  return [];
737
839
  }
738
- function T(n) {
739
- return `${n.code}:${n.path}:${n.message}`;
840
+ function w(i) {
841
+ return `${i.code}:${i.path}:${i.message}`;
740
842
  }
741
- function ht(n) {
742
- const r = n.slots();
743
- return n.props.customSlots.map((t) => {
744
- var s, o, a, l;
745
- const e = { id: t.id, location: t.location }, i = (l = (a = (o = (s = n.scopedSlots)[t.id]) == null ? void 0 : o.call(s, e)) != null ? a : r[t.id]) != null ? l : [];
746
- return A(m({}, t), { content: i });
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 });
747
849
  });
748
850
  }
749
- function yt(n, r) {
750
- Array.isArray(n) ? n.forEach((t) => t(r)) : n == null || n(r);
851
+ function Nt(i, r) {
852
+ Array.isArray(i) ? i.forEach((t) => t(r)) : i == null || i(r);
751
853
  }
752
- const mt = $.extend({
854
+ const Et = Y.extend({
753
855
  name: "ArticleContentRenderIssueReporter",
754
856
  props: {
755
857
  issues: {
@@ -766,30 +868,30 @@ const mt = $.extend({
766
868
  issues: {
767
869
  immediate: !0,
768
870
  deep: !0,
769
- handler(n) {
770
- const r = n.map(T).join("|");
771
- r !== this.reportedFingerprint && (this.reportedFingerprint = r, this.$nextTick(() => n.forEach((t) => this.$emit("render-error", t))));
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))));
772
874
  }
773
875
  }
774
876
  },
775
- render(n) {
877
+ render(i) {
776
878
  var r, t;
777
- return (t = (r = this.$slots.default) == null ? void 0 : r[0]) != null ? t : n();
879
+ return (t = (r = this.$slots.default) == null ? void 0 : r[0]) != null ? t : i();
778
880
  }
779
881
  });
780
- function D(n, r, t, e) {
882
+ function M(i, r, t, e) {
781
883
  var a;
782
- const i = (a = t[0]) != null ? a : n(), s = r.listeners["render-error"], o = n(
783
- mt,
884
+ const n = (a = t[0]) != null ? a : i(), s = r.listeners["render-error"], o = i(
885
+ Et,
784
886
  {
785
887
  props: { issues: e },
786
888
  on: s ? { "render-error": s } : void 0
787
889
  },
788
- [i]
890
+ [n]
789
891
  );
790
892
  return t.length > 1 ? [o, ...t.slice(1)] : o;
791
893
  }
792
- const kt = {
894
+ const Rt = {
793
895
  name: "ArticleContentRenderer",
794
896
  functional: !0,
795
897
  props: {
@@ -799,7 +901,7 @@ const kt = {
799
901
  },
800
902
  protocolVersion: {
801
903
  type: Number,
802
- default: z
904
+ default: W
803
905
  },
804
906
  strict: {
805
907
  type: Boolean,
@@ -807,23 +909,27 @@ const kt = {
807
909
  },
808
910
  customSlots: {
809
911
  type: Array,
810
- default: pt
912
+ default: It
811
913
  },
812
914
  imageBaseUrl: {
813
915
  type: String,
814
- default: N
916
+ default: _
815
917
  },
816
918
  resolveArticleButtonLink: {
817
919
  type: Function,
818
920
  default: void 0
921
+ },
922
+ resolveCustomLink: {
923
+ type: Function,
924
+ default: void 0
819
925
  }
820
926
  },
821
- render(n, r) {
822
- const { props: t } = r, e = gt(t.document, {
927
+ render(i, r) {
928
+ const { props: t } = r, e = bt(t.document, {
823
929
  protocolVersion: t.protocolVersion
824
- }), i = M(t.protocolVersion), s = [];
825
- if (!i || t.strict && !e.valid) {
826
- const a = n(
930
+ }), n = H(t.protocolVersion), s = [];
931
+ if (!n || t.strict && !e.valid) {
932
+ const a = i(
827
933
  "div",
828
934
  {
829
935
  class: "acp-render-error",
@@ -834,35 +940,36 @@ const kt = {
834
940
  },
835
941
  "Invalid article content"
836
942
  );
837
- return D(n, r, [a], e.issues);
943
+ return M(i, r, [a], e.issues);
838
944
  }
839
- const o = i.render(t.document, {
840
- createElement: n,
841
- customSlots: ht(r),
945
+ const o = n.render(t.document, {
946
+ createElement: i,
947
+ customSlots: Lt(r),
842
948
  imageBaseUrl: t.imageBaseUrl,
843
949
  resolveArticleButtonLink: t.resolveArticleButtonLink,
844
- emitArticleButtonClick: (a) => yt(r.listeners["article-button-click"], a),
950
+ resolveCustomLink: t.resolveCustomLink,
951
+ emitArticleButtonClick: (a) => Nt(r.listeners["article-button-click"], a),
845
952
  reportIssue: (a) => s.push(a)
846
953
  });
847
- return D(n, r, o, [
954
+ return M(i, r, o, [
848
955
  ...e.issues,
849
956
  ...s.filter(
850
- (a, l, u) => u.findIndex((g) => T(g) === T(a)) === l
957
+ (a, c, u) => u.findIndex((g) => w(g) === w(a)) === c
851
958
  )
852
959
  ]);
853
960
  }
854
- }, bt = $.extend(kt);
855
- function At(n, r, t, e, i, s, o, a) {
856
- var l = typeof n == "function" ? n.options : n;
961
+ }, Tt = Y.extend(Rt);
962
+ function _t(i, r, t, e, n, s, o, a) {
963
+ var c = typeof i == "function" ? i.options : i;
857
964
  return {
858
- exports: n,
859
- options: l
965
+ exports: i,
966
+ options: c
860
967
  };
861
968
  }
862
- var It = /* @__PURE__ */ At(
863
- bt
969
+ var St = /* @__PURE__ */ _t(
970
+ Tt
864
971
  );
865
- const Lt = It.exports, Tt = Object.freeze({
972
+ const Pt = St.exports, Vt = Object.freeze({
866
973
  fileFormat: "article-content-protocol",
867
974
  fileFormatVersion: 1,
868
975
  mediaType: "application/vnd.article-content-protocol+json",
@@ -889,17 +996,17 @@ const Lt = It.exports, Tt = Object.freeze({
889
996
  "text"
890
997
  ]),
891
998
  markTypes: Object.freeze(["bold", "italic", "strike", "underline", "code", "link"])
892
- }), _t = {
893
- install(n) {
894
- n.component("ArticleContentRenderer", Lt);
999
+ }), Ct = {
1000
+ install(i) {
1001
+ i.component("ArticleContentRenderer", Pt);
895
1002
  }
896
1003
  };
897
1004
  export {
898
- Tt as ARTICLE_CONTENT_PROTOCOL_V1,
899
- Lt as ArticleContentRenderer,
900
- _t as ArticleContentRendererPlugin,
901
- z as CURRENT_PROTOCOL_VERSION,
902
- Rt as SUPPORTED_PROTOCOL_VERSIONS,
903
- Lt as default,
904
- gt 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
905
1012
  };