@kg-ui/kg-ui-plus 0.0.1 → 0.0.2

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 (155) hide show
  1. package/dist/es/KgCopilot/CopiContent/AnswerHead.vue.mjs +16 -0
  2. package/dist/es/KgCopilot/CopiContent/AnswerHead.vue2.mjs +4 -0
  3. package/dist/es/KgCopilot/CopiContent/UserHead.vue.mjs +26 -0
  4. package/dist/es/KgCopilot/CopiContent/UserHead.vue2.mjs +4 -0
  5. package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue.mjs +7 -0
  6. package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue2.mjs +49 -0
  7. package/dist/es/KgCopilot/CopiFooter/components/NewTheme.vue3.mjs +4 -0
  8. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue.mjs +7 -0
  9. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue2.mjs +94 -0
  10. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SelectPlugin.vue3.mjs +4 -0
  11. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue.mjs +7 -0
  12. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue2.mjs +33 -0
  13. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/SpeechControl.vue3.mjs +4 -0
  14. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue.mjs +7 -0
  15. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue2.mjs +140 -0
  16. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/Upload.vue3.mjs +4 -0
  17. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue.mjs +7 -0
  18. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue2.mjs +131 -0
  19. package/dist/es/KgCopilot/CopiFooter/components/SearchInput/index.vue3.mjs +4 -0
  20. package/dist/es/KgCopilot/CopiFooter/index.vue.mjs +7 -0
  21. package/dist/es/KgCopilot/CopiFooter/index.vue2.mjs +21 -0
  22. package/dist/es/KgCopilot/CopiFooter/index.vue3.mjs +4 -0
  23. package/dist/es/KgCopilot/dialogue.vue.mjs +7 -0
  24. package/dist/es/KgCopilot/dialogue.vue2.mjs +131 -0
  25. package/dist/es/KgCopilot/dialogue.vue3.mjs +4 -0
  26. package/dist/es/KgCopilot/index.vue.mjs +7 -0
  27. package/dist/es/KgCopilot/index.vue2.mjs +49 -0
  28. package/dist/es/KgCopilot/index.vue3.mjs +4 -0
  29. package/dist/es/KgCopilot/mdInCode.mjs +56 -0
  30. package/dist/es/KgCopilot/readMd.vue.mjs +7 -0
  31. package/dist/es/KgCopilot/readMd.vue2.mjs +87 -0
  32. package/dist/es/KgCopilot/readMd.vue3.mjs +4 -0
  33. package/dist/es/ReIcon/index.mjs +11 -0
  34. package/dist/es/ReIcon/src/iconfont.mjs +46 -0
  35. package/dist/es/ReIcon/src/iconifyIconOffline.mjs +30 -0
  36. package/dist/es/ReIcon/src/iconifyIconOnline.mjs +29 -0
  37. package/dist/es/_virtual/___vite-browser-external.mjs +6 -0
  38. package/dist/es/_virtual/__vite-browser-external.mjs +4 -0
  39. package/dist/es/_virtual/_commonjsHelpers.mjs +34 -0
  40. package/dist/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
  41. package/dist/es/_virtual/index.mjs +13 -0
  42. package/dist/es/api/project.mjs +51 -0
  43. package/dist/es/directives/heighlight/index.mjs +69 -0
  44. package/dist/es/directives/index.mjs +4 -0
  45. package/dist/es/home/LFilter/FilterArea.vue.mjs +7 -0
  46. package/dist/es/home/LFilter/FilterArea.vue2.mjs +507 -0
  47. package/dist/es/home/LFilter/FilterArea.vue3.mjs +4 -0
  48. package/dist/es/home/LFilter/FilterHead.vue.mjs +129 -0
  49. package/dist/es/home/LFilter/FilterHead.vue2.mjs +4 -0
  50. package/dist/es/home/LFilter/FilterItem.vue.mjs +7 -0
  51. package/dist/es/home/LFilter/FilterItem.vue2.mjs +114 -0
  52. package/dist/es/home/LFilter/FilterItem.vue3.mjs +4 -0
  53. package/dist/es/home/LFilter/FilterItemIcon.vue.mjs +7 -0
  54. package/dist/es/home/LFilter/FilterItemIcon.vue2.mjs +171 -0
  55. package/dist/es/home/LFilter/FilterItemIcon.vue3.mjs +4 -0
  56. package/dist/es/home/LFilter/index.vue.mjs +17 -0
  57. package/dist/es/home/LFilter/index.vue2.mjs +4 -0
  58. package/dist/es/home/LProject/index.vue.mjs +7 -0
  59. package/dist/es/home/LProject/index.vue2.mjs +70 -0
  60. package/dist/es/home/LProject/index.vue3.mjs +4 -0
  61. package/dist/es/home/index.vue.mjs +7 -0
  62. package/dist/es/home/index.vue2.mjs +80 -0
  63. package/dist/es/home/index.vue3.mjs +4 -0
  64. package/dist/es/index.mjs +36 -0
  65. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/check.mjs +8 -0
  66. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/circle-plus.mjs +8 -0
  67. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/close.mjs +8 -0
  68. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/microphone.mjs +8 -0
  69. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/paperclip.mjs +8 -0
  70. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/promotion.mjs +8 -0
  71. package/dist/es/node_modules/.pnpm/@iconify-icons_ep@1.2.7/node_modules/@iconify-icons/ep/upload.mjs +8 -0
  72. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/copy-simple.mjs +8 -0
  73. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/speaker-high-light.mjs +8 -0
  74. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-down-thin.mjs +8 -0
  75. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/thumbs-up-thin.mjs +8 -0
  76. package/dist/es/node_modules/.pnpm/@iconify-icons_ph@1.2.5/node_modules/@iconify-icons/ph/warning-bold.mjs +8 -0
  77. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/add-line.mjs +8 -0
  78. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-down-s-line.mjs +8 -0
  79. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/arrow-up-s-line.mjs +8 -0
  80. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/check-fill.mjs +8 -0
  81. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/download-line.mjs +8 -0
  82. package/dist/es/node_modules/.pnpm/@iconify-icons_ri@1.2.3/node_modules/@iconify-icons/ri/more-2-fill.mjs +8 -0
  83. package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/iconify.mjs +1702 -0
  84. package/dist/es/node_modules/.pnpm/@iconify_vue@4.0.0_vue@3.2.45/node_modules/@iconify/vue/dist/offline.mjs +436 -0
  85. package/dist/es/node_modules/.pnpm/@pureadmin_utils@1.8.5_vue@3.2.45/node_modules/@pureadmin/utils/dist/index.mjs +70 -0
  86. package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/callBound.mjs +16 -0
  87. package/dist/es/node_modules/.pnpm/call-bind@1.0.7/node_modules/call-bind/index.mjs +36 -0
  88. package/dist/es/node_modules/.pnpm/define-data-property@1.1.4/node_modules/define-data-property/index.mjs +48 -0
  89. package/dist/es/node_modules/.pnpm/dompurify@3.0.10/node_modules/dompurify/dist/purify.es.mjs +949 -0
  90. package/dist/es/node_modules/.pnpm/es-define-property@1.0.0/node_modules/es-define-property/index.mjs +22 -0
  91. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.mjs +4 -0
  92. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.mjs +4 -0
  93. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.mjs +4 -0
  94. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.mjs +4 -0
  95. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.mjs +4 -0
  96. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.mjs +4 -0
  97. package/dist/es/node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.mjs +4 -0
  98. package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.mjs +72 -0
  99. package/dist/es/node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.mjs +6 -0
  100. package/dist/es/node_modules/.pnpm/get-intrinsic@1.2.4/node_modules/get-intrinsic/index.mjs +320 -0
  101. package/dist/es/node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.mjs +14 -0
  102. package/dist/es/node_modules/.pnpm/has-property-descriptors@1.0.2/node_modules/has-property-descriptors/index.mjs +19 -0
  103. package/dist/es/node_modules/.pnpm/has-proto@1.0.3/node_modules/has-proto/index.mjs +11 -0
  104. package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/index.mjs +21 -0
  105. package/dist/es/node_modules/.pnpm/has-symbols@1.0.3/node_modules/has-symbols/shams.mjs +48 -0
  106. package/dist/es/node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.mjs +8 -0
  107. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/core.mjs +5 -0
  108. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/apache.mjs +91 -0
  109. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/bash.mjs +377 -0
  110. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/basic.mjs +221 -0
  111. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/c.mjs +280 -0
  112. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/css.mjs +732 -0
  113. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dart.mjs +247 -0
  114. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/django.mjs +47 -0
  115. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dns.mjs +71 -0
  116. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dos.mjs +160 -0
  117. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/dust.mjs +38 -0
  118. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/erlang.mjs +176 -0
  119. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/go.mjs +135 -0
  120. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/http.mjs +89 -0
  121. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/java.mjs +254 -0
  122. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/javascript.mjs +698 -0
  123. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/json.mjs +40 -0
  124. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/markdown.mjs +227 -0
  125. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/nginx.mjs +144 -0
  126. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/php.mjs +589 -0
  127. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/python.mjs +414 -0
  128. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/ruby.mjs +414 -0
  129. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/stylus.mjs +766 -0
  130. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/swift.mjs +832 -0
  131. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/typescript.mjs +788 -0
  132. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/es/languages/xml.mjs +227 -0
  133. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/lib/core.mjs +1580 -0
  134. package/dist/es/node_modules/.pnpm/highlight.js@11.9.0/node_modules/highlight.js/styles/paraiso-light.css.mjs +4 -0
  135. package/dist/es/node_modules/.pnpm/marked@12.0.1/node_modules/marked/lib/marked.esm.mjs +2045 -0
  136. package/dist/es/node_modules/.pnpm/object-inspect@1.13.1/node_modules/object-inspect/index.mjs +514 -0
  137. package/dist/es/node_modules/.pnpm/pinyin-match@1.2.4/node_modules/pinyin-match/es/main.mjs +124 -0
  138. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/formats.mjs +22 -0
  139. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/index.mjs +14 -0
  140. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/parse.mjs +199 -0
  141. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/stringify.mjs +262 -0
  142. package/dist/es/node_modules/.pnpm/qs@6.11.0/node_modules/qs/lib/utils.mjs +196 -0
  143. package/dist/es/node_modules/.pnpm/set-function-length@1.2.2/node_modules/set-function-length/index.mjs +54 -0
  144. package/dist/es/node_modules/.pnpm/side-channel@1.0.6/node_modules/side-channel/index.mjs +115 -0
  145. package/dist/es/store/index.mjs +8 -0
  146. package/dist/es/store/modules/copilot.mjs +108 -0
  147. package/dist/es/store/modules/filters.mjs +346 -0
  148. package/dist/es/store/modules/types.mjs +19 -0
  149. package/dist/es/style/index.scss.mjs +4 -0
  150. package/dist/es/style/tailwind.css.mjs +4 -0
  151. package/dist/es/style.css +1 -0
  152. package/dist/es/utils/home.mjs +129 -0
  153. package/dist/es/utils/http/index.mjs +90 -0
  154. package/dist/es/utils/message.mjs +42 -0
  155. package/package.json +1 -1
@@ -0,0 +1,2045 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => {
4
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ return value;
6
+ };
7
+ var __accessCheck = (obj, member, msg) => {
8
+ if (!member.has(obj))
9
+ throw TypeError("Cannot " + msg);
10
+ };
11
+ var __privateAdd = (obj, member, value) => {
12
+ if (member.has(obj))
13
+ throw TypeError("Cannot add the same private member more than once");
14
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
15
+ };
16
+ var __privateMethod = (obj, member, method) => {
17
+ __accessCheck(obj, member, "access private method");
18
+ return method;
19
+ };
20
+ var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
21
+ function _getDefaults() {
22
+ return {
23
+ async: false,
24
+ breaks: false,
25
+ extensions: null,
26
+ gfm: true,
27
+ hooks: null,
28
+ pedantic: false,
29
+ renderer: null,
30
+ silent: false,
31
+ tokenizer: null,
32
+ walkTokens: null
33
+ };
34
+ }
35
+ let _defaults = _getDefaults();
36
+ function changeDefaults(newDefaults) {
37
+ _defaults = newDefaults;
38
+ }
39
+ const escapeTest = /[&<>"']/;
40
+ const escapeReplace = new RegExp(escapeTest.source, "g");
41
+ const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
42
+ const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
43
+ const escapeReplacements = {
44
+ "&": "&amp;",
45
+ "<": "&lt;",
46
+ ">": "&gt;",
47
+ '"': "&quot;",
48
+ "'": "&#39;"
49
+ };
50
+ const getEscapeReplacement = (ch) => escapeReplacements[ch];
51
+ function escape$1(html2, encode) {
52
+ if (encode) {
53
+ if (escapeTest.test(html2)) {
54
+ return html2.replace(escapeReplace, getEscapeReplacement);
55
+ }
56
+ } else {
57
+ if (escapeTestNoEncode.test(html2)) {
58
+ return html2.replace(escapeReplaceNoEncode, getEscapeReplacement);
59
+ }
60
+ }
61
+ return html2;
62
+ }
63
+ const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
64
+ function unescape(html2) {
65
+ return html2.replace(unescapeTest, (_, n) => {
66
+ n = n.toLowerCase();
67
+ if (n === "colon")
68
+ return ":";
69
+ if (n.charAt(0) === "#") {
70
+ return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
71
+ }
72
+ return "";
73
+ });
74
+ }
75
+ const caret = /(^|[^\[])\^/g;
76
+ function edit(regex, opt) {
77
+ let source = typeof regex === "string" ? regex : regex.source;
78
+ opt = opt || "";
79
+ const obj = {
80
+ replace: (name, val) => {
81
+ let valSource = typeof val === "string" ? val : val.source;
82
+ valSource = valSource.replace(caret, "$1");
83
+ source = source.replace(name, valSource);
84
+ return obj;
85
+ },
86
+ getRegex: () => {
87
+ return new RegExp(source, opt);
88
+ }
89
+ };
90
+ return obj;
91
+ }
92
+ function cleanUrl(href) {
93
+ try {
94
+ href = encodeURI(href).replace(/%25/g, "%");
95
+ } catch (e) {
96
+ return null;
97
+ }
98
+ return href;
99
+ }
100
+ const noopTest = { exec: () => null };
101
+ function splitCells(tableRow, count) {
102
+ const row = tableRow.replace(/\|/g, (match, offset, str) => {
103
+ let escaped = false;
104
+ let curr = offset;
105
+ while (--curr >= 0 && str[curr] === "\\")
106
+ escaped = !escaped;
107
+ if (escaped) {
108
+ return "|";
109
+ } else {
110
+ return " |";
111
+ }
112
+ }), cells = row.split(/ \|/);
113
+ let i = 0;
114
+ if (!cells[0].trim()) {
115
+ cells.shift();
116
+ }
117
+ if (cells.length > 0 && !cells[cells.length - 1].trim()) {
118
+ cells.pop();
119
+ }
120
+ if (count) {
121
+ if (cells.length > count) {
122
+ cells.splice(count);
123
+ } else {
124
+ while (cells.length < count)
125
+ cells.push("");
126
+ }
127
+ }
128
+ for (; i < cells.length; i++) {
129
+ cells[i] = cells[i].trim().replace(/\\\|/g, "|");
130
+ }
131
+ return cells;
132
+ }
133
+ function rtrim(str, c, invert) {
134
+ const l = str.length;
135
+ if (l === 0) {
136
+ return "";
137
+ }
138
+ let suffLen = 0;
139
+ while (suffLen < l) {
140
+ const currChar = str.charAt(l - suffLen - 1);
141
+ if (currChar === c && !invert) {
142
+ suffLen++;
143
+ } else if (currChar !== c && invert) {
144
+ suffLen++;
145
+ } else {
146
+ break;
147
+ }
148
+ }
149
+ return str.slice(0, l - suffLen);
150
+ }
151
+ function findClosingBracket(str, b) {
152
+ if (str.indexOf(b[1]) === -1) {
153
+ return -1;
154
+ }
155
+ let level = 0;
156
+ for (let i = 0; i < str.length; i++) {
157
+ if (str[i] === "\\") {
158
+ i++;
159
+ } else if (str[i] === b[0]) {
160
+ level++;
161
+ } else if (str[i] === b[1]) {
162
+ level--;
163
+ if (level < 0) {
164
+ return i;
165
+ }
166
+ }
167
+ }
168
+ return -1;
169
+ }
170
+ function outputLink(cap, link2, raw, lexer) {
171
+ const href = link2.href;
172
+ const title = link2.title ? escape$1(link2.title) : null;
173
+ const text = cap[1].replace(/\\([\[\]])/g, "$1");
174
+ if (cap[0].charAt(0) !== "!") {
175
+ lexer.state.inLink = true;
176
+ const token = {
177
+ type: "link",
178
+ raw,
179
+ href,
180
+ title,
181
+ text,
182
+ tokens: lexer.inlineTokens(text)
183
+ };
184
+ lexer.state.inLink = false;
185
+ return token;
186
+ }
187
+ return {
188
+ type: "image",
189
+ raw,
190
+ href,
191
+ title,
192
+ text: escape$1(text)
193
+ };
194
+ }
195
+ function indentCodeCompensation(raw, text) {
196
+ const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
197
+ if (matchIndentToCode === null) {
198
+ return text;
199
+ }
200
+ const indentToCode = matchIndentToCode[1];
201
+ return text.split("\n").map((node) => {
202
+ const matchIndentInNode = node.match(/^\s+/);
203
+ if (matchIndentInNode === null) {
204
+ return node;
205
+ }
206
+ const [indentInNode] = matchIndentInNode;
207
+ if (indentInNode.length >= indentToCode.length) {
208
+ return node.slice(indentToCode.length);
209
+ }
210
+ return node;
211
+ }).join("\n");
212
+ }
213
+ class _Tokenizer {
214
+ // set by the lexer
215
+ constructor(options) {
216
+ __publicField(this, "options");
217
+ __publicField(this, "rules");
218
+ // set by the lexer
219
+ __publicField(this, "lexer");
220
+ this.options = options || _defaults;
221
+ }
222
+ space(src) {
223
+ const cap = this.rules.block.newline.exec(src);
224
+ if (cap && cap[0].length > 0) {
225
+ return {
226
+ type: "space",
227
+ raw: cap[0]
228
+ };
229
+ }
230
+ }
231
+ code(src) {
232
+ const cap = this.rules.block.code.exec(src);
233
+ if (cap) {
234
+ const text = cap[0].replace(/^ {1,4}/gm, "");
235
+ return {
236
+ type: "code",
237
+ raw: cap[0],
238
+ codeBlockStyle: "indented",
239
+ text: !this.options.pedantic ? rtrim(text, "\n") : text
240
+ };
241
+ }
242
+ }
243
+ fences(src) {
244
+ const cap = this.rules.block.fences.exec(src);
245
+ if (cap) {
246
+ const raw = cap[0];
247
+ const text = indentCodeCompensation(raw, cap[3] || "");
248
+ return {
249
+ type: "code",
250
+ raw,
251
+ lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
252
+ text
253
+ };
254
+ }
255
+ }
256
+ heading(src) {
257
+ const cap = this.rules.block.heading.exec(src);
258
+ if (cap) {
259
+ let text = cap[2].trim();
260
+ if (/#$/.test(text)) {
261
+ const trimmed = rtrim(text, "#");
262
+ if (this.options.pedantic) {
263
+ text = trimmed.trim();
264
+ } else if (!trimmed || / $/.test(trimmed)) {
265
+ text = trimmed.trim();
266
+ }
267
+ }
268
+ return {
269
+ type: "heading",
270
+ raw: cap[0],
271
+ depth: cap[1].length,
272
+ text,
273
+ tokens: this.lexer.inline(text)
274
+ };
275
+ }
276
+ }
277
+ hr(src) {
278
+ const cap = this.rules.block.hr.exec(src);
279
+ if (cap) {
280
+ return {
281
+ type: "hr",
282
+ raw: cap[0]
283
+ };
284
+ }
285
+ }
286
+ blockquote(src) {
287
+ const cap = this.rules.block.blockquote.exec(src);
288
+ if (cap) {
289
+ const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ""), "\n");
290
+ const top = this.lexer.state.top;
291
+ this.lexer.state.top = true;
292
+ const tokens = this.lexer.blockTokens(text);
293
+ this.lexer.state.top = top;
294
+ return {
295
+ type: "blockquote",
296
+ raw: cap[0],
297
+ tokens,
298
+ text
299
+ };
300
+ }
301
+ }
302
+ list(src) {
303
+ let cap = this.rules.block.list.exec(src);
304
+ if (cap) {
305
+ let bull = cap[1].trim();
306
+ const isordered = bull.length > 1;
307
+ const list2 = {
308
+ type: "list",
309
+ raw: "",
310
+ ordered: isordered,
311
+ start: isordered ? +bull.slice(0, -1) : "",
312
+ loose: false,
313
+ items: []
314
+ };
315
+ bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
316
+ if (this.options.pedantic) {
317
+ bull = isordered ? bull : "[*+-]";
318
+ }
319
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[ ][^\\n]*)?(?:\\n|$))`);
320
+ let raw = "";
321
+ let itemContents = "";
322
+ let endsWithBlankLine = false;
323
+ while (src) {
324
+ let endEarly = false;
325
+ if (!(cap = itemRegex.exec(src))) {
326
+ break;
327
+ }
328
+ if (this.rules.block.hr.test(src)) {
329
+ break;
330
+ }
331
+ raw = cap[0];
332
+ src = src.substring(raw.length);
333
+ let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t) => " ".repeat(3 * t.length));
334
+ let nextLine = src.split("\n", 1)[0];
335
+ let indent = 0;
336
+ if (this.options.pedantic) {
337
+ indent = 2;
338
+ itemContents = line.trimStart();
339
+ } else {
340
+ indent = cap[2].search(/[^ ]/);
341
+ indent = indent > 4 ? 1 : indent;
342
+ itemContents = line.slice(indent);
343
+ indent += cap[1].length;
344
+ }
345
+ let blankLine = false;
346
+ if (!line && /^ *$/.test(nextLine)) {
347
+ raw += nextLine + "\n";
348
+ src = src.substring(nextLine.length + 1);
349
+ endEarly = true;
350
+ }
351
+ if (!endEarly) {
352
+ const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`);
353
+ const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
354
+ const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
355
+ const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
356
+ while (src) {
357
+ const rawLine = src.split("\n", 1)[0];
358
+ nextLine = rawLine;
359
+ if (this.options.pedantic) {
360
+ nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, " ");
361
+ }
362
+ if (fencesBeginRegex.test(nextLine)) {
363
+ break;
364
+ }
365
+ if (headingBeginRegex.test(nextLine)) {
366
+ break;
367
+ }
368
+ if (nextBulletRegex.test(nextLine)) {
369
+ break;
370
+ }
371
+ if (hrRegex.test(src)) {
372
+ break;
373
+ }
374
+ if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
375
+ itemContents += "\n" + nextLine.slice(indent);
376
+ } else {
377
+ if (blankLine) {
378
+ break;
379
+ }
380
+ if (line.search(/[^ ]/) >= 4) {
381
+ break;
382
+ }
383
+ if (fencesBeginRegex.test(line)) {
384
+ break;
385
+ }
386
+ if (headingBeginRegex.test(line)) {
387
+ break;
388
+ }
389
+ if (hrRegex.test(line)) {
390
+ break;
391
+ }
392
+ itemContents += "\n" + nextLine;
393
+ }
394
+ if (!blankLine && !nextLine.trim()) {
395
+ blankLine = true;
396
+ }
397
+ raw += rawLine + "\n";
398
+ src = src.substring(rawLine.length + 1);
399
+ line = nextLine.slice(indent);
400
+ }
401
+ }
402
+ if (!list2.loose) {
403
+ if (endsWithBlankLine) {
404
+ list2.loose = true;
405
+ } else if (/\n *\n *$/.test(raw)) {
406
+ endsWithBlankLine = true;
407
+ }
408
+ }
409
+ let istask = null;
410
+ let ischecked;
411
+ if (this.options.gfm) {
412
+ istask = /^\[[ xX]\] /.exec(itemContents);
413
+ if (istask) {
414
+ ischecked = istask[0] !== "[ ] ";
415
+ itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
416
+ }
417
+ }
418
+ list2.items.push({
419
+ type: "list_item",
420
+ raw,
421
+ task: !!istask,
422
+ checked: ischecked,
423
+ loose: false,
424
+ text: itemContents,
425
+ tokens: []
426
+ });
427
+ list2.raw += raw;
428
+ }
429
+ list2.items[list2.items.length - 1].raw = raw.trimEnd();
430
+ list2.items[list2.items.length - 1].text = itemContents.trimEnd();
431
+ list2.raw = list2.raw.trimEnd();
432
+ for (let i = 0; i < list2.items.length; i++) {
433
+ this.lexer.state.top = false;
434
+ list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
435
+ if (!list2.loose) {
436
+ const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
437
+ const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => /\n.*\n/.test(t.raw));
438
+ list2.loose = hasMultipleLineBreaks;
439
+ }
440
+ }
441
+ if (list2.loose) {
442
+ for (let i = 0; i < list2.items.length; i++) {
443
+ list2.items[i].loose = true;
444
+ }
445
+ }
446
+ return list2;
447
+ }
448
+ }
449
+ html(src) {
450
+ const cap = this.rules.block.html.exec(src);
451
+ if (cap) {
452
+ const token = {
453
+ type: "html",
454
+ block: true,
455
+ raw: cap[0],
456
+ pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
457
+ text: cap[0]
458
+ };
459
+ return token;
460
+ }
461
+ }
462
+ def(src) {
463
+ const cap = this.rules.block.def.exec(src);
464
+ if (cap) {
465
+ const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
466
+ const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
467
+ const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
468
+ return {
469
+ type: "def",
470
+ tag: tag2,
471
+ raw: cap[0],
472
+ href,
473
+ title
474
+ };
475
+ }
476
+ }
477
+ table(src) {
478
+ const cap = this.rules.block.table.exec(src);
479
+ if (!cap) {
480
+ return;
481
+ }
482
+ if (!/[:|]/.test(cap[2])) {
483
+ return;
484
+ }
485
+ const headers = splitCells(cap[1]);
486
+ const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
487
+ const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
488
+ const item = {
489
+ type: "table",
490
+ raw: cap[0],
491
+ header: [],
492
+ align: [],
493
+ rows: []
494
+ };
495
+ if (headers.length !== aligns.length) {
496
+ return;
497
+ }
498
+ for (const align of aligns) {
499
+ if (/^ *-+: *$/.test(align)) {
500
+ item.align.push("right");
501
+ } else if (/^ *:-+: *$/.test(align)) {
502
+ item.align.push("center");
503
+ } else if (/^ *:-+ *$/.test(align)) {
504
+ item.align.push("left");
505
+ } else {
506
+ item.align.push(null);
507
+ }
508
+ }
509
+ for (const header of headers) {
510
+ item.header.push({
511
+ text: header,
512
+ tokens: this.lexer.inline(header)
513
+ });
514
+ }
515
+ for (const row of rows) {
516
+ item.rows.push(splitCells(row, item.header.length).map((cell) => {
517
+ return {
518
+ text: cell,
519
+ tokens: this.lexer.inline(cell)
520
+ };
521
+ }));
522
+ }
523
+ return item;
524
+ }
525
+ lheading(src) {
526
+ const cap = this.rules.block.lheading.exec(src);
527
+ if (cap) {
528
+ return {
529
+ type: "heading",
530
+ raw: cap[0],
531
+ depth: cap[2].charAt(0) === "=" ? 1 : 2,
532
+ text: cap[1],
533
+ tokens: this.lexer.inline(cap[1])
534
+ };
535
+ }
536
+ }
537
+ paragraph(src) {
538
+ const cap = this.rules.block.paragraph.exec(src);
539
+ if (cap) {
540
+ const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
541
+ return {
542
+ type: "paragraph",
543
+ raw: cap[0],
544
+ text,
545
+ tokens: this.lexer.inline(text)
546
+ };
547
+ }
548
+ }
549
+ text(src) {
550
+ const cap = this.rules.block.text.exec(src);
551
+ if (cap) {
552
+ return {
553
+ type: "text",
554
+ raw: cap[0],
555
+ text: cap[0],
556
+ tokens: this.lexer.inline(cap[0])
557
+ };
558
+ }
559
+ }
560
+ escape(src) {
561
+ const cap = this.rules.inline.escape.exec(src);
562
+ if (cap) {
563
+ return {
564
+ type: "escape",
565
+ raw: cap[0],
566
+ text: escape$1(cap[1])
567
+ };
568
+ }
569
+ }
570
+ tag(src) {
571
+ const cap = this.rules.inline.tag.exec(src);
572
+ if (cap) {
573
+ if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
574
+ this.lexer.state.inLink = true;
575
+ } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
576
+ this.lexer.state.inLink = false;
577
+ }
578
+ if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
579
+ this.lexer.state.inRawBlock = true;
580
+ } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
581
+ this.lexer.state.inRawBlock = false;
582
+ }
583
+ return {
584
+ type: "html",
585
+ raw: cap[0],
586
+ inLink: this.lexer.state.inLink,
587
+ inRawBlock: this.lexer.state.inRawBlock,
588
+ block: false,
589
+ text: cap[0]
590
+ };
591
+ }
592
+ }
593
+ link(src) {
594
+ const cap = this.rules.inline.link.exec(src);
595
+ if (cap) {
596
+ const trimmedUrl = cap[2].trim();
597
+ if (!this.options.pedantic && /^</.test(trimmedUrl)) {
598
+ if (!/>$/.test(trimmedUrl)) {
599
+ return;
600
+ }
601
+ const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
602
+ if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
603
+ return;
604
+ }
605
+ } else {
606
+ const lastParenIndex = findClosingBracket(cap[2], "()");
607
+ if (lastParenIndex > -1) {
608
+ const start = cap[0].indexOf("!") === 0 ? 5 : 4;
609
+ const linkLen = start + cap[1].length + lastParenIndex;
610
+ cap[2] = cap[2].substring(0, lastParenIndex);
611
+ cap[0] = cap[0].substring(0, linkLen).trim();
612
+ cap[3] = "";
613
+ }
614
+ }
615
+ let href = cap[2];
616
+ let title = "";
617
+ if (this.options.pedantic) {
618
+ const link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
619
+ if (link2) {
620
+ href = link2[1];
621
+ title = link2[3];
622
+ }
623
+ } else {
624
+ title = cap[3] ? cap[3].slice(1, -1) : "";
625
+ }
626
+ href = href.trim();
627
+ if (/^</.test(href)) {
628
+ if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
629
+ href = href.slice(1);
630
+ } else {
631
+ href = href.slice(1, -1);
632
+ }
633
+ }
634
+ return outputLink(cap, {
635
+ href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
636
+ title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
637
+ }, cap[0], this.lexer);
638
+ }
639
+ }
640
+ reflink(src, links) {
641
+ let cap;
642
+ if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
643
+ const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
644
+ const link2 = links[linkString.toLowerCase()];
645
+ if (!link2) {
646
+ const text = cap[0].charAt(0);
647
+ return {
648
+ type: "text",
649
+ raw: text,
650
+ text
651
+ };
652
+ }
653
+ return outputLink(cap, link2, cap[0], this.lexer);
654
+ }
655
+ }
656
+ emStrong(src, maskedSrc, prevChar = "") {
657
+ let match = this.rules.inline.emStrongLDelim.exec(src);
658
+ if (!match)
659
+ return;
660
+ if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
661
+ return;
662
+ const nextChar = match[1] || match[2] || "";
663
+ if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
664
+ const lLength = [...match[0]].length - 1;
665
+ let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
666
+ const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
667
+ endReg.lastIndex = 0;
668
+ maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
669
+ while ((match = endReg.exec(maskedSrc)) != null) {
670
+ rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
671
+ if (!rDelim)
672
+ continue;
673
+ rLength = [...rDelim].length;
674
+ if (match[3] || match[4]) {
675
+ delimTotal += rLength;
676
+ continue;
677
+ } else if (match[5] || match[6]) {
678
+ if (lLength % 3 && !((lLength + rLength) % 3)) {
679
+ midDelimTotal += rLength;
680
+ continue;
681
+ }
682
+ }
683
+ delimTotal -= rLength;
684
+ if (delimTotal > 0)
685
+ continue;
686
+ rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
687
+ const lastCharLength = [...match[0]][0].length;
688
+ const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
689
+ if (Math.min(lLength, rLength) % 2) {
690
+ const text2 = raw.slice(1, -1);
691
+ return {
692
+ type: "em",
693
+ raw,
694
+ text: text2,
695
+ tokens: this.lexer.inlineTokens(text2)
696
+ };
697
+ }
698
+ const text = raw.slice(2, -2);
699
+ return {
700
+ type: "strong",
701
+ raw,
702
+ text,
703
+ tokens: this.lexer.inlineTokens(text)
704
+ };
705
+ }
706
+ }
707
+ }
708
+ codespan(src) {
709
+ const cap = this.rules.inline.code.exec(src);
710
+ if (cap) {
711
+ let text = cap[2].replace(/\n/g, " ");
712
+ const hasNonSpaceChars = /[^ ]/.test(text);
713
+ const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
714
+ if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
715
+ text = text.substring(1, text.length - 1);
716
+ }
717
+ text = escape$1(text, true);
718
+ return {
719
+ type: "codespan",
720
+ raw: cap[0],
721
+ text
722
+ };
723
+ }
724
+ }
725
+ br(src) {
726
+ const cap = this.rules.inline.br.exec(src);
727
+ if (cap) {
728
+ return {
729
+ type: "br",
730
+ raw: cap[0]
731
+ };
732
+ }
733
+ }
734
+ del(src) {
735
+ const cap = this.rules.inline.del.exec(src);
736
+ if (cap) {
737
+ return {
738
+ type: "del",
739
+ raw: cap[0],
740
+ text: cap[2],
741
+ tokens: this.lexer.inlineTokens(cap[2])
742
+ };
743
+ }
744
+ }
745
+ autolink(src) {
746
+ const cap = this.rules.inline.autolink.exec(src);
747
+ if (cap) {
748
+ let text, href;
749
+ if (cap[2] === "@") {
750
+ text = escape$1(cap[1]);
751
+ href = "mailto:" + text;
752
+ } else {
753
+ text = escape$1(cap[1]);
754
+ href = text;
755
+ }
756
+ return {
757
+ type: "link",
758
+ raw: cap[0],
759
+ text,
760
+ href,
761
+ tokens: [
762
+ {
763
+ type: "text",
764
+ raw: text,
765
+ text
766
+ }
767
+ ]
768
+ };
769
+ }
770
+ }
771
+ url(src) {
772
+ var _a;
773
+ let cap;
774
+ if (cap = this.rules.inline.url.exec(src)) {
775
+ let text, href;
776
+ if (cap[2] === "@") {
777
+ text = escape$1(cap[0]);
778
+ href = "mailto:" + text;
779
+ } else {
780
+ let prevCapZero;
781
+ do {
782
+ prevCapZero = cap[0];
783
+ cap[0] = ((_a = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a[0]) ?? "";
784
+ } while (prevCapZero !== cap[0]);
785
+ text = escape$1(cap[0]);
786
+ if (cap[1] === "www.") {
787
+ href = "http://" + cap[0];
788
+ } else {
789
+ href = cap[0];
790
+ }
791
+ }
792
+ return {
793
+ type: "link",
794
+ raw: cap[0],
795
+ text,
796
+ href,
797
+ tokens: [
798
+ {
799
+ type: "text",
800
+ raw: text,
801
+ text
802
+ }
803
+ ]
804
+ };
805
+ }
806
+ }
807
+ inlineText(src) {
808
+ const cap = this.rules.inline.text.exec(src);
809
+ if (cap) {
810
+ let text;
811
+ if (this.lexer.state.inRawBlock) {
812
+ text = cap[0];
813
+ } else {
814
+ text = escape$1(cap[0]);
815
+ }
816
+ return {
817
+ type: "text",
818
+ raw: cap[0],
819
+ text
820
+ };
821
+ }
822
+ }
823
+ }
824
+ const newline = /^(?: *(?:\n|$))+/;
825
+ const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
826
+ const fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
827
+ const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
828
+ const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
829
+ const bullet = /(?:[*+-]|\d{1,9}[.)])/;
830
+ const 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();
831
+ const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
832
+ const blockText = /^[^\n]+/;
833
+ const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
834
+ const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
835
+ const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
836
+ const _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";
837
+ const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
838
+ const 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();
839
+ const 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();
840
+ const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
841
+ const blockNormal = {
842
+ blockquote,
843
+ code: blockCode,
844
+ def,
845
+ fences,
846
+ heading,
847
+ hr,
848
+ html,
849
+ lheading,
850
+ list,
851
+ newline,
852
+ paragraph,
853
+ table: noopTest,
854
+ text: blockText
855
+ };
856
+ const 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();
857
+ const blockGfm = {
858
+ ...blockNormal,
859
+ table: gfmTable,
860
+ 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()
861
+ };
862
+ const blockPedantic = {
863
+ ...blockNormal,
864
+ 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(),
865
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
866
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
867
+ fences: noopTest,
868
+ // fences not supported
869
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
870
+ 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()
871
+ };
872
+ const escape = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
873
+ const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
874
+ const br = /^( {2,}|\\)\n(?!\s*$)/;
875
+ const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
876
+ const _punctuation = "\\p{P}\\p{S}";
877
+ const punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
878
+ const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
879
+ const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
880
+ const 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();
881
+ const emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
882
+ const anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
883
+ const 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();
884
+ const _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
885
+ const 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();
886
+ const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
887
+ const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
888
+ const reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
889
+ const nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
890
+ const reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
891
+ const inlineNormal = {
892
+ _backpedal: noopTest,
893
+ // only used for GFM url
894
+ anyPunctuation,
895
+ autolink,
896
+ blockSkip,
897
+ br,
898
+ code: inlineCode,
899
+ del: noopTest,
900
+ emStrongLDelim,
901
+ emStrongRDelimAst,
902
+ emStrongRDelimUnd,
903
+ escape,
904
+ link,
905
+ nolink,
906
+ punctuation,
907
+ reflink,
908
+ reflinkSearch,
909
+ tag,
910
+ text: inlineText,
911
+ url: noopTest
912
+ };
913
+ const inlinePedantic = {
914
+ ...inlineNormal,
915
+ link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
916
+ reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
917
+ };
918
+ const inlineGfm = {
919
+ ...inlineNormal,
920
+ escape: edit(escape).replace("])", "~|])").getRegex(),
921
+ 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(),
922
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
923
+ del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
924
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
925
+ };
926
+ const inlineBreaks = {
927
+ ...inlineGfm,
928
+ br: edit(br).replace("{2,}", "*").getRegex(),
929
+ text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
930
+ };
931
+ const block = {
932
+ normal: blockNormal,
933
+ gfm: blockGfm,
934
+ pedantic: blockPedantic
935
+ };
936
+ const inline = {
937
+ normal: inlineNormal,
938
+ gfm: inlineGfm,
939
+ breaks: inlineBreaks,
940
+ pedantic: inlinePedantic
941
+ };
942
+ class _Lexer {
943
+ constructor(options) {
944
+ __publicField(this, "tokens");
945
+ __publicField(this, "options");
946
+ __publicField(this, "state");
947
+ __publicField(this, "tokenizer");
948
+ __publicField(this, "inlineQueue");
949
+ this.tokens = [];
950
+ this.tokens.links = /* @__PURE__ */ Object.create(null);
951
+ this.options = options || _defaults;
952
+ this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
953
+ this.tokenizer = this.options.tokenizer;
954
+ this.tokenizer.options = this.options;
955
+ this.tokenizer.lexer = this;
956
+ this.inlineQueue = [];
957
+ this.state = {
958
+ inLink: false,
959
+ inRawBlock: false,
960
+ top: true
961
+ };
962
+ const rules = {
963
+ block: block.normal,
964
+ inline: inline.normal
965
+ };
966
+ if (this.options.pedantic) {
967
+ rules.block = block.pedantic;
968
+ rules.inline = inline.pedantic;
969
+ } else if (this.options.gfm) {
970
+ rules.block = block.gfm;
971
+ if (this.options.breaks) {
972
+ rules.inline = inline.breaks;
973
+ } else {
974
+ rules.inline = inline.gfm;
975
+ }
976
+ }
977
+ this.tokenizer.rules = rules;
978
+ }
979
+ /**
980
+ * Expose Rules
981
+ */
982
+ static get rules() {
983
+ return {
984
+ block,
985
+ inline
986
+ };
987
+ }
988
+ /**
989
+ * Static Lex Method
990
+ */
991
+ static lex(src, options) {
992
+ const lexer = new _Lexer(options);
993
+ return lexer.lex(src);
994
+ }
995
+ /**
996
+ * Static Lex Inline Method
997
+ */
998
+ static lexInline(src, options) {
999
+ const lexer = new _Lexer(options);
1000
+ return lexer.inlineTokens(src);
1001
+ }
1002
+ /**
1003
+ * Preprocessing
1004
+ */
1005
+ lex(src) {
1006
+ src = src.replace(/\r\n|\r/g, "\n");
1007
+ this.blockTokens(src, this.tokens);
1008
+ for (let i = 0; i < this.inlineQueue.length; i++) {
1009
+ const next = this.inlineQueue[i];
1010
+ this.inlineTokens(next.src, next.tokens);
1011
+ }
1012
+ this.inlineQueue = [];
1013
+ return this.tokens;
1014
+ }
1015
+ blockTokens(src, tokens = []) {
1016
+ if (this.options.pedantic) {
1017
+ src = src.replace(/\t/g, " ").replace(/^ +$/gm, "");
1018
+ } else {
1019
+ src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1020
+ return leading + " ".repeat(tabs.length);
1021
+ });
1022
+ }
1023
+ let token;
1024
+ let lastToken;
1025
+ let cutSrc;
1026
+ let lastParagraphClipped;
1027
+ while (src) {
1028
+ if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
1029
+ if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1030
+ src = src.substring(token.raw.length);
1031
+ tokens.push(token);
1032
+ return true;
1033
+ }
1034
+ return false;
1035
+ })) {
1036
+ continue;
1037
+ }
1038
+ if (token = this.tokenizer.space(src)) {
1039
+ src = src.substring(token.raw.length);
1040
+ if (token.raw.length === 1 && tokens.length > 0) {
1041
+ tokens[tokens.length - 1].raw += "\n";
1042
+ } else {
1043
+ tokens.push(token);
1044
+ }
1045
+ continue;
1046
+ }
1047
+ if (token = this.tokenizer.code(src)) {
1048
+ src = src.substring(token.raw.length);
1049
+ lastToken = tokens[tokens.length - 1];
1050
+ if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
1051
+ lastToken.raw += "\n" + token.raw;
1052
+ lastToken.text += "\n" + token.text;
1053
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1054
+ } else {
1055
+ tokens.push(token);
1056
+ }
1057
+ continue;
1058
+ }
1059
+ if (token = this.tokenizer.fences(src)) {
1060
+ src = src.substring(token.raw.length);
1061
+ tokens.push(token);
1062
+ continue;
1063
+ }
1064
+ if (token = this.tokenizer.heading(src)) {
1065
+ src = src.substring(token.raw.length);
1066
+ tokens.push(token);
1067
+ continue;
1068
+ }
1069
+ if (token = this.tokenizer.hr(src)) {
1070
+ src = src.substring(token.raw.length);
1071
+ tokens.push(token);
1072
+ continue;
1073
+ }
1074
+ if (token = this.tokenizer.blockquote(src)) {
1075
+ src = src.substring(token.raw.length);
1076
+ tokens.push(token);
1077
+ continue;
1078
+ }
1079
+ if (token = this.tokenizer.list(src)) {
1080
+ src = src.substring(token.raw.length);
1081
+ tokens.push(token);
1082
+ continue;
1083
+ }
1084
+ if (token = this.tokenizer.html(src)) {
1085
+ src = src.substring(token.raw.length);
1086
+ tokens.push(token);
1087
+ continue;
1088
+ }
1089
+ if (token = this.tokenizer.def(src)) {
1090
+ src = src.substring(token.raw.length);
1091
+ lastToken = tokens[tokens.length - 1];
1092
+ if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
1093
+ lastToken.raw += "\n" + token.raw;
1094
+ lastToken.text += "\n" + token.raw;
1095
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1096
+ } else if (!this.tokens.links[token.tag]) {
1097
+ this.tokens.links[token.tag] = {
1098
+ href: token.href,
1099
+ title: token.title
1100
+ };
1101
+ }
1102
+ continue;
1103
+ }
1104
+ if (token = this.tokenizer.table(src)) {
1105
+ src = src.substring(token.raw.length);
1106
+ tokens.push(token);
1107
+ continue;
1108
+ }
1109
+ if (token = this.tokenizer.lheading(src)) {
1110
+ src = src.substring(token.raw.length);
1111
+ tokens.push(token);
1112
+ continue;
1113
+ }
1114
+ cutSrc = src;
1115
+ if (this.options.extensions && this.options.extensions.startBlock) {
1116
+ let startIndex = Infinity;
1117
+ const tempSrc = src.slice(1);
1118
+ let tempStart;
1119
+ this.options.extensions.startBlock.forEach((getStartIndex) => {
1120
+ tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1121
+ if (typeof tempStart === "number" && tempStart >= 0) {
1122
+ startIndex = Math.min(startIndex, tempStart);
1123
+ }
1124
+ });
1125
+ if (startIndex < Infinity && startIndex >= 0) {
1126
+ cutSrc = src.substring(0, startIndex + 1);
1127
+ }
1128
+ }
1129
+ if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
1130
+ lastToken = tokens[tokens.length - 1];
1131
+ if (lastParagraphClipped && lastToken.type === "paragraph") {
1132
+ lastToken.raw += "\n" + token.raw;
1133
+ lastToken.text += "\n" + token.text;
1134
+ this.inlineQueue.pop();
1135
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1136
+ } else {
1137
+ tokens.push(token);
1138
+ }
1139
+ lastParagraphClipped = cutSrc.length !== src.length;
1140
+ src = src.substring(token.raw.length);
1141
+ continue;
1142
+ }
1143
+ if (token = this.tokenizer.text(src)) {
1144
+ src = src.substring(token.raw.length);
1145
+ lastToken = tokens[tokens.length - 1];
1146
+ if (lastToken && lastToken.type === "text") {
1147
+ lastToken.raw += "\n" + token.raw;
1148
+ lastToken.text += "\n" + token.text;
1149
+ this.inlineQueue.pop();
1150
+ this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
1151
+ } else {
1152
+ tokens.push(token);
1153
+ }
1154
+ continue;
1155
+ }
1156
+ if (src) {
1157
+ const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1158
+ if (this.options.silent) {
1159
+ console.error(errMsg);
1160
+ break;
1161
+ } else {
1162
+ throw new Error(errMsg);
1163
+ }
1164
+ }
1165
+ }
1166
+ this.state.top = true;
1167
+ return tokens;
1168
+ }
1169
+ inline(src, tokens = []) {
1170
+ this.inlineQueue.push({ src, tokens });
1171
+ return tokens;
1172
+ }
1173
+ /**
1174
+ * Lexing/Compiling
1175
+ */
1176
+ inlineTokens(src, tokens = []) {
1177
+ let token, lastToken, cutSrc;
1178
+ let maskedSrc = src;
1179
+ let match;
1180
+ let keepPrevChar, prevChar;
1181
+ if (this.tokens.links) {
1182
+ const links = Object.keys(this.tokens.links);
1183
+ if (links.length > 0) {
1184
+ while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
1185
+ if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
1186
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
1187
+ }
1188
+ }
1189
+ }
1190
+ }
1191
+ while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
1192
+ maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
1193
+ }
1194
+ while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
1195
+ maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
1196
+ }
1197
+ while (src) {
1198
+ if (!keepPrevChar) {
1199
+ prevChar = "";
1200
+ }
1201
+ keepPrevChar = false;
1202
+ if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
1203
+ if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
1204
+ src = src.substring(token.raw.length);
1205
+ tokens.push(token);
1206
+ return true;
1207
+ }
1208
+ return false;
1209
+ })) {
1210
+ continue;
1211
+ }
1212
+ if (token = this.tokenizer.escape(src)) {
1213
+ src = src.substring(token.raw.length);
1214
+ tokens.push(token);
1215
+ continue;
1216
+ }
1217
+ if (token = this.tokenizer.tag(src)) {
1218
+ src = src.substring(token.raw.length);
1219
+ lastToken = tokens[tokens.length - 1];
1220
+ if (lastToken && token.type === "text" && lastToken.type === "text") {
1221
+ lastToken.raw += token.raw;
1222
+ lastToken.text += token.text;
1223
+ } else {
1224
+ tokens.push(token);
1225
+ }
1226
+ continue;
1227
+ }
1228
+ if (token = this.tokenizer.link(src)) {
1229
+ src = src.substring(token.raw.length);
1230
+ tokens.push(token);
1231
+ continue;
1232
+ }
1233
+ if (token = this.tokenizer.reflink(src, this.tokens.links)) {
1234
+ src = src.substring(token.raw.length);
1235
+ lastToken = tokens[tokens.length - 1];
1236
+ if (lastToken && token.type === "text" && lastToken.type === "text") {
1237
+ lastToken.raw += token.raw;
1238
+ lastToken.text += token.text;
1239
+ } else {
1240
+ tokens.push(token);
1241
+ }
1242
+ continue;
1243
+ }
1244
+ if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
1245
+ src = src.substring(token.raw.length);
1246
+ tokens.push(token);
1247
+ continue;
1248
+ }
1249
+ if (token = this.tokenizer.codespan(src)) {
1250
+ src = src.substring(token.raw.length);
1251
+ tokens.push(token);
1252
+ continue;
1253
+ }
1254
+ if (token = this.tokenizer.br(src)) {
1255
+ src = src.substring(token.raw.length);
1256
+ tokens.push(token);
1257
+ continue;
1258
+ }
1259
+ if (token = this.tokenizer.del(src)) {
1260
+ src = src.substring(token.raw.length);
1261
+ tokens.push(token);
1262
+ continue;
1263
+ }
1264
+ if (token = this.tokenizer.autolink(src)) {
1265
+ src = src.substring(token.raw.length);
1266
+ tokens.push(token);
1267
+ continue;
1268
+ }
1269
+ if (!this.state.inLink && (token = this.tokenizer.url(src))) {
1270
+ src = src.substring(token.raw.length);
1271
+ tokens.push(token);
1272
+ continue;
1273
+ }
1274
+ cutSrc = src;
1275
+ if (this.options.extensions && this.options.extensions.startInline) {
1276
+ let startIndex = Infinity;
1277
+ const tempSrc = src.slice(1);
1278
+ let tempStart;
1279
+ this.options.extensions.startInline.forEach((getStartIndex) => {
1280
+ tempStart = getStartIndex.call({ lexer: this }, tempSrc);
1281
+ if (typeof tempStart === "number" && tempStart >= 0) {
1282
+ startIndex = Math.min(startIndex, tempStart);
1283
+ }
1284
+ });
1285
+ if (startIndex < Infinity && startIndex >= 0) {
1286
+ cutSrc = src.substring(0, startIndex + 1);
1287
+ }
1288
+ }
1289
+ if (token = this.tokenizer.inlineText(cutSrc)) {
1290
+ src = src.substring(token.raw.length);
1291
+ if (token.raw.slice(-1) !== "_") {
1292
+ prevChar = token.raw.slice(-1);
1293
+ }
1294
+ keepPrevChar = true;
1295
+ lastToken = tokens[tokens.length - 1];
1296
+ if (lastToken && lastToken.type === "text") {
1297
+ lastToken.raw += token.raw;
1298
+ lastToken.text += token.text;
1299
+ } else {
1300
+ tokens.push(token);
1301
+ }
1302
+ continue;
1303
+ }
1304
+ if (src) {
1305
+ const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
1306
+ if (this.options.silent) {
1307
+ console.error(errMsg);
1308
+ break;
1309
+ } else {
1310
+ throw new Error(errMsg);
1311
+ }
1312
+ }
1313
+ }
1314
+ return tokens;
1315
+ }
1316
+ }
1317
+ class _Renderer {
1318
+ constructor(options) {
1319
+ __publicField(this, "options");
1320
+ this.options = options || _defaults;
1321
+ }
1322
+ code(code, infostring, escaped) {
1323
+ var _a;
1324
+ const lang = (_a = (infostring || "").match(/^\S*/)) == null ? void 0 : _a[0];
1325
+ code = code.replace(/\n$/, "") + "\n";
1326
+ if (!lang) {
1327
+ return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
1328
+ }
1329
+ return '<pre><code class="language-' + escape$1(lang) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
1330
+ }
1331
+ blockquote(quote) {
1332
+ return `<blockquote>
1333
+ ${quote}</blockquote>
1334
+ `;
1335
+ }
1336
+ html(html2, block2) {
1337
+ return html2;
1338
+ }
1339
+ heading(text, level, raw) {
1340
+ return `<h${level}>${text}</h${level}>
1341
+ `;
1342
+ }
1343
+ hr() {
1344
+ return "<hr>\n";
1345
+ }
1346
+ list(body, ordered, start) {
1347
+ const type = ordered ? "ol" : "ul";
1348
+ const startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
1349
+ return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
1350
+ }
1351
+ listitem(text, task, checked) {
1352
+ return `<li>${text}</li>
1353
+ `;
1354
+ }
1355
+ checkbox(checked) {
1356
+ return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1357
+ }
1358
+ paragraph(text) {
1359
+ return `<p>${text}</p>
1360
+ `;
1361
+ }
1362
+ table(header, body) {
1363
+ if (body)
1364
+ body = `<tbody>${body}</tbody>`;
1365
+ return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
1366
+ }
1367
+ tablerow(content) {
1368
+ return `<tr>
1369
+ ${content}</tr>
1370
+ `;
1371
+ }
1372
+ tablecell(content, flags) {
1373
+ const type = flags.header ? "th" : "td";
1374
+ const tag2 = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
1375
+ return tag2 + content + `</${type}>
1376
+ `;
1377
+ }
1378
+ /**
1379
+ * span level renderer
1380
+ */
1381
+ strong(text) {
1382
+ return `<strong>${text}</strong>`;
1383
+ }
1384
+ em(text) {
1385
+ return `<em>${text}</em>`;
1386
+ }
1387
+ codespan(text) {
1388
+ return `<code>${text}</code>`;
1389
+ }
1390
+ br() {
1391
+ return "<br>";
1392
+ }
1393
+ del(text) {
1394
+ return `<del>${text}</del>`;
1395
+ }
1396
+ link(href, title, text) {
1397
+ const cleanHref = cleanUrl(href);
1398
+ if (cleanHref === null) {
1399
+ return text;
1400
+ }
1401
+ href = cleanHref;
1402
+ let out = '<a href="' + href + '"';
1403
+ if (title) {
1404
+ out += ' title="' + title + '"';
1405
+ }
1406
+ out += ">" + text + "</a>";
1407
+ return out;
1408
+ }
1409
+ image(href, title, text) {
1410
+ const cleanHref = cleanUrl(href);
1411
+ if (cleanHref === null) {
1412
+ return text;
1413
+ }
1414
+ href = cleanHref;
1415
+ let out = `<img src="${href}" alt="${text}"`;
1416
+ if (title) {
1417
+ out += ` title="${title}"`;
1418
+ }
1419
+ out += ">";
1420
+ return out;
1421
+ }
1422
+ text(text) {
1423
+ return text;
1424
+ }
1425
+ }
1426
+ class _TextRenderer {
1427
+ // no need for block level renderers
1428
+ strong(text) {
1429
+ return text;
1430
+ }
1431
+ em(text) {
1432
+ return text;
1433
+ }
1434
+ codespan(text) {
1435
+ return text;
1436
+ }
1437
+ del(text) {
1438
+ return text;
1439
+ }
1440
+ html(text) {
1441
+ return text;
1442
+ }
1443
+ text(text) {
1444
+ return text;
1445
+ }
1446
+ link(href, title, text) {
1447
+ return "" + text;
1448
+ }
1449
+ image(href, title, text) {
1450
+ return "" + text;
1451
+ }
1452
+ br() {
1453
+ return "";
1454
+ }
1455
+ }
1456
+ class _Parser {
1457
+ constructor(options) {
1458
+ __publicField(this, "options");
1459
+ __publicField(this, "renderer");
1460
+ __publicField(this, "textRenderer");
1461
+ this.options = options || _defaults;
1462
+ this.options.renderer = this.options.renderer || new _Renderer();
1463
+ this.renderer = this.options.renderer;
1464
+ this.renderer.options = this.options;
1465
+ this.textRenderer = new _TextRenderer();
1466
+ }
1467
+ /**
1468
+ * Static Parse Method
1469
+ */
1470
+ static parse(tokens, options) {
1471
+ const parser = new _Parser(options);
1472
+ return parser.parse(tokens);
1473
+ }
1474
+ /**
1475
+ * Static Parse Inline Method
1476
+ */
1477
+ static parseInline(tokens, options) {
1478
+ const parser = new _Parser(options);
1479
+ return parser.parseInline(tokens);
1480
+ }
1481
+ /**
1482
+ * Parse Loop
1483
+ */
1484
+ parse(tokens, top = true) {
1485
+ let out = "";
1486
+ for (let i = 0; i < tokens.length; i++) {
1487
+ const token = tokens[i];
1488
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
1489
+ const genericToken = token;
1490
+ const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
1491
+ if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
1492
+ out += ret || "";
1493
+ continue;
1494
+ }
1495
+ }
1496
+ switch (token.type) {
1497
+ case "space": {
1498
+ continue;
1499
+ }
1500
+ case "hr": {
1501
+ out += this.renderer.hr();
1502
+ continue;
1503
+ }
1504
+ case "heading": {
1505
+ const headingToken = token;
1506
+ out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)));
1507
+ continue;
1508
+ }
1509
+ case "code": {
1510
+ const codeToken = token;
1511
+ out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
1512
+ continue;
1513
+ }
1514
+ case "table": {
1515
+ const tableToken = token;
1516
+ let header = "";
1517
+ let cell = "";
1518
+ for (let j = 0; j < tableToken.header.length; j++) {
1519
+ cell += this.renderer.tablecell(this.parseInline(tableToken.header[j].tokens), { header: true, align: tableToken.align[j] });
1520
+ }
1521
+ header += this.renderer.tablerow(cell);
1522
+ let body = "";
1523
+ for (let j = 0; j < tableToken.rows.length; j++) {
1524
+ const row = tableToken.rows[j];
1525
+ cell = "";
1526
+ for (let k = 0; k < row.length; k++) {
1527
+ cell += this.renderer.tablecell(this.parseInline(row[k].tokens), { header: false, align: tableToken.align[k] });
1528
+ }
1529
+ body += this.renderer.tablerow(cell);
1530
+ }
1531
+ out += this.renderer.table(header, body);
1532
+ continue;
1533
+ }
1534
+ case "blockquote": {
1535
+ const blockquoteToken = token;
1536
+ const body = this.parse(blockquoteToken.tokens);
1537
+ out += this.renderer.blockquote(body);
1538
+ continue;
1539
+ }
1540
+ case "list": {
1541
+ const listToken = token;
1542
+ const ordered = listToken.ordered;
1543
+ const start = listToken.start;
1544
+ const loose = listToken.loose;
1545
+ let body = "";
1546
+ for (let j = 0; j < listToken.items.length; j++) {
1547
+ const item = listToken.items[j];
1548
+ const checked = item.checked;
1549
+ const task = item.task;
1550
+ let itemBody = "";
1551
+ if (item.task) {
1552
+ const checkbox = this.renderer.checkbox(!!checked);
1553
+ if (loose) {
1554
+ if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
1555
+ item.tokens[0].text = checkbox + " " + item.tokens[0].text;
1556
+ if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
1557
+ item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
1558
+ }
1559
+ } else {
1560
+ item.tokens.unshift({
1561
+ type: "text",
1562
+ text: checkbox + " "
1563
+ });
1564
+ }
1565
+ } else {
1566
+ itemBody += checkbox + " ";
1567
+ }
1568
+ }
1569
+ itemBody += this.parse(item.tokens, loose);
1570
+ body += this.renderer.listitem(itemBody, task, !!checked);
1571
+ }
1572
+ out += this.renderer.list(body, ordered, start);
1573
+ continue;
1574
+ }
1575
+ case "html": {
1576
+ const htmlToken = token;
1577
+ out += this.renderer.html(htmlToken.text, htmlToken.block);
1578
+ continue;
1579
+ }
1580
+ case "paragraph": {
1581
+ const paragraphToken = token;
1582
+ out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
1583
+ continue;
1584
+ }
1585
+ case "text": {
1586
+ let textToken = token;
1587
+ let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
1588
+ while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
1589
+ textToken = tokens[++i];
1590
+ body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
1591
+ }
1592
+ out += top ? this.renderer.paragraph(body) : body;
1593
+ continue;
1594
+ }
1595
+ default: {
1596
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
1597
+ if (this.options.silent) {
1598
+ console.error(errMsg);
1599
+ return "";
1600
+ } else {
1601
+ throw new Error(errMsg);
1602
+ }
1603
+ }
1604
+ }
1605
+ }
1606
+ return out;
1607
+ }
1608
+ /**
1609
+ * Parse Inline Tokens
1610
+ */
1611
+ parseInline(tokens, renderer) {
1612
+ renderer = renderer || this.renderer;
1613
+ let out = "";
1614
+ for (let i = 0; i < tokens.length; i++) {
1615
+ const token = tokens[i];
1616
+ if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
1617
+ const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
1618
+ if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
1619
+ out += ret || "";
1620
+ continue;
1621
+ }
1622
+ }
1623
+ switch (token.type) {
1624
+ case "escape": {
1625
+ const escapeToken = token;
1626
+ out += renderer.text(escapeToken.text);
1627
+ break;
1628
+ }
1629
+ case "html": {
1630
+ const tagToken = token;
1631
+ out += renderer.html(tagToken.text);
1632
+ break;
1633
+ }
1634
+ case "link": {
1635
+ const linkToken = token;
1636
+ out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
1637
+ break;
1638
+ }
1639
+ case "image": {
1640
+ const imageToken = token;
1641
+ out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
1642
+ break;
1643
+ }
1644
+ case "strong": {
1645
+ const strongToken = token;
1646
+ out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
1647
+ break;
1648
+ }
1649
+ case "em": {
1650
+ const emToken = token;
1651
+ out += renderer.em(this.parseInline(emToken.tokens, renderer));
1652
+ break;
1653
+ }
1654
+ case "codespan": {
1655
+ const codespanToken = token;
1656
+ out += renderer.codespan(codespanToken.text);
1657
+ break;
1658
+ }
1659
+ case "br": {
1660
+ out += renderer.br();
1661
+ break;
1662
+ }
1663
+ case "del": {
1664
+ const delToken = token;
1665
+ out += renderer.del(this.parseInline(delToken.tokens, renderer));
1666
+ break;
1667
+ }
1668
+ case "text": {
1669
+ const textToken = token;
1670
+ out += renderer.text(textToken.text);
1671
+ break;
1672
+ }
1673
+ default: {
1674
+ const errMsg = 'Token with "' + token.type + '" type was not found.';
1675
+ if (this.options.silent) {
1676
+ console.error(errMsg);
1677
+ return "";
1678
+ } else {
1679
+ throw new Error(errMsg);
1680
+ }
1681
+ }
1682
+ }
1683
+ }
1684
+ return out;
1685
+ }
1686
+ }
1687
+ class _Hooks {
1688
+ constructor(options) {
1689
+ __publicField(this, "options");
1690
+ this.options = options || _defaults;
1691
+ }
1692
+ /**
1693
+ * Process markdown before marked
1694
+ */
1695
+ preprocess(markdown) {
1696
+ return markdown;
1697
+ }
1698
+ /**
1699
+ * Process HTML after marked is finished
1700
+ */
1701
+ postprocess(html2) {
1702
+ return html2;
1703
+ }
1704
+ /**
1705
+ * Process all tokens before walk tokens
1706
+ */
1707
+ processAllTokens(tokens) {
1708
+ return tokens;
1709
+ }
1710
+ }
1711
+ __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
1712
+ "preprocess",
1713
+ "postprocess",
1714
+ "processAllTokens"
1715
+ ]));
1716
+ class Marked {
1717
+ constructor(...args) {
1718
+ __privateAdd(this, _parseMarkdown);
1719
+ __privateAdd(this, _onError);
1720
+ __publicField(this, "defaults", _getDefaults());
1721
+ __publicField(this, "options", this.setOptions);
1722
+ __publicField(this, "parse", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse));
1723
+ __publicField(this, "parseInline", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline));
1724
+ __publicField(this, "Parser", _Parser);
1725
+ __publicField(this, "Renderer", _Renderer);
1726
+ __publicField(this, "TextRenderer", _TextRenderer);
1727
+ __publicField(this, "Lexer", _Lexer);
1728
+ __publicField(this, "Tokenizer", _Tokenizer);
1729
+ __publicField(this, "Hooks", _Hooks);
1730
+ this.use(...args);
1731
+ }
1732
+ /**
1733
+ * Run callback for every token
1734
+ */
1735
+ walkTokens(tokens, callback) {
1736
+ var _a, _b;
1737
+ let values = [];
1738
+ for (const token of tokens) {
1739
+ values = values.concat(callback.call(this, token));
1740
+ switch (token.type) {
1741
+ case "table": {
1742
+ const tableToken = token;
1743
+ for (const cell of tableToken.header) {
1744
+ values = values.concat(this.walkTokens(cell.tokens, callback));
1745
+ }
1746
+ for (const row of tableToken.rows) {
1747
+ for (const cell of row) {
1748
+ values = values.concat(this.walkTokens(cell.tokens, callback));
1749
+ }
1750
+ }
1751
+ break;
1752
+ }
1753
+ case "list": {
1754
+ const listToken = token;
1755
+ values = values.concat(this.walkTokens(listToken.items, callback));
1756
+ break;
1757
+ }
1758
+ default: {
1759
+ const genericToken = token;
1760
+ if ((_b = (_a = this.defaults.extensions) == null ? void 0 : _a.childTokens) == null ? void 0 : _b[genericToken.type]) {
1761
+ this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
1762
+ const tokens2 = genericToken[childTokens].flat(Infinity);
1763
+ values = values.concat(this.walkTokens(tokens2, callback));
1764
+ });
1765
+ } else if (genericToken.tokens) {
1766
+ values = values.concat(this.walkTokens(genericToken.tokens, callback));
1767
+ }
1768
+ }
1769
+ }
1770
+ }
1771
+ return values;
1772
+ }
1773
+ use(...args) {
1774
+ const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
1775
+ args.forEach((pack) => {
1776
+ const opts = { ...pack };
1777
+ opts.async = this.defaults.async || opts.async || false;
1778
+ if (pack.extensions) {
1779
+ pack.extensions.forEach((ext) => {
1780
+ if (!ext.name) {
1781
+ throw new Error("extension name required");
1782
+ }
1783
+ if ("renderer" in ext) {
1784
+ const prevRenderer = extensions.renderers[ext.name];
1785
+ if (prevRenderer) {
1786
+ extensions.renderers[ext.name] = function(...args2) {
1787
+ let ret = ext.renderer.apply(this, args2);
1788
+ if (ret === false) {
1789
+ ret = prevRenderer.apply(this, args2);
1790
+ }
1791
+ return ret;
1792
+ };
1793
+ } else {
1794
+ extensions.renderers[ext.name] = ext.renderer;
1795
+ }
1796
+ }
1797
+ if ("tokenizer" in ext) {
1798
+ if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
1799
+ throw new Error("extension level must be 'block' or 'inline'");
1800
+ }
1801
+ const extLevel = extensions[ext.level];
1802
+ if (extLevel) {
1803
+ extLevel.unshift(ext.tokenizer);
1804
+ } else {
1805
+ extensions[ext.level] = [ext.tokenizer];
1806
+ }
1807
+ if (ext.start) {
1808
+ if (ext.level === "block") {
1809
+ if (extensions.startBlock) {
1810
+ extensions.startBlock.push(ext.start);
1811
+ } else {
1812
+ extensions.startBlock = [ext.start];
1813
+ }
1814
+ } else if (ext.level === "inline") {
1815
+ if (extensions.startInline) {
1816
+ extensions.startInline.push(ext.start);
1817
+ } else {
1818
+ extensions.startInline = [ext.start];
1819
+ }
1820
+ }
1821
+ }
1822
+ }
1823
+ if ("childTokens" in ext && ext.childTokens) {
1824
+ extensions.childTokens[ext.name] = ext.childTokens;
1825
+ }
1826
+ });
1827
+ opts.extensions = extensions;
1828
+ }
1829
+ if (pack.renderer) {
1830
+ const renderer = this.defaults.renderer || new _Renderer(this.defaults);
1831
+ for (const prop in pack.renderer) {
1832
+ if (!(prop in renderer)) {
1833
+ throw new Error(`renderer '${prop}' does not exist`);
1834
+ }
1835
+ if (prop === "options") {
1836
+ continue;
1837
+ }
1838
+ const rendererProp = prop;
1839
+ const rendererFunc = pack.renderer[rendererProp];
1840
+ const prevRenderer = renderer[rendererProp];
1841
+ renderer[rendererProp] = (...args2) => {
1842
+ let ret = rendererFunc.apply(renderer, args2);
1843
+ if (ret === false) {
1844
+ ret = prevRenderer.apply(renderer, args2);
1845
+ }
1846
+ return ret || "";
1847
+ };
1848
+ }
1849
+ opts.renderer = renderer;
1850
+ }
1851
+ if (pack.tokenizer) {
1852
+ const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
1853
+ for (const prop in pack.tokenizer) {
1854
+ if (!(prop in tokenizer)) {
1855
+ throw new Error(`tokenizer '${prop}' does not exist`);
1856
+ }
1857
+ if (["options", "rules", "lexer"].includes(prop)) {
1858
+ continue;
1859
+ }
1860
+ const tokenizerProp = prop;
1861
+ const tokenizerFunc = pack.tokenizer[tokenizerProp];
1862
+ const prevTokenizer = tokenizer[tokenizerProp];
1863
+ tokenizer[tokenizerProp] = (...args2) => {
1864
+ let ret = tokenizerFunc.apply(tokenizer, args2);
1865
+ if (ret === false) {
1866
+ ret = prevTokenizer.apply(tokenizer, args2);
1867
+ }
1868
+ return ret;
1869
+ };
1870
+ }
1871
+ opts.tokenizer = tokenizer;
1872
+ }
1873
+ if (pack.hooks) {
1874
+ const hooks = this.defaults.hooks || new _Hooks();
1875
+ for (const prop in pack.hooks) {
1876
+ if (!(prop in hooks)) {
1877
+ throw new Error(`hook '${prop}' does not exist`);
1878
+ }
1879
+ if (prop === "options") {
1880
+ continue;
1881
+ }
1882
+ const hooksProp = prop;
1883
+ const hooksFunc = pack.hooks[hooksProp];
1884
+ const prevHook = hooks[hooksProp];
1885
+ if (_Hooks.passThroughHooks.has(prop)) {
1886
+ hooks[hooksProp] = (arg) => {
1887
+ if (this.defaults.async) {
1888
+ return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
1889
+ return prevHook.call(hooks, ret2);
1890
+ });
1891
+ }
1892
+ const ret = hooksFunc.call(hooks, arg);
1893
+ return prevHook.call(hooks, ret);
1894
+ };
1895
+ } else {
1896
+ hooks[hooksProp] = (...args2) => {
1897
+ let ret = hooksFunc.apply(hooks, args2);
1898
+ if (ret === false) {
1899
+ ret = prevHook.apply(hooks, args2);
1900
+ }
1901
+ return ret;
1902
+ };
1903
+ }
1904
+ }
1905
+ opts.hooks = hooks;
1906
+ }
1907
+ if (pack.walkTokens) {
1908
+ const walkTokens = this.defaults.walkTokens;
1909
+ const packWalktokens = pack.walkTokens;
1910
+ opts.walkTokens = function(token) {
1911
+ let values = [];
1912
+ values.push(packWalktokens.call(this, token));
1913
+ if (walkTokens) {
1914
+ values = values.concat(walkTokens.call(this, token));
1915
+ }
1916
+ return values;
1917
+ };
1918
+ }
1919
+ this.defaults = { ...this.defaults, ...opts };
1920
+ });
1921
+ return this;
1922
+ }
1923
+ setOptions(opt) {
1924
+ this.defaults = { ...this.defaults, ...opt };
1925
+ return this;
1926
+ }
1927
+ lexer(src, options) {
1928
+ return _Lexer.lex(src, options ?? this.defaults);
1929
+ }
1930
+ parser(tokens, options) {
1931
+ return _Parser.parse(tokens, options ?? this.defaults);
1932
+ }
1933
+ }
1934
+ _parseMarkdown = new WeakSet();
1935
+ parseMarkdown_fn = function(lexer, parser) {
1936
+ return (src, options) => {
1937
+ const origOpt = { ...options };
1938
+ const opt = { ...this.defaults, ...origOpt };
1939
+ if (this.defaults.async === true && origOpt.async === false) {
1940
+ if (!opt.silent) {
1941
+ console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
1942
+ }
1943
+ opt.async = true;
1944
+ }
1945
+ const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async);
1946
+ if (typeof src === "undefined" || src === null) {
1947
+ return throwError(new Error("marked(): input parameter is undefined or null"));
1948
+ }
1949
+ if (typeof src !== "string") {
1950
+ return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
1951
+ }
1952
+ if (opt.hooks) {
1953
+ opt.hooks.options = opt;
1954
+ }
1955
+ if (opt.async) {
1956
+ return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(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) => parser(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
1957
+ }
1958
+ try {
1959
+ if (opt.hooks) {
1960
+ src = opt.hooks.preprocess(src);
1961
+ }
1962
+ let tokens = lexer(src, opt);
1963
+ if (opt.hooks) {
1964
+ tokens = opt.hooks.processAllTokens(tokens);
1965
+ }
1966
+ if (opt.walkTokens) {
1967
+ this.walkTokens(tokens, opt.walkTokens);
1968
+ }
1969
+ let html2 = parser(tokens, opt);
1970
+ if (opt.hooks) {
1971
+ html2 = opt.hooks.postprocess(html2);
1972
+ }
1973
+ return html2;
1974
+ } catch (e) {
1975
+ return throwError(e);
1976
+ }
1977
+ };
1978
+ };
1979
+ _onError = new WeakSet();
1980
+ onError_fn = function(silent, async) {
1981
+ return (e) => {
1982
+ e.message += "\nPlease report this to https://github.com/markedjs/marked.";
1983
+ if (silent) {
1984
+ const msg = "<p>An error occurred:</p><pre>" + escape$1(e.message + "", true) + "</pre>";
1985
+ if (async) {
1986
+ return Promise.resolve(msg);
1987
+ }
1988
+ return msg;
1989
+ }
1990
+ if (async) {
1991
+ return Promise.reject(e);
1992
+ }
1993
+ throw e;
1994
+ };
1995
+ };
1996
+ const markedInstance = new Marked();
1997
+ function marked(src, opt) {
1998
+ return markedInstance.parse(src, opt);
1999
+ }
2000
+ marked.options = marked.setOptions = function(options) {
2001
+ markedInstance.setOptions(options);
2002
+ marked.defaults = markedInstance.defaults;
2003
+ changeDefaults(marked.defaults);
2004
+ return marked;
2005
+ };
2006
+ marked.getDefaults = _getDefaults;
2007
+ marked.defaults = _defaults;
2008
+ marked.use = function(...args) {
2009
+ markedInstance.use(...args);
2010
+ marked.defaults = markedInstance.defaults;
2011
+ changeDefaults(marked.defaults);
2012
+ return marked;
2013
+ };
2014
+ marked.walkTokens = function(tokens, callback) {
2015
+ return markedInstance.walkTokens(tokens, callback);
2016
+ };
2017
+ marked.parseInline = markedInstance.parseInline;
2018
+ marked.Parser = _Parser;
2019
+ marked.parser = _Parser.parse;
2020
+ marked.Renderer = _Renderer;
2021
+ marked.TextRenderer = _TextRenderer;
2022
+ marked.Lexer = _Lexer;
2023
+ marked.lexer = _Lexer.lex;
2024
+ marked.Tokenizer = _Tokenizer;
2025
+ marked.Hooks = _Hooks;
2026
+ marked.parse = marked;
2027
+ marked.options;
2028
+ marked.setOptions;
2029
+ marked.use;
2030
+ marked.walkTokens;
2031
+ marked.parseInline;
2032
+ _Parser.parse;
2033
+ _Lexer.lex;
2034
+ export {
2035
+ _Hooks as Hooks,
2036
+ _Lexer as Lexer,
2037
+ Marked,
2038
+ _Parser as Parser,
2039
+ _Renderer as Renderer,
2040
+ _TextRenderer as TextRenderer,
2041
+ _Tokenizer as Tokenizer,
2042
+ _defaults as defaults,
2043
+ _getDefaults as getDefaults,
2044
+ marked
2045
+ };