@n8n-zengchao/chat 0.62.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 (151) hide show
  1. package/README.md +289 -0
  2. package/dist/App.vue.d.ts +2 -0
  3. package/dist/__stories__/App.stories.d.ts +18 -0
  4. package/dist/__tests__/Input.spec.d.ts +1 -0
  5. package/dist/__tests__/api/generic.spec.d.ts +1 -0
  6. package/dist/__tests__/api/message.spec.d.ts +1 -0
  7. package/dist/__tests__/index.spec.d.ts +1 -0
  8. package/dist/__tests__/plugins/chat.spec.d.ts +1 -0
  9. package/dist/__tests__/plugins/chat.test.d.ts +1 -0
  10. package/dist/__tests__/setup.d.ts +0 -0
  11. package/dist/__tests__/utils/create.d.ts +5 -0
  12. package/dist/__tests__/utils/fetch.d.ts +13 -0
  13. package/dist/__tests__/utils/index.d.ts +3 -0
  14. package/dist/__tests__/utils/selectors.d.ts +12 -0
  15. package/dist/__tests__/utils/streaming.spec.d.ts +1 -0
  16. package/dist/__tests__/utils/streamingHandlers.spec.d.ts +1 -0
  17. package/dist/_basePickBy-aQilsjEs.mjs +106 -0
  18. package/dist/_baseUniq-Agc10qFQ.mjs +232 -0
  19. package/dist/api/generic.d.ts +7 -0
  20. package/dist/api/index.d.ts +2 -0
  21. package/dist/api/message.d.ts +11 -0
  22. package/dist/arc-EhYU_DB1.mjs +79 -0
  23. package/dist/architecture-U656AL7Q-B1STlXpR.mjs +10 -0
  24. package/dist/architectureDiagram-VXUJARFQ-DOVAbXSw.mjs +4054 -0
  25. package/dist/array-B5w981Vk.mjs +5 -0
  26. package/dist/blockDiagram-VD42YOAC-BsX3Fkg3.mjs +3013 -0
  27. package/dist/c4Diagram-YG6GDRKO-B5JaLuX6.mjs +2957 -0
  28. package/dist/channel-CqrIo07y.mjs +4 -0
  29. package/dist/chat.bundle.es.js +37656 -0
  30. package/dist/chat.bundle.umd.js +2784 -0
  31. package/dist/chat.es.js +35738 -0
  32. package/dist/chat.umd.js +2776 -0
  33. package/dist/chunk-4BX2VUAB-dn0RXIrC.mjs +7 -0
  34. package/dist/chunk-55IACEB6-DrIttNoL.mjs +7 -0
  35. package/dist/chunk-76Q3JFCE-D7DMbWeQ.mjs +20 -0
  36. package/dist/chunk-ABZYJK2D-_NXv778f.mjs +2516 -0
  37. package/dist/chunk-ATLVNIR6-CBnG7Ev9.mjs +66 -0
  38. package/dist/chunk-B4BG7PRW-DElmmAse.mjs +3109 -0
  39. package/dist/chunk-CVBHYZKI-kPsSw5G9.mjs +11 -0
  40. package/dist/chunk-DI55MBZ5-Bw6uFFfD.mjs +1995 -0
  41. package/dist/chunk-DZXZ2BO8.mjs +19 -0
  42. package/dist/chunk-EXTU4WIE-DWzncOZf.mjs +8 -0
  43. package/dist/chunk-FMBD7UC4-CQf-nVrj.mjs +4 -0
  44. package/dist/chunk-FPAJGGOC-HRc6DGju.mjs +12254 -0
  45. package/dist/chunk-FWNWRKHM-CGiJVNMo.mjs +57 -0
  46. package/dist/chunk-HN2XXSSU-DMfVdeUE.mjs +75 -0
  47. package/dist/chunk-JA3XYJ7Z-b0Li4NN8.mjs +1834 -0
  48. package/dist/chunk-JZLCHNYA-C_4MLySW.mjs +4862 -0
  49. package/dist/chunk-KS23V3DP-BRKOfbU6.mjs +136 -0
  50. package/dist/chunk-LBM3YZW2-JIQK8wiH.mjs +20 -0
  51. package/dist/chunk-LHMN2FUI-PNCyIUgu.mjs +20 -0
  52. package/dist/chunk-MI3HLSF2-B9GTCmLp.mjs +1146 -0
  53. package/dist/chunk-N4CR4FBY-CjlmnCPD.mjs +40 -0
  54. package/dist/chunk-O7ZBX7Z2-DmJUfqJj.mjs +27 -0
  55. package/dist/chunk-QN33PNHL-nN1zLFSf.mjs +24 -0
  56. package/dist/chunk-QXUST7PY-CY78Btj9.mjs +487 -0
  57. package/dist/chunk-QZHKN3VN-BF5N1pfB.mjs +12 -0
  58. package/dist/chunk-S3R3BYOJ-BhFsv0Go.mjs +1076 -0
  59. package/dist/chunk-S6J4BHB3-BvrWTdbl.mjs +20 -0
  60. package/dist/chunk-T53DSG4Q-XzY06amw.mjs +25 -0
  61. package/dist/chunk-TZMSLE5B-DVmJQ8eg.mjs +57 -0
  62. package/dist/classDiagram-2ON5EDUG-CKxiEVX9.mjs +33 -0
  63. package/dist/classDiagram-v2-WZHVMYZB-sAa_2keq.mjs +33 -0
  64. package/dist/clone-nkGlb0Gn.mjs +8 -0
  65. package/dist/components/Button.vue.d.ts +17 -0
  66. package/dist/components/Chat.vue.d.ts +2 -0
  67. package/dist/components/ChatFile.vue.d.ts +11 -0
  68. package/dist/components/ChatWindow.vue.d.ts +2 -0
  69. package/dist/components/GetStarted.vue.d.ts +2 -0
  70. package/dist/components/GetStartedFooter.vue.d.ts +2 -0
  71. package/dist/components/Input.vue.d.ts +39 -0
  72. package/dist/components/Layout.vue.d.ts +23 -0
  73. package/dist/components/Message.vue.d.ts +39 -0
  74. package/dist/components/MessageTyping.vue.d.ts +76 -0
  75. package/dist/components/MessagesList.vue.d.ts +164 -0
  76. package/dist/components/PoweredBy.vue.d.ts +2 -0
  77. package/dist/components/index.d.ts +10 -0
  78. package/dist/composables/index.d.ts +3 -0
  79. package/dist/composables/useChat.d.ts +2 -0
  80. package/dist/composables/useI18n.d.ts +4 -0
  81. package/dist/composables/useOptions.d.ts +4 -0
  82. package/dist/constants/defaults.d.ts +3 -0
  83. package/dist/constants/index.d.ts +3 -0
  84. package/dist/constants/localStorage.d.ts +2 -0
  85. package/dist/constants/symbols.d.ts +4 -0
  86. package/dist/cose-bilkent-S5V4N54A-1lKG2PUg.mjs +2251 -0
  87. package/dist/cytoscape.esm-Dls1_mGy.mjs +18108 -0
  88. package/dist/dagre-6UL2VRFP-CbWFu9xQ.mjs +300 -0
  89. package/dist/dagre-DEdOheHq.mjs +1385 -0
  90. package/dist/defaultLocale-CyoQm63E.mjs +178 -0
  91. package/dist/diagram-PSM6KHXK-CJcHbrJH.mjs +499 -0
  92. package/dist/diagram-QEK2KX5R-XQ9XOVL4.mjs +228 -0
  93. package/dist/diagram-S2PKOQOG-CmRfaeSf.mjs +146 -0
  94. package/dist/dist-BT0fjU7K.mjs +50 -0
  95. package/dist/erDiagram-Q2GNP2WA-iuoUWHwm.mjs +1603 -0
  96. package/dist/event-buses/chatEventBus.d.ts +1 -0
  97. package/dist/event-buses/index.d.ts +1 -0
  98. package/dist/favicon.ico +0 -0
  99. package/dist/flowDiagram-NV44I4VS-D3GMS8-G.mjs +4132 -0
  100. package/dist/ganttDiagram-LVOFAZNH-DMTZVZDR.mjs +2832 -0
  101. package/dist/gitGraph-F6HP7TQM-CrdUzURw.mjs +10 -0
  102. package/dist/gitGraphDiagram-NY62KEGX-DipP5Fgt.mjs +636 -0
  103. package/dist/graphlib-D9eH5icd.mjs +224 -0
  104. package/dist/index.d.ts +2 -0
  105. package/dist/info-NVLQJR56-C-93Yf3U.mjs +10 -0
  106. package/dist/infoDiagram-F6ZHWCRC-jM50s26K.mjs +33 -0
  107. package/dist/init-CYeu4QfE.mjs +14 -0
  108. package/dist/isArrayLikeObject-BPcFdnyK.mjs +459 -0
  109. package/dist/isUndefined-BvarJ1wS.mjs +374 -0
  110. package/dist/journeyDiagram-XKPGCS4Q-BEEO_0Bh.mjs +885 -0
  111. package/dist/kanban-definition-3W4ZIXB7-B8u_HDmL.mjs +971 -0
  112. package/dist/katex-Dc1vXbUC.mjs +22094 -0
  113. package/dist/line-BJxACIPZ.mjs +31 -0
  114. package/dist/linear-DHHVI-cj.mjs +251 -0
  115. package/dist/math-Byg0NvhS.mjs +9 -0
  116. package/dist/mermaid-parser.core-YT4qvimq.mjs +49 -0
  117. package/dist/mindmap-definition-VGOIOE7T-ah41V88S.mjs +960 -0
  118. package/dist/now-DsJMgI1z.mjs +6 -0
  119. package/dist/ordinal-L0-EVPg8.mjs +62 -0
  120. package/dist/packet-BFZMPI3H-Cs4kRHct.mjs +10 -0
  121. package/dist/path-BcDHwjEr.mjs +80 -0
  122. package/dist/pie-7BOR55EZ-YZ5Xu4o6.mjs +10 -0
  123. package/dist/pieDiagram-ADFJNKIX-CqI33m1a.mjs +174 -0
  124. package/dist/plugins/chat.d.ts +3 -0
  125. package/dist/plugins/index.d.ts +1 -0
  126. package/dist/quadrantDiagram-AYHSOK5B-DDv2X9c1.mjs +1971 -0
  127. package/dist/radar-NHE76QYJ-TpirOFtv.mjs +10 -0
  128. package/dist/requirementDiagram-UZGBJVZJ-DXa77VzO.mjs +2194 -0
  129. package/dist/sankeyDiagram-TZEHDZUN--B9DInJC.mjs +885 -0
  130. package/dist/sequenceDiagram-WL72ISMW-Dqn9jJ3g.mjs +3562 -0
  131. package/dist/src-DdwtiGjk.mjs +1976 -0
  132. package/dist/stateDiagram-FKZM4ZOC-D3eEcVjS.mjs +226 -0
  133. package/dist/stateDiagram-v2-4FDKWEC3-dzwJ4caL.mjs +32 -0
  134. package/dist/style.css +3 -0
  135. package/dist/timeline-definition-IT6M3QCI-z93ry7RN.mjs +831 -0
  136. package/dist/toInteger-1S_4Byef.mjs +36 -0
  137. package/dist/treemap-KMMF4GRG-BlF0Ev1z.mjs +10 -0
  138. package/dist/types/chat.d.ts +13 -0
  139. package/dist/types/index.d.ts +5 -0
  140. package/dist/types/messages.d.ts +17 -0
  141. package/dist/types/options.d.ts +33 -0
  142. package/dist/types/streaming.d.ts +18 -0
  143. package/dist/types/webhook.d.ts +19 -0
  144. package/dist/utils/event-bus.d.ts +8 -0
  145. package/dist/utils/index.d.ts +3 -0
  146. package/dist/utils/mount.d.ts +1 -0
  147. package/dist/utils/streaming.d.ts +26 -0
  148. package/dist/utils/streamingHandlers.d.ts +6 -0
  149. package/dist/utils/utils.d.ts +1 -0
  150. package/dist/xychartDiagram-PRI3JC2R-C3aDcgBz.mjs +2022 -0
  151. package/package.json +78 -0
@@ -0,0 +1,1834 @@
1
+ /*! Package version @n8n/chat@0.62.0 */
2
+ import { a as decodeEntities } from "./chunk-S3R3BYOJ-BhFsv0Go.mjs";
3
+ import { g as log, h as __name, p as select_default } from "./src-DdwtiGjk.mjs";
4
+ import { I as sanitizeText, N as renderKatexSanitized, O as hasKatex, s as common_default, y as getConfig } from "./chunk-ABZYJK2D-_NXv778f.mjs";
5
+ var defaultIconDimensions = Object.freeze({
6
+ left: 0,
7
+ top: 0,
8
+ width: 16,
9
+ height: 16
10
+ }), defaultIconTransformations = Object.freeze({
11
+ rotate: 0,
12
+ vFlip: !1,
13
+ hFlip: !1
14
+ }), defaultIconProps = Object.freeze({
15
+ ...defaultIconDimensions,
16
+ ...defaultIconTransformations
17
+ }), defaultExtendedIconProps = Object.freeze({
18
+ ...defaultIconProps,
19
+ body: "",
20
+ hidden: !1
21
+ }), defaultIconSizeCustomisations = Object.freeze({
22
+ width: null,
23
+ height: null
24
+ }), defaultIconCustomisations = Object.freeze({
25
+ ...defaultIconSizeCustomisations,
26
+ ...defaultIconTransformations
27
+ }), stringToIcon = (e, o, s, c = "") => {
28
+ let l = e.split(":");
29
+ if (e.slice(0, 1) === "@") {
30
+ if (l.length < 2 || l.length > 3) return null;
31
+ c = l.shift().slice(1);
32
+ }
33
+ if (l.length > 3 || !l.length) return null;
34
+ if (l.length > 1) {
35
+ let e = l.pop(), s = l.pop(), u = {
36
+ provider: l.length > 0 ? l[0] : c,
37
+ prefix: s,
38
+ name: e
39
+ };
40
+ return o && !validateIconName(u) ? null : u;
41
+ }
42
+ let u = l[0], d = u.split("-");
43
+ if (d.length > 1) {
44
+ let e = {
45
+ provider: c,
46
+ prefix: d.shift(),
47
+ name: d.join("-")
48
+ };
49
+ return o && !validateIconName(e) ? null : e;
50
+ }
51
+ if (s && c === "") {
52
+ let e = {
53
+ provider: c,
54
+ prefix: "",
55
+ name: u
56
+ };
57
+ return o && !validateIconName(e, s) ? null : e;
58
+ }
59
+ return null;
60
+ }, validateIconName = (e, o) => e ? !!((o && e.prefix === "" || e.prefix) && e.name) : !1;
61
+ function mergeIconTransformations(e, o) {
62
+ let s = {};
63
+ !e.hFlip != !o.hFlip && (s.hFlip = !0), !e.vFlip != !o.vFlip && (s.vFlip = !0);
64
+ let c = ((e.rotate || 0) + (o.rotate || 0)) % 4;
65
+ return c && (s.rotate = c), s;
66
+ }
67
+ function mergeIconData(e, o) {
68
+ let s = mergeIconTransformations(e, o);
69
+ for (let c in defaultExtendedIconProps) c in defaultIconTransformations ? c in e && !(c in s) && (s[c] = defaultIconTransformations[c]) : c in o ? s[c] = o[c] : c in e && (s[c] = e[c]);
70
+ return s;
71
+ }
72
+ function getIconsTree(e, o) {
73
+ let s = e.icons, c = e.aliases || Object.create(null), l = Object.create(null);
74
+ function u(e) {
75
+ if (s[e]) return l[e] = [];
76
+ if (!(e in l)) {
77
+ l[e] = null;
78
+ let o = c[e] && c[e].parent, s = o && u(o);
79
+ s && (l[e] = [o].concat(s));
80
+ }
81
+ return l[e];
82
+ }
83
+ return (o || Object.keys(s).concat(Object.keys(c))).forEach(u), l;
84
+ }
85
+ function internalGetIconData(e, o, s) {
86
+ let c = e.icons, l = e.aliases || Object.create(null), u = {};
87
+ function d(e) {
88
+ u = mergeIconData(c[e] || l[e], u);
89
+ }
90
+ return d(o), s.forEach(d), mergeIconData(e, u);
91
+ }
92
+ function getIconData(e, o) {
93
+ if (e.icons[o]) return internalGetIconData(e, o, []);
94
+ let s = getIconsTree(e, [o])[o];
95
+ return s ? internalGetIconData(e, o, s) : null;
96
+ }
97
+ var unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g, unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
98
+ function calculateSize(e, o, s) {
99
+ if (o === 1) return e;
100
+ if (s ||= 100, typeof e == "number") return Math.ceil(e * o * s) / s;
101
+ if (typeof e != "string") return e;
102
+ let c = e.split(unitsSplit);
103
+ if (c === null || !c.length) return e;
104
+ let l = [], u = c.shift(), d = unitsTest.test(u);
105
+ for (;;) {
106
+ if (d) {
107
+ let e = parseFloat(u);
108
+ isNaN(e) ? l.push(u) : l.push(Math.ceil(e * o * s) / s);
109
+ } else l.push(u);
110
+ if (u = c.shift(), u === void 0) return l.join("");
111
+ d = !d;
112
+ }
113
+ }
114
+ function splitSVGDefs(e, o = "defs") {
115
+ let s = "", c = e.indexOf("<" + o);
116
+ for (; c >= 0;) {
117
+ let l = e.indexOf(">", c), u = e.indexOf("</" + o);
118
+ if (l === -1 || u === -1) break;
119
+ let d = e.indexOf(">", u);
120
+ if (d === -1) break;
121
+ s += e.slice(l + 1, u).trim(), e = e.slice(0, c).trim() + e.slice(d + 1);
122
+ }
123
+ return {
124
+ defs: s,
125
+ content: e
126
+ };
127
+ }
128
+ function mergeDefsAndContent(e, o) {
129
+ return e ? "<defs>" + e + "</defs>" + o : o;
130
+ }
131
+ function wrapSVGContent(e, o, s) {
132
+ let c = splitSVGDefs(e);
133
+ return mergeDefsAndContent(c.defs, o + c.content + s);
134
+ }
135
+ var isUnsetKeyword = (e) => e === "unset" || e === "undefined" || e === "none";
136
+ function iconToSVG(e, o) {
137
+ let s = {
138
+ ...defaultIconProps,
139
+ ...e
140
+ }, c = {
141
+ ...defaultIconCustomisations,
142
+ ...o
143
+ }, l = {
144
+ left: s.left,
145
+ top: s.top,
146
+ width: s.width,
147
+ height: s.height
148
+ }, u = s.body;
149
+ [s, c].forEach((e) => {
150
+ let o = [], s = e.hFlip, c = e.vFlip, d = e.rotate;
151
+ s ? c ? d += 2 : (o.push("translate(" + (l.width + l.left).toString() + " " + (0 - l.top).toString() + ")"), o.push("scale(-1 1)"), l.top = l.left = 0) : c && (o.push("translate(" + (0 - l.left).toString() + " " + (l.height + l.top).toString() + ")"), o.push("scale(1 -1)"), l.top = l.left = 0);
152
+ let f;
153
+ switch (d < 0 && (d -= Math.floor(d / 4) * 4), d %= 4, d) {
154
+ case 1:
155
+ f = l.height / 2 + l.top, o.unshift("rotate(90 " + f.toString() + " " + f.toString() + ")");
156
+ break;
157
+ case 2:
158
+ o.unshift("rotate(180 " + (l.width / 2 + l.left).toString() + " " + (l.height / 2 + l.top).toString() + ")");
159
+ break;
160
+ case 3:
161
+ f = l.width / 2 + l.left, o.unshift("rotate(-90 " + f.toString() + " " + f.toString() + ")");
162
+ break;
163
+ }
164
+ d % 2 == 1 && (l.left !== l.top && (f = l.left, l.left = l.top, l.top = f), l.width !== l.height && (f = l.width, l.width = l.height, l.height = f)), o.length && (u = wrapSVGContent(u, "<g transform=\"" + o.join(" ") + "\">", "</g>"));
165
+ });
166
+ let d = c.width, f = c.height, p = l.width, g = l.height, O, R;
167
+ d === null ? (R = f === null ? "1em" : f === "auto" ? g : f, O = calculateSize(R, p / g)) : (O = d === "auto" ? p : d, R = f === null ? calculateSize(O, g / p) : f === "auto" ? g : f);
168
+ let B = {}, Y = (e, o) => {
169
+ isUnsetKeyword(o) || (B[e] = o.toString());
170
+ };
171
+ Y("width", O), Y("height", R);
172
+ let Z = [
173
+ l.left,
174
+ l.top,
175
+ p,
176
+ g
177
+ ];
178
+ return B.viewBox = Z.join(" "), {
179
+ attributes: B,
180
+ viewBox: Z,
181
+ body: u
182
+ };
183
+ }
184
+ var regex = /\sid="(\S+)"/g, randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16), counter = 0;
185
+ function replaceIDs(e, o = randomPrefix) {
186
+ let s = [], c;
187
+ for (; c = regex.exec(e);) s.push(c[1]);
188
+ if (!s.length) return e;
189
+ let l = "suffix" + (Math.random() * 16777216 | Date.now()).toString(16);
190
+ return s.forEach((s) => {
191
+ let c = typeof o == "function" ? o(s) : o + (counter++).toString(), u = s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
192
+ e = e.replace(RegExp("([#;\"])(" + u + ")([\")]|\\.[a-z])", "g"), "$1" + c + l + "$3");
193
+ }), e = e.replace(new RegExp(l, "g"), ""), e;
194
+ }
195
+ function iconToHTML(e, o) {
196
+ let s = e.indexOf("xlink:") === -1 ? "" : " xmlns:xlink=\"http://www.w3.org/1999/xlink\"";
197
+ for (let e in o) s += " " + e + "=\"" + o[e] + "\"";
198
+ return "<svg xmlns=\"http://www.w3.org/2000/svg\"" + s + ">" + e + "</svg>";
199
+ }
200
+ function L() {
201
+ return {
202
+ async: !1,
203
+ breaks: !1,
204
+ extensions: null,
205
+ gfm: !0,
206
+ hooks: null,
207
+ pedantic: !1,
208
+ renderer: null,
209
+ silent: !1,
210
+ tokenizer: null,
211
+ walkTokens: null
212
+ };
213
+ }
214
+ var T = L();
215
+ function G(e) {
216
+ T = e;
217
+ }
218
+ var I = { exec: () => null };
219
+ function h(e, o = "") {
220
+ let s = typeof e == "string" ? e : e.source, c = {
221
+ replace: (e, o) => {
222
+ let l = typeof o == "string" ? o : o.source;
223
+ return l = l.replace(m.caret, "$1"), s = s.replace(e, l), c;
224
+ },
225
+ getRegex: () => new RegExp(s, o)
226
+ };
227
+ return c;
228
+ }
229
+ var m = {
230
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
231
+ outputLinkReplace: /\\([\[\]])/g,
232
+ indentCodeCompensation: /^(\s+)(?:```)/,
233
+ beginningSpace: /^\s+/,
234
+ endingHash: /#$/,
235
+ startingSpaceChar: /^ /,
236
+ endingSpaceChar: / $/,
237
+ nonSpaceChar: /[^ ]/,
238
+ newLineCharGlobal: /\n/g,
239
+ tabCharGlobal: /\t/g,
240
+ multipleSpaceGlobal: /\s+/g,
241
+ blankLine: /^[ \t]*$/,
242
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
243
+ blockquoteStart: /^ {0,3}>/,
244
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
245
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
246
+ listReplaceTabs: /^\t+/,
247
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
248
+ listIsTask: /^\[[ xX]\] /,
249
+ listReplaceTask: /^\[[ xX]\] +/,
250
+ anyLine: /\n.*\n/,
251
+ hrefBrackets: /^<(.*)>$/,
252
+ tableDelimiter: /[:|]/,
253
+ tableAlignChars: /^\||\| *$/g,
254
+ tableRowBlankLine: /\n[ \t]*$/,
255
+ tableAlignRight: /^ *-+: *$/,
256
+ tableAlignCenter: /^ *:-+: *$/,
257
+ tableAlignLeft: /^ *:-+ *$/,
258
+ startATag: /^<a /i,
259
+ endATag: /^<\/a>/i,
260
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
261
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
262
+ startAngleBracket: /^</,
263
+ endAngleBracket: />$/,
264
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
265
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
266
+ escapeTest: /[&<>"']/,
267
+ escapeReplace: /[&<>"']/g,
268
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
269
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
270
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,
271
+ caret: /(^|[^\[])\^/g,
272
+ percentDecode: /%25/g,
273
+ findPipe: /\|/g,
274
+ splitPipe: / \|/,
275
+ slashPipe: /\\\|/g,
276
+ carriageReturn: /\r\n|\r/g,
277
+ spaceLine: /^ +$/gm,
278
+ notSpaceStart: /^\S*/,
279
+ endingNewline: /\n$/,
280
+ listItemRegex: (e) => /* @__PURE__ */ RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
281
+ nextBulletRegex: (e) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
282
+ hrRegex: (e) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
283
+ fencesBeginRegex: (e) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e - 1)}}(?:\`\`\`|~~~)`),
284
+ headingBeginRegex: (e) => /* @__PURE__ */ RegExp(`^ {0,${Math.min(3, e - 1)}}#`),
285
+ htmlBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}<(?:[a-z].*>|!--)`, "i")
286
+ }, be = /^(?:[ \t]*(?:\n|$))+/, Re = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Te = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, E = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Oe = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, F = /(?:[*+-]|\d{1,9}[.)])/, ie = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, oe = h(ie).replace(/bull/g, F).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).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/).replace(/\|table/g, "").getRegex(), we = h(ie).replace(/bull/g, F).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).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/).replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(), j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, ye = /^[^\n]+/, Q = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Pe = h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Q).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Se = h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, F).getRegex(), v = "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", U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, $e = h("^ {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", U).replace("tag", v).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), ae = h(j).replace("hr", E).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", v).getRegex(), K = {
287
+ blockquote: h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex(),
288
+ code: Re,
289
+ def: Pe,
290
+ fences: Te,
291
+ heading: Oe,
292
+ hr: E,
293
+ html: $e,
294
+ lheading: oe,
295
+ list: Se,
296
+ newline: be,
297
+ paragraph: ae,
298
+ table: I,
299
+ text: ye
300
+ }, re = h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", E).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\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", v).getRegex(), Le = {
301
+ ...K,
302
+ lheading: we,
303
+ table: re,
304
+ paragraph: h(j).replace("hr", E).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).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", v).getRegex()
305
+ }, Me = {
306
+ ...K,
307
+ html: h("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", U).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(),
308
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
309
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
310
+ fences: I,
311
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
312
+ paragraph: h(j).replace("hr", E).replace("heading", " *#{1,6} *[^\n]").replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
313
+ }, ze = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ae = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, le = /^( {2,}|\\)\n(?!\s*$)/, Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, D = /[\p{P}\p{S}]/u, W = /[\s\p{P}\p{S}]/u, ue = /[^\s\p{P}\p{S}]/u, Ee = h(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, W).getRegex(), pe = /(?!~)[\p{P}\p{S}]/u, Ce = /(?!~)[\s\p{P}\p{S}]/u, Be = /(?:[^\s\p{P}\p{S}]|~)/u, qe = h(/link|code|html/, "g").replace("link", RegExp("\\[(?:[^\\[\\]`]|(?<!`)(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)", "")).replace("code", RegExp("(?<!`)(?<b>`+)[^`]+\\k<b>(?!`)", "")).replace("html", /<(?! )[^<>]*?>/).getRegex(), ce = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, ve = h(ce, "u").replace(/punct/g, D).getRegex(), De = h(ce, "u").replace(/punct/g, pe).getRegex(), he = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", He = h(he, "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), Ze = h(he, "gu").replace(/notPunctSpace/g, Be).replace(/punctSpace/g, Ce).replace(/punct/g, pe).getRegex(), Ge = h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, W).replace(/punct/g, D).getRegex(), Ne = h(/\\(punct)/, "gu").replace(/punct/g, D).getRegex(), Fe = h(/^<(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(), je = h(U).replace("(?:-->|$)", "-->").getRegex(), Qe = h("^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", je).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/, Ue = h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), de = h(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", Q).getRegex(), ke = h(/^!?\[(ref)\](?:\[\])?/).replace("ref", Q).getRegex(), Ke = h("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", ke).getRegex(), se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, X = {
314
+ _backpedal: I,
315
+ anyPunctuation: Ne,
316
+ autolink: Fe,
317
+ blockSkip: qe,
318
+ br: le,
319
+ code: Ae,
320
+ del: I,
321
+ emStrongLDelim: ve,
322
+ emStrongRDelimAst: He,
323
+ emStrongRDelimUnd: Ge,
324
+ escape: ze,
325
+ link: Ue,
326
+ nolink: ke,
327
+ punctuation: Ee,
328
+ reflink: de,
329
+ reflinkSearch: Ke,
330
+ tag: Qe,
331
+ text: Ie,
332
+ url: I
333
+ }, We = {
334
+ ...X,
335
+ link: h(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(),
336
+ reflink: h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex()
337
+ }, N = {
338
+ ...X,
339
+ emStrongRDelimAst: Ze,
340
+ emStrongLDelim: De,
341
+ url: h(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", se).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
342
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
343
+ del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
344
+ text: h(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", se).getRegex()
345
+ }, Xe = {
346
+ ...N,
347
+ br: h(le).replace("{2,}", "*").getRegex(),
348
+ text: h(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
349
+ }, C = {
350
+ normal: K,
351
+ gfm: Le,
352
+ pedantic: Me
353
+ }, M = {
354
+ normal: X,
355
+ gfm: N,
356
+ breaks: Xe,
357
+ pedantic: We
358
+ }, Je = {
359
+ "&": "&amp;",
360
+ "<": "&lt;",
361
+ ">": "&gt;",
362
+ "\"": "&quot;",
363
+ "'": "&#39;"
364
+ }, ge = (e) => Je[e];
365
+ function w(e, o) {
366
+ if (o) {
367
+ if (m.escapeTest.test(e)) return e.replace(m.escapeReplace, ge);
368
+ } else if (m.escapeTestNoEncode.test(e)) return e.replace(m.escapeReplaceNoEncode, ge);
369
+ return e;
370
+ }
371
+ function J(e) {
372
+ try {
373
+ e = encodeURI(e).replace(m.percentDecode, "%");
374
+ } catch {
375
+ return null;
376
+ }
377
+ return e;
378
+ }
379
+ function V(e, o) {
380
+ let s = e.replace(m.findPipe, (e, o, s) => {
381
+ let c = !1, l = o;
382
+ for (; --l >= 0 && s[l] === "\\";) c = !c;
383
+ return c ? "|" : " |";
384
+ }).split(m.splitPipe), c = 0;
385
+ if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), o) if (s.length > o) s.splice(o);
386
+ else for (; s.length < o;) s.push("");
387
+ for (; c < s.length; c++) s[c] = s[c].trim().replace(m.slashPipe, "|");
388
+ return s;
389
+ }
390
+ function z(e, o, s) {
391
+ let c = e.length;
392
+ if (c === 0) return "";
393
+ let l = 0;
394
+ for (; l < c;) {
395
+ let u = e.charAt(c - l - 1);
396
+ if (u === o && !s) l++;
397
+ else if (u !== o && s) l++;
398
+ else break;
399
+ }
400
+ return e.slice(0, c - l);
401
+ }
402
+ function fe(e, o) {
403
+ if (e.indexOf(o[1]) === -1) return -1;
404
+ let s = 0;
405
+ for (let c = 0; c < e.length; c++) if (e[c] === "\\") c++;
406
+ else if (e[c] === o[0]) s++;
407
+ else if (e[c] === o[1] && (s--, s < 0)) return c;
408
+ return s > 0 ? -2 : -1;
409
+ }
410
+ function me(e, o, s, c, l) {
411
+ let u = o.href, d = o.title || null, f = e[1].replace(l.other.outputLinkReplace, "$1");
412
+ c.state.inLink = !0;
413
+ let p = {
414
+ type: e[0].charAt(0) === "!" ? "image" : "link",
415
+ raw: s,
416
+ href: u,
417
+ title: d,
418
+ text: f,
419
+ tokens: c.inlineTokens(f)
420
+ };
421
+ return c.state.inLink = !1, p;
422
+ }
423
+ function Ve(e, o, s) {
424
+ let c = e.match(s.other.indentCodeCompensation);
425
+ if (c === null) return o;
426
+ let l = c[1];
427
+ return o.split("\n").map((e) => {
428
+ let o = e.match(s.other.beginningSpace);
429
+ if (o === null) return e;
430
+ let [c] = o;
431
+ return c.length >= l.length ? e.slice(l.length) : e;
432
+ }).join("\n");
433
+ }
434
+ var y = class {
435
+ options;
436
+ rules;
437
+ lexer;
438
+ constructor(e) {
439
+ this.options = e || T;
440
+ }
441
+ space(e) {
442
+ let o = this.rules.block.newline.exec(e);
443
+ if (o && o[0].length > 0) return {
444
+ type: "space",
445
+ raw: o[0]
446
+ };
447
+ }
448
+ code(e) {
449
+ let o = this.rules.block.code.exec(e);
450
+ if (o) {
451
+ let e = o[0].replace(this.rules.other.codeRemoveIndent, "");
452
+ return {
453
+ type: "code",
454
+ raw: o[0],
455
+ codeBlockStyle: "indented",
456
+ text: this.options.pedantic ? e : z(e, "\n")
457
+ };
458
+ }
459
+ }
460
+ fences(e) {
461
+ let o = this.rules.block.fences.exec(e);
462
+ if (o) {
463
+ let e = o[0], s = Ve(e, o[3] || "", this.rules);
464
+ return {
465
+ type: "code",
466
+ raw: e,
467
+ lang: o[2] ? o[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : o[2],
468
+ text: s
469
+ };
470
+ }
471
+ }
472
+ heading(e) {
473
+ let o = this.rules.block.heading.exec(e);
474
+ if (o) {
475
+ let e = o[2].trim();
476
+ if (this.rules.other.endingHash.test(e)) {
477
+ let o = z(e, "#");
478
+ (this.options.pedantic || !o || this.rules.other.endingSpaceChar.test(o)) && (e = o.trim());
479
+ }
480
+ return {
481
+ type: "heading",
482
+ raw: o[0],
483
+ depth: o[1].length,
484
+ text: e,
485
+ tokens: this.lexer.inline(e)
486
+ };
487
+ }
488
+ }
489
+ hr(e) {
490
+ let o = this.rules.block.hr.exec(e);
491
+ if (o) return {
492
+ type: "hr",
493
+ raw: z(o[0], "\n")
494
+ };
495
+ }
496
+ blockquote(e) {
497
+ let o = this.rules.block.blockquote.exec(e);
498
+ if (o) {
499
+ let e = z(o[0], "\n").split("\n"), s = "", c = "", l = [];
500
+ for (; e.length > 0;) {
501
+ let o = !1, u = [], d;
502
+ for (d = 0; d < e.length; d++) if (this.rules.other.blockquoteStart.test(e[d])) u.push(e[d]), o = !0;
503
+ else if (!o) u.push(e[d]);
504
+ else break;
505
+ e = e.slice(d);
506
+ let f = u.join("\n"), p = f.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
507
+ s = s ? `${s}
508
+ ${f}` : f, c = c ? `${c}
509
+ ${p}` : p;
510
+ let g = this.lexer.state.top;
511
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(p, l, !0), this.lexer.state.top = g, e.length === 0) break;
512
+ let O = l.at(-1);
513
+ if (O?.type === "code") break;
514
+ if (O?.type === "blockquote") {
515
+ let o = O, u = o.raw + "\n" + e.join("\n"), d = this.blockquote(u);
516
+ l[l.length - 1] = d, s = s.substring(0, s.length - o.raw.length) + d.raw, c = c.substring(0, c.length - o.text.length) + d.text;
517
+ break;
518
+ } else if (O?.type === "list") {
519
+ let o = O, u = o.raw + "\n" + e.join("\n"), d = this.list(u);
520
+ l[l.length - 1] = d, s = s.substring(0, s.length - O.raw.length) + d.raw, c = c.substring(0, c.length - o.raw.length) + d.raw, e = u.substring(l.at(-1).raw.length).split("\n");
521
+ continue;
522
+ }
523
+ }
524
+ return {
525
+ type: "blockquote",
526
+ raw: s,
527
+ tokens: l,
528
+ text: c
529
+ };
530
+ }
531
+ }
532
+ list(e) {
533
+ let o = this.rules.block.list.exec(e);
534
+ if (o) {
535
+ let s = o[1].trim(), c = s.length > 1, l = {
536
+ type: "list",
537
+ raw: "",
538
+ ordered: c,
539
+ start: c ? +s.slice(0, -1) : "",
540
+ loose: !1,
541
+ items: []
542
+ };
543
+ s = c ? `\\d{1,9}\\${s.slice(-1)}` : `\\${s}`, this.options.pedantic && (s = c ? s : "[*+-]");
544
+ let u = this.rules.other.listItemRegex(s), d = !1;
545
+ for (; e;) {
546
+ let s = !1, c = "", f = "";
547
+ if (!(o = u.exec(e)) || this.rules.block.hr.test(e)) break;
548
+ c = o[0], e = e.substring(c.length);
549
+ let p = o[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (e) => " ".repeat(3 * e.length)), g = e.split("\n", 1)[0], O = !p.trim(), A = 0;
550
+ if (this.options.pedantic ? (A = 2, f = p.trimStart()) : O ? A = o[1].length + 1 : (A = o[2].search(this.rules.other.nonSpaceChar), A = A > 4 ? 1 : A, f = p.slice(A), A += o[1].length), O && this.rules.other.blankLine.test(g) && (c += g + "\n", e = e.substring(g.length + 1), s = !0), !s) {
551
+ let o = this.rules.other.nextBulletRegex(A), s = this.rules.other.hrRegex(A), l = this.rules.other.fencesBeginRegex(A), u = this.rules.other.headingBeginRegex(A), d = this.rules.other.htmlBeginRegex(A);
552
+ for (; e;) {
553
+ let R = e.split("\n", 1)[0], B;
554
+ if (g = R, this.options.pedantic ? (g = g.replace(this.rules.other.listReplaceNesting, " "), B = g) : B = g.replace(this.rules.other.tabCharGlobal, " "), l.test(g) || u.test(g) || d.test(g) || o.test(g) || s.test(g)) break;
555
+ if (B.search(this.rules.other.nonSpaceChar) >= A || !g.trim()) f += "\n" + B.slice(A);
556
+ else {
557
+ if (O || p.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || l.test(p) || u.test(p) || s.test(p)) break;
558
+ f += "\n" + g;
559
+ }
560
+ !O && !g.trim() && (O = !0), c += R + "\n", e = e.substring(R.length + 1), p = B.slice(A);
561
+ }
562
+ }
563
+ l.loose || (d ? l.loose = !0 : this.rules.other.doubleBlankLine.test(c) && (d = !0));
564
+ let R = null, B;
565
+ this.options.gfm && (R = this.rules.other.listIsTask.exec(f), R && (B = R[0] !== "[ ] ", f = f.replace(this.rules.other.listReplaceTask, ""))), l.items.push({
566
+ type: "list_item",
567
+ raw: c,
568
+ task: !!R,
569
+ checked: B,
570
+ loose: !1,
571
+ text: f,
572
+ tokens: []
573
+ }), l.raw += c;
574
+ }
575
+ let f = l.items.at(-1);
576
+ if (f) f.raw = f.raw.trimEnd(), f.text = f.text.trimEnd();
577
+ else return;
578
+ l.raw = l.raw.trimEnd();
579
+ for (let e = 0; e < l.items.length; e++) if (this.lexer.state.top = !1, l.items[e].tokens = this.lexer.blockTokens(l.items[e].text, []), !l.loose) {
580
+ let o = l.items[e].tokens.filter((e) => e.type === "space");
581
+ l.loose = o.length > 0 && o.some((e) => this.rules.other.anyLine.test(e.raw));
582
+ }
583
+ if (l.loose) for (let e = 0; e < l.items.length; e++) l.items[e].loose = !0;
584
+ return l;
585
+ }
586
+ }
587
+ html(e) {
588
+ let o = this.rules.block.html.exec(e);
589
+ if (o) return {
590
+ type: "html",
591
+ block: !0,
592
+ raw: o[0],
593
+ pre: o[1] === "pre" || o[1] === "script" || o[1] === "style",
594
+ text: o[0]
595
+ };
596
+ }
597
+ def(e) {
598
+ let o = this.rules.block.def.exec(e);
599
+ if (o) {
600
+ let e = o[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = o[2] ? o[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", c = o[3] ? o[3].substring(1, o[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : o[3];
601
+ return {
602
+ type: "def",
603
+ tag: e,
604
+ raw: o[0],
605
+ href: s,
606
+ title: c
607
+ };
608
+ }
609
+ }
610
+ table(e) {
611
+ let o = this.rules.block.table.exec(e);
612
+ if (!o || !this.rules.other.tableDelimiter.test(o[2])) return;
613
+ let s = V(o[1]), c = o[2].replace(this.rules.other.tableAlignChars, "").split("|"), l = o[3]?.trim() ? o[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], u = {
614
+ type: "table",
615
+ raw: o[0],
616
+ header: [],
617
+ align: [],
618
+ rows: []
619
+ };
620
+ if (s.length === c.length) {
621
+ for (let e of c) this.rules.other.tableAlignRight.test(e) ? u.align.push("right") : this.rules.other.tableAlignCenter.test(e) ? u.align.push("center") : this.rules.other.tableAlignLeft.test(e) ? u.align.push("left") : u.align.push(null);
622
+ for (let e = 0; e < s.length; e++) u.header.push({
623
+ text: s[e],
624
+ tokens: this.lexer.inline(s[e]),
625
+ header: !0,
626
+ align: u.align[e]
627
+ });
628
+ for (let e of l) u.rows.push(V(e, u.header.length).map((e, o) => ({
629
+ text: e,
630
+ tokens: this.lexer.inline(e),
631
+ header: !1,
632
+ align: u.align[o]
633
+ })));
634
+ return u;
635
+ }
636
+ }
637
+ lheading(e) {
638
+ let o = this.rules.block.lheading.exec(e);
639
+ if (o) return {
640
+ type: "heading",
641
+ raw: o[0],
642
+ depth: o[2].charAt(0) === "=" ? 1 : 2,
643
+ text: o[1],
644
+ tokens: this.lexer.inline(o[1])
645
+ };
646
+ }
647
+ paragraph(e) {
648
+ let o = this.rules.block.paragraph.exec(e);
649
+ if (o) {
650
+ let e = o[1].charAt(o[1].length - 1) === "\n" ? o[1].slice(0, -1) : o[1];
651
+ return {
652
+ type: "paragraph",
653
+ raw: o[0],
654
+ text: e,
655
+ tokens: this.lexer.inline(e)
656
+ };
657
+ }
658
+ }
659
+ text(e) {
660
+ let o = this.rules.block.text.exec(e);
661
+ if (o) return {
662
+ type: "text",
663
+ raw: o[0],
664
+ text: o[0],
665
+ tokens: this.lexer.inline(o[0])
666
+ };
667
+ }
668
+ escape(e) {
669
+ let o = this.rules.inline.escape.exec(e);
670
+ if (o) return {
671
+ type: "escape",
672
+ raw: o[0],
673
+ text: o[1]
674
+ };
675
+ }
676
+ tag(e) {
677
+ let o = this.rules.inline.tag.exec(e);
678
+ if (o) return !this.lexer.state.inLink && this.rules.other.startATag.test(o[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(o[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(o[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(o[0]) && (this.lexer.state.inRawBlock = !1), {
679
+ type: "html",
680
+ raw: o[0],
681
+ inLink: this.lexer.state.inLink,
682
+ inRawBlock: this.lexer.state.inRawBlock,
683
+ block: !1,
684
+ text: o[0]
685
+ };
686
+ }
687
+ link(e) {
688
+ let o = this.rules.inline.link.exec(e);
689
+ if (o) {
690
+ let e = o[2].trim();
691
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(e)) {
692
+ if (!this.rules.other.endAngleBracket.test(e)) return;
693
+ let o = z(e.slice(0, -1), "\\");
694
+ if ((e.length - o.length) % 2 == 0) return;
695
+ } else {
696
+ let e = fe(o[2], "()");
697
+ if (e === -2) return;
698
+ if (e > -1) {
699
+ let s = (o[0].indexOf("!") === 0 ? 5 : 4) + o[1].length + e;
700
+ o[2] = o[2].substring(0, e), o[0] = o[0].substring(0, s).trim(), o[3] = "";
701
+ }
702
+ }
703
+ let s = o[2], c = "";
704
+ if (this.options.pedantic) {
705
+ let e = this.rules.other.pedanticHrefTitle.exec(s);
706
+ e && (s = e[1], c = e[3]);
707
+ } else c = o[3] ? o[3].slice(1, -1) : "";
708
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (s = this.options.pedantic && !this.rules.other.endAngleBracket.test(e) ? s.slice(1) : s.slice(1, -1)), me(o, {
709
+ href: s && s.replace(this.rules.inline.anyPunctuation, "$1"),
710
+ title: c && c.replace(this.rules.inline.anyPunctuation, "$1")
711
+ }, o[0], this.lexer, this.rules);
712
+ }
713
+ }
714
+ reflink(e, o) {
715
+ let s;
716
+ if ((s = this.rules.inline.reflink.exec(e)) || (s = this.rules.inline.nolink.exec(e))) {
717
+ let e = o[(s[2] || s[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()];
718
+ if (!e) {
719
+ let e = s[0].charAt(0);
720
+ return {
721
+ type: "text",
722
+ raw: e,
723
+ text: e
724
+ };
725
+ }
726
+ return me(s, e, s[0], this.lexer, this.rules);
727
+ }
728
+ }
729
+ emStrong(e, o, s = "") {
730
+ let c = this.rules.inline.emStrongLDelim.exec(e);
731
+ if (!(!c || c[3] && s.match(this.rules.other.unicodeAlphaNumeric)) && (!(c[1] || c[2]) || !s || this.rules.inline.punctuation.exec(s))) {
732
+ let s = [...c[0]].length - 1, l, u, d = s, f = 0, p = c[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
733
+ for (p.lastIndex = 0, o = o.slice(-1 * e.length + s); (c = p.exec(o)) != null;) {
734
+ if (l = c[1] || c[2] || c[3] || c[4] || c[5] || c[6], !l) continue;
735
+ if (u = [...l].length, c[3] || c[4]) {
736
+ d += u;
737
+ continue;
738
+ } else if ((c[5] || c[6]) && s % 3 && !((s + u) % 3)) {
739
+ f += u;
740
+ continue;
741
+ }
742
+ if (d -= u, d > 0) continue;
743
+ u = Math.min(u, u + d + f);
744
+ let o = [...c[0]][0].length, p = e.slice(0, s + c.index + o + u);
745
+ if (Math.min(s, u) % 2) {
746
+ let e = p.slice(1, -1);
747
+ return {
748
+ type: "em",
749
+ raw: p,
750
+ text: e,
751
+ tokens: this.lexer.inlineTokens(e)
752
+ };
753
+ }
754
+ let g = p.slice(2, -2);
755
+ return {
756
+ type: "strong",
757
+ raw: p,
758
+ text: g,
759
+ tokens: this.lexer.inlineTokens(g)
760
+ };
761
+ }
762
+ }
763
+ }
764
+ codespan(e) {
765
+ let o = this.rules.inline.code.exec(e);
766
+ if (o) {
767
+ let e = o[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(e), c = this.rules.other.startingSpaceChar.test(e) && this.rules.other.endingSpaceChar.test(e);
768
+ return s && c && (e = e.substring(1, e.length - 1)), {
769
+ type: "codespan",
770
+ raw: o[0],
771
+ text: e
772
+ };
773
+ }
774
+ }
775
+ br(e) {
776
+ let o = this.rules.inline.br.exec(e);
777
+ if (o) return {
778
+ type: "br",
779
+ raw: o[0]
780
+ };
781
+ }
782
+ del(e) {
783
+ let o = this.rules.inline.del.exec(e);
784
+ if (o) return {
785
+ type: "del",
786
+ raw: o[0],
787
+ text: o[2],
788
+ tokens: this.lexer.inlineTokens(o[2])
789
+ };
790
+ }
791
+ autolink(e) {
792
+ let o = this.rules.inline.autolink.exec(e);
793
+ if (o) {
794
+ let e, s;
795
+ return o[2] === "@" ? (e = o[1], s = "mailto:" + e) : (e = o[1], s = e), {
796
+ type: "link",
797
+ raw: o[0],
798
+ text: e,
799
+ href: s,
800
+ tokens: [{
801
+ type: "text",
802
+ raw: e,
803
+ text: e
804
+ }]
805
+ };
806
+ }
807
+ }
808
+ url(e) {
809
+ let o;
810
+ if (o = this.rules.inline.url.exec(e)) {
811
+ let e, s;
812
+ if (o[2] === "@") e = o[0], s = "mailto:" + e;
813
+ else {
814
+ let c;
815
+ do
816
+ c = o[0], o[0] = this.rules.inline._backpedal.exec(o[0])?.[0] ?? "";
817
+ while (c !== o[0]);
818
+ e = o[0], s = o[1] === "www." ? "http://" + o[0] : o[0];
819
+ }
820
+ return {
821
+ type: "link",
822
+ raw: o[0],
823
+ text: e,
824
+ href: s,
825
+ tokens: [{
826
+ type: "text",
827
+ raw: e,
828
+ text: e
829
+ }]
830
+ };
831
+ }
832
+ }
833
+ inlineText(e) {
834
+ let o = this.rules.inline.text.exec(e);
835
+ if (o) {
836
+ let e = this.lexer.state.inRawBlock;
837
+ return {
838
+ type: "text",
839
+ raw: o[0],
840
+ text: o[0],
841
+ escaped: e
842
+ };
843
+ }
844
+ }
845
+ }, x = class e {
846
+ tokens;
847
+ options;
848
+ state;
849
+ tokenizer;
850
+ inlineQueue;
851
+ constructor(e) {
852
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new y(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
853
+ inLink: !1,
854
+ inRawBlock: !1,
855
+ top: !0
856
+ };
857
+ let o = {
858
+ other: m,
859
+ block: C.normal,
860
+ inline: M.normal
861
+ };
862
+ this.options.pedantic ? (o.block = C.pedantic, o.inline = M.pedantic) : this.options.gfm && (o.block = C.gfm, this.options.breaks ? o.inline = M.breaks : o.inline = M.gfm), this.tokenizer.rules = o;
863
+ }
864
+ static get rules() {
865
+ return {
866
+ block: C,
867
+ inline: M
868
+ };
869
+ }
870
+ static lex(o, s) {
871
+ return new e(s).lex(o);
872
+ }
873
+ static lexInline(o, s) {
874
+ return new e(s).inlineTokens(o);
875
+ }
876
+ lex(e) {
877
+ e = e.replace(m.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
878
+ for (let e = 0; e < this.inlineQueue.length; e++) {
879
+ let o = this.inlineQueue[e];
880
+ this.inlineTokens(o.src, o.tokens);
881
+ }
882
+ return this.inlineQueue = [], this.tokens;
883
+ }
884
+ blockTokens(e, o = [], s = !1) {
885
+ for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e;) {
886
+ let c;
887
+ if (this.options.extensions?.block?.some((s) => (c = s.call({ lexer: this }, e, o)) ? (e = e.substring(c.raw.length), o.push(c), !0) : !1)) continue;
888
+ if (c = this.tokenizer.space(e)) {
889
+ e = e.substring(c.raw.length);
890
+ let s = o.at(-1);
891
+ c.raw.length === 1 && s !== void 0 ? s.raw += "\n" : o.push(c);
892
+ continue;
893
+ }
894
+ if (c = this.tokenizer.code(e)) {
895
+ e = e.substring(c.raw.length);
896
+ let s = o.at(-1);
897
+ s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith("\n") ? "" : "\n") + c.raw, s.text += "\n" + c.text, this.inlineQueue.at(-1).src = s.text) : o.push(c);
898
+ continue;
899
+ }
900
+ if (c = this.tokenizer.fences(e)) {
901
+ e = e.substring(c.raw.length), o.push(c);
902
+ continue;
903
+ }
904
+ if (c = this.tokenizer.heading(e)) {
905
+ e = e.substring(c.raw.length), o.push(c);
906
+ continue;
907
+ }
908
+ if (c = this.tokenizer.hr(e)) {
909
+ e = e.substring(c.raw.length), o.push(c);
910
+ continue;
911
+ }
912
+ if (c = this.tokenizer.blockquote(e)) {
913
+ e = e.substring(c.raw.length), o.push(c);
914
+ continue;
915
+ }
916
+ if (c = this.tokenizer.list(e)) {
917
+ e = e.substring(c.raw.length), o.push(c);
918
+ continue;
919
+ }
920
+ if (c = this.tokenizer.html(e)) {
921
+ e = e.substring(c.raw.length), o.push(c);
922
+ continue;
923
+ }
924
+ if (c = this.tokenizer.def(e)) {
925
+ e = e.substring(c.raw.length);
926
+ let s = o.at(-1);
927
+ s?.type === "paragraph" || s?.type === "text" ? (s.raw += (s.raw.endsWith("\n") ? "" : "\n") + c.raw, s.text += "\n" + c.raw, this.inlineQueue.at(-1).src = s.text) : this.tokens.links[c.tag] || (this.tokens.links[c.tag] = {
928
+ href: c.href,
929
+ title: c.title
930
+ }, o.push(c));
931
+ continue;
932
+ }
933
+ if (c = this.tokenizer.table(e)) {
934
+ e = e.substring(c.raw.length), o.push(c);
935
+ continue;
936
+ }
937
+ if (c = this.tokenizer.lheading(e)) {
938
+ e = e.substring(c.raw.length), o.push(c);
939
+ continue;
940
+ }
941
+ let l = e;
942
+ if (this.options.extensions?.startBlock) {
943
+ let o = Infinity, s = e.slice(1), c;
944
+ this.options.extensions.startBlock.forEach((e) => {
945
+ c = e.call({ lexer: this }, s), typeof c == "number" && c >= 0 && (o = Math.min(o, c));
946
+ }), o < Infinity && o >= 0 && (l = e.substring(0, o + 1));
947
+ }
948
+ if (this.state.top && (c = this.tokenizer.paragraph(l))) {
949
+ let u = o.at(-1);
950
+ s && u?.type === "paragraph" ? (u.raw += (u.raw.endsWith("\n") ? "" : "\n") + c.raw, u.text += "\n" + c.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = u.text) : o.push(c), s = l.length !== e.length, e = e.substring(c.raw.length);
951
+ continue;
952
+ }
953
+ if (c = this.tokenizer.text(e)) {
954
+ e = e.substring(c.raw.length);
955
+ let s = o.at(-1);
956
+ s?.type === "text" ? (s.raw += (s.raw.endsWith("\n") ? "" : "\n") + c.raw, s.text += "\n" + c.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = s.text) : o.push(c);
957
+ continue;
958
+ }
959
+ if (e) {
960
+ let o = "Infinite loop on byte: " + e.charCodeAt(0);
961
+ if (this.options.silent) {
962
+ console.error(o);
963
+ break;
964
+ } else throw Error(o);
965
+ }
966
+ }
967
+ return this.state.top = !0, o;
968
+ }
969
+ inline(e, o = []) {
970
+ return this.inlineQueue.push({
971
+ src: e,
972
+ tokens: o
973
+ }), o;
974
+ }
975
+ inlineTokens(e, o = []) {
976
+ let s = e, c = null;
977
+ if (this.tokens.links) {
978
+ let e = Object.keys(this.tokens.links);
979
+ if (e.length > 0) for (; (c = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null;) e.includes(c[0].slice(c[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, c.index) + "[" + "a".repeat(c[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
980
+ }
981
+ for (; (c = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null;) s = s.slice(0, c.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
982
+ for (; (c = this.tokenizer.rules.inline.blockSkip.exec(s)) != null;) s = s.slice(0, c.index) + "[" + "a".repeat(c[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
983
+ s = this.options.hooks?.emStrongMask?.call({ lexer: this }, s) ?? s;
984
+ let l = !1, u = "";
985
+ for (; e;) {
986
+ l || (u = ""), l = !1;
987
+ let c;
988
+ if (this.options.extensions?.inline?.some((s) => (c = s.call({ lexer: this }, e, o)) ? (e = e.substring(c.raw.length), o.push(c), !0) : !1)) continue;
989
+ if (c = this.tokenizer.escape(e)) {
990
+ e = e.substring(c.raw.length), o.push(c);
991
+ continue;
992
+ }
993
+ if (c = this.tokenizer.tag(e)) {
994
+ e = e.substring(c.raw.length), o.push(c);
995
+ continue;
996
+ }
997
+ if (c = this.tokenizer.link(e)) {
998
+ e = e.substring(c.raw.length), o.push(c);
999
+ continue;
1000
+ }
1001
+ if (c = this.tokenizer.reflink(e, this.tokens.links)) {
1002
+ e = e.substring(c.raw.length);
1003
+ let s = o.at(-1);
1004
+ c.type === "text" && s?.type === "text" ? (s.raw += c.raw, s.text += c.text) : o.push(c);
1005
+ continue;
1006
+ }
1007
+ if (c = this.tokenizer.emStrong(e, s, u)) {
1008
+ e = e.substring(c.raw.length), o.push(c);
1009
+ continue;
1010
+ }
1011
+ if (c = this.tokenizer.codespan(e)) {
1012
+ e = e.substring(c.raw.length), o.push(c);
1013
+ continue;
1014
+ }
1015
+ if (c = this.tokenizer.br(e)) {
1016
+ e = e.substring(c.raw.length), o.push(c);
1017
+ continue;
1018
+ }
1019
+ if (c = this.tokenizer.del(e)) {
1020
+ e = e.substring(c.raw.length), o.push(c);
1021
+ continue;
1022
+ }
1023
+ if (c = this.tokenizer.autolink(e)) {
1024
+ e = e.substring(c.raw.length), o.push(c);
1025
+ continue;
1026
+ }
1027
+ if (!this.state.inLink && (c = this.tokenizer.url(e))) {
1028
+ e = e.substring(c.raw.length), o.push(c);
1029
+ continue;
1030
+ }
1031
+ let d = e;
1032
+ if (this.options.extensions?.startInline) {
1033
+ let o = Infinity, s = e.slice(1), c;
1034
+ this.options.extensions.startInline.forEach((e) => {
1035
+ c = e.call({ lexer: this }, s), typeof c == "number" && c >= 0 && (o = Math.min(o, c));
1036
+ }), o < Infinity && o >= 0 && (d = e.substring(0, o + 1));
1037
+ }
1038
+ if (c = this.tokenizer.inlineText(d)) {
1039
+ e = e.substring(c.raw.length), c.raw.slice(-1) !== "_" && (u = c.raw.slice(-1)), l = !0;
1040
+ let s = o.at(-1);
1041
+ s?.type === "text" ? (s.raw += c.raw, s.text += c.text) : o.push(c);
1042
+ continue;
1043
+ }
1044
+ if (e) {
1045
+ let o = "Infinite loop on byte: " + e.charCodeAt(0);
1046
+ if (this.options.silent) {
1047
+ console.error(o);
1048
+ break;
1049
+ } else throw Error(o);
1050
+ }
1051
+ }
1052
+ return o;
1053
+ }
1054
+ }, P = class {
1055
+ options;
1056
+ parser;
1057
+ constructor(e) {
1058
+ this.options = e || T;
1059
+ }
1060
+ space(e) {
1061
+ return "";
1062
+ }
1063
+ code({ text: e, lang: o, escaped: s }) {
1064
+ let c = (o || "").match(m.notSpaceStart)?.[0], l = e.replace(m.endingNewline, "") + "\n";
1065
+ return c ? "<pre><code class=\"language-" + w(c) + "\">" + (s ? l : w(l, !0)) + "</code></pre>\n" : "<pre><code>" + (s ? l : w(l, !0)) + "</code></pre>\n";
1066
+ }
1067
+ blockquote({ tokens: e }) {
1068
+ return `<blockquote>
1069
+ ${this.parser.parse(e)}</blockquote>
1070
+ `;
1071
+ }
1072
+ html({ text: e }) {
1073
+ return e;
1074
+ }
1075
+ def(e) {
1076
+ return "";
1077
+ }
1078
+ heading({ tokens: e, depth: o }) {
1079
+ return `<h${o}>${this.parser.parseInline(e)}</h${o}>
1080
+ `;
1081
+ }
1082
+ hr(e) {
1083
+ return "<hr>\n";
1084
+ }
1085
+ list(e) {
1086
+ let o = e.ordered, s = e.start, c = "";
1087
+ for (let o = 0; o < e.items.length; o++) {
1088
+ let s = e.items[o];
1089
+ c += this.listitem(s);
1090
+ }
1091
+ let l = o ? "ol" : "ul", u = o && s !== 1 ? " start=\"" + s + "\"" : "";
1092
+ return "<" + l + u + ">\n" + c + "</" + l + ">\n";
1093
+ }
1094
+ listitem(e) {
1095
+ let o = "";
1096
+ if (e.task) {
1097
+ let s = this.checkbox({ checked: !!e.checked });
1098
+ e.loose ? e.tokens[0]?.type === "paragraph" ? (e.tokens[0].text = s + " " + e.tokens[0].text, e.tokens[0].tokens && e.tokens[0].tokens.length > 0 && e.tokens[0].tokens[0].type === "text" && (e.tokens[0].tokens[0].text = s + " " + w(e.tokens[0].tokens[0].text), e.tokens[0].tokens[0].escaped = !0)) : e.tokens.unshift({
1099
+ type: "text",
1100
+ raw: s + " ",
1101
+ text: s + " ",
1102
+ escaped: !0
1103
+ }) : o += s + " ";
1104
+ }
1105
+ return o += this.parser.parse(e.tokens, !!e.loose), `<li>${o}</li>
1106
+ `;
1107
+ }
1108
+ checkbox({ checked: e }) {
1109
+ return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\">";
1110
+ }
1111
+ paragraph({ tokens: e }) {
1112
+ return `<p>${this.parser.parseInline(e)}</p>
1113
+ `;
1114
+ }
1115
+ table(e) {
1116
+ let o = "", s = "";
1117
+ for (let o = 0; o < e.header.length; o++) s += this.tablecell(e.header[o]);
1118
+ o += this.tablerow({ text: s });
1119
+ let c = "";
1120
+ for (let o = 0; o < e.rows.length; o++) {
1121
+ let l = e.rows[o];
1122
+ s = "";
1123
+ for (let e = 0; e < l.length; e++) s += this.tablecell(l[e]);
1124
+ c += this.tablerow({ text: s });
1125
+ }
1126
+ return c &&= `<tbody>${c}</tbody>`, "<table>\n<thead>\n" + o + "</thead>\n" + c + "</table>\n";
1127
+ }
1128
+ tablerow({ text: e }) {
1129
+ return `<tr>
1130
+ ${e}</tr>
1131
+ `;
1132
+ }
1133
+ tablecell(e) {
1134
+ let o = this.parser.parseInline(e.tokens), s = e.header ? "th" : "td";
1135
+ return (e.align ? `<${s} align="${e.align}">` : `<${s}>`) + o + `</${s}>
1136
+ `;
1137
+ }
1138
+ strong({ tokens: e }) {
1139
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
1140
+ }
1141
+ em({ tokens: e }) {
1142
+ return `<em>${this.parser.parseInline(e)}</em>`;
1143
+ }
1144
+ codespan({ text: e }) {
1145
+ return `<code>${w(e, !0)}</code>`;
1146
+ }
1147
+ br(e) {
1148
+ return "<br>";
1149
+ }
1150
+ del({ tokens: e }) {
1151
+ return `<del>${this.parser.parseInline(e)}</del>`;
1152
+ }
1153
+ link({ href: e, title: o, tokens: s }) {
1154
+ let c = this.parser.parseInline(s), l = J(e);
1155
+ if (l === null) return c;
1156
+ e = l;
1157
+ let u = "<a href=\"" + e + "\"";
1158
+ return o && (u += " title=\"" + w(o) + "\""), u += ">" + c + "</a>", u;
1159
+ }
1160
+ image({ href: e, title: o, text: s, tokens: c }) {
1161
+ c && (s = this.parser.parseInline(c, this.parser.textRenderer));
1162
+ let l = J(e);
1163
+ if (l === null) return w(s);
1164
+ e = l;
1165
+ let u = `<img src="${e}" alt="${s}"`;
1166
+ return o && (u += ` title="${w(o)}"`), u += ">", u;
1167
+ }
1168
+ text(e) {
1169
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : w(e.text);
1170
+ }
1171
+ }, $ = class {
1172
+ strong({ text: e }) {
1173
+ return e;
1174
+ }
1175
+ em({ text: e }) {
1176
+ return e;
1177
+ }
1178
+ codespan({ text: e }) {
1179
+ return e;
1180
+ }
1181
+ del({ text: e }) {
1182
+ return e;
1183
+ }
1184
+ html({ text: e }) {
1185
+ return e;
1186
+ }
1187
+ text({ text: e }) {
1188
+ return e;
1189
+ }
1190
+ link({ text: e }) {
1191
+ return "" + e;
1192
+ }
1193
+ image({ text: e }) {
1194
+ return "" + e;
1195
+ }
1196
+ br() {
1197
+ return "";
1198
+ }
1199
+ }, b = class e {
1200
+ options;
1201
+ renderer;
1202
+ textRenderer;
1203
+ constructor(e) {
1204
+ this.options = e || T, this.options.renderer = this.options.renderer || new P(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new $();
1205
+ }
1206
+ static parse(o, s) {
1207
+ return new e(s).parse(o);
1208
+ }
1209
+ static parseInline(o, s) {
1210
+ return new e(s).parseInline(o);
1211
+ }
1212
+ parse(e, o = !0) {
1213
+ let s = "";
1214
+ for (let c = 0; c < e.length; c++) {
1215
+ let l = e[c];
1216
+ if (this.options.extensions?.renderers?.[l.type]) {
1217
+ let e = l, o = this.options.extensions.renderers[e.type].call({ parser: this }, e);
1218
+ if (o !== !1 || ![
1219
+ "space",
1220
+ "hr",
1221
+ "heading",
1222
+ "code",
1223
+ "table",
1224
+ "blockquote",
1225
+ "list",
1226
+ "html",
1227
+ "def",
1228
+ "paragraph",
1229
+ "text"
1230
+ ].includes(e.type)) {
1231
+ s += o || "";
1232
+ continue;
1233
+ }
1234
+ }
1235
+ let u = l;
1236
+ switch (u.type) {
1237
+ case "space":
1238
+ s += this.renderer.space(u);
1239
+ continue;
1240
+ case "hr":
1241
+ s += this.renderer.hr(u);
1242
+ continue;
1243
+ case "heading":
1244
+ s += this.renderer.heading(u);
1245
+ continue;
1246
+ case "code":
1247
+ s += this.renderer.code(u);
1248
+ continue;
1249
+ case "table":
1250
+ s += this.renderer.table(u);
1251
+ continue;
1252
+ case "blockquote":
1253
+ s += this.renderer.blockquote(u);
1254
+ continue;
1255
+ case "list":
1256
+ s += this.renderer.list(u);
1257
+ continue;
1258
+ case "html":
1259
+ s += this.renderer.html(u);
1260
+ continue;
1261
+ case "def":
1262
+ s += this.renderer.def(u);
1263
+ continue;
1264
+ case "paragraph":
1265
+ s += this.renderer.paragraph(u);
1266
+ continue;
1267
+ case "text": {
1268
+ let l = u, d = this.renderer.text(l);
1269
+ for (; c + 1 < e.length && e[c + 1].type === "text";) l = e[++c], d += "\n" + this.renderer.text(l);
1270
+ o ? s += this.renderer.paragraph({
1271
+ type: "paragraph",
1272
+ raw: d,
1273
+ text: d,
1274
+ tokens: [{
1275
+ type: "text",
1276
+ raw: d,
1277
+ text: d,
1278
+ escaped: !0
1279
+ }]
1280
+ }) : s += d;
1281
+ continue;
1282
+ }
1283
+ default: {
1284
+ let e = "Token with \"" + u.type + "\" type was not found.";
1285
+ if (this.options.silent) return console.error(e), "";
1286
+ throw Error(e);
1287
+ }
1288
+ }
1289
+ }
1290
+ return s;
1291
+ }
1292
+ parseInline(e, o = this.renderer) {
1293
+ let s = "";
1294
+ for (let c = 0; c < e.length; c++) {
1295
+ let l = e[c];
1296
+ if (this.options.extensions?.renderers?.[l.type]) {
1297
+ let e = this.options.extensions.renderers[l.type].call({ parser: this }, l);
1298
+ if (e !== !1 || ![
1299
+ "escape",
1300
+ "html",
1301
+ "link",
1302
+ "image",
1303
+ "strong",
1304
+ "em",
1305
+ "codespan",
1306
+ "br",
1307
+ "del",
1308
+ "text"
1309
+ ].includes(l.type)) {
1310
+ s += e || "";
1311
+ continue;
1312
+ }
1313
+ }
1314
+ let u = l;
1315
+ switch (u.type) {
1316
+ case "escape":
1317
+ s += o.text(u);
1318
+ break;
1319
+ case "html":
1320
+ s += o.html(u);
1321
+ break;
1322
+ case "link":
1323
+ s += o.link(u);
1324
+ break;
1325
+ case "image":
1326
+ s += o.image(u);
1327
+ break;
1328
+ case "strong":
1329
+ s += o.strong(u);
1330
+ break;
1331
+ case "em":
1332
+ s += o.em(u);
1333
+ break;
1334
+ case "codespan":
1335
+ s += o.codespan(u);
1336
+ break;
1337
+ case "br":
1338
+ s += o.br(u);
1339
+ break;
1340
+ case "del":
1341
+ s += o.del(u);
1342
+ break;
1343
+ case "text":
1344
+ s += o.text(u);
1345
+ break;
1346
+ default: {
1347
+ let e = "Token with \"" + u.type + "\" type was not found.";
1348
+ if (this.options.silent) return console.error(e), "";
1349
+ throw Error(e);
1350
+ }
1351
+ }
1352
+ }
1353
+ return s;
1354
+ }
1355
+ }, S = class {
1356
+ options;
1357
+ block;
1358
+ constructor(e) {
1359
+ this.options = e || T;
1360
+ }
1361
+ static passThroughHooks = new Set([
1362
+ "preprocess",
1363
+ "postprocess",
1364
+ "processAllTokens",
1365
+ "emStrongMask"
1366
+ ]);
1367
+ static passThroughHooksRespectAsync = new Set([
1368
+ "preprocess",
1369
+ "postprocess",
1370
+ "processAllTokens"
1371
+ ]);
1372
+ preprocess(e) {
1373
+ return e;
1374
+ }
1375
+ postprocess(e) {
1376
+ return e;
1377
+ }
1378
+ processAllTokens(e) {
1379
+ return e;
1380
+ }
1381
+ emStrongMask(e) {
1382
+ return e;
1383
+ }
1384
+ provideLexer() {
1385
+ return this.block ? x.lex : x.lexInline;
1386
+ }
1387
+ provideParser() {
1388
+ return this.block ? b.parse : b.parseInline;
1389
+ }
1390
+ }, _ = new class {
1391
+ defaults = L();
1392
+ options = this.setOptions;
1393
+ parse = this.parseMarkdown(!0);
1394
+ parseInline = this.parseMarkdown(!1);
1395
+ Parser = b;
1396
+ Renderer = P;
1397
+ TextRenderer = $;
1398
+ Lexer = x;
1399
+ Tokenizer = y;
1400
+ Hooks = S;
1401
+ constructor(...e) {
1402
+ this.use(...e);
1403
+ }
1404
+ walkTokens(e, o) {
1405
+ let s = [];
1406
+ for (let c of e) switch (s = s.concat(o.call(this, c)), c.type) {
1407
+ case "table": {
1408
+ let e = c;
1409
+ for (let c of e.header) s = s.concat(this.walkTokens(c.tokens, o));
1410
+ for (let c of e.rows) for (let e of c) s = s.concat(this.walkTokens(e.tokens, o));
1411
+ break;
1412
+ }
1413
+ case "list": {
1414
+ let e = c;
1415
+ s = s.concat(this.walkTokens(e.items, o));
1416
+ break;
1417
+ }
1418
+ default: {
1419
+ let e = c;
1420
+ this.defaults.extensions?.childTokens?.[e.type] ? this.defaults.extensions.childTokens[e.type].forEach((c) => {
1421
+ let l = e[c].flat(Infinity);
1422
+ s = s.concat(this.walkTokens(l, o));
1423
+ }) : e.tokens && (s = s.concat(this.walkTokens(e.tokens, o)));
1424
+ }
1425
+ }
1426
+ return s;
1427
+ }
1428
+ use(...e) {
1429
+ let o = this.defaults.extensions || {
1430
+ renderers: {},
1431
+ childTokens: {}
1432
+ };
1433
+ return e.forEach((e) => {
1434
+ let s = { ...e };
1435
+ if (s.async = this.defaults.async || s.async || !1, e.extensions && (e.extensions.forEach((e) => {
1436
+ if (!e.name) throw Error("extension name required");
1437
+ if ("renderer" in e) {
1438
+ let s = o.renderers[e.name];
1439
+ s ? o.renderers[e.name] = function(...o) {
1440
+ let c = e.renderer.apply(this, o);
1441
+ return c === !1 && (c = s.apply(this, o)), c;
1442
+ } : o.renderers[e.name] = e.renderer;
1443
+ }
1444
+ if ("tokenizer" in e) {
1445
+ if (!e.level || e.level !== "block" && e.level !== "inline") throw Error("extension level must be 'block' or 'inline'");
1446
+ let s = o[e.level];
1447
+ s ? s.unshift(e.tokenizer) : o[e.level] = [e.tokenizer], e.start && (e.level === "block" ? o.startBlock ? o.startBlock.push(e.start) : o.startBlock = [e.start] : e.level === "inline" && (o.startInline ? o.startInline.push(e.start) : o.startInline = [e.start]));
1448
+ }
1449
+ "childTokens" in e && e.childTokens && (o.childTokens[e.name] = e.childTokens);
1450
+ }), s.extensions = o), e.renderer) {
1451
+ let o = this.defaults.renderer || new P(this.defaults);
1452
+ for (let s in e.renderer) {
1453
+ if (!(s in o)) throw Error(`renderer '${s}' does not exist`);
1454
+ if (["options", "parser"].includes(s)) continue;
1455
+ let c = s, l = e.renderer[c], u = o[c];
1456
+ o[c] = (...e) => {
1457
+ let s = l.apply(o, e);
1458
+ return s === !1 && (s = u.apply(o, e)), s || "";
1459
+ };
1460
+ }
1461
+ s.renderer = o;
1462
+ }
1463
+ if (e.tokenizer) {
1464
+ let o = this.defaults.tokenizer || new y(this.defaults);
1465
+ for (let s in e.tokenizer) {
1466
+ if (!(s in o)) throw Error(`tokenizer '${s}' does not exist`);
1467
+ if ([
1468
+ "options",
1469
+ "rules",
1470
+ "lexer"
1471
+ ].includes(s)) continue;
1472
+ let c = s, l = e.tokenizer[c], u = o[c];
1473
+ o[c] = (...e) => {
1474
+ let s = l.apply(o, e);
1475
+ return s === !1 && (s = u.apply(o, e)), s;
1476
+ };
1477
+ }
1478
+ s.tokenizer = o;
1479
+ }
1480
+ if (e.hooks) {
1481
+ let o = this.defaults.hooks || new S();
1482
+ for (let s in e.hooks) {
1483
+ if (!(s in o)) throw Error(`hook '${s}' does not exist`);
1484
+ if (["options", "block"].includes(s)) continue;
1485
+ let c = s, l = e.hooks[c], u = o[c];
1486
+ S.passThroughHooks.has(s) ? o[c] = (e) => {
1487
+ if (this.defaults.async && S.passThroughHooksRespectAsync.has(s)) return (async () => {
1488
+ let s = await l.call(o, e);
1489
+ return u.call(o, s);
1490
+ })();
1491
+ let c = l.call(o, e);
1492
+ return u.call(o, c);
1493
+ } : o[c] = (...e) => {
1494
+ if (this.defaults.async) return (async () => {
1495
+ let s = await l.apply(o, e);
1496
+ return s === !1 && (s = await u.apply(o, e)), s;
1497
+ })();
1498
+ let s = l.apply(o, e);
1499
+ return s === !1 && (s = u.apply(o, e)), s;
1500
+ };
1501
+ }
1502
+ s.hooks = o;
1503
+ }
1504
+ if (e.walkTokens) {
1505
+ let o = this.defaults.walkTokens, c = e.walkTokens;
1506
+ s.walkTokens = function(e) {
1507
+ let s = [];
1508
+ return s.push(c.call(this, e)), o && (s = s.concat(o.call(this, e))), s;
1509
+ };
1510
+ }
1511
+ this.defaults = {
1512
+ ...this.defaults,
1513
+ ...s
1514
+ };
1515
+ }), this;
1516
+ }
1517
+ setOptions(e) {
1518
+ return this.defaults = {
1519
+ ...this.defaults,
1520
+ ...e
1521
+ }, this;
1522
+ }
1523
+ lexer(e, o) {
1524
+ return x.lex(e, o ?? this.defaults);
1525
+ }
1526
+ parser(e, o) {
1527
+ return b.parse(e, o ?? this.defaults);
1528
+ }
1529
+ parseMarkdown(e) {
1530
+ return (o, s) => {
1531
+ let c = { ...s }, l = {
1532
+ ...this.defaults,
1533
+ ...c
1534
+ }, u = this.onError(!!l.silent, !!l.async);
1535
+ if (this.defaults.async === !0 && c.async === !1) return u(/* @__PURE__ */ Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1536
+ if (typeof o > "u" || o === null) return u(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
1537
+ if (typeof o != "string") return u(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(o) + ", string expected"));
1538
+ if (l.hooks && (l.hooks.options = l, l.hooks.block = e), l.async) return (async () => {
1539
+ let s = l.hooks ? await l.hooks.preprocess(o) : o, c = await (l.hooks ? await l.hooks.provideLexer() : e ? x.lex : x.lexInline)(s, l), u = l.hooks ? await l.hooks.processAllTokens(c) : c;
1540
+ l.walkTokens && await Promise.all(this.walkTokens(u, l.walkTokens));
1541
+ let d = await (l.hooks ? await l.hooks.provideParser() : e ? b.parse : b.parseInline)(u, l);
1542
+ return l.hooks ? await l.hooks.postprocess(d) : d;
1543
+ })().catch(u);
1544
+ try {
1545
+ l.hooks && (o = l.hooks.preprocess(o));
1546
+ let s = (l.hooks ? l.hooks.provideLexer() : e ? x.lex : x.lexInline)(o, l);
1547
+ l.hooks && (s = l.hooks.processAllTokens(s)), l.walkTokens && this.walkTokens(s, l.walkTokens);
1548
+ let c = (l.hooks ? l.hooks.provideParser() : e ? b.parse : b.parseInline)(s, l);
1549
+ return l.hooks && (c = l.hooks.postprocess(c)), c;
1550
+ } catch (e) {
1551
+ return u(e);
1552
+ }
1553
+ };
1554
+ }
1555
+ onError(e, o) {
1556
+ return (s) => {
1557
+ if (s.message += "\nPlease report this to https://github.com/markedjs/marked.", e) {
1558
+ let e = "<p>An error occurred:</p><pre>" + w(s.message + "", !0) + "</pre>";
1559
+ return o ? Promise.resolve(e) : e;
1560
+ }
1561
+ if (o) return Promise.reject(s);
1562
+ throw s;
1563
+ };
1564
+ }
1565
+ }();
1566
+ function k(e, o) {
1567
+ return _.parse(e, o);
1568
+ }
1569
+ k.options = k.setOptions = function(e) {
1570
+ return _.setOptions(e), k.defaults = _.defaults, G(k.defaults), k;
1571
+ }, k.getDefaults = L, k.defaults = T, k.use = function(...e) {
1572
+ return _.use(...e), k.defaults = _.defaults, G(k.defaults), k;
1573
+ }, k.walkTokens = function(e, o) {
1574
+ return _.walkTokens(e, o);
1575
+ }, k.parseInline = _.parseInline, k.Parser = b, k.parser = b.parse, k.Renderer = P, k.TextRenderer = $, k.Lexer = x, k.lexer = x.lex, k.Tokenizer = y, k.Hooks = S, k.parse = k, k.options, k.setOptions, k.use, k.walkTokens, k.parseInline, b.parse, x.lex;
1576
+ function dedent(e) {
1577
+ var o = [...arguments].slice(1), s = Array.from(typeof e == "string" ? [e] : e);
1578
+ s[s.length - 1] = s[s.length - 1].replace(/\r?\n([\t ]*)$/, "");
1579
+ var c = s.reduce(function(e, o) {
1580
+ var s = o.match(/\n([\t ]+|(?!\s).)/g);
1581
+ return s ? e.concat(s.map(function(e) {
1582
+ return e.match(/[\t ]/g)?.length ?? 0;
1583
+ })) : e;
1584
+ }, []);
1585
+ if (c.length) {
1586
+ var l = RegExp("\n[ ]{" + Math.min.apply(Math, c) + "}", "g");
1587
+ s = s.map(function(e) {
1588
+ return e.replace(l, "\n");
1589
+ });
1590
+ }
1591
+ s[0] = s[0].replace(/^\r?\n/, "");
1592
+ var u = s[0];
1593
+ return o.forEach(function(e, o) {
1594
+ var c = u.match(/(?:^|\n)( *)$/), l = c ? c[1] : "", d = e;
1595
+ typeof e == "string" && e.includes("\n") && (d = String(e).split("\n").map(function(e, o) {
1596
+ return o === 0 ? e : "" + l + e;
1597
+ }).join("\n")), u += d + s[o + 1];
1598
+ }), u;
1599
+ }
1600
+ var unknownIcon = {
1601
+ body: "<g><rect width=\"80\" height=\"80\" style=\"fill: #087ebf; stroke-width: 0px;\"/><text transform=\"translate(21.16 64.67)\" style=\"fill: #fff; font-family: ArialMT, Arial; font-size: 67.75px;\"><tspan x=\"0\" y=\"0\">?</tspan></text></g>",
1602
+ height: 80,
1603
+ width: 80
1604
+ }, iconsStore = /* @__PURE__ */ new Map(), loaderStore = /* @__PURE__ */ new Map(), registerIconPacks = /* @__PURE__ */ __name((e) => {
1605
+ for (let s of e) {
1606
+ if (!s.name) throw Error("Invalid icon loader. Must have a \"name\" property with non-empty string value.");
1607
+ if (log.debug("Registering icon pack:", s.name), "loader" in s) loaderStore.set(s.name, s.loader);
1608
+ else if ("icons" in s) iconsStore.set(s.name, s.icons);
1609
+ else throw log.error("Invalid icon loader:", s), Error("Invalid icon loader. Must have either \"icons\" or \"loader\" property.");
1610
+ }
1611
+ }, "registerIconPacks"), getRegisteredIconData = /* @__PURE__ */ __name(async (e, s) => {
1612
+ let c = stringToIcon(e, !0, s !== void 0);
1613
+ if (!c) throw Error(`Invalid icon name: ${e}`);
1614
+ let l = c.prefix || s;
1615
+ if (!l) throw Error(`Icon name must contain a prefix: ${e}`);
1616
+ let u = iconsStore.get(l);
1617
+ if (!u) {
1618
+ let e = loaderStore.get(l);
1619
+ if (!e) throw Error(`Icon set not found: ${c.prefix}`);
1620
+ try {
1621
+ u = {
1622
+ ...await e(),
1623
+ prefix: l
1624
+ }, iconsStore.set(l, u);
1625
+ } catch (e) {
1626
+ throw log.error(e), Error(`Failed to load icon set: ${c.prefix}`);
1627
+ }
1628
+ }
1629
+ let d = getIconData(u, c.name);
1630
+ if (!d) throw Error(`Icon not found: ${e}`);
1631
+ return d;
1632
+ }, "getRegisteredIconData"), isIconAvailable = /* @__PURE__ */ __name(async (e) => {
1633
+ try {
1634
+ return await getRegisteredIconData(e), !0;
1635
+ } catch {
1636
+ return !1;
1637
+ }
1638
+ }, "isIconAvailable"), getIconSVG = /* @__PURE__ */ __name(async (e, s, c) => {
1639
+ let u;
1640
+ try {
1641
+ u = await getRegisteredIconData(e, s?.fallbackPrefix);
1642
+ } catch (e) {
1643
+ log.error(e), u = unknownIcon;
1644
+ }
1645
+ let d = iconToSVG(u, s);
1646
+ return sanitizeText(iconToHTML(replaceIDs(d.body), {
1647
+ ...d.attributes,
1648
+ ...c
1649
+ }), getConfig());
1650
+ }, "getIconSVG");
1651
+ function preprocessMarkdown(e, { markdownAutoWrap: o }) {
1652
+ let s = dedent(e.replace(/<br\/>/g, "\n").replace(/\n{2,}/g, "\n"));
1653
+ return o === !1 ? s.replace(/ /g, "&nbsp;") : s;
1654
+ }
1655
+ __name(preprocessMarkdown, "preprocessMarkdown");
1656
+ function markdownToLines(e, o = {}) {
1657
+ let c = preprocessMarkdown(e, o), l = k.lexer(c), u = [[]], d = 0;
1658
+ function f(e, o = "normal") {
1659
+ e.type === "text" ? e.text.split("\n").forEach((e, s) => {
1660
+ s !== 0 && (d++, u.push([])), e.split(" ").forEach((e) => {
1661
+ e = e.replace(/&#39;/g, "'"), e && u[d].push({
1662
+ content: e,
1663
+ type: o
1664
+ });
1665
+ });
1666
+ }) : e.type === "strong" || e.type === "em" ? e.tokens.forEach((o) => {
1667
+ f(o, e.type);
1668
+ }) : e.type === "html" && u[d].push({
1669
+ content: e.text,
1670
+ type: "normal"
1671
+ });
1672
+ }
1673
+ return __name(f, "processNode"), l.forEach((e) => {
1674
+ e.type === "paragraph" ? e.tokens?.forEach((e) => {
1675
+ f(e);
1676
+ }) : e.type === "html" ? u[d].push({
1677
+ content: e.text,
1678
+ type: "normal"
1679
+ }) : u[d].push({
1680
+ content: e.raw,
1681
+ type: "normal"
1682
+ });
1683
+ }), u;
1684
+ }
1685
+ __name(markdownToLines, "markdownToLines");
1686
+ function markdownToHTML(e, { markdownAutoWrap: c } = {}) {
1687
+ let l = k.lexer(e);
1688
+ function u(e) {
1689
+ return e.type === "text" ? c === !1 ? e.text.replace(/\n */g, "<br/>").replace(/ /g, "&nbsp;") : e.text.replace(/\n */g, "<br/>") : e.type === "strong" ? `<strong>${e.tokens?.map(u).join("")}</strong>` : e.type === "em" ? `<em>${e.tokens?.map(u).join("")}</em>` : e.type === "paragraph" ? `<p>${e.tokens?.map(u).join("")}</p>` : e.type === "space" ? "" : e.type === "html" ? `${e.text}` : e.type === "escape" ? e.text : (log.warn(`Unsupported markdown: ${e.type}`), e.raw);
1690
+ }
1691
+ return __name(u, "output"), l.map(u).join("");
1692
+ }
1693
+ __name(markdownToHTML, "markdownToHTML");
1694
+ function splitTextToChars(e) {
1695
+ return Intl.Segmenter ? [...new Intl.Segmenter().segment(e)].map((e) => e.segment) : [...e];
1696
+ }
1697
+ __name(splitTextToChars, "splitTextToChars");
1698
+ function splitWordToFitWidth(e, o) {
1699
+ return splitWordToFitWidthRecursion(e, [], splitTextToChars(o.content), o.type);
1700
+ }
1701
+ __name(splitWordToFitWidth, "splitWordToFitWidth");
1702
+ function splitWordToFitWidthRecursion(e, o, s, c) {
1703
+ if (s.length === 0) return [{
1704
+ content: o.join(""),
1705
+ type: c
1706
+ }, {
1707
+ content: "",
1708
+ type: c
1709
+ }];
1710
+ let [l, ...u] = s, d = [...o, l];
1711
+ return e([{
1712
+ content: d.join(""),
1713
+ type: c
1714
+ }]) ? splitWordToFitWidthRecursion(e, d, u, c) : (o.length === 0 && l && (o.push(l), s.shift()), [{
1715
+ content: o.join(""),
1716
+ type: c
1717
+ }, {
1718
+ content: s.join(""),
1719
+ type: c
1720
+ }]);
1721
+ }
1722
+ __name(splitWordToFitWidthRecursion, "splitWordToFitWidthRecursion");
1723
+ function splitLineToFitWidth(e, o) {
1724
+ if (e.some(({ content: e }) => e.includes("\n"))) throw Error("splitLineToFitWidth does not support newlines in the line");
1725
+ return splitLineToFitWidthRecursion(e, o);
1726
+ }
1727
+ __name(splitLineToFitWidth, "splitLineToFitWidth");
1728
+ function splitLineToFitWidthRecursion(e, o, s = [], c = []) {
1729
+ if (e.length === 0) return c.length > 0 && s.push(c), s.length > 0 ? s : [];
1730
+ let l = "";
1731
+ e[0].content === " " && (l = " ", e.shift());
1732
+ let u = e.shift() ?? {
1733
+ content: " ",
1734
+ type: "normal"
1735
+ }, d = [...c];
1736
+ if (l !== "" && d.push({
1737
+ content: l,
1738
+ type: "normal"
1739
+ }), d.push(u), o(d)) return splitLineToFitWidthRecursion(e, o, s, d);
1740
+ if (c.length > 0) s.push(c), e.unshift(u);
1741
+ else if (u.content) {
1742
+ let [c, l] = splitWordToFitWidth(o, u);
1743
+ s.push([c]), l.content && e.unshift(l);
1744
+ }
1745
+ return splitLineToFitWidthRecursion(e, o, s);
1746
+ }
1747
+ __name(splitLineToFitWidthRecursion, "splitLineToFitWidthRecursion");
1748
+ function applyStyle(e, o) {
1749
+ o && e.attr("style", o);
1750
+ }
1751
+ __name(applyStyle, "applyStyle");
1752
+ async function addHtmlSpan(e, o, s, c, g = !1, O = getConfig()) {
1753
+ let A = e.append("foreignObject");
1754
+ A.attr("width", `${10 * s}px`), A.attr("height", `${10 * s}px`);
1755
+ let R = A.append("xhtml:div"), B = hasKatex(o.label) ? await renderKatexSanitized(o.label.replace(common_default.lineBreakRegex, "\n"), O) : sanitizeText(o.label, O), H = o.isNode ? "nodeLabel" : "edgeLabel", Y = R.append("span");
1756
+ Y.html(B), applyStyle(Y, o.labelStyle), Y.attr("class", `${H} ${c}`), applyStyle(R, o.labelStyle), R.style("display", "table-cell"), R.style("white-space", "nowrap"), R.style("line-height", "1.5"), R.style("max-width", s + "px"), R.style("text-align", "center"), R.attr("xmlns", "http://www.w3.org/1999/xhtml"), g && R.attr("class", "labelBkg");
1757
+ let Z = R.node().getBoundingClientRect();
1758
+ return Z.width === s && (R.style("display", "table"), R.style("white-space", "break-spaces"), R.style("width", s + "px"), Z = R.node().getBoundingClientRect()), A.node();
1759
+ }
1760
+ __name(addHtmlSpan, "addHtmlSpan");
1761
+ function createTspan(e, o, s) {
1762
+ return e.append("tspan").attr("class", "text-outer-tspan").attr("x", 0).attr("y", o * s - .1 + "em").attr("dy", s + "em");
1763
+ }
1764
+ __name(createTspan, "createTspan");
1765
+ function computeWidthOfText(e, o, s) {
1766
+ let c = e.append("text"), l = createTspan(c, 1, o);
1767
+ updateTextContentAndStyles(l, s);
1768
+ let u = l.node().getComputedTextLength();
1769
+ return c.remove(), u;
1770
+ }
1771
+ __name(computeWidthOfText, "computeWidthOfText");
1772
+ function computeDimensionOfText(e, o, s) {
1773
+ let c = e.append("text"), l = createTspan(c, 1, o);
1774
+ updateTextContentAndStyles(l, [{
1775
+ content: s,
1776
+ type: "normal"
1777
+ }]);
1778
+ let u = l.node()?.getBoundingClientRect();
1779
+ return u && c.remove(), u;
1780
+ }
1781
+ __name(computeDimensionOfText, "computeDimensionOfText");
1782
+ function createFormattedText(e, o, c, l = !1) {
1783
+ let u = 1.1, d = o.append("g"), f = d.insert("rect").attr("class", "background").attr("style", "stroke: none"), p = d.append("text").attr("y", "-10.1"), g = 0;
1784
+ for (let o of c) {
1785
+ let c = /* @__PURE__ */ __name((o) => computeWidthOfText(d, u, o) <= e, "checkWidth"), l = c(o) ? [o] : splitLineToFitWidth(o, c);
1786
+ for (let e of l) updateTextContentAndStyles(createTspan(p, g, u), e), g++;
1787
+ }
1788
+ if (l) {
1789
+ let e = p.node().getBBox();
1790
+ return f.attr("x", e.x - 2).attr("y", e.y - 2).attr("width", e.width + 4).attr("height", e.height + 4), d.node();
1791
+ } else return p.node();
1792
+ }
1793
+ __name(createFormattedText, "createFormattedText");
1794
+ function updateTextContentAndStyles(e, o) {
1795
+ e.text(""), o.forEach((o, s) => {
1796
+ let c = e.append("tspan").attr("font-style", o.type === "em" ? "italic" : "normal").attr("class", "text-inner-tspan").attr("font-weight", o.type === "strong" ? "bold" : "normal");
1797
+ s === 0 ? c.text(o.content) : c.text(" " + o.content);
1798
+ });
1799
+ }
1800
+ __name(updateTextContentAndStyles, "updateTextContentAndStyles");
1801
+ async function replaceIconSubstring(e, o = {}) {
1802
+ let s = [];
1803
+ e.replace(/(fa[bklrs]?):fa-([\w-]+)/g, (e, c, u) => (s.push((async () => {
1804
+ let s = `${c}:${u}`;
1805
+ return await isIconAvailable(s) ? await getIconSVG(s, void 0, { class: "label-icon" }) : `<i class='${sanitizeText(e, o).replace(":", " ")}'></i>`;
1806
+ })()), e));
1807
+ let c = await Promise.all(s);
1808
+ return e.replace(/(fa[bklrs]?):fa-([\w-]+)/g, () => c.shift() ?? "");
1809
+ }
1810
+ __name(replaceIconSubstring, "replaceIconSubstring");
1811
+ var createText = /* @__PURE__ */ __name(async (s, l = "", { style: u = "", isTitle: f = !1, classes: p = "", useHtmlLabels: g = !0, isNode: O = !0, width: A = 200, addSvgBackground: R = !1 } = {}, B) => {
1812
+ if (log.debug("XYZ createText", l, u, f, p, g, O, "addSvgBackground: ", R), g) {
1813
+ let o = await replaceIconSubstring(decodeEntities(markdownToHTML(l, B)), B), c = l.replace(/\\\\/g, "\\");
1814
+ return await addHtmlSpan(s, {
1815
+ isNode: O,
1816
+ label: hasKatex(l) ? c : o,
1817
+ labelStyle: u.replace("fill:", "color:")
1818
+ }, A, p, R, B);
1819
+ } else {
1820
+ let e = createFormattedText(A, s, markdownToLines(l.replace(/<br\s*\/?>/g, "<br/>").replace("<br>", "<br/>"), B), l ? R : !1);
1821
+ if (O) {
1822
+ /stroke:/.exec(u) && (u = u.replace("stroke:", "lineColor:"));
1823
+ let o = u.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
1824
+ select_default(e).attr("style", o);
1825
+ } else {
1826
+ let o = u.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/background:/g, "fill:");
1827
+ select_default(e).select("rect").attr("style", o.replace(/background:/g, "fill:"));
1828
+ let s = u.replace(/stroke:[^;]+;?/g, "").replace(/stroke-width:[^;]+;?/g, "").replace(/fill:[^;]+;?/g, "").replace(/color:/g, "fill:");
1829
+ select_default(e).select("text").attr("style", s);
1830
+ }
1831
+ return e;
1832
+ }
1833
+ }, "createText");
1834
+ export { replaceIconSubstring as a, registerIconPacks as i, createText as n, unknownIcon as o, getIconSVG as r, dedent as s, computeDimensionOfText as t };