@oxide/design-system 1.7.6 → 1.7.7--canary.87d60df.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.
Files changed (131) hide show
  1. package/components/dist/architecture-I3QFYML2-YZWO3N3B.js +14 -0
  2. package/components/dist/architecture-I3QFYML2-YZWO3N3B.js.map +1 -0
  3. package/components/dist/architectureDiagram-UYN6MBPD-HXPGIDN7.js +8846 -0
  4. package/components/dist/architectureDiagram-UYN6MBPD-HXPGIDN7.js.map +1 -0
  5. package/components/dist/asciidoc.css +1 -1
  6. package/components/dist/blockDiagram-ZHA2E4KO-OAYYKCLF.js +3721 -0
  7. package/components/dist/blockDiagram-ZHA2E4KO-OAYYKCLF.js.map +1 -0
  8. package/components/dist/c4Diagram-6F5ED5ID-TBHFK2XY.js +2599 -0
  9. package/components/dist/c4Diagram-6F5ED5ID-TBHFK2XY.js.map +1 -0
  10. package/components/dist/chunk-2DDKDUUO.js +439 -0
  11. package/components/dist/chunk-2DDKDUUO.js.map +1 -0
  12. package/components/dist/chunk-2NHDMTP7.js +26905 -0
  13. package/components/dist/chunk-2NHDMTP7.js.map +1 -0
  14. package/components/dist/chunk-4IJS44L3.js +22 -0
  15. package/components/dist/chunk-4IJS44L3.js.map +1 -0
  16. package/components/dist/chunk-562WOS3Z.js +1109 -0
  17. package/components/dist/chunk-562WOS3Z.js.map +1 -0
  18. package/components/dist/chunk-6UD2HOKB.js +17082 -0
  19. package/components/dist/chunk-6UD2HOKB.js.map +1 -0
  20. package/components/dist/chunk-76BOQ7BT.js +63 -0
  21. package/components/dist/chunk-76BOQ7BT.js.map +1 -0
  22. package/components/dist/chunk-7I5DT373.js +97 -0
  23. package/components/dist/chunk-7I5DT373.js.map +1 -0
  24. package/components/dist/chunk-BPREMNVP.js +1875 -0
  25. package/components/dist/chunk-BPREMNVP.js.map +1 -0
  26. package/components/dist/chunk-BVYAEHG3.js +122 -0
  27. package/components/dist/chunk-BVYAEHG3.js.map +1 -0
  28. package/components/dist/chunk-BW7DFBOS.js +152 -0
  29. package/components/dist/chunk-BW7DFBOS.js.map +1 -0
  30. package/components/dist/chunk-EZG2MNHW.js +59 -0
  31. package/components/dist/chunk-EZG2MNHW.js.map +1 -0
  32. package/components/dist/chunk-G6QWNAHJ.js +43 -0
  33. package/components/dist/chunk-G6QWNAHJ.js.map +1 -0
  34. package/components/dist/chunk-H72D3HRR.js +1244 -0
  35. package/components/dist/chunk-H72D3HRR.js.map +1 -0
  36. package/components/dist/chunk-K532NZMW.js +46 -0
  37. package/components/dist/chunk-K532NZMW.js.map +1 -0
  38. package/components/dist/chunk-LC3BX2KL.js +25 -0
  39. package/components/dist/chunk-LC3BX2KL.js.map +1 -0
  40. package/components/dist/chunk-LQ2ABR7F.js +5665 -0
  41. package/components/dist/chunk-LQ2ABR7F.js.map +1 -0
  42. package/components/dist/chunk-M6L3MM6K.js +22 -0
  43. package/components/dist/chunk-M6L3MM6K.js.map +1 -0
  44. package/components/dist/chunk-MWA4PRRW.js +122 -0
  45. package/components/dist/chunk-MWA4PRRW.js.map +1 -0
  46. package/components/dist/chunk-ND3FLKHU.js +570 -0
  47. package/components/dist/chunk-ND3FLKHU.js.map +1 -0
  48. package/components/dist/chunk-NIVHLOPB.js +2621 -0
  49. package/components/dist/chunk-NIVHLOPB.js.map +1 -0
  50. package/components/dist/chunk-R6F6FFK7.js +65 -0
  51. package/components/dist/chunk-R6F6FFK7.js.map +1 -0
  52. package/components/dist/chunk-RN5R3L7O.js +2041 -0
  53. package/components/dist/chunk-RN5R3L7O.js.map +1 -0
  54. package/components/dist/chunk-RWDBBMDN.js +10910 -0
  55. package/components/dist/chunk-RWDBBMDN.js.map +1 -0
  56. package/components/dist/chunk-T7HPDS4Z.js +573 -0
  57. package/components/dist/chunk-T7HPDS4Z.js.map +1 -0
  58. package/components/dist/chunk-TG4YEU4Q.js +23 -0
  59. package/components/dist/chunk-TG4YEU4Q.js.map +1 -0
  60. package/components/dist/chunk-U5WCXBW2.js +48 -0
  61. package/components/dist/chunk-U5WCXBW2.js.map +1 -0
  62. package/components/dist/chunk-V6PWN6OH.js +1875 -0
  63. package/components/dist/chunk-V6PWN6OH.js.map +1 -0
  64. package/components/dist/chunk-VLTHNCSD.js +48 -0
  65. package/components/dist/chunk-VLTHNCSD.js.map +1 -0
  66. package/components/dist/chunk-WDK4G4UR.js +2791 -0
  67. package/components/dist/chunk-WDK4G4UR.js.map +1 -0
  68. package/components/dist/chunk-WLVQWTC6.js +77 -0
  69. package/components/dist/chunk-WLVQWTC6.js.map +1 -0
  70. package/components/dist/chunk-YDLS5R4M.js +48 -0
  71. package/components/dist/chunk-YDLS5R4M.js.map +1 -0
  72. package/components/dist/chunk-YGFBWU2Q.js +7 -0
  73. package/components/dist/chunk-YGFBWU2Q.js.map +1 -0
  74. package/components/dist/chunk-ZBL4CWCH.js +2120 -0
  75. package/components/dist/chunk-ZBL4CWCH.js.map +1 -0
  76. package/components/dist/classDiagram-LNE6IOMH-VRQHEQWM.js +40 -0
  77. package/components/dist/classDiagram-LNE6IOMH-VRQHEQWM.js.map +1 -0
  78. package/components/dist/classDiagram-v2-MQ7JQ4JX-5GB4NXXM.js +40 -0
  79. package/components/dist/classDiagram-v2-MQ7JQ4JX-5GB4NXXM.js.map +1 -0
  80. package/components/dist/dagre-4EVJKHTY-XW45LMKR.js +734 -0
  81. package/components/dist/dagre-4EVJKHTY-XW45LMKR.js.map +1 -0
  82. package/components/dist/diagram-QW4FP2JN-J2YMUPB5.js +226 -0
  83. package/components/dist/diagram-QW4FP2JN-J2YMUPB5.js.map +1 -0
  84. package/components/dist/erDiagram-6RL3IURR-HQULDVJI.js +1381 -0
  85. package/components/dist/erDiagram-6RL3IURR-HQULDVJI.js.map +1 -0
  86. package/components/dist/flowDiagram-7ASYPVHJ-2542732I.js +2349 -0
  87. package/components/dist/flowDiagram-7ASYPVHJ-2542732I.js.map +1 -0
  88. package/components/dist/ganttDiagram-NTVNEXSI-V66YQQB3.js +2413 -0
  89. package/components/dist/ganttDiagram-NTVNEXSI-V66YQQB3.js.map +1 -0
  90. package/components/dist/gitGraph-YCYPL57B-AAXPWQN7.js +14 -0
  91. package/components/dist/gitGraph-YCYPL57B-AAXPWQN7.js.map +1 -0
  92. package/components/dist/gitGraphDiagram-NRZ2UAAF-5DU6QMYZ.js +1763 -0
  93. package/components/dist/gitGraphDiagram-NRZ2UAAF-5DU6QMYZ.js.map +1 -0
  94. package/components/dist/index.d.ts +54 -3
  95. package/components/dist/index.js +3794 -226
  96. package/components/dist/index.js.map +1 -1
  97. package/components/dist/info-46DW6VJ7-43TTIEYF.js +14 -0
  98. package/components/dist/info-46DW6VJ7-43TTIEYF.js.map +1 -0
  99. package/components/dist/infoDiagram-A4XQUW5V-UZERSQDI.js +54 -0
  100. package/components/dist/infoDiagram-A4XQUW5V-UZERSQDI.js.map +1 -0
  101. package/components/dist/journeyDiagram-G5WM74LC-RVKMRGRW.js +1244 -0
  102. package/components/dist/journeyDiagram-G5WM74LC-RVKMRGRW.js.map +1 -0
  103. package/components/dist/kanban-definition-QRCXZQQD-NWU5I3TK.js +1119 -0
  104. package/components/dist/kanban-definition-QRCXZQQD-NWU5I3TK.js.map +1 -0
  105. package/components/dist/katex-WNZY3CE5.js +14484 -0
  106. package/components/dist/katex-WNZY3CE5.js.map +1 -0
  107. package/components/dist/mindmap-definition-GWI6TPTV-MISEH6LG.js +6013 -0
  108. package/components/dist/mindmap-definition-GWI6TPTV-MISEH6LG.js.map +1 -0
  109. package/components/dist/packet-W2GHVCYJ-FBZCFIPR.js +14 -0
  110. package/components/dist/packet-W2GHVCYJ-FBZCFIPR.js.map +1 -0
  111. package/components/dist/pie-BEWT4RHE-UFFBBCXM.js +14 -0
  112. package/components/dist/pie-BEWT4RHE-UFFBBCXM.js.map +1 -0
  113. package/components/dist/pieDiagram-YF2LJOPJ-IXEVHPCM.js +223 -0
  114. package/components/dist/pieDiagram-YF2LJOPJ-IXEVHPCM.js.map +1 -0
  115. package/components/dist/quadrantDiagram-OS5C2QUG-MW26UCZV.js +1408 -0
  116. package/components/dist/quadrantDiagram-OS5C2QUG-MW26UCZV.js.map +1 -0
  117. package/components/dist/requirementDiagram-MIRIMTAZ-BX24AAHL.js +1175 -0
  118. package/components/dist/requirementDiagram-MIRIMTAZ-BX24AAHL.js.map +1 -0
  119. package/components/dist/sankeyDiagram-Y46BX6SQ-5RKUGG63.js +1278 -0
  120. package/components/dist/sankeyDiagram-Y46BX6SQ-5RKUGG63.js.map +1 -0
  121. package/components/dist/sequenceDiagram-G6AWOVSC-2T3JBUZ2.js +3529 -0
  122. package/components/dist/sequenceDiagram-G6AWOVSC-2T3JBUZ2.js.map +1 -0
  123. package/components/dist/stateDiagram-MAYHULR4-HZ5EGLPA.js +505 -0
  124. package/components/dist/stateDiagram-MAYHULR4-HZ5EGLPA.js.map +1 -0
  125. package/components/dist/stateDiagram-v2-4JROLMXI-DN2FEZV3.js +40 -0
  126. package/components/dist/stateDiagram-v2-4JROLMXI-DN2FEZV3.js.map +1 -0
  127. package/components/dist/timeline-definition-U7ZMHBDA-GB6AKKW4.js +1260 -0
  128. package/components/dist/timeline-definition-U7ZMHBDA-GB6AKKW4.js.map +1 -0
  129. package/components/dist/xychartDiagram-6QU3TZC5-BFFLEHUP.js +1877 -0
  130. package/components/dist/xychartDiagram-6QU3TZC5-BFFLEHUP.js.map +1 -0
  131. package/package.json +8 -2
@@ -0,0 +1,2621 @@
1
+ import {
2
+ decodeEntities
3
+ } from "./chunk-T7HPDS4Z.js";
4
+ import {
5
+ __name,
6
+ common_default,
7
+ getConfig2,
8
+ hasKatex,
9
+ log,
10
+ renderKatex,
11
+ select_default
12
+ } from "./chunk-RWDBBMDN.js";
13
+
14
+ // node_modules/marked/lib/marked.esm.js
15
+ function _getDefaults() {
16
+ return {
17
+ async: false,
18
+ breaks: false,
19
+ extensions: null,
20
+ gfm: true,
21
+ hooks: null,
22
+ pedantic: false,
23
+ renderer: null,
24
+ silent: false,
25
+ tokenizer: null,
26
+ walkTokens: null
27
+ };
28
+ }
29
+ var _defaults = _getDefaults();
30
+ function changeDefaults(newDefaults) {
31
+ _defaults = newDefaults;
32
+ }
33
+ var escapeTest = /[&<>"']/;
34
+ var escapeReplace = new RegExp(escapeTest.source, "g");
35
+ var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
36
+ var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
37
+ var escapeReplacements = {
38
+ "&": "&amp;",
39
+ "<": "&lt;",
40
+ ">": "&gt;",
41
+ '"': "&quot;",
42
+ "'": "&#39;"
43
+ };
44
+ var getEscapeReplacement = (ch) => escapeReplacements[ch];
45
+ function escape$1(html2, encode) {
46
+ if (encode) {
47
+ if (escapeTest.test(html2)) {
48
+ return html2.replace(escapeReplace, getEscapeReplacement);
49
+ }
50
+ } else {
51
+ if (escapeTestNoEncode.test(html2)) {
52
+ return html2.replace(escapeReplaceNoEncode, getEscapeReplacement);
53
+ }
54
+ }
55
+ return html2;
56
+ }
57
+ var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
58
+ function unescape(html2) {
59
+ return html2.replace(unescapeTest, (_, n) => {
60
+ n = n.toLowerCase();
61
+ if (n === "colon")
62
+ return ":";
63
+ if (n.charAt(0) === "#") {
64
+ return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
65
+ }
66
+ return "";
67
+ });
68
+ }
69
+ var caret = /(^|[^\[])\^/g;
70
+ function edit(regex, opt) {
71
+ let source = typeof regex === "string" ? regex : regex.source;
72
+ opt = opt || "";
73
+ const obj = {
74
+ replace: (name, val) => {
75
+ let valSource = typeof val === "string" ? val : val.source;
76
+ valSource = valSource.replace(caret, "$1");
77
+ source = source.replace(name, valSource);
78
+ return obj;
79
+ },
80
+ getRegex: () => {
81
+ return new RegExp(source, opt);
82
+ }
83
+ };
84
+ return obj;
85
+ }
86
+ function cleanUrl(href) {
87
+ try {
88
+ href = encodeURI(href).replace(/%25/g, "%");
89
+ } catch {
90
+ return null;
91
+ }
92
+ return href;
93
+ }
94
+ var noopTest = { exec: () => null };
95
+ function splitCells(tableRow, count) {
96
+ const row = tableRow.replace(/\|/g, (match, offset, str) => {
97
+ let escaped = false;
98
+ let curr = offset;
99
+ while (--curr >= 0 && str[curr] === "\\")
100
+ escaped = !escaped;
101
+ if (escaped) {
102
+ return "|";
103
+ } else {
104
+ return " |";
105
+ }
106
+ }), cells = row.split(/ \|/);
107
+ let i = 0;
108
+ if (!cells[0].trim()) {
109
+ cells.shift();
110
+ }
111
+ if (cells.length > 0 && !cells[cells.length - 1].trim()) {
112
+ cells.pop();
113
+ }
114
+ if (count) {
115
+ if (cells.length > count) {
116
+ cells.splice(count);
117
+ } else {
118
+ while (cells.length < count)
119
+ cells.push("");
120
+ }
121
+ }
122
+ for (; i < cells.length; i++) {
123
+ cells[i] = cells[i].trim().replace(/\\\|/g, "|");
124
+ }
125
+ return cells;
126
+ }
127
+ function rtrim(str, c, invert) {
128
+ const l = str.length;
129
+ if (l === 0) {
130
+ return "";
131
+ }
132
+ let suffLen = 0;
133
+ while (suffLen < l) {
134
+ const currChar = str.charAt(l - suffLen - 1);
135
+ if (currChar === c && !invert) {
136
+ suffLen++;
137
+ } else if (currChar !== c && invert) {
138
+ suffLen++;
139
+ } else {
140
+ break;
141
+ }
142
+ }
143
+ return str.slice(0, l - suffLen);
144
+ }
145
+ function findClosingBracket(str, b) {
146
+ if (str.indexOf(b[1]) === -1) {
147
+ return -1;
148
+ }
149
+ let level = 0;
150
+ for (let i = 0; i < str.length; i++) {
151
+ if (str[i] === "\\") {
152
+ i++;
153
+ } else if (str[i] === b[0]) {
154
+ level++;
155
+ } else if (str[i] === b[1]) {
156
+ level--;
157
+ if (level < 0) {
158
+ return i;
159
+ }
160
+ }
161
+ }
162
+ return -1;
163
+ }
164
+ function outputLink(cap, link2, raw, lexer2) {
165
+ const href = link2.href;
166
+ const title = link2.title ? escape$1(link2.title) : null;
167
+ const text = cap[1].replace(/\\([\[\]])/g, "$1");
168
+ if (cap[0].charAt(0) !== "!") {
169
+ lexer2.state.inLink = true;
170
+ const token = {
171
+ type: "link",
172
+ raw,
173
+ href,
174
+ title,
175
+ text,
176
+ tokens: lexer2.inlineTokens(text)
177
+ };
178
+ lexer2.state.inLink = false;
179
+ return token;
180
+ }
181
+ return {
182
+ type: "image",
183
+ raw,
184
+ href,
185
+ title,
186
+ text: escape$1(text)
187
+ };
188
+ }
189
+ function indentCodeCompensation(raw, text) {
190
+ const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
191
+ if (matchIndentToCode === null) {
192
+ return text;
193
+ }
194
+ const indentToCode = matchIndentToCode[1];
195
+ return text.split("\n").map((node) => {
196
+ const matchIndentInNode = node.match(/^\s+/);
197
+ if (matchIndentInNode === null) {
198
+ return node;
199
+ }
200
+ const [indentInNode] = matchIndentInNode;
201
+ if (indentInNode.length >= indentToCode.length) {
202
+ return node.slice(indentToCode.length);
203
+ }
204
+ return node;
205
+ }).join("\n");
206
+ }
207
+ var _Tokenizer = class {
208
+ options;
209
+ rules;
210
+ // set by the lexer
211
+ lexer;
212
+ // set by the lexer
213
+ constructor(options2) {
214
+ this.options = options2 || _defaults;
215
+ }
216
+ space(src) {
217
+ const cap = this.rules.block.newline.exec(src);
218
+ if (cap && cap[0].length > 0) {
219
+ return {
220
+ type: "space",
221
+ raw: cap[0]
222
+ };
223
+ }
224
+ }
225
+ code(src) {
226
+ const cap = this.rules.block.code.exec(src);
227
+ if (cap) {
228
+ const text = cap[0].replace(/^ {1,4}/gm, "");
229
+ return {
230
+ type: "code",
231
+ raw: cap[0],
232
+ codeBlockStyle: "indented",
233
+ text: !this.options.pedantic ? rtrim(text, "\n") : text
234
+ };
235
+ }
236
+ }
237
+ fences(src) {
238
+ const cap = this.rules.block.fences.exec(src);
239
+ if (cap) {
240
+ const raw = cap[0];
241
+ const text = indentCodeCompensation(raw, cap[3] || "");
242
+ return {
243
+ type: "code",
244
+ raw,
245
+ lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
246
+ text
247
+ };
248
+ }
249
+ }
250
+ heading(src) {
251
+ const cap = this.rules.block.heading.exec(src);
252
+ if (cap) {
253
+ let text = cap[2].trim();
254
+ if (/#$/.test(text)) {
255
+ const trimmed = rtrim(text, "#");
256
+ if (this.options.pedantic) {
257
+ text = trimmed.trim();
258
+ } else if (!trimmed || / $/.test(trimmed)) {
259
+ text = trimmed.trim();
260
+ }
261
+ }
262
+ return {
263
+ type: "heading",
264
+ raw: cap[0],
265
+ depth: cap[1].length,
266
+ text,
267
+ tokens: this.lexer.inline(text)
268
+ };
269
+ }
270
+ }
271
+ hr(src) {
272
+ const cap = this.rules.block.hr.exec(src);
273
+ if (cap) {
274
+ return {
275
+ type: "hr",
276
+ raw: rtrim(cap[0], "\n")
277
+ };
278
+ }
279
+ }
280
+ blockquote(src) {
281
+ const cap = this.rules.block.blockquote.exec(src);
282
+ if (cap) {
283
+ let lines = rtrim(cap[0], "\n").split("\n");
284
+ let raw = "";
285
+ let text = "";
286
+ const tokens = [];
287
+ while (lines.length > 0) {
288
+ let inBlockquote = false;
289
+ const currentLines = [];
290
+ let i;
291
+ for (i = 0; i < lines.length; i++) {
292
+ if (/^ {0,3}>/.test(lines[i])) {
293
+ currentLines.push(lines[i]);
294
+ inBlockquote = true;
295
+ } else if (!inBlockquote) {
296
+ currentLines.push(lines[i]);
297
+ } else {
298
+ break;
299
+ }
300
+ }
301
+ lines = lines.slice(i);
302
+ const currentRaw = currentLines.join("\n");
303
+ const currentText = currentRaw.replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n $1").replace(/^ {0,3}>[ \t]?/gm, "");
304
+ raw = raw ? `${raw}
305
+ ${currentRaw}` : currentRaw;
306
+ text = text ? `${text}
307
+ ${currentText}` : currentText;
308
+ const top = this.lexer.state.top;
309
+ this.lexer.state.top = true;
310
+ this.lexer.blockTokens(currentText, tokens, true);
311
+ this.lexer.state.top = top;
312
+ if (lines.length === 0) {
313
+ break;
314
+ }
315
+ const lastToken = tokens[tokens.length - 1];
316
+ if (lastToken?.type === "code") {
317
+ break;
318
+ } else if (lastToken?.type === "blockquote") {
319
+ const oldToken = lastToken;
320
+ const newText = oldToken.raw + "\n" + lines.join("\n");
321
+ const newToken = this.blockquote(newText);
322
+ tokens[tokens.length - 1] = newToken;
323
+ raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
324
+ text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
325
+ break;
326
+ } else if (lastToken?.type === "list") {
327
+ const oldToken = lastToken;
328
+ const newText = oldToken.raw + "\n" + lines.join("\n");
329
+ const newToken = this.list(newText);
330
+ tokens[tokens.length - 1] = newToken;
331
+ raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
332
+ text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
333
+ lines = newText.substring(tokens[tokens.length - 1].raw.length).split("\n");
334
+ continue;
335
+ }
336
+ }
337
+ return {
338
+ type: "blockquote",
339
+ raw,
340
+ tokens,
341
+ text
342
+ };
343
+ }
344
+ }
345
+ list(src) {
346
+ let cap = this.rules.block.list.exec(src);
347
+ if (cap) {
348
+ let bull = cap[1].trim();
349
+ const isordered = bull.length > 1;
350
+ const list2 = {
351
+ type: "list",
352
+ raw: "",
353
+ ordered: isordered,
354
+ start: isordered ? +bull.slice(0, -1) : "",
355
+ loose: false,
356
+ items: []
357
+ };
358
+ bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
359
+ if (this.options.pedantic) {
360
+ bull = isordered ? bull : "[*+-]";
361
+ }
362
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
363
+ let endsWithBlankLine = false;
364
+ while (src) {
365
+ let endEarly = false;
366
+ let raw = "";
367
+ let itemContents = "";
368
+ if (!(cap = itemRegex.exec(src))) {
369
+ break;
370
+ }
371
+ if (this.rules.block.hr.test(src)) {
372
+ break;
373
+ }
374
+ raw = cap[0];
375
+ src = src.substring(raw.length);
376
+ let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t) => " ".repeat(3 * t.length));
377
+ let nextLine = src.split("\n", 1)[0];
378
+ let blankLine = !line.trim();
379
+ let indent = 0;
380
+ if (this.options.pedantic) {
381
+ indent = 2;
382
+ itemContents = line.trimStart();
383
+ } else if (blankLine) {
384
+ indent = cap[1].length + 1;
385
+ } else {
386
+ indent = cap[2].search(/[^ ]/);
387
+ indent = indent > 4 ? 1 : indent;
388
+ itemContents = line.slice(indent);
389
+ indent += cap[1].length;
390
+ }
391
+ if (blankLine && /^ *$/.test(nextLine)) {
392
+ raw += nextLine + "\n";
393
+ src = src.substring(nextLine.length + 1);
394
+ endEarly = true;
395
+ }
396
+ if (!endEarly) {
397
+ const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`);
398
+ const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
399
+ const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
400
+ const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
401
+ while (src) {
402
+ const rawLine = src.split("\n", 1)[0];
403
+ nextLine = rawLine;
404
+ if (this.options.pedantic) {
405
+ nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
406
+ }
407
+ if (fencesBeginRegex.test(nextLine)) {
408
+ break;
409
+ }
410
+ if (headingBeginRegex.test(nextLine)) {
411
+ break;
412
+ }
413
+ if (nextBulletRegex.test(nextLine)) {
414
+ break;
415
+ }
416
+ if (hrRegex.test(src)) {
417
+ break;
418
+ }
419
+ if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
420
+ itemContents += "\n" + nextLine.slice(indent);
421
+ } else {
422
+ if (blankLine) {
423
+ break;
424
+ }
425
+ if (line.search(/[^ ]/) >= 4) {
426
+ break;
427
+ }
428
+ if (fencesBeginRegex.test(line)) {
429
+ break;
430
+ }
431
+ if (headingBeginRegex.test(line)) {
432
+ break;
433
+ }
434
+ if (hrRegex.test(line)) {
435
+ break;
436
+ }
437
+ itemContents += "\n" + nextLine;
438
+ }
439
+ if (!blankLine && !nextLine.trim()) {
440
+ blankLine = true;
441
+ }
442
+ raw += rawLine + "\n";
443
+ src = src.substring(rawLine.length + 1);
444
+ line = nextLine.slice(indent);
445
+ }
446
+ }
447
+ if (!list2.loose) {
448
+ if (endsWithBlankLine) {
449
+ list2.loose = true;
450
+ } else if (/\n *\n *$/.test(raw)) {
451
+ endsWithBlankLine = true;
452
+ }
453
+ }
454
+ let istask = null;
455
+ let ischecked;
456
+ if (this.options.gfm) {
457
+ istask = /^\[[ xX]\] /.exec(itemContents);
458
+ if (istask) {
459
+ ischecked = istask[0] !== "[ ] ";
460
+ itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
461
+ }
462
+ }
463
+ list2.items.push({
464
+ type: "list_item",
465
+ raw,
466
+ task: !!istask,
467
+ checked: ischecked,
468
+ loose: false,
469
+ text: itemContents,
470
+ tokens: []
471
+ });
472
+ list2.raw += raw;
473
+ }
474
+ list2.items[list2.items.length - 1].raw = list2.items[list2.items.length - 1].raw.trimEnd();
475
+ list2.items[list2.items.length - 1].text = list2.items[list2.items.length - 1].text.trimEnd();
476
+ list2.raw = list2.raw.trimEnd();
477
+ for (let i = 0; i < list2.items.length; i++) {
478
+ this.lexer.state.top = false;
479
+ list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
480
+ if (!list2.loose) {
481
+ const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
482
+ const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => /\n.*\n/.test(t.raw));
483
+ list2.loose = hasMultipleLineBreaks;
484
+ }
485
+ }
486
+ if (list2.loose) {
487
+ for (let i = 0; i < list2.items.length; i++) {
488
+ list2.items[i].loose = true;
489
+ }
490
+ }
491
+ return list2;
492
+ }
493
+ }
494
+ html(src) {
495
+ const cap = this.rules.block.html.exec(src);
496
+ if (cap) {
497
+ const token = {
498
+ type: "html",
499
+ block: true,
500
+ raw: cap[0],
501
+ pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
502
+ text: cap[0]
503
+ };
504
+ return token;
505
+ }
506
+ }
507
+ def(src) {
508
+ const cap = this.rules.block.def.exec(src);
509
+ if (cap) {
510
+ const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
511
+ const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
512
+ const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
513
+ return {
514
+ type: "def",
515
+ tag: tag2,
516
+ raw: cap[0],
517
+ href,
518
+ title
519
+ };
520
+ }
521
+ }
522
+ table(src) {
523
+ const cap = this.rules.block.table.exec(src);
524
+ if (!cap) {
525
+ return;
526
+ }
527
+ if (!/[:|]/.test(cap[2])) {
528
+ return;
529
+ }
530
+ const headers = splitCells(cap[1]);
531
+ const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
532
+ const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
533
+ const item = {
534
+ type: "table",
535
+ raw: cap[0],
536
+ header: [],
537
+ align: [],
538
+ rows: []
539
+ };
540
+ if (headers.length !== aligns.length) {
541
+ return;
542
+ }
543
+ for (const align of aligns) {
544
+ if (/^ *-+: *$/.test(align)) {
545
+ item.align.push("right");
546
+ } else if (/^ *:-+: *$/.test(align)) {
547
+ item.align.push("center");
548
+ } else if (/^ *:-+ *$/.test(align)) {
549
+ item.align.push("left");
550
+ } else {
551
+ item.align.push(null);
552
+ }
553
+ }
554
+ for (let i = 0; i < headers.length; i++) {
555
+ item.header.push({
556
+ text: headers[i],
557
+ tokens: this.lexer.inline(headers[i]),
558
+ header: true,
559
+ align: item.align[i]
560
+ });
561
+ }
562
+ for (const row of rows) {
563
+ item.rows.push(splitCells(row, item.header.length).map((cell, i) => {
564
+ return {
565
+ text: cell,
566
+ tokens: this.lexer.inline(cell),
567
+ header: false,
568
+ align: item.align[i]
569
+ };
570
+ }));
571
+ }
572
+ return item;
573
+ }
574
+ lheading(src) {
575
+ const cap = this.rules.block.lheading.exec(src);
576
+ if (cap) {
577
+ return {
578
+ type: "heading",
579
+ raw: cap[0],
580
+ depth: cap[2].charAt(0) === "=" ? 1 : 2,
581
+ text: cap[1],
582
+ tokens: this.lexer.inline(cap[1])
583
+ };
584
+ }
585
+ }
586
+ paragraph(src) {
587
+ const cap = this.rules.block.paragraph.exec(src);
588
+ if (cap) {
589
+ const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
590
+ return {
591
+ type: "paragraph",
592
+ raw: cap[0],
593
+ text,
594
+ tokens: this.lexer.inline(text)
595
+ };
596
+ }
597
+ }
598
+ text(src) {
599
+ const cap = this.rules.block.text.exec(src);
600
+ if (cap) {
601
+ return {
602
+ type: "text",
603
+ raw: cap[0],
604
+ text: cap[0],
605
+ tokens: this.lexer.inline(cap[0])
606
+ };
607
+ }
608
+ }
609
+ escape(src) {
610
+ const cap = this.rules.inline.escape.exec(src);
611
+ if (cap) {
612
+ return {
613
+ type: "escape",
614
+ raw: cap[0],
615
+ text: escape$1(cap[1])
616
+ };
617
+ }
618
+ }
619
+ tag(src) {
620
+ const cap = this.rules.inline.tag.exec(src);
621
+ if (cap) {
622
+ if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
623
+ this.lexer.state.inLink = true;
624
+ } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
625
+ this.lexer.state.inLink = false;
626
+ }
627
+ if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
628
+ this.lexer.state.inRawBlock = true;
629
+ } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
630
+ this.lexer.state.inRawBlock = false;
631
+ }
632
+ return {
633
+ type: "html",
634
+ raw: cap[0],
635
+ inLink: this.lexer.state.inLink,
636
+ inRawBlock: this.lexer.state.inRawBlock,
637
+ block: false,
638
+ text: cap[0]
639
+ };
640
+ }
641
+ }
642
+ link(src) {
643
+ const cap = this.rules.inline.link.exec(src);
644
+ if (cap) {
645
+ const trimmedUrl = cap[2].trim();
646
+ if (!this.options.pedantic && /^</.test(trimmedUrl)) {
647
+ if (!/>$/.test(trimmedUrl)) {
648
+ return;
649
+ }
650
+ const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
651
+ if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
652
+ return;
653
+ }
654
+ } else {
655
+ const lastParenIndex = findClosingBracket(cap[2], "()");
656
+ if (lastParenIndex > -1) {
657
+ const start = cap[0].indexOf("!") === 0 ? 5 : 4;
658
+ const linkLen = start + cap[1].length + lastParenIndex;
659
+ cap[2] = cap[2].substring(0, lastParenIndex);
660
+ cap[0] = cap[0].substring(0, linkLen).trim();
661
+ cap[3] = "";
662
+ }
663
+ }
664
+ let href = cap[2];
665
+ let title = "";
666
+ if (this.options.pedantic) {
667
+ const link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
668
+ if (link2) {
669
+ href = link2[1];
670
+ title = link2[3];
671
+ }
672
+ } else {
673
+ title = cap[3] ? cap[3].slice(1, -1) : "";
674
+ }
675
+ href = href.trim();
676
+ if (/^</.test(href)) {
677
+ if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
678
+ href = href.slice(1);
679
+ } else {
680
+ href = href.slice(1, -1);
681
+ }
682
+ }
683
+ return outputLink(cap, {
684
+ href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
685
+ title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
686
+ }, cap[0], this.lexer);
687
+ }
688
+ }
689
+ reflink(src, links) {
690
+ let cap;
691
+ if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
692
+ const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
693
+ const link2 = links[linkString.toLowerCase()];
694
+ if (!link2) {
695
+ const text = cap[0].charAt(0);
696
+ return {
697
+ type: "text",
698
+ raw: text,
699
+ text
700
+ };
701
+ }
702
+ return outputLink(cap, link2, cap[0], this.lexer);
703
+ }
704
+ }
705
+ emStrong(src, maskedSrc, prevChar = "") {
706
+ let match = this.rules.inline.emStrongLDelim.exec(src);
707
+ if (!match)
708
+ return;
709
+ if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
710
+ return;
711
+ const nextChar = match[1] || match[2] || "";
712
+ if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
713
+ const lLength = [...match[0]].length - 1;
714
+ let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
715
+ const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
716
+ endReg.lastIndex = 0;
717
+ maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
718
+ while ((match = endReg.exec(maskedSrc)) != null) {
719
+ rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
720
+ if (!rDelim)
721
+ continue;
722
+ rLength = [...rDelim].length;
723
+ if (match[3] || match[4]) {
724
+ delimTotal += rLength;
725
+ continue;
726
+ } else if (match[5] || match[6]) {
727
+ if (lLength % 3 && !((lLength + rLength) % 3)) {
728
+ midDelimTotal += rLength;
729
+ continue;
730
+ }
731
+ }
732
+ delimTotal -= rLength;
733
+ if (delimTotal > 0)
734
+ continue;
735
+ rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
736
+ const lastCharLength = [...match[0]][0].length;
737
+ const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
738
+ if (Math.min(lLength, rLength) % 2) {
739
+ const text2 = raw.slice(1, -1);
740
+ return {
741
+ type: "em",
742
+ raw,
743
+ text: text2,
744
+ tokens: this.lexer.inlineTokens(text2)
745
+ };
746
+ }
747
+ const text = raw.slice(2, -2);
748
+ return {
749
+ type: "strong",
750
+ raw,
751
+ text,
752
+ tokens: this.lexer.inlineTokens(text)
753
+ };
754
+ }
755
+ }
756
+ }
757
+ codespan(src) {
758
+ const cap = this.rules.inline.code.exec(src);
759
+ if (cap) {
760
+ let text = cap[2].replace(/\n/g, " ");
761
+ const hasNonSpaceChars = /[^ ]/.test(text);
762
+ const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
763
+ if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
764
+ text = text.substring(1, text.length - 1);
765
+ }
766
+ text = escape$1(text, true);
767
+ return {
768
+ type: "codespan",
769
+ raw: cap[0],
770
+ text
771
+ };
772
+ }
773
+ }
774
+ br(src) {
775
+ const cap = this.rules.inline.br.exec(src);
776
+ if (cap) {
777
+ return {
778
+ type: "br",
779
+ raw: cap[0]
780
+ };
781
+ }
782
+ }
783
+ del(src) {
784
+ const cap = this.rules.inline.del.exec(src);
785
+ if (cap) {
786
+ return {
787
+ type: "del",
788
+ raw: cap[0],
789
+ text: cap[2],
790
+ tokens: this.lexer.inlineTokens(cap[2])
791
+ };
792
+ }
793
+ }
794
+ autolink(src) {
795
+ const cap = this.rules.inline.autolink.exec(src);
796
+ if (cap) {
797
+ let text, href;
798
+ if (cap[2] === "@") {
799
+ text = escape$1(cap[1]);
800
+ href = "mailto:" + text;
801
+ } else {
802
+ text = escape$1(cap[1]);
803
+ href = text;
804
+ }
805
+ return {
806
+ type: "link",
807
+ raw: cap[0],
808
+ text,
809
+ href,
810
+ tokens: [
811
+ {
812
+ type: "text",
813
+ raw: text,
814
+ text
815
+ }
816
+ ]
817
+ };
818
+ }
819
+ }
820
+ url(src) {
821
+ let cap;
822
+ if (cap = this.rules.inline.url.exec(src)) {
823
+ let text, href;
824
+ if (cap[2] === "@") {
825
+ text = escape$1(cap[0]);
826
+ href = "mailto:" + text;
827
+ } else {
828
+ let prevCapZero;
829
+ do {
830
+ prevCapZero = cap[0];
831
+ cap[0] = this.rules.inline._backpedal.exec(cap[0])?.[0] ?? "";
832
+ } while (prevCapZero !== cap[0]);
833
+ text = escape$1(cap[0]);
834
+ if (cap[1] === "www.") {
835
+ href = "http://" + cap[0];
836
+ } else {
837
+ href = cap[0];
838
+ }
839
+ }
840
+ return {
841
+ type: "link",
842
+ raw: cap[0],
843
+ text,
844
+ href,
845
+ tokens: [
846
+ {
847
+ type: "text",
848
+ raw: text,
849
+ text
850
+ }
851
+ ]
852
+ };
853
+ }
854
+ }
855
+ inlineText(src) {
856
+ const cap = this.rules.inline.text.exec(src);
857
+ if (cap) {
858
+ let text;
859
+ if (this.lexer.state.inRawBlock) {
860
+ text = cap[0];
861
+ } else {
862
+ text = escape$1(cap[0]);
863
+ }
864
+ return {
865
+ type: "text",
866
+ raw: cap[0],
867
+ text
868
+ };
869
+ }
870
+ }
871
+ };
872
+ var newline = /^(?: *(?:\n|$))+/;
873
+ var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
874
+ var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
875
+ var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
876
+ var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
877
+ var bullet = /(?:[*+-]|\d{1,9}[.)])/;
878
+ var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
879
+ var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
880
+ var blockText = /^[^\n]+/;
881
+ var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
882
+ var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
883
+ var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
884
+ var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
885
+ var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
886
+ var html = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
887
+ var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
888
+ var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
889
+ var blockNormal = {
890
+ blockquote,
891
+ code: blockCode,
892
+ def,
893
+ fences,
894
+ heading,
895
+ hr,
896
+ html,
897
+ lheading,
898
+ list,
899
+ newline,
900
+ paragraph,
901
+ table: noopTest,
902
+ text: blockText
903
+ };
904
+ var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
905
+ var blockGfm = {
906
+ ...blockNormal,
907
+ table: gfmTable,
908
+ paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
909
+ };
910
+ var blockPedantic = {
911
+ ...blockNormal,
912
+ html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
913
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
914
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
915
+ fences: noopTest,
916
+ // fences not supported
917
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
918
+ paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
919
+ };
920
+ var escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
921
+ var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
922
+ var br = /^( {2,}|\\)\n(?!\s*$)/;
923
+ var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
924
+ var _punctuation = "\\p{P}\\p{S}";
925
+ var punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
926
+ var blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
927
+ var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
928
+ var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex();
929
+ var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
930
+ var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
931
+ var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
932
+ var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
933
+ var tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
934
+ var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
935
+ var link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
936
+ var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
937
+ var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
938
+ var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
939
+ var inlineNormal = {
940
+ _backpedal: noopTest,
941
+ // only used for GFM url
942
+ anyPunctuation,
943
+ autolink,
944
+ blockSkip,
945
+ br,
946
+ code: inlineCode,
947
+ del: noopTest,
948
+ emStrongLDelim,
949
+ emStrongRDelimAst,
950
+ emStrongRDelimUnd,
951
+ escape,
952
+ link,
953
+ nolink,
954
+ punctuation,
955
+ reflink,
956
+ reflinkSearch,
957
+ tag,
958
+ text: inlineText,
959
+ url: noopTest
960
+ };
961
+ var inlinePedantic = {
962
+ ...inlineNormal,
963
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
964
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
965
+ };
966
+ var inlineGfm = {
967
+ ...inlineNormal,
968
+ escape: edit(escape).replace("])", "~|])").getRegex(),
969
+ url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
970
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
971
+ del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
972
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
973
+ };
974
+ var inlineBreaks = {
975
+ ...inlineGfm,
976
+ br: edit(br).replace("{2,}", "*").getRegex(),
977
+ text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
978
+ };
979
+ var block = {
980
+ normal: blockNormal,
981
+ gfm: blockGfm,
982
+ pedantic: blockPedantic
983
+ };
984
+ var inline = {
985
+ normal: inlineNormal,
986
+ gfm: inlineGfm,
987
+ breaks: inlineBreaks,
988
+ pedantic: inlinePedantic
989
+ };
990
+ var _Lexer = class __Lexer {
991
+ tokens;
992
+ options;
993
+ state;
994
+ tokenizer;
995
+ inlineQueue;
996
+ constructor(options2) {
997
+ this.tokens = [];
998
+ this.tokens.links = /* @__PURE__ */ Object.create(null);
999
+ this.options = options2 || _defaults;
1000
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
1001
+ this.tokenizer = this.options.tokenizer;
1002
+ this.tokenizer.options = this.options;
1003
+ this.tokenizer.lexer = this;
1004
+ this.inlineQueue = [];
1005
+ this.state = {
1006
+ inLink: false,
1007
+ inRawBlock: false,
1008
+ top: true
1009
+ };
1010
+ const rules = {
1011
+ block: block.normal,
1012
+ inline: inline.normal
1013
+ };
1014
+ if (this.options.pedantic) {
1015
+ rules.block = block.pedantic;
1016
+ rules.inline = inline.pedantic;
1017
+ } else if (this.options.gfm) {
1018
+ rules.block = block.gfm;
1019
+ if (this.options.breaks) {
1020
+ rules.inline = inline.breaks;
1021
+ } else {
1022
+ rules.inline = inline.gfm;
1023
+ }
1024
+ }
1025
+ this.tokenizer.rules = rules;
1026
+ }
1027
+ /**
1028
+ * Expose Rules
1029
+ */
1030
+ static get rules() {
1031
+ return {
1032
+ block,
1033
+ inline
1034
+ };
1035
+ }
1036
+ /**
1037
+ * Static Lex Method
1038
+ */
1039
+ static lex(src, options2) {
1040
+ const lexer2 = new __Lexer(options2);
1041
+ return lexer2.lex(src);
1042
+ }
1043
+ /**
1044
+ * Static Lex Inline Method
1045
+ */
1046
+ static lexInline(src, options2) {
1047
+ const lexer2 = new __Lexer(options2);
1048
+ return lexer2.inlineTokens(src);
1049
+ }
1050
+ /**
1051
+ * Preprocessing
1052
+ */
1053
+ lex(src) {
1054
+ src = src.replace(/\r\n|\r/g, "\n");
1055
+ this.blockTokens(src, this.tokens);
1056
+ for (let i = 0; i < this.inlineQueue.length; i++) {
1057
+ const next = this.inlineQueue[i];
1058
+ this.inlineTokens(next.src, next.tokens);
1059
+ }
1060
+ this.inlineQueue = [];
1061
+ return this.tokens;
1062
+ }
1063
+ blockTokens(src, tokens = [], lastParagraphClipped = false) {
1064
+ if (this.options.pedantic) {
1065
+ src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
1066
+ } else {
1067
+ src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1068
+ return leading + " ".repeat(tabs.length);
1069
+ });
1070
+ }
1071
+ let token;
1072
+ let lastToken;
1073
+ let cutSrc;
1074
+ while (src) {
1075
+ if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
1076
+ if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1077
+ src = src.substring(token.raw.length);
1078
+ tokens.push(token);
1079
+ return true;
1080
+ }
1081
+ return false;
1082
+ })) {
1083
+ continue;
1084
+ }
1085
+ if (token = this.tokenizer.space(src)) {
1086
+ src = src.substring(token.raw.length);
1087
+ if (token.raw.length === 1 && tokens.length > 0) {
1088
+ tokens[tokens.length - 1].raw += "\n";
1089
+ } else {
1090
+ tokens.push(token);
1091
+ }
1092
+ continue;
1093
+ }
1094
+ if (token = this.tokenizer.code(src)) {
1095
+ src = src.substring(token.raw.length);
1096
+ lastToken = tokens[tokens.length - 1];
1097
+ if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
1098
+ lastToken.raw += "\n" + token.raw;
1099
+ lastToken.text += "\n" + token.text;
1100
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1101
+ } else {
1102
+ tokens.push(token);
1103
+ }
1104
+ continue;
1105
+ }
1106
+ if (token = this.tokenizer.fences(src)) {
1107
+ src = src.substring(token.raw.length);
1108
+ tokens.push(token);
1109
+ continue;
1110
+ }
1111
+ if (token = this.tokenizer.heading(src)) {
1112
+ src = src.substring(token.raw.length);
1113
+ tokens.push(token);
1114
+ continue;
1115
+ }
1116
+ if (token = this.tokenizer.hr(src)) {
1117
+ src = src.substring(token.raw.length);
1118
+ tokens.push(token);
1119
+ continue;
1120
+ }
1121
+ if (token = this.tokenizer.blockquote(src)) {
1122
+ src = src.substring(token.raw.length);
1123
+ tokens.push(token);
1124
+ continue;
1125
+ }
1126
+ if (token = this.tokenizer.list(src)) {
1127
+ src = src.substring(token.raw.length);
1128
+ tokens.push(token);
1129
+ continue;
1130
+ }
1131
+ if (token = this.tokenizer.html(src)) {
1132
+ src = src.substring(token.raw.length);
1133
+ tokens.push(token);
1134
+ continue;
1135
+ }
1136
+ if (token = this.tokenizer.def(src)) {
1137
+ src = src.substring(token.raw.length);
1138
+ lastToken = tokens[tokens.length - 1];
1139
+ if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
1140
+ lastToken.raw += "\n" + token.raw;
1141
+ lastToken.text += "\n" + token.raw;
1142
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1143
+ } else if (!this.tokens.links[token.tag]) {
1144
+ this.tokens.links[token.tag] = {
1145
+ href: token.href,
1146
+ title: token.title
1147
+ };
1148
+ }
1149
+ continue;
1150
+ }
1151
+ if (token = this.tokenizer.table(src)) {
1152
+ src = src.substring(token.raw.length);
1153
+ tokens.push(token);
1154
+ continue;
1155
+ }
1156
+ if (token = this.tokenizer.lheading(src)) {
1157
+ src = src.substring(token.raw.length);
1158
+ tokens.push(token);
1159
+ continue;
1160
+ }
1161
+ cutSrc = src;
1162
+ if (this.options.extensions && this.options.extensions.startBlock) {
1163
+ let startIndex = Infinity;
1164
+ const tempSrc = src.slice(1);
1165
+ let tempStart;
1166
+ this.options.extensions.startBlock.forEach((getStartIndex) => {
1167
+ tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1168
+ if (typeof tempStart === "number" && tempStart >= 0) {
1169
+ startIndex = Math.min(startIndex, tempStart);
1170
+ }
1171
+ });
1172
+ if (startIndex < Infinity && startIndex >= 0) {
1173
+ cutSrc = src.substring(0, startIndex + 1);
1174
+ }
1175
+ }
1176
+ if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1177
+ lastToken = tokens[tokens.length - 1];
1178
+ if (lastParagraphClipped && lastToken?.type === "paragraph") {
1179
+ lastToken.raw += "\n" + token.raw;
1180
+ lastToken.text += "\n" + token.text;
1181
+ this.inlineQueue.pop();
1182
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1183
+ } else {
1184
+ tokens.push(token);
1185
+ }
1186
+ lastParagraphClipped = cutSrc.length !== src.length;
1187
+ src = src.substring(token.raw.length);
1188
+ continue;
1189
+ }
1190
+ if (token = this.tokenizer.text(src)) {
1191
+ src = src.substring(token.raw.length);
1192
+ lastToken = tokens[tokens.length - 1];
1193
+ if (lastToken && lastToken.type === "text") {
1194
+ lastToken.raw += "\n" + token.raw;
1195
+ lastToken.text += "\n" + token.text;
1196
+ this.inlineQueue.pop();
1197
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1198
+ } else {
1199
+ tokens.push(token);
1200
+ }
1201
+ continue;
1202
+ }
1203
+ if (src) {
1204
+ const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1205
+ if (this.options.silent) {
1206
+ console.error(errMsg);
1207
+ break;
1208
+ } else {
1209
+ throw new Error(errMsg);
1210
+ }
1211
+ }
1212
+ }
1213
+ this.state.top = true;
1214
+ return tokens;
1215
+ }
1216
+ inline(src, tokens = []) {
1217
+ this.inlineQueue.push({ src, tokens });
1218
+ return tokens;
1219
+ }
1220
+ /**
1221
+ * Lexing/Compiling
1222
+ */
1223
+ inlineTokens(src, tokens = []) {
1224
+ let token, lastToken, cutSrc;
1225
+ let maskedSrc = src;
1226
+ let match;
1227
+ let keepPrevChar, prevChar;
1228
+ if (this.tokens.links) {
1229
+ const links = Object.keys(this.tokens.links);
1230
+ if (links.length > 0) {
1231
+ while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1232
+ if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1233
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1234
+ }
1235
+ }
1236
+ }
1237
+ }
1238
+ while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1239
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1240
+ }
1241
+ while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1242
+ maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1243
+ }
1244
+ while (src) {
1245
+ if (!keepPrevChar) {
1246
+ prevChar = "";
1247
+ }
1248
+ keepPrevChar = false;
1249
+ if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
1250
+ if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1251
+ src = src.substring(token.raw.length);
1252
+ tokens.push(token);
1253
+ return true;
1254
+ }
1255
+ return false;
1256
+ })) {
1257
+ continue;
1258
+ }
1259
+ if (token = this.tokenizer.escape(src)) {
1260
+ src = src.substring(token.raw.length);
1261
+ tokens.push(token);
1262
+ continue;
1263
+ }
1264
+ if (token = this.tokenizer.tag(src)) {
1265
+ src = src.substring(token.raw.length);
1266
+ lastToken = tokens[tokens.length - 1];
1267
+ if (lastToken && token.type === "text" && lastToken.type === "text") {
1268
+ lastToken.raw += token.raw;
1269
+ lastToken.text += token.text;
1270
+ } else {
1271
+ tokens.push(token);
1272
+ }
1273
+ continue;
1274
+ }
1275
+ if (token = this.tokenizer.link(src)) {
1276
+ src = src.substring(token.raw.length);
1277
+ tokens.push(token);
1278
+ continue;
1279
+ }
1280
+ if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1281
+ src = src.substring(token.raw.length);
1282
+ lastToken = tokens[tokens.length - 1];
1283
+ if (lastToken && token.type === "text" && lastToken.type === "text") {
1284
+ lastToken.raw += token.raw;
1285
+ lastToken.text += token.text;
1286
+ } else {
1287
+ tokens.push(token);
1288
+ }
1289
+ continue;
1290
+ }
1291
+ if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1292
+ src = src.substring(token.raw.length);
1293
+ tokens.push(token);
1294
+ continue;
1295
+ }
1296
+ if (token = this.tokenizer.codespan(src)) {
1297
+ src = src.substring(token.raw.length);
1298
+ tokens.push(token);
1299
+ continue;
1300
+ }
1301
+ if (token = this.tokenizer.br(src)) {
1302
+ src = src.substring(token.raw.length);
1303
+ tokens.push(token);
1304
+ continue;
1305
+ }
1306
+ if (token = this.tokenizer.del(src)) {
1307
+ src = src.substring(token.raw.length);
1308
+ tokens.push(token);
1309
+ continue;
1310
+ }
1311
+ if (token = this.tokenizer.autolink(src)) {
1312
+ src = src.substring(token.raw.length);
1313
+ tokens.push(token);
1314
+ continue;
1315
+ }
1316
+ if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1317
+ src = src.substring(token.raw.length);
1318
+ tokens.push(token);
1319
+ continue;
1320
+ }
1321
+ cutSrc = src;
1322
+ if (this.options.extensions && this.options.extensions.startInline) {
1323
+ let startIndex = Infinity;
1324
+ const tempSrc = src.slice(1);
1325
+ let tempStart;
1326
+ this.options.extensions.startInline.forEach((getStartIndex) => {
1327
+ tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1328
+ if (typeof tempStart === "number" && tempStart >= 0) {
1329
+ startIndex = Math.min(startIndex, tempStart);
1330
+ }
1331
+ });
1332
+ if (startIndex < Infinity && startIndex >= 0) {
1333
+ cutSrc = src.substring(0, startIndex + 1);
1334
+ }
1335
+ }
1336
+ if (token = this.tokenizer.inlineText(cutSrc)) {
1337
+ src = src.substring(token.raw.length);
1338
+ if (token.raw.slice(-1) !== "_") {
1339
+ prevChar = token.raw.slice(-1);
1340
+ }
1341
+ keepPrevChar = true;
1342
+ lastToken = tokens[tokens.length - 1];
1343
+ if (lastToken && lastToken.type === "text") {
1344
+ lastToken.raw += token.raw;
1345
+ lastToken.text += token.text;
1346
+ } else {
1347
+ tokens.push(token);
1348
+ }
1349
+ continue;
1350
+ }
1351
+ if (src) {
1352
+ const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1353
+ if (this.options.silent) {
1354
+ console.error(errMsg);
1355
+ break;
1356
+ } else {
1357
+ throw new Error(errMsg);
1358
+ }
1359
+ }
1360
+ }
1361
+ return tokens;
1362
+ }
1363
+ };
1364
+ var _Renderer = class {
1365
+ options;
1366
+ parser;
1367
+ // set by the parser
1368
+ constructor(options2) {
1369
+ this.options = options2 || _defaults;
1370
+ }
1371
+ space(token) {
1372
+ return "";
1373
+ }
1374
+ code({ text, lang, escaped }) {
1375
+ const langString = (lang || "").match(/^\S*/)?.[0];
1376
+ const code = text.replace(/\n$/, "") + "\n";
1377
+ if (!langString) {
1378
+ return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
1379
+ }
1380
+ return '<pre><code class="language-' + escape$1(langString) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
1381
+ }
1382
+ blockquote({ tokens }) {
1383
+ const body = this.parser.parse(tokens);
1384
+ return `<blockquote>
1385
+ ${body}</blockquote>
1386
+ `;
1387
+ }
1388
+ html({ text }) {
1389
+ return text;
1390
+ }
1391
+ heading({ tokens, depth }) {
1392
+ return `<h${depth}>${this.parser.parseInline(tokens)}</h${depth}>
1393
+ `;
1394
+ }
1395
+ hr(token) {
1396
+ return "<hr>\n";
1397
+ }
1398
+ list(token) {
1399
+ const ordered = token.ordered;
1400
+ const start = token.start;
1401
+ let body = "";
1402
+ for (let j = 0; j < token.items.length; j++) {
1403
+ const item = token.items[j];
1404
+ body += this.listitem(item);
1405
+ }
1406
+ const type = ordered ? "ol" : "ul";
1407
+ const startAttr = ordered && start !== 1 ? ' start="' + start + '"' : "";
1408
+ return "<" + type + startAttr + ">\n" + body + "</" + type + ">\n";
1409
+ }
1410
+ listitem(item) {
1411
+ let itemBody = "";
1412
+ if (item.task) {
1413
+ const checkbox = this.checkbox({ checked: !!item.checked });
1414
+ if (item.loose) {
1415
+ if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
1416
+ item.tokens[0].text = checkbox + " " + item.tokens[0].text;
1417
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
1418
+ item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
1419
+ }
1420
+ } else {
1421
+ item.tokens.unshift({
1422
+ type: "text",
1423
+ raw: checkbox + " ",
1424
+ text: checkbox + " "
1425
+ });
1426
+ }
1427
+ } else {
1428
+ itemBody += checkbox + " ";
1429
+ }
1430
+ }
1431
+ itemBody += this.parser.parse(item.tokens, !!item.loose);
1432
+ return `<li>${itemBody}</li>
1433
+ `;
1434
+ }
1435
+ checkbox({ checked }) {
1436
+ return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1437
+ }
1438
+ paragraph({ tokens }) {
1439
+ return `<p>${this.parser.parseInline(tokens)}</p>
1440
+ `;
1441
+ }
1442
+ table(token) {
1443
+ let header = "";
1444
+ let cell = "";
1445
+ for (let j = 0; j < token.header.length; j++) {
1446
+ cell += this.tablecell(token.header[j]);
1447
+ }
1448
+ header += this.tablerow({ text: cell });
1449
+ let body = "";
1450
+ for (let j = 0; j < token.rows.length; j++) {
1451
+ const row = token.rows[j];
1452
+ cell = "";
1453
+ for (let k = 0; k < row.length; k++) {
1454
+ cell += this.tablecell(row[k]);
1455
+ }
1456
+ body += this.tablerow({ text: cell });
1457
+ }
1458
+ if (body)
1459
+ body = `<tbody>${body}</tbody>`;
1460
+ return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
1461
+ }
1462
+ tablerow({ text }) {
1463
+ return `<tr>
1464
+ ${text}</tr>
1465
+ `;
1466
+ }
1467
+ tablecell(token) {
1468
+ const content = this.parser.parseInline(token.tokens);
1469
+ const type = token.header ? "th" : "td";
1470
+ const tag2 = token.align ? `<${type} align="${token.align}">` : `<${type}>`;
1471
+ return tag2 + content + `</${type}>
1472
+ `;
1473
+ }
1474
+ /**
1475
+ * span level renderer
1476
+ */
1477
+ strong({ tokens }) {
1478
+ return `<strong>${this.parser.parseInline(tokens)}</strong>`;
1479
+ }
1480
+ em({ tokens }) {
1481
+ return `<em>${this.parser.parseInline(tokens)}</em>`;
1482
+ }
1483
+ codespan({ text }) {
1484
+ return `<code>${text}</code>`;
1485
+ }
1486
+ br(token) {
1487
+ return "<br>";
1488
+ }
1489
+ del({ tokens }) {
1490
+ return `<del>${this.parser.parseInline(tokens)}</del>`;
1491
+ }
1492
+ link({ href, title, tokens }) {
1493
+ const text = this.parser.parseInline(tokens);
1494
+ const cleanHref = cleanUrl(href);
1495
+ if (cleanHref === null) {
1496
+ return text;
1497
+ }
1498
+ href = cleanHref;
1499
+ let out = '<a href="' + href + '"';
1500
+ if (title) {
1501
+ out += ' title="' + title + '"';
1502
+ }
1503
+ out += ">" + text + "</a>";
1504
+ return out;
1505
+ }
1506
+ image({ href, title, text }) {
1507
+ const cleanHref = cleanUrl(href);
1508
+ if (cleanHref === null) {
1509
+ return text;
1510
+ }
1511
+ href = cleanHref;
1512
+ let out = `<img src="${href}" alt="${text}"`;
1513
+ if (title) {
1514
+ out += ` title="${title}"`;
1515
+ }
1516
+ out += ">";
1517
+ return out;
1518
+ }
1519
+ text(token) {
1520
+ return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : token.text;
1521
+ }
1522
+ };
1523
+ var _TextRenderer = class {
1524
+ // no need for block level renderers
1525
+ strong({ text }) {
1526
+ return text;
1527
+ }
1528
+ em({ text }) {
1529
+ return text;
1530
+ }
1531
+ codespan({ text }) {
1532
+ return text;
1533
+ }
1534
+ del({ text }) {
1535
+ return text;
1536
+ }
1537
+ html({ text }) {
1538
+ return text;
1539
+ }
1540
+ text({ text }) {
1541
+ return text;
1542
+ }
1543
+ link({ text }) {
1544
+ return "" + text;
1545
+ }
1546
+ image({ text }) {
1547
+ return "" + text;
1548
+ }
1549
+ br() {
1550
+ return "";
1551
+ }
1552
+ };
1553
+ var _Parser = class __Parser {
1554
+ options;
1555
+ renderer;
1556
+ textRenderer;
1557
+ constructor(options2) {
1558
+ this.options = options2 || _defaults;
1559
+ this.options.renderer = this.options.renderer || new _Renderer();
1560
+ this.renderer = this.options.renderer;
1561
+ this.renderer.options = this.options;
1562
+ this.renderer.parser = this;
1563
+ this.textRenderer = new _TextRenderer();
1564
+ }
1565
+ /**
1566
+ * Static Parse Method
1567
+ */
1568
+ static parse(tokens, options2) {
1569
+ const parser2 = new __Parser(options2);
1570
+ return parser2.parse(tokens);
1571
+ }
1572
+ /**
1573
+ * Static Parse Inline Method
1574
+ */
1575
+ static parseInline(tokens, options2) {
1576
+ const parser2 = new __Parser(options2);
1577
+ return parser2.parseInline(tokens);
1578
+ }
1579
+ /**
1580
+ * Parse Loop
1581
+ */
1582
+ parse(tokens, top = true) {
1583
+ let out = "";
1584
+ for (let i = 0; i < tokens.length; i++) {
1585
+ const anyToken = tokens[i];
1586
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
1587
+ const genericToken = anyToken;
1588
+ const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
1589
+ if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
1590
+ out += ret || "";
1591
+ continue;
1592
+ }
1593
+ }
1594
+ const token = anyToken;
1595
+ switch (token.type) {
1596
+ case "space": {
1597
+ out += this.renderer.space(token);
1598
+ continue;
1599
+ }
1600
+ case "hr": {
1601
+ out += this.renderer.hr(token);
1602
+ continue;
1603
+ }
1604
+ case "heading": {
1605
+ out += this.renderer.heading(token);
1606
+ continue;
1607
+ }
1608
+ case "code": {
1609
+ out += this.renderer.code(token);
1610
+ continue;
1611
+ }
1612
+ case "table": {
1613
+ out += this.renderer.table(token);
1614
+ continue;
1615
+ }
1616
+ case "blockquote": {
1617
+ out += this.renderer.blockquote(token);
1618
+ continue;
1619
+ }
1620
+ case "list": {
1621
+ out += this.renderer.list(token);
1622
+ continue;
1623
+ }
1624
+ case "html": {
1625
+ out += this.renderer.html(token);
1626
+ continue;
1627
+ }
1628
+ case "paragraph": {
1629
+ out += this.renderer.paragraph(token);
1630
+ continue;
1631
+ }
1632
+ case "text": {
1633
+ let textToken = token;
1634
+ let body = this.renderer.text(textToken);
1635
+ while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
1636
+ textToken = tokens[++i];
1637
+ body += "\n" + this.renderer.text(textToken);
1638
+ }
1639
+ if (top) {
1640
+ out += this.renderer.paragraph({
1641
+ type: "paragraph",
1642
+ raw: body,
1643
+ text: body,
1644
+ tokens: [{ type: "text", raw: body, text: body }]
1645
+ });
1646
+ } else {
1647
+ out += body;
1648
+ }
1649
+ continue;
1650
+ }
1651
+ default: {
1652
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
1653
+ if (this.options.silent) {
1654
+ console.error(errMsg);
1655
+ return "";
1656
+ } else {
1657
+ throw new Error(errMsg);
1658
+ }
1659
+ }
1660
+ }
1661
+ }
1662
+ return out;
1663
+ }
1664
+ /**
1665
+ * Parse Inline Tokens
1666
+ */
1667
+ parseInline(tokens, renderer) {
1668
+ renderer = renderer || this.renderer;
1669
+ let out = "";
1670
+ for (let i = 0; i < tokens.length; i++) {
1671
+ const anyToken = tokens[i];
1672
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[anyToken.type]) {
1673
+ const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
1674
+ if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
1675
+ out += ret || "";
1676
+ continue;
1677
+ }
1678
+ }
1679
+ const token = anyToken;
1680
+ switch (token.type) {
1681
+ case "escape": {
1682
+ out += renderer.text(token);
1683
+ break;
1684
+ }
1685
+ case "html": {
1686
+ out += renderer.html(token);
1687
+ break;
1688
+ }
1689
+ case "link": {
1690
+ out += renderer.link(token);
1691
+ break;
1692
+ }
1693
+ case "image": {
1694
+ out += renderer.image(token);
1695
+ break;
1696
+ }
1697
+ case "strong": {
1698
+ out += renderer.strong(token);
1699
+ break;
1700
+ }
1701
+ case "em": {
1702
+ out += renderer.em(token);
1703
+ break;
1704
+ }
1705
+ case "codespan": {
1706
+ out += renderer.codespan(token);
1707
+ break;
1708
+ }
1709
+ case "br": {
1710
+ out += renderer.br(token);
1711
+ break;
1712
+ }
1713
+ case "del": {
1714
+ out += renderer.del(token);
1715
+ break;
1716
+ }
1717
+ case "text": {
1718
+ out += renderer.text(token);
1719
+ break;
1720
+ }
1721
+ default: {
1722
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
1723
+ if (this.options.silent) {
1724
+ console.error(errMsg);
1725
+ return "";
1726
+ } else {
1727
+ throw new Error(errMsg);
1728
+ }
1729
+ }
1730
+ }
1731
+ }
1732
+ return out;
1733
+ }
1734
+ };
1735
+ var _Hooks = class {
1736
+ options;
1737
+ constructor(options2) {
1738
+ this.options = options2 || _defaults;
1739
+ }
1740
+ static passThroughHooks = /* @__PURE__ */ new Set([
1741
+ "preprocess",
1742
+ "postprocess",
1743
+ "processAllTokens"
1744
+ ]);
1745
+ /**
1746
+ * Process markdown before marked
1747
+ */
1748
+ preprocess(markdown) {
1749
+ return markdown;
1750
+ }
1751
+ /**
1752
+ * Process HTML after marked is finished
1753
+ */
1754
+ postprocess(html2) {
1755
+ return html2;
1756
+ }
1757
+ /**
1758
+ * Process all tokens before walk tokens
1759
+ */
1760
+ processAllTokens(tokens) {
1761
+ return tokens;
1762
+ }
1763
+ };
1764
+ var Marked = class {
1765
+ defaults = _getDefaults();
1766
+ options = this.setOptions;
1767
+ parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
1768
+ parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
1769
+ Parser = _Parser;
1770
+ Renderer = _Renderer;
1771
+ TextRenderer = _TextRenderer;
1772
+ Lexer = _Lexer;
1773
+ Tokenizer = _Tokenizer;
1774
+ Hooks = _Hooks;
1775
+ constructor(...args) {
1776
+ this.use(...args);
1777
+ }
1778
+ /**
1779
+ * Run callback for every token
1780
+ */
1781
+ walkTokens(tokens, callback) {
1782
+ let values = [];
1783
+ for (const token of tokens) {
1784
+ values = values.concat(callback.call(this, token));
1785
+ switch (token.type) {
1786
+ case "table": {
1787
+ const tableToken = token;
1788
+ for (const cell of tableToken.header) {
1789
+ values = values.concat(this.walkTokens(cell.tokens, callback));
1790
+ }
1791
+ for (const row of tableToken.rows) {
1792
+ for (const cell of row) {
1793
+ values = values.concat(this.walkTokens(cell.tokens, callback));
1794
+ }
1795
+ }
1796
+ break;
1797
+ }
1798
+ case "list": {
1799
+ const listToken = token;
1800
+ values = values.concat(this.walkTokens(listToken.items, callback));
1801
+ break;
1802
+ }
1803
+ default: {
1804
+ const genericToken = token;
1805
+ if (this.defaults.extensions?.childTokens?.[genericToken.type]) {
1806
+ this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
1807
+ const tokens2 = genericToken[childTokens].flat(Infinity);
1808
+ values = values.concat(this.walkTokens(tokens2, callback));
1809
+ });
1810
+ } else if (genericToken.tokens) {
1811
+ values = values.concat(this.walkTokens(genericToken.tokens, callback));
1812
+ }
1813
+ }
1814
+ }
1815
+ }
1816
+ return values;
1817
+ }
1818
+ use(...args) {
1819
+ const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
1820
+ args.forEach((pack) => {
1821
+ const opts = { ...pack };
1822
+ opts.async = this.defaults.async || opts.async || false;
1823
+ if (pack.extensions) {
1824
+ pack.extensions.forEach((ext) => {
1825
+ if (!ext.name) {
1826
+ throw new Error("extension name required");
1827
+ }
1828
+ if ("renderer" in ext) {
1829
+ const prevRenderer = extensions.renderers[ext.name];
1830
+ if (prevRenderer) {
1831
+ extensions.renderers[ext.name] = function(...args2) {
1832
+ let ret = ext.renderer.apply(this, args2);
1833
+ if (ret === false) {
1834
+ ret = prevRenderer.apply(this, args2);
1835
+ }
1836
+ return ret;
1837
+ };
1838
+ } else {
1839
+ extensions.renderers[ext.name] = ext.renderer;
1840
+ }
1841
+ }
1842
+ if ("tokenizer" in ext) {
1843
+ if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
1844
+ throw new Error("extension level must be 'block' or 'inline'");
1845
+ }
1846
+ const extLevel = extensions[ext.level];
1847
+ if (extLevel) {
1848
+ extLevel.unshift(ext.tokenizer);
1849
+ } else {
1850
+ extensions[ext.level] = [ext.tokenizer];
1851
+ }
1852
+ if (ext.start) {
1853
+ if (ext.level === "block") {
1854
+ if (extensions.startBlock) {
1855
+ extensions.startBlock.push(ext.start);
1856
+ } else {
1857
+ extensions.startBlock = [ext.start];
1858
+ }
1859
+ } else if (ext.level === "inline") {
1860
+ if (extensions.startInline) {
1861
+ extensions.startInline.push(ext.start);
1862
+ } else {
1863
+ extensions.startInline = [ext.start];
1864
+ }
1865
+ }
1866
+ }
1867
+ }
1868
+ if ("childTokens" in ext && ext.childTokens) {
1869
+ extensions.childTokens[ext.name] = ext.childTokens;
1870
+ }
1871
+ });
1872
+ opts.extensions = extensions;
1873
+ }
1874
+ if (pack.renderer) {
1875
+ const renderer = this.defaults.renderer || new _Renderer(this.defaults);
1876
+ for (const prop in pack.renderer) {
1877
+ if (!(prop in renderer)) {
1878
+ throw new Error(`renderer '${prop}' does not exist`);
1879
+ }
1880
+ if (["options", "parser"].includes(prop)) {
1881
+ continue;
1882
+ }
1883
+ const rendererProp = prop;
1884
+ let rendererFunc = pack.renderer[rendererProp];
1885
+ if (!pack.useNewRenderer) {
1886
+ rendererFunc = this.#convertRendererFunction(rendererFunc, rendererProp, renderer);
1887
+ }
1888
+ const prevRenderer = renderer[rendererProp];
1889
+ renderer[rendererProp] = (...args2) => {
1890
+ let ret = rendererFunc.apply(renderer, args2);
1891
+ if (ret === false) {
1892
+ ret = prevRenderer.apply(renderer, args2);
1893
+ }
1894
+ return ret || "";
1895
+ };
1896
+ }
1897
+ opts.renderer = renderer;
1898
+ }
1899
+ if (pack.tokenizer) {
1900
+ const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
1901
+ for (const prop in pack.tokenizer) {
1902
+ if (!(prop in tokenizer)) {
1903
+ throw new Error(`tokenizer '${prop}' does not exist`);
1904
+ }
1905
+ if (["options", "rules", "lexer"].includes(prop)) {
1906
+ continue;
1907
+ }
1908
+ const tokenizerProp = prop;
1909
+ const tokenizerFunc = pack.tokenizer[tokenizerProp];
1910
+ const prevTokenizer = tokenizer[tokenizerProp];
1911
+ tokenizer[tokenizerProp] = (...args2) => {
1912
+ let ret = tokenizerFunc.apply(tokenizer, args2);
1913
+ if (ret === false) {
1914
+ ret = prevTokenizer.apply(tokenizer, args2);
1915
+ }
1916
+ return ret;
1917
+ };
1918
+ }
1919
+ opts.tokenizer = tokenizer;
1920
+ }
1921
+ if (pack.hooks) {
1922
+ const hooks = this.defaults.hooks || new _Hooks();
1923
+ for (const prop in pack.hooks) {
1924
+ if (!(prop in hooks)) {
1925
+ throw new Error(`hook '${prop}' does not exist`);
1926
+ }
1927
+ if (prop === "options") {
1928
+ continue;
1929
+ }
1930
+ const hooksProp = prop;
1931
+ const hooksFunc = pack.hooks[hooksProp];
1932
+ const prevHook = hooks[hooksProp];
1933
+ if (_Hooks.passThroughHooks.has(prop)) {
1934
+ hooks[hooksProp] = (arg) => {
1935
+ if (this.defaults.async) {
1936
+ return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
1937
+ return prevHook.call(hooks, ret2);
1938
+ });
1939
+ }
1940
+ const ret = hooksFunc.call(hooks, arg);
1941
+ return prevHook.call(hooks, ret);
1942
+ };
1943
+ } else {
1944
+ hooks[hooksProp] = (...args2) => {
1945
+ let ret = hooksFunc.apply(hooks, args2);
1946
+ if (ret === false) {
1947
+ ret = prevHook.apply(hooks, args2);
1948
+ }
1949
+ return ret;
1950
+ };
1951
+ }
1952
+ }
1953
+ opts.hooks = hooks;
1954
+ }
1955
+ if (pack.walkTokens) {
1956
+ const walkTokens2 = this.defaults.walkTokens;
1957
+ const packWalktokens = pack.walkTokens;
1958
+ opts.walkTokens = function(token) {
1959
+ let values = [];
1960
+ values.push(packWalktokens.call(this, token));
1961
+ if (walkTokens2) {
1962
+ values = values.concat(walkTokens2.call(this, token));
1963
+ }
1964
+ return values;
1965
+ };
1966
+ }
1967
+ this.defaults = { ...this.defaults, ...opts };
1968
+ });
1969
+ return this;
1970
+ }
1971
+ // TODO: Remove this in next major release
1972
+ #convertRendererFunction(func, prop, renderer) {
1973
+ switch (prop) {
1974
+ case "heading":
1975
+ return function(token) {
1976
+ if (!token.type || token.type !== prop) {
1977
+ return func.apply(this, arguments);
1978
+ }
1979
+ return func.call(this, renderer.parser.parseInline(token.tokens), token.depth, unescape(renderer.parser.parseInline(token.tokens, renderer.parser.textRenderer)));
1980
+ };
1981
+ case "code":
1982
+ return function(token) {
1983
+ if (!token.type || token.type !== prop) {
1984
+ return func.apply(this, arguments);
1985
+ }
1986
+ return func.call(this, token.text, token.lang, !!token.escaped);
1987
+ };
1988
+ case "table":
1989
+ return function(token) {
1990
+ if (!token.type || token.type !== prop) {
1991
+ return func.apply(this, arguments);
1992
+ }
1993
+ let header = "";
1994
+ let cell = "";
1995
+ for (let j = 0; j < token.header.length; j++) {
1996
+ cell += this.tablecell({
1997
+ text: token.header[j].text,
1998
+ tokens: token.header[j].tokens,
1999
+ header: true,
2000
+ align: token.align[j]
2001
+ });
2002
+ }
2003
+ header += this.tablerow({ text: cell });
2004
+ let body = "";
2005
+ for (let j = 0; j < token.rows.length; j++) {
2006
+ const row = token.rows[j];
2007
+ cell = "";
2008
+ for (let k = 0; k < row.length; k++) {
2009
+ cell += this.tablecell({
2010
+ text: row[k].text,
2011
+ tokens: row[k].tokens,
2012
+ header: false,
2013
+ align: token.align[k]
2014
+ });
2015
+ }
2016
+ body += this.tablerow({ text: cell });
2017
+ }
2018
+ return func.call(this, header, body);
2019
+ };
2020
+ case "blockquote":
2021
+ return function(token) {
2022
+ if (!token.type || token.type !== prop) {
2023
+ return func.apply(this, arguments);
2024
+ }
2025
+ const body = this.parser.parse(token.tokens);
2026
+ return func.call(this, body);
2027
+ };
2028
+ case "list":
2029
+ return function(token) {
2030
+ if (!token.type || token.type !== prop) {
2031
+ return func.apply(this, arguments);
2032
+ }
2033
+ const ordered = token.ordered;
2034
+ const start = token.start;
2035
+ const loose = token.loose;
2036
+ let body = "";
2037
+ for (let j = 0; j < token.items.length; j++) {
2038
+ const item = token.items[j];
2039
+ const checked = item.checked;
2040
+ const task = item.task;
2041
+ let itemBody = "";
2042
+ if (item.task) {
2043
+ const checkbox = this.checkbox({ checked: !!checked });
2044
+ if (loose) {
2045
+ if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
2046
+ item.tokens[0].text = checkbox + " " + item.tokens[0].text;
2047
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
2048
+ item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
2049
+ }
2050
+ } else {
2051
+ item.tokens.unshift({
2052
+ type: "text",
2053
+ text: checkbox + " "
2054
+ });
2055
+ }
2056
+ } else {
2057
+ itemBody += checkbox + " ";
2058
+ }
2059
+ }
2060
+ itemBody += this.parser.parse(item.tokens, loose);
2061
+ body += this.listitem({
2062
+ type: "list_item",
2063
+ raw: itemBody,
2064
+ text: itemBody,
2065
+ task,
2066
+ checked: !!checked,
2067
+ loose,
2068
+ tokens: item.tokens
2069
+ });
2070
+ }
2071
+ return func.call(this, body, ordered, start);
2072
+ };
2073
+ case "html":
2074
+ return function(token) {
2075
+ if (!token.type || token.type !== prop) {
2076
+ return func.apply(this, arguments);
2077
+ }
2078
+ return func.call(this, token.text, token.block);
2079
+ };
2080
+ case "paragraph":
2081
+ return function(token) {
2082
+ if (!token.type || token.type !== prop) {
2083
+ return func.apply(this, arguments);
2084
+ }
2085
+ return func.call(this, this.parser.parseInline(token.tokens));
2086
+ };
2087
+ case "escape":
2088
+ return function(token) {
2089
+ if (!token.type || token.type !== prop) {
2090
+ return func.apply(this, arguments);
2091
+ }
2092
+ return func.call(this, token.text);
2093
+ };
2094
+ case "link":
2095
+ return function(token) {
2096
+ if (!token.type || token.type !== prop) {
2097
+ return func.apply(this, arguments);
2098
+ }
2099
+ return func.call(this, token.href, token.title, this.parser.parseInline(token.tokens));
2100
+ };
2101
+ case "image":
2102
+ return function(token) {
2103
+ if (!token.type || token.type !== prop) {
2104
+ return func.apply(this, arguments);
2105
+ }
2106
+ return func.call(this, token.href, token.title, token.text);
2107
+ };
2108
+ case "strong":
2109
+ return function(token) {
2110
+ if (!token.type || token.type !== prop) {
2111
+ return func.apply(this, arguments);
2112
+ }
2113
+ return func.call(this, this.parser.parseInline(token.tokens));
2114
+ };
2115
+ case "em":
2116
+ return function(token) {
2117
+ if (!token.type || token.type !== prop) {
2118
+ return func.apply(this, arguments);
2119
+ }
2120
+ return func.call(this, this.parser.parseInline(token.tokens));
2121
+ };
2122
+ case "codespan":
2123
+ return function(token) {
2124
+ if (!token.type || token.type !== prop) {
2125
+ return func.apply(this, arguments);
2126
+ }
2127
+ return func.call(this, token.text);
2128
+ };
2129
+ case "del":
2130
+ return function(token) {
2131
+ if (!token.type || token.type !== prop) {
2132
+ return func.apply(this, arguments);
2133
+ }
2134
+ return func.call(this, this.parser.parseInline(token.tokens));
2135
+ };
2136
+ case "text":
2137
+ return function(token) {
2138
+ if (!token.type || token.type !== prop) {
2139
+ return func.apply(this, arguments);
2140
+ }
2141
+ return func.call(this, token.text);
2142
+ };
2143
+ }
2144
+ return func;
2145
+ }
2146
+ setOptions(opt) {
2147
+ this.defaults = { ...this.defaults, ...opt };
2148
+ return this;
2149
+ }
2150
+ lexer(src, options2) {
2151
+ return _Lexer.lex(src, options2 ?? this.defaults);
2152
+ }
2153
+ parser(tokens, options2) {
2154
+ return _Parser.parse(tokens, options2 ?? this.defaults);
2155
+ }
2156
+ #parseMarkdown(lexer2, parser2) {
2157
+ return (src, options2) => {
2158
+ const origOpt = { ...options2 };
2159
+ const opt = { ...this.defaults, ...origOpt };
2160
+ if (this.defaults.async === true && origOpt.async === false) {
2161
+ if (!opt.silent) {
2162
+ console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
2163
+ }
2164
+ opt.async = true;
2165
+ }
2166
+ const throwError = this.#onError(!!opt.silent, !!opt.async);
2167
+ if (typeof src === "undefined" || src === null) {
2168
+ return throwError(new Error("marked(): input parameter is undefined or null"));
2169
+ }
2170
+ if (typeof src !== "string") {
2171
+ return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
2172
+ }
2173
+ if (opt.hooks) {
2174
+ opt.hooks.options = opt;
2175
+ }
2176
+ if (opt.async) {
2177
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
2178
+ }
2179
+ try {
2180
+ if (opt.hooks) {
2181
+ src = opt.hooks.preprocess(src);
2182
+ }
2183
+ let tokens = lexer2(src, opt);
2184
+ if (opt.hooks) {
2185
+ tokens = opt.hooks.processAllTokens(tokens);
2186
+ }
2187
+ if (opt.walkTokens) {
2188
+ this.walkTokens(tokens, opt.walkTokens);
2189
+ }
2190
+ let html2 = parser2(tokens, opt);
2191
+ if (opt.hooks) {
2192
+ html2 = opt.hooks.postprocess(html2);
2193
+ }
2194
+ return html2;
2195
+ } catch (e) {
2196
+ return throwError(e);
2197
+ }
2198
+ };
2199
+ }
2200
+ #onError(silent, async) {
2201
+ return (e) => {
2202
+ e.message += "\nPlease report this to https://github.com/markedjs/marked.";
2203
+ if (silent) {
2204
+ const msg = "<p>An error occurred:</p><pre>" + escape$1(e.message + "", true) + "</pre>";
2205
+ if (async) {
2206
+ return Promise.resolve(msg);
2207
+ }
2208
+ return msg;
2209
+ }
2210
+ if (async) {
2211
+ return Promise.reject(e);
2212
+ }
2213
+ throw e;
2214
+ };
2215
+ }
2216
+ };
2217
+ var markedInstance = new Marked();
2218
+ function marked(src, opt) {
2219
+ return markedInstance.parse(src, opt);
2220
+ }
2221
+ marked.options = marked.setOptions = function(options2) {
2222
+ markedInstance.setOptions(options2);
2223
+ marked.defaults = markedInstance.defaults;
2224
+ changeDefaults(marked.defaults);
2225
+ return marked;
2226
+ };
2227
+ marked.getDefaults = _getDefaults;
2228
+ marked.defaults = _defaults;
2229
+ marked.use = function(...args) {
2230
+ markedInstance.use(...args);
2231
+ marked.defaults = markedInstance.defaults;
2232
+ changeDefaults(marked.defaults);
2233
+ return marked;
2234
+ };
2235
+ marked.walkTokens = function(tokens, callback) {
2236
+ return markedInstance.walkTokens(tokens, callback);
2237
+ };
2238
+ marked.parseInline = markedInstance.parseInline;
2239
+ marked.Parser = _Parser;
2240
+ marked.parser = _Parser.parse;
2241
+ marked.Renderer = _Renderer;
2242
+ marked.TextRenderer = _TextRenderer;
2243
+ marked.Lexer = _Lexer;
2244
+ marked.lexer = _Lexer.lex;
2245
+ marked.Tokenizer = _Tokenizer;
2246
+ marked.Hooks = _Hooks;
2247
+ marked.parse = marked;
2248
+ var options = marked.options;
2249
+ var setOptions = marked.setOptions;
2250
+ var use = marked.use;
2251
+ var walkTokens = marked.walkTokens;
2252
+ var parseInline = marked.parseInline;
2253
+ var parser = _Parser.parse;
2254
+ var lexer = _Lexer.lex;
2255
+
2256
+ // node_modules/ts-dedent/esm/index.js
2257
+ function dedent(templ) {
2258
+ var values = [];
2259
+ for (var _i = 1; _i < arguments.length; _i++) {
2260
+ values[_i - 1] = arguments[_i];
2261
+ }
2262
+ var strings = Array.from(typeof templ === "string" ? [templ] : templ);
2263
+ strings[strings.length - 1] = strings[strings.length - 1].replace(/\r?\n([\t ]*)$/, "");
2264
+ var indentLengths = strings.reduce(function(arr, str) {
2265
+ var matches = str.match(/\n([\t ]+|(?!\s).)/g);
2266
+ if (matches) {
2267
+ return arr.concat(matches.map(function(match) {
2268
+ var _a, _b;
2269
+ return (_b = (_a = match.match(/[\t ]/g)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
2270
+ }));
2271
+ }
2272
+ return arr;
2273
+ }, []);
2274
+ if (indentLengths.length) {
2275
+ var pattern_1 = new RegExp("\n[ ]{" + Math.min.apply(Math, indentLengths) + "}", "g");
2276
+ strings = strings.map(function(str) {
2277
+ return str.replace(pattern_1, "\n");
2278
+ });
2279
+ }
2280
+ strings[0] = strings[0].replace(/^\r?\n/, "");
2281
+ var string = strings[0];
2282
+ values.forEach(function(value, i) {
2283
+ var endentations = string.match(/(?:^|\n)( *)$/);
2284
+ var endentation = endentations ? endentations[1] : "";
2285
+ var indentedValue = value;
2286
+ if (typeof value === "string" && value.includes("\n")) {
2287
+ indentedValue = String(value).split("\n").map(function(str, i2) {
2288
+ return i2 === 0 ? str : "" + endentation + str;
2289
+ }).join("\n");
2290
+ }
2291
+ string += indentedValue + strings[i + 1];
2292
+ });
2293
+ return string;
2294
+ }
2295
+
2296
+ // node_modules/mermaid/dist/chunks/mermaid.core/chunk-6JOS74DS.mjs
2297
+ function preprocessMarkdown(markdown, { markdownAutoWrap }) {
2298
+ const withoutBR = markdown.replace(/<br\/>/g, "\n");
2299
+ const withoutMultipleNewlines = withoutBR.replace(/\n{2,}/g, "\n");
2300
+ const withoutExtraSpaces = dedent(withoutMultipleNewlines);
2301
+ if (markdownAutoWrap === false) {
2302
+ return withoutExtraSpaces.replace(/ /g, "&nbsp;");
2303
+ }
2304
+ return withoutExtraSpaces;
2305
+ }
2306
+ __name(preprocessMarkdown, "preprocessMarkdown");
2307
+ function markdownToLines(markdown, config = {}) {
2308
+ const preprocessedMarkdown = preprocessMarkdown(markdown, config);
2309
+ const nodes = marked.lexer(preprocessedMarkdown);
2310
+ const lines = [[]];
2311
+ let currentLine = 0;
2312
+ function processNode(node, parentType = "normal") {
2313
+ if (node.type === "text") {
2314
+ const textLines = node.text.split("\n");
2315
+ textLines.forEach((textLine, index) => {
2316
+ if (index !== 0) {
2317
+ currentLine++;
2318
+ lines.push([]);
2319
+ }
2320
+ textLine.split(" ").forEach((word) => {
2321
+ word = word.replace(/&#39;/g, `'`);
2322
+ if (word) {
2323
+ lines[currentLine].push({ content: word, type: parentType });
2324
+ }
2325
+ });
2326
+ });
2327
+ } else if (node.type === "strong" || node.type === "em") {
2328
+ node.tokens.forEach((contentNode) => {
2329
+ processNode(contentNode, node.type);
2330
+ });
2331
+ } else if (node.type === "html") {
2332
+ lines[currentLine].push({ content: node.text, type: "normal" });
2333
+ }
2334
+ }
2335
+ __name(processNode, "processNode");
2336
+ nodes.forEach((treeNode) => {
2337
+ if (treeNode.type === "paragraph") {
2338
+ treeNode.tokens?.forEach((contentNode) => {
2339
+ processNode(contentNode);
2340
+ });
2341
+ } else if (treeNode.type === "html") {
2342
+ lines[currentLine].push({ content: treeNode.text, type: "normal" });
2343
+ }
2344
+ });
2345
+ return lines;
2346
+ }
2347
+ __name(markdownToLines, "markdownToLines");
2348
+ function markdownToHTML(markdown, { markdownAutoWrap } = {}) {
2349
+ const nodes = marked.lexer(markdown);
2350
+ function output(node) {
2351
+ if (node.type === "text") {
2352
+ if (markdownAutoWrap === false) {
2353
+ return node.text.replace(/\n */g, "<br/>").replace(/ /g, "&nbsp;");
2354
+ }
2355
+ return node.text.replace(/\n */g, "<br/>");
2356
+ } else if (node.type === "strong") {
2357
+ return `<strong>${node.tokens?.map(output).join("")}</strong>`;
2358
+ } else if (node.type === "em") {
2359
+ return `<em>${node.tokens?.map(output).join("")}</em>`;
2360
+ } else if (node.type === "paragraph") {
2361
+ return `<p>${node.tokens?.map(output).join("")}</p>`;
2362
+ } else if (node.type === "space") {
2363
+ return "";
2364
+ } else if (node.type === "html") {
2365
+ return `${node.text}`;
2366
+ } else if (node.type === "escape") {
2367
+ return node.text;
2368
+ }
2369
+ return `Unsupported markdown: ${node.type}`;
2370
+ }
2371
+ __name(output, "output");
2372
+ return nodes.map(output).join("");
2373
+ }
2374
+ __name(markdownToHTML, "markdownToHTML");
2375
+ function splitTextToChars(text) {
2376
+ if (Intl.Segmenter) {
2377
+ return [...new Intl.Segmenter().segment(text)].map((s) => s.segment);
2378
+ }
2379
+ return [...text];
2380
+ }
2381
+ __name(splitTextToChars, "splitTextToChars");
2382
+ function splitWordToFitWidth(checkFit, word) {
2383
+ const characters = splitTextToChars(word.content);
2384
+ return splitWordToFitWidthRecursion(checkFit, [], characters, word.type);
2385
+ }
2386
+ __name(splitWordToFitWidth, "splitWordToFitWidth");
2387
+ function splitWordToFitWidthRecursion(checkFit, usedChars, remainingChars, type) {
2388
+ if (remainingChars.length === 0) {
2389
+ return [
2390
+ { content: usedChars.join(""), type },
2391
+ { content: "", type }
2392
+ ];
2393
+ }
2394
+ const [nextChar, ...rest] = remainingChars;
2395
+ const newWord = [...usedChars, nextChar];
2396
+ if (checkFit([{ content: newWord.join(""), type }])) {
2397
+ return splitWordToFitWidthRecursion(checkFit, newWord, rest, type);
2398
+ }
2399
+ if (usedChars.length === 0 && nextChar) {
2400
+ usedChars.push(nextChar);
2401
+ remainingChars.shift();
2402
+ }
2403
+ return [
2404
+ { content: usedChars.join(""), type },
2405
+ { content: remainingChars.join(""), type }
2406
+ ];
2407
+ }
2408
+ __name(splitWordToFitWidthRecursion, "splitWordToFitWidthRecursion");
2409
+ function splitLineToFitWidth(line, checkFit) {
2410
+ if (line.some(({ content }) => content.includes("\n"))) {
2411
+ throw new Error("splitLineToFitWidth does not support newlines in the line");
2412
+ }
2413
+ return splitLineToFitWidthRecursion(line, checkFit);
2414
+ }
2415
+ __name(splitLineToFitWidth, "splitLineToFitWidth");
2416
+ function splitLineToFitWidthRecursion(words, checkFit, lines = [], newLine = []) {
2417
+ if (words.length === 0) {
2418
+ if (newLine.length > 0) {
2419
+ lines.push(newLine);
2420
+ }
2421
+ return lines.length > 0 ? lines : [];
2422
+ }
2423
+ let joiner = "";
2424
+ if (words[0].content === " ") {
2425
+ joiner = " ";
2426
+ words.shift();
2427
+ }
2428
+ const nextWord = words.shift() ?? { content: " ", type: "normal" };
2429
+ const lineWithNextWord = [...newLine];
2430
+ if (joiner !== "") {
2431
+ lineWithNextWord.push({ content: joiner, type: "normal" });
2432
+ }
2433
+ lineWithNextWord.push(nextWord);
2434
+ if (checkFit(lineWithNextWord)) {
2435
+ return splitLineToFitWidthRecursion(words, checkFit, lines, lineWithNextWord);
2436
+ }
2437
+ if (newLine.length > 0) {
2438
+ lines.push(newLine);
2439
+ words.unshift(nextWord);
2440
+ } else if (nextWord.content) {
2441
+ const [line, rest] = splitWordToFitWidth(checkFit, nextWord);
2442
+ lines.push([line]);
2443
+ if (rest.content) {
2444
+ words.unshift(rest);
2445
+ }
2446
+ }
2447
+ return splitLineToFitWidthRecursion(words, checkFit, lines);
2448
+ }
2449
+ __name(splitLineToFitWidthRecursion, "splitLineToFitWidthRecursion");
2450
+ function applyStyle(dom, styleFn) {
2451
+ if (styleFn) {
2452
+ dom.attr("style", styleFn);
2453
+ }
2454
+ }
2455
+ __name(applyStyle, "applyStyle");
2456
+ async function addHtmlSpan(element, node, width, classes, addBackground = false) {
2457
+ const fo = element.append("foreignObject");
2458
+ fo.attr("width", `${10 * width}px`);
2459
+ fo.attr("height", `${10 * width}px`);
2460
+ const div = fo.append("xhtml:div");
2461
+ let label = node.label;
2462
+ if (node.label && hasKatex(node.label)) {
2463
+ label = await renderKatex(node.label.replace(common_default.lineBreakRegex, "\n"), getConfig2());
2464
+ }
2465
+ const labelClass = node.isNode ? "nodeLabel" : "edgeLabel";
2466
+ const span = div.append("span");
2467
+ span.html(label);
2468
+ applyStyle(span, node.labelStyle);
2469
+ span.attr("class", `${labelClass} ${classes}`);
2470
+ applyStyle(div, node.labelStyle);
2471
+ div.style("display", "table-cell");
2472
+ div.style("white-space", "nowrap");
2473
+ div.style("line-height", "1.5");
2474
+ div.style("max-width", width + "px");
2475
+ div.style("text-align", "center");
2476
+ div.attr("xmlns", "http://www.w3.org/1999/xhtml");
2477
+ if (addBackground) {
2478
+ div.attr("class", "labelBkg");
2479
+ }
2480
+ let bbox = div.node().getBoundingClientRect();
2481
+ if (bbox.width === width) {
2482
+ div.style("display", "table");
2483
+ div.style("white-space", "break-spaces");
2484
+ div.style("width", width + "px");
2485
+ bbox = div.node().getBoundingClientRect();
2486
+ }
2487
+ return fo.node();
2488
+ }
2489
+ __name(addHtmlSpan, "addHtmlSpan");
2490
+ function createTspan(textElement, lineIndex, lineHeight) {
2491
+ return textElement.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", lineIndex * lineHeight - 0.1 + "em").attr("dy", lineHeight + "em");
2492
+ }
2493
+ __name(createTspan, "createTspan");
2494
+ function computeWidthOfText(parentNode, lineHeight, line) {
2495
+ const testElement = parentNode.append("text");
2496
+ const testSpan = createTspan(testElement, 1, lineHeight);
2497
+ updateTextContentAndStyles(testSpan, line);
2498
+ const textLength = testSpan.node().getComputedTextLength();
2499
+ testElement.remove();
2500
+ return textLength;
2501
+ }
2502
+ __name(computeWidthOfText, "computeWidthOfText");
2503
+ function computeDimensionOfText(parentNode, lineHeight, text) {
2504
+ const testElement = parentNode.append("text");
2505
+ const testSpan = createTspan(testElement, 1, lineHeight);
2506
+ updateTextContentAndStyles(testSpan, [{ content: text, type: "normal" }]);
2507
+ const textDimension = testSpan.node()?.getBoundingClientRect();
2508
+ if (textDimension) {
2509
+ testElement.remove();
2510
+ }
2511
+ return textDimension;
2512
+ }
2513
+ __name(computeDimensionOfText, "computeDimensionOfText");
2514
+ function createFormattedText(width, g, structuredText, addBackground = false) {
2515
+ const lineHeight = 1.1;
2516
+ const labelGroup = g.append("g");
2517
+ const bkg = labelGroup.insert("rect").attr("class", "background").attr("style", "stroke: none");
2518
+ const textElement = labelGroup.append("text").attr("y", "-10.1");
2519
+ let lineIndex = 0;
2520
+ for (const line of structuredText) {
2521
+ const checkWidth = /* @__PURE__ */ __name((line2) => computeWidthOfText(labelGroup, lineHeight, line2) <= width, "checkWidth");
2522
+ const linesUnderWidth = checkWidth(line) ? [line] : splitLineToFitWidth(line, checkWidth);
2523
+ for (const preparedLine of linesUnderWidth) {
2524
+ const tspan = createTspan(textElement, lineIndex, lineHeight);
2525
+ updateTextContentAndStyles(tspan, preparedLine);
2526
+ lineIndex++;
2527
+ }
2528
+ }
2529
+ if (addBackground) {
2530
+ const bbox = textElement.node().getBBox();
2531
+ const padding = 2;
2532
+ bkg.attr("x", bbox.x - padding).attr("y", bbox.y - padding).attr("width", bbox.width + 2 * padding).attr("height", bbox.height + 2 * padding);
2533
+ return labelGroup.node();
2534
+ } else {
2535
+ return textElement.node();
2536
+ }
2537
+ }
2538
+ __name(createFormattedText, "createFormattedText");
2539
+ function updateTextContentAndStyles(tspan, wrappedLine) {
2540
+ tspan.text("");
2541
+ wrappedLine.forEach((word, index) => {
2542
+ const innerTspan = tspan.append("tspan").attr("font-style", word.type === "em" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", word.type === "strong" ? "bold" : "normal");
2543
+ if (index === 0) {
2544
+ innerTspan.text(word.content);
2545
+ } else {
2546
+ innerTspan.text(" " + word.content);
2547
+ }
2548
+ });
2549
+ }
2550
+ __name(updateTextContentAndStyles, "updateTextContentAndStyles");
2551
+ function replaceIconSubstring(text) {
2552
+ return text.replace(
2553
+ /fa[bklrs]?:fa-[\w-]+/g,
2554
+ // cspell: disable-line
2555
+ (s) => `<i class='${s.replace(":", " ")}'></i>`
2556
+ );
2557
+ }
2558
+ __name(replaceIconSubstring, "replaceIconSubstring");
2559
+ var createText = /* @__PURE__ */ __name(async (el, text = "", {
2560
+ style = "",
2561
+ isTitle = false,
2562
+ classes = "",
2563
+ useHtmlLabels = true,
2564
+ isNode = true,
2565
+ width = 200,
2566
+ addSvgBackground = false
2567
+ } = {}, config) => {
2568
+ log.debug(
2569
+ "XYZ createText",
2570
+ text,
2571
+ style,
2572
+ isTitle,
2573
+ classes,
2574
+ useHtmlLabels,
2575
+ isNode,
2576
+ "addSvgBackground: ",
2577
+ addSvgBackground
2578
+ );
2579
+ if (useHtmlLabels) {
2580
+ const htmlText = markdownToHTML(text, config);
2581
+ const decodedReplacedText = replaceIconSubstring(decodeEntities(htmlText));
2582
+ const inputForKatex = text.replace(/\\\\/g, "\\");
2583
+ const node = {
2584
+ isNode,
2585
+ label: hasKatex(text) ? inputForKatex : decodedReplacedText,
2586
+ labelStyle: style.replace("fill:", "color:")
2587
+ };
2588
+ const vertexNode = await addHtmlSpan(el, node, width, classes, addSvgBackground);
2589
+ return vertexNode;
2590
+ } else {
2591
+ const sanitizeBR = text.replace(/<br\s*\/?>/g, "<br/>");
2592
+ const structuredText = markdownToLines(sanitizeBR.replace("<br>", "<br/>"), config);
2593
+ const svgLabel = createFormattedText(
2594
+ width,
2595
+ el,
2596
+ structuredText,
2597
+ text ? addSvgBackground : false
2598
+ );
2599
+ if (isNode) {
2600
+ if (/stroke:/.exec(style)) {
2601
+ style = style.replace("stroke:", "lineColor:");
2602
+ }
2603
+ const nodeLabelTextStyle = style.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
2604
+ select_default(svgLabel).attr("style", nodeLabelTextStyle);
2605
+ } else {
2606
+ const edgeLabelRectStyle = style.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/background:/g, "fill:");
2607
+ select_default(svgLabel).select("rect").attr("style", edgeLabelRectStyle.replace(/background:/g, "fill:"));
2608
+ const edgeLabelTextStyle = style.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
2609
+ select_default(svgLabel).select("text").attr("style", edgeLabelTextStyle);
2610
+ }
2611
+ return svgLabel;
2612
+ }
2613
+ }, "createText");
2614
+
2615
+ export {
2616
+ dedent,
2617
+ computeDimensionOfText,
2618
+ replaceIconSubstring,
2619
+ createText
2620
+ };
2621
+ //# sourceMappingURL=chunk-NIVHLOPB.js.map