@ant-design/x-markdown-mini 0.1.0-beta.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 (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -0
  3. package/dist/components/Markdown/index.acss +103 -0
  4. package/dist/components/Markdown/index.axml +12 -0
  5. package/dist/components/Markdown/index.js +93 -0
  6. package/dist/components/Markdown/index.json +7 -0
  7. package/dist/components/MiniNodeRenderer/index.acss +11 -0
  8. package/dist/components/MiniNodeRenderer/index.axml +113 -0
  9. package/dist/components/MiniNodeRenderer/index.js +37 -0
  10. package/dist/components/MiniNodeRenderer/index.json +7 -0
  11. package/dist/components/MiniNodeRenderer/index.sjs +63 -0
  12. package/dist/es/Markdown/index.acss +103 -0
  13. package/dist/es/Markdown/index.axml +12 -0
  14. package/dist/es/Markdown/index.js +93 -0
  15. package/dist/es/Markdown/index.json +7 -0
  16. package/dist/es/MiniNodeRenderer/index.acss +11 -0
  17. package/dist/es/MiniNodeRenderer/index.axml +113 -0
  18. package/dist/es/MiniNodeRenderer/index.js +37 -0
  19. package/dist/es/MiniNodeRenderer/index.json +7 -0
  20. package/dist/es/MiniNodeRenderer/index.sjs +63 -0
  21. package/dist/index.d.mts +508 -0
  22. package/dist/index.d.ts +508 -0
  23. package/dist/index.js +3151 -0
  24. package/dist/index.mjs +3111 -0
  25. package/dist/miniprogram_dist/components/Markdown/index.js +85 -0
  26. package/dist/miniprogram_dist/components/Markdown/index.json +10 -0
  27. package/dist/miniprogram_dist/components/Markdown/index.wxml +11 -0
  28. package/dist/miniprogram_dist/components/Markdown/index.wxss +103 -0
  29. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.js +39 -0
  30. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.json +10 -0
  31. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxml +112 -0
  32. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxs +40 -0
  33. package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxss +11 -0
  34. package/dist/miniprogram_dist/es/Markdown/index.js +85 -0
  35. package/dist/miniprogram_dist/es/Markdown/index.json +10 -0
  36. package/dist/miniprogram_dist/es/Markdown/index.wxml +11 -0
  37. package/dist/miniprogram_dist/es/Markdown/index.wxss +103 -0
  38. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.js +39 -0
  39. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.json +10 -0
  40. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxml +112 -0
  41. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxs +40 -0
  42. package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxss +11 -0
  43. package/dist/miniprogram_dist/index.js +3151 -0
  44. package/dist/miniprogram_dist/plugins/CodeHighlight/index.js +8038 -0
  45. package/dist/miniprogram_dist/plugins/CodeHighlight/style.wxss +105 -0
  46. package/dist/miniprogram_dist/plugins/Latex/index.js +14728 -0
  47. package/dist/miniprogram_dist/plugins/Latex/style.wxss +648 -0
  48. package/dist/miniprogram_dist/shared/flattenInline.js +100 -0
  49. package/dist/plugins/CodeHighlight/index.d.mts +27 -0
  50. package/dist/plugins/CodeHighlight/index.d.ts +27 -0
  51. package/dist/plugins/CodeHighlight/index.js +8038 -0
  52. package/dist/plugins/CodeHighlight/index.mjs +8028 -0
  53. package/dist/plugins/CodeHighlight/style.acss +105 -0
  54. package/dist/plugins/Latex/index.d.mts +12 -0
  55. package/dist/plugins/Latex/index.d.ts +12 -0
  56. package/dist/plugins/Latex/index.js +14728 -0
  57. package/dist/plugins/Latex/index.mjs +14705 -0
  58. package/dist/plugins/Latex/style.acss +648 -0
  59. package/dist/shared/flattenInline.js +100 -0
  60. package/dist/types-CegkonfJ.d.mts +83 -0
  61. package/dist/types-CegkonfJ.d.ts +83 -0
  62. package/package.json +93 -0
@@ -0,0 +1,3151 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // src/index.ts
23
+ var src_exports = {};
24
+ __export(src_exports, {
25
+ Footnote: () => Footnote,
26
+ StreamingProcessor: () => StreamingProcessor,
27
+ XMarkdownMini: () => XMarkdownMini,
28
+ alipayRenderer: () => alipayRenderer,
29
+ flattenInlineTokens: () => flattenInlineTokens,
30
+ getPlatformRenderer: () => getPlatformRenderer,
31
+ parse: () => parse,
32
+ registerPlatformRenderer: () => registerPlatformRenderer,
33
+ render: () => render,
34
+ renderNodes: () => renderNodes,
35
+ resolvePlatform: () => resolvePlatform,
36
+ tokensToAlipay: () => tokensToAlipay,
37
+ tokensToAlipayNodes: () => tokensToAlipayNodes,
38
+ tokensToWechat: () => tokensToWechat,
39
+ tokensToWechatNodes: () => tokensToWechatNodes,
40
+ wechatRenderer: () => wechatRenderer
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+
44
+ // node_modules/marked/lib/marked.esm.js
45
+ function z() {
46
+ return { async: false, breaks: false, extensions: null, gfm: true, hooks: null, pedantic: false, renderer: null, silent: false, tokenizer: null, walkTokens: null };
47
+ }
48
+ var T = z();
49
+ function G(l3) {
50
+ T = l3;
51
+ }
52
+ var _ = { exec: () => null };
53
+ function d(l3, e = "") {
54
+ let t = typeof l3 == "string" ? l3 : l3.source, n = { replace: (s, r) => {
55
+ let i = typeof r == "string" ? r : r.source;
56
+ return i = i.replace(m.caret, "$1"), t = t.replace(s, i), n;
57
+ }, getRegex: () => new RegExp(t, e) };
58
+ return n;
59
+ }
60
+ var Re = ((l3 = "") => {
61
+ try {
62
+ return !!new RegExp("(?<=1)(?<!1)" + l3);
63
+ } catch (e) {
64
+ return false;
65
+ }
66
+ })();
67
+ var m = { codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm, outputLinkReplace: /\\([\[\]])/g, indentCodeCompensation: /^(\s+)(?:```)/, beginningSpace: /^\s+/, endingHash: /#$/, startingSpaceChar: /^ /, endingSpaceChar: / $/, nonSpaceChar: /[^ ]/, newLineCharGlobal: /\n/g, tabCharGlobal: /\t/g, multipleSpaceGlobal: /\s+/g, blankLine: /^[ \t]*$/, doubleBlankLine: /\n[ \t]*\n[ \t]*$/, blockquoteStart: /^ {0,3}>/, blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g, blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] +\S/, listReplaceTask: /^\[[ xX]\] +/, listTaskCheckbox: /\[[ xX]\]/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (l3) => new RegExp(`^( {0,3}${l3})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}#`), htmlBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (l3) => new RegExp(`^ {0,${Math.min(3, l3 - 1)}}>`) };
68
+ var Te = /^(?:[ \t]*(?:\n|$))+/;
69
+ var Oe = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
70
+ var we = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
71
+ var I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
72
+ var ye = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
73
+ var Q = / {0,3}(?:[*+-]|\d{1,9}[.)])/;
74
+ var ie = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/;
75
+ var oe = d(ie).replace(/bull/g, Q).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();
76
+ var Pe = d(ie).replace(/bull/g, Q).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();
77
+ var j = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
78
+ var Se = /^[^\n]+/;
79
+ var F = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/;
80
+ var $e = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", F).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
81
+ var Le = d(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex();
82
+ var 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";
83
+ var U = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
84
+ var _e = d("^ {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();
85
+ var ae = d(j).replace("hr", I).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
86
+ var Me = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", ae).getRegex();
87
+ var K = { blockquote: Me, code: Oe, def: $e, fences: we, heading: ye, hr: I, html: _e, lheading: oe, list: Le, newline: Te, paragraph: ae, table: _, text: Se };
88
+ var re = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex();
89
+ var ze = { ...K, lheading: Pe, table: re, paragraph: d(j).replace("hr", I).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[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", v).getRegex() };
90
+ var Ee = { ...K, html: d(`^ *(?: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(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: _, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(j).replace("hr", I).replace("heading", ` *#{1,6} *[^
91
+ ]`).replace("lheading", oe).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() };
92
+ var Ae = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
93
+ var Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
94
+ var le = /^( {2,}|\\)\n(?!\s*$)/;
95
+ var Ie = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
96
+ var E = /[\p{P}\p{S}]/u;
97
+ var H = /[\s\p{P}\p{S}]/u;
98
+ var W = /[^\s\p{P}\p{S}]/u;
99
+ var Be = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, H).getRegex();
100
+ var ue = /(?!~)[\p{P}\p{S}]/u;
101
+ var De = /(?!~)[\s\p{P}\p{S}]/u;
102
+ var qe = /(?:[^\s\p{P}\p{S}]|~)/u;
103
+ var ve = d(/link|precode-code|html/, "g").replace("link", new RegExp("\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)")).replace("precode-", Re ? "(?<!`)()" : "(^^|[^`])").replace("code", new RegExp("(?<b>`+)[^`]+\\k<b>(?!`)")).replace("html", /<(?! )[^<>]*?>/).getRegex();
104
+ var pe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/;
105
+ var He = d(pe, "u").replace(/punct/g, E).getRegex();
106
+ var Ze = d(pe, "u").replace(/punct/g, ue).getRegex();
107
+ var ce = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
108
+ var Ge = d(ce, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
109
+ var Ne = d(ce, "gu").replace(/notPunctSpace/g, qe).replace(/punctSpace/g, De).replace(/punct/g, ue).getRegex();
110
+ var Qe = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
111
+ var je = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, E).getRegex();
112
+ var Fe = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)";
113
+ var Ue = d(Fe, "gu").replace(/notPunctSpace/g, W).replace(/punctSpace/g, H).replace(/punct/g, E).getRegex();
114
+ var Ke = d(/\\(punct)/, "gu").replace(/punct/g, E).getRegex();
115
+ var We = d(/^<(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();
116
+ var Xe = d(U).replace("(?:-->|$)", "-->").getRegex();
117
+ var Je = d("^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", Xe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
118
+ var q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/;
119
+ var Ve = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
120
+ var he = d(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", F).getRegex();
121
+ var ke = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", F).getRegex();
122
+ var Ye = d("reflink|nolink(?!\\()", "g").replace("reflink", he).replace("nolink", ke).getRegex();
123
+ var se = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/;
124
+ var X = { _backpedal: _, anyPunctuation: Ke, autolink: We, blockSkip: ve, br: le, code: Ce, del: _, delLDelim: _, delRDelim: _, emStrongLDelim: He, emStrongRDelimAst: Ge, emStrongRDelimUnd: Qe, escape: Ae, link: Ve, nolink: ke, punctuation: Be, reflink: he, reflinkSearch: Ye, tag: Je, text: Ie, url: _ };
125
+ var et = { ...X, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() };
126
+ var N = { ...X, emStrongRDelimAst: Ne, emStrongLDelim: Ze, delLDelim: je, delRDelim: Ue, url: d(/^((?: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(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {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() };
127
+ var tt = { ...N, br: d(le).replace("{2,}", "*").getRegex(), text: d(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() };
128
+ var B = { normal: K, gfm: ze, pedantic: Ee };
129
+ var A = { normal: X, gfm: N, breaks: tt, pedantic: et };
130
+ var nt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" };
131
+ var de = (l3) => nt[l3];
132
+ function O(l3, e) {
133
+ if (e) {
134
+ if (m.escapeTest.test(l3)) return l3.replace(m.escapeReplace, de);
135
+ } else if (m.escapeTestNoEncode.test(l3)) return l3.replace(m.escapeReplaceNoEncode, de);
136
+ return l3;
137
+ }
138
+ function J(l3) {
139
+ try {
140
+ l3 = encodeURI(l3).replace(m.percentDecode, "%");
141
+ } catch (e) {
142
+ return null;
143
+ }
144
+ return l3;
145
+ }
146
+ function V(l3, e) {
147
+ var _a2;
148
+ let t = l3.replace(m.findPipe, (r, i, o) => {
149
+ let u2 = false, a = i;
150
+ for (; --a >= 0 && o[a] === "\\"; ) u2 = !u2;
151
+ return u2 ? "|" : " |";
152
+ }), n = t.split(m.splitPipe), s = 0;
153
+ if (n[0].trim() || n.shift(), n.length > 0 && !((_a2 = n.at(-1)) == null ? void 0 : _a2.trim()) && n.pop(), e) if (n.length > e) n.splice(e);
154
+ else for (; n.length < e; ) n.push("");
155
+ for (; s < n.length; s++) n[s] = n[s].trim().replace(m.slashPipe, "|");
156
+ return n;
157
+ }
158
+ function $(l3, e, t) {
159
+ let n = l3.length;
160
+ if (n === 0) return "";
161
+ let s = 0;
162
+ for (; s < n; ) {
163
+ let r = l3.charAt(n - s - 1);
164
+ if (r === e && !t) s++;
165
+ else if (r !== e && t) s++;
166
+ else break;
167
+ }
168
+ return l3.slice(0, n - s);
169
+ }
170
+ function Y(l3) {
171
+ let e = l3.split(`
172
+ `), t = e.length - 1;
173
+ for (; t >= 0 && m.blankLine.test(e[t]); ) t--;
174
+ return e.length - t <= 2 ? l3 : e.slice(0, t + 1).join(`
175
+ `);
176
+ }
177
+ function ge(l3, e) {
178
+ if (l3.indexOf(e[1]) === -1) return -1;
179
+ let t = 0;
180
+ for (let n = 0; n < l3.length; n++) if (l3[n] === "\\") n++;
181
+ else if (l3[n] === e[0]) t++;
182
+ else if (l3[n] === e[1] && (t--, t < 0)) return n;
183
+ return t > 0 ? -2 : -1;
184
+ }
185
+ function fe(l3, e = 0) {
186
+ let t = e, n = "";
187
+ for (let s of l3) if (s === " ") {
188
+ let r = 4 - t % 4;
189
+ n += " ".repeat(r), t += r;
190
+ } else n += s, t++;
191
+ return n;
192
+ }
193
+ function me(l3, e, t, n, s) {
194
+ let r = e.href, i = e.title || null, o = l3[1].replace(s.other.outputLinkReplace, "$1");
195
+ n.state.inLink = true;
196
+ let u2 = { type: l3[0].charAt(0) === "!" ? "image" : "link", raw: t, href: r, title: i, text: o, tokens: n.inlineTokens(o) };
197
+ return n.state.inLink = false, u2;
198
+ }
199
+ function rt(l3, e, t) {
200
+ let n = l3.match(t.other.indentCodeCompensation);
201
+ if (n === null) return e;
202
+ let s = n[1];
203
+ return e.split(`
204
+ `).map((r) => {
205
+ let i = r.match(t.other.beginningSpace);
206
+ if (i === null) return r;
207
+ let [o] = i;
208
+ return o.length >= s.length ? r.slice(s.length) : r;
209
+ }).join(`
210
+ `);
211
+ }
212
+ var w = class {
213
+ constructor(e) {
214
+ __publicField(this, "options");
215
+ __publicField(this, "rules");
216
+ __publicField(this, "lexer");
217
+ this.options = e || T;
218
+ }
219
+ space(e) {
220
+ let t = this.rules.block.newline.exec(e);
221
+ if (t && t[0].length > 0) return { type: "space", raw: t[0] };
222
+ }
223
+ code(e) {
224
+ let t = this.rules.block.code.exec(e);
225
+ if (t) {
226
+ let n = this.options.pedantic ? t[0] : Y(t[0]), s = n.replace(this.rules.other.codeRemoveIndent, "");
227
+ return { type: "code", raw: n, codeBlockStyle: "indented", text: s };
228
+ }
229
+ }
230
+ fences(e) {
231
+ let t = this.rules.block.fences.exec(e);
232
+ if (t) {
233
+ let n = t[0], s = rt(n, t[3] || "", this.rules);
234
+ return { type: "code", raw: n, lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2], text: s };
235
+ }
236
+ }
237
+ heading(e) {
238
+ let t = this.rules.block.heading.exec(e);
239
+ if (t) {
240
+ let n = t[2].trim();
241
+ if (this.rules.other.endingHash.test(n)) {
242
+ let s = $(n, "#");
243
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
244
+ }
245
+ return { type: "heading", raw: $(t[0], `
246
+ `), depth: t[1].length, text: n, tokens: this.lexer.inline(n) };
247
+ }
248
+ }
249
+ hr(e) {
250
+ let t = this.rules.block.hr.exec(e);
251
+ if (t) return { type: "hr", raw: $(t[0], `
252
+ `) };
253
+ }
254
+ blockquote(e) {
255
+ let t = this.rules.block.blockquote.exec(e);
256
+ if (t) {
257
+ let n = $(t[0], `
258
+ `).split(`
259
+ `), s = "", r = "", i = [];
260
+ for (; n.length > 0; ) {
261
+ let o = false, u2 = [], a;
262
+ for (a = 0; a < n.length; a++) if (this.rules.other.blockquoteStart.test(n[a])) u2.push(n[a]), o = true;
263
+ else if (!o) u2.push(n[a]);
264
+ else break;
265
+ n = n.slice(a);
266
+ let c2 = u2.join(`
267
+ `), p2 = c2.replace(this.rules.other.blockquoteSetextReplace, `
268
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
269
+ s = s ? `${s}
270
+ ${c2}` : c2, r = r ? `${r}
271
+ ${p2}` : p2;
272
+ let k2 = this.lexer.state.top;
273
+ if (this.lexer.state.top = true, this.lexer.blockTokens(p2, i, true), this.lexer.state.top = k2, n.length === 0) break;
274
+ let h2 = i.at(-1);
275
+ if ((h2 == null ? void 0 : h2.type) === "code") break;
276
+ if ((h2 == null ? void 0 : h2.type) === "blockquote") {
277
+ let R2 = h2, f2 = R2.raw + `
278
+ ` + n.join(`
279
+ `), S2 = this.blockquote(f2);
280
+ i[i.length - 1] = S2, s = s.substring(0, s.length - R2.raw.length) + S2.raw, r = r.substring(0, r.length - R2.text.length) + S2.text;
281
+ break;
282
+ } else if ((h2 == null ? void 0 : h2.type) === "list") {
283
+ let R2 = h2, f2 = R2.raw + `
284
+ ` + n.join(`
285
+ `), S2 = this.list(f2);
286
+ i[i.length - 1] = S2, s = s.substring(0, s.length - h2.raw.length) + S2.raw, r = r.substring(0, r.length - R2.raw.length) + S2.raw, n = f2.substring(i.at(-1).raw.length).split(`
287
+ `);
288
+ continue;
289
+ }
290
+ }
291
+ return { type: "blockquote", raw: s, tokens: i, text: r };
292
+ }
293
+ }
294
+ list(e) {
295
+ let t = this.rules.block.list.exec(e);
296
+ if (t) {
297
+ let n = t[1].trim(), s = n.length > 1, r = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: false, items: [] };
298
+ n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
299
+ let i = this.rules.other.listItemRegex(n), o = false;
300
+ for (; e; ) {
301
+ let a = false, c2 = "", p2 = "";
302
+ if (!(t = i.exec(e)) || this.rules.block.hr.test(e)) break;
303
+ c2 = t[0], e = e.substring(c2.length);
304
+ let k2 = fe(t[2].split(`
305
+ `, 1)[0], t[1].length), h2 = e.split(`
306
+ `, 1)[0], R2 = !k2.trim(), f2 = 0;
307
+ if (this.options.pedantic ? (f2 = 2, p2 = k2.trimStart()) : R2 ? f2 = t[1].length + 1 : (f2 = k2.search(this.rules.other.nonSpaceChar), f2 = f2 > 4 ? 1 : f2, p2 = k2.slice(f2), f2 += t[1].length), R2 && this.rules.other.blankLine.test(h2) && (c2 += h2 + `
308
+ `, e = e.substring(h2.length + 1), a = true), !a) {
309
+ let S2 = this.rules.other.nextBulletRegex(f2), ee = this.rules.other.hrRegex(f2), te = this.rules.other.fencesBeginRegex(f2), ne = this.rules.other.headingBeginRegex(f2), xe = this.rules.other.htmlBeginRegex(f2), be = this.rules.other.blockquoteBeginRegex(f2);
310
+ for (; e; ) {
311
+ let Z2 = e.split(`
312
+ `, 1)[0], C2;
313
+ if (h2 = Z2, this.options.pedantic ? (h2 = h2.replace(this.rules.other.listReplaceNesting, " "), C2 = h2) : C2 = h2.replace(this.rules.other.tabCharGlobal, " "), te.test(h2) || ne.test(h2) || xe.test(h2) || be.test(h2) || S2.test(h2) || ee.test(h2)) break;
314
+ if (C2.search(this.rules.other.nonSpaceChar) >= f2 || !h2.trim()) p2 += `
315
+ ` + C2.slice(f2);
316
+ else {
317
+ if (R2 || k2.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(k2) || ne.test(k2) || ee.test(k2)) break;
318
+ p2 += `
319
+ ` + h2;
320
+ }
321
+ R2 = !h2.trim(), c2 += Z2 + `
322
+ `, e = e.substring(Z2.length + 1), k2 = C2.slice(f2);
323
+ }
324
+ }
325
+ r.loose || (o ? r.loose = true : this.rules.other.doubleBlankLine.test(c2) && (o = true)), r.items.push({ type: "list_item", raw: c2, task: !!this.options.gfm && this.rules.other.listIsTask.test(p2), loose: false, text: p2, tokens: [] }), r.raw += c2;
326
+ }
327
+ let u2 = r.items.at(-1);
328
+ if (u2) u2.raw = u2.raw.trimEnd(), u2.text = u2.text.trimEnd();
329
+ else return;
330
+ r.raw = r.raw.trimEnd();
331
+ for (let a of r.items) {
332
+ this.lexer.state.top = false, a.tokens = this.lexer.blockTokens(a.text, []);
333
+ let c2 = a.tokens[0];
334
+ if (a.task && ((c2 == null ? void 0 : c2.type) === "text" || (c2 == null ? void 0 : c2.type) === "paragraph")) {
335
+ a.text = a.text.replace(this.rules.other.listReplaceTask, ""), c2.raw = c2.raw.replace(this.rules.other.listReplaceTask, ""), c2.text = c2.text.replace(this.rules.other.listReplaceTask, "");
336
+ for (let k2 = this.lexer.inlineQueue.length - 1; k2 >= 0; k2--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[k2].src)) {
337
+ this.lexer.inlineQueue[k2].src = this.lexer.inlineQueue[k2].src.replace(this.rules.other.listReplaceTask, "");
338
+ break;
339
+ }
340
+ let p2 = this.rules.other.listTaskCheckbox.exec(a.raw);
341
+ if (p2) {
342
+ let k2 = { type: "checkbox", raw: p2[0] + " ", checked: p2[0] !== "[ ]" };
343
+ a.checked = k2.checked, r.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = k2.raw + a.tokens[0].raw, a.tokens[0].text = k2.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(k2)) : a.tokens.unshift({ type: "paragraph", raw: k2.raw, text: k2.raw, tokens: [k2] }) : a.tokens.unshift(k2);
344
+ }
345
+ } else a.task && (a.task = false);
346
+ if (!r.loose) {
347
+ let p2 = a.tokens.filter((h2) => h2.type === "space"), k2 = p2.length > 0 && p2.some((h2) => this.rules.other.anyLine.test(h2.raw));
348
+ r.loose = k2;
349
+ }
350
+ }
351
+ if (r.loose) for (let a of r.items) {
352
+ a.loose = true;
353
+ for (let c2 of a.tokens) c2.type === "text" && (c2.type = "paragraph");
354
+ }
355
+ return r;
356
+ }
357
+ }
358
+ html(e) {
359
+ let t = this.rules.block.html.exec(e);
360
+ if (t) {
361
+ let n = Y(t[0]);
362
+ return { type: "html", block: true, raw: n, pre: t[1] === "pre" || t[1] === "script" || t[1] === "style", text: n };
363
+ }
364
+ }
365
+ def(e) {
366
+ let t = this.rules.block.def.exec(e);
367
+ if (t) {
368
+ let n = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
369
+ return { type: "def", tag: n, raw: $(t[0], `
370
+ `), href: s, title: r };
371
+ }
372
+ }
373
+ table(e) {
374
+ var _a2;
375
+ let t = this.rules.block.table.exec(e);
376
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
377
+ let n = V(t[1]), s = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = ((_a2 = t[3]) == null ? void 0 : _a2.trim()) ? t[3].replace(this.rules.other.tableRowBlankLine, "").split(`
378
+ `) : [], i = { type: "table", raw: $(t[0], `
379
+ `), header: [], align: [], rows: [] };
380
+ if (n.length === s.length) {
381
+ for (let o of s) this.rules.other.tableAlignRight.test(o) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(o) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(o) ? i.align.push("left") : i.align.push(null);
382
+ for (let o = 0; o < n.length; o++) i.header.push({ text: n[o], tokens: this.lexer.inline(n[o]), header: true, align: i.align[o] });
383
+ for (let o of r) i.rows.push(V(o, i.header.length).map((u2, a) => ({ text: u2, tokens: this.lexer.inline(u2), header: false, align: i.align[a] })));
384
+ return i;
385
+ }
386
+ }
387
+ lheading(e) {
388
+ let t = this.rules.block.lheading.exec(e);
389
+ if (t) {
390
+ let n = t[1].trim();
391
+ return { type: "heading", raw: $(t[0], `
392
+ `), depth: t[2].charAt(0) === "=" ? 1 : 2, text: n, tokens: this.lexer.inline(n) };
393
+ }
394
+ }
395
+ paragraph(e) {
396
+ let t = this.rules.block.paragraph.exec(e);
397
+ if (t) {
398
+ let n = t[1].charAt(t[1].length - 1) === `
399
+ ` ? t[1].slice(0, -1) : t[1];
400
+ return { type: "paragraph", raw: t[0], text: n, tokens: this.lexer.inline(n) };
401
+ }
402
+ }
403
+ text(e) {
404
+ let t = this.rules.block.text.exec(e);
405
+ if (t) return { type: "text", raw: t[0], text: t[0], tokens: this.lexer.inline(t[0]) };
406
+ }
407
+ escape(e) {
408
+ let t = this.rules.inline.escape.exec(e);
409
+ if (t) return { type: "escape", raw: t[0], text: t[1] };
410
+ }
411
+ tag(e) {
412
+ let t = this.rules.inline.tag.exec(e);
413
+ if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = true : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = false), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = true : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = false), { type: "html", raw: t[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: false, text: t[0] };
414
+ }
415
+ link(e) {
416
+ let t = this.rules.inline.link.exec(e);
417
+ if (t) {
418
+ let n = t[2].trim();
419
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
420
+ if (!this.rules.other.endAngleBracket.test(n)) return;
421
+ let i = $(n.slice(0, -1), "\\");
422
+ if ((n.length - i.length) % 2 === 0) return;
423
+ } else {
424
+ let i = ge(t[2], "()");
425
+ if (i === -2) return;
426
+ if (i > -1) {
427
+ let u2 = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + i;
428
+ t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, u2).trim(), t[3] = "";
429
+ }
430
+ }
431
+ let s = t[2], r = "";
432
+ if (this.options.pedantic) {
433
+ let i = this.rules.other.pedanticHrefTitle.exec(s);
434
+ i && (s = i[1], r = i[3]);
435
+ } else r = t[3] ? t[3].slice(1, -1) : "";
436
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(n) ? s = s.slice(1) : s = s.slice(1, -1)), me(t, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: r && r.replace(this.rules.inline.anyPunctuation, "$1") }, t[0], this.lexer, this.rules);
437
+ }
438
+ }
439
+ reflink(e, t) {
440
+ let n;
441
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
442
+ let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = t[s.toLowerCase()];
443
+ if (!r) {
444
+ let i = n[0].charAt(0);
445
+ return { type: "text", raw: i, text: i };
446
+ }
447
+ return me(n, r, n[0], this.lexer, this.rules);
448
+ }
449
+ }
450
+ emStrong(e, t, n = "") {
451
+ let s = this.rules.inline.emStrongLDelim.exec(e);
452
+ if (!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && n.match(this.rules.other.unicodeAlphaNumeric)) return;
453
+ if (!(s[1] || s[3] || "") || !n || this.rules.inline.punctuation.exec(n)) {
454
+ let i = [...s[0]].length - 1, o, u2, a = i, c2 = 0, p2 = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
455
+ for (p2.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = p2.exec(t)) !== null; ) {
456
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o) continue;
457
+ if (u2 = [...o].length, s[3] || s[4]) {
458
+ a += u2;
459
+ continue;
460
+ } else if ((s[5] || s[6]) && i % 3 && !((i + u2) % 3)) {
461
+ c2 += u2;
462
+ continue;
463
+ }
464
+ if (a -= u2, a > 0) continue;
465
+ u2 = Math.min(u2, u2 + a + c2);
466
+ let k2 = [...s[0]][0].length, h2 = e.slice(0, i + s.index + k2 + u2);
467
+ if (Math.min(i, u2) % 2) {
468
+ let f2 = h2.slice(1, -1);
469
+ return { type: "em", raw: h2, text: f2, tokens: this.lexer.inlineTokens(f2) };
470
+ }
471
+ let R2 = h2.slice(2, -2);
472
+ return { type: "strong", raw: h2, text: R2, tokens: this.lexer.inlineTokens(R2) };
473
+ }
474
+ }
475
+ }
476
+ codespan(e) {
477
+ let t = this.rules.inline.code.exec(e);
478
+ if (t) {
479
+ let n = t[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), r = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
480
+ return s && r && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: t[0], text: n };
481
+ }
482
+ }
483
+ br(e) {
484
+ let t = this.rules.inline.br.exec(e);
485
+ if (t) return { type: "br", raw: t[0] };
486
+ }
487
+ del(e, t, n = "") {
488
+ let s = this.rules.inline.delLDelim.exec(e);
489
+ if (!s) return;
490
+ if (!(s[1] || "") || !n || this.rules.inline.punctuation.exec(n)) {
491
+ let i = [...s[0]].length - 1, o, u2, a = i, c2 = this.rules.inline.delRDelim;
492
+ for (c2.lastIndex = 0, t = t.slice(-1 * e.length + i); (s = c2.exec(t)) !== null; ) {
493
+ if (o = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !o || (u2 = [...o].length, u2 !== i)) continue;
494
+ if (s[3] || s[4]) {
495
+ a += u2;
496
+ continue;
497
+ }
498
+ if (a -= u2, a > 0) continue;
499
+ u2 = Math.min(u2, u2 + a);
500
+ let p2 = [...s[0]][0].length, k2 = e.slice(0, i + s.index + p2 + u2), h2 = k2.slice(i, -i);
501
+ return { type: "del", raw: k2, text: h2, tokens: this.lexer.inlineTokens(h2) };
502
+ }
503
+ }
504
+ }
505
+ autolink(e) {
506
+ let t = this.rules.inline.autolink.exec(e);
507
+ if (t) {
508
+ let n, s;
509
+ return t[2] === "@" ? (n = t[1], s = "mailto:" + n) : (n = t[1], s = n), { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
510
+ }
511
+ }
512
+ url(e) {
513
+ var _a2, _b;
514
+ let t;
515
+ if (t = this.rules.inline.url.exec(e)) {
516
+ let n, s;
517
+ if (t[2] === "@") n = t[0], s = "mailto:" + n;
518
+ else {
519
+ let r;
520
+ do
521
+ r = t[0], t[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(t[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
522
+ while (r !== t[0]);
523
+ n = t[0], t[1] === "www." ? s = "http://" + t[0] : s = t[0];
524
+ }
525
+ return { type: "link", raw: t[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
526
+ }
527
+ }
528
+ inlineText(e) {
529
+ let t = this.rules.inline.text.exec(e);
530
+ if (t) {
531
+ let n = this.lexer.state.inRawBlock;
532
+ return { type: "text", raw: t[0], text: t[0], escaped: n };
533
+ }
534
+ }
535
+ };
536
+ var x = class l {
537
+ constructor(e) {
538
+ __publicField(this, "tokens");
539
+ __publicField(this, "options");
540
+ __publicField(this, "state");
541
+ __publicField(this, "inlineQueue");
542
+ __publicField(this, "tokenizer");
543
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new w(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: false, inRawBlock: false, top: true };
544
+ let t = { other: m, block: B.normal, inline: A.normal };
545
+ this.options.pedantic ? (t.block = B.pedantic, t.inline = A.pedantic) : this.options.gfm && (t.block = B.gfm, this.options.breaks ? t.inline = A.breaks : t.inline = A.gfm), this.tokenizer.rules = t;
546
+ }
547
+ static get rules() {
548
+ return { block: B, inline: A };
549
+ }
550
+ static lex(e, t) {
551
+ return new l(t).lex(e);
552
+ }
553
+ static lexInline(e, t) {
554
+ return new l(t).inlineTokens(e);
555
+ }
556
+ lex(e) {
557
+ e = e.replace(m.carriageReturn, `
558
+ `), this.blockTokens(e, this.tokens);
559
+ for (let t = 0; t < this.inlineQueue.length; t++) {
560
+ let n = this.inlineQueue[t];
561
+ this.inlineTokens(n.src, n.tokens);
562
+ }
563
+ return this.inlineQueue = [], this.tokens;
564
+ }
565
+ blockTokens(e, t = [], n = false) {
566
+ var _a2, _b, _c;
567
+ this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, ""));
568
+ let s = 1 / 0;
569
+ for (; e; ) {
570
+ if (e.length < s) s = e.length;
571
+ else {
572
+ this.infiniteLoopError(e.charCodeAt(0));
573
+ break;
574
+ }
575
+ let r;
576
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.block) == null ? void 0 : _b.some((o) => (r = o.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), true) : false)) continue;
577
+ if (r = this.tokenizer.space(e)) {
578
+ e = e.substring(r.raw.length);
579
+ let o = t.at(-1);
580
+ r.raw.length === 1 && o !== void 0 ? o.raw += `
581
+ ` : t.push(r);
582
+ continue;
583
+ }
584
+ if (r = this.tokenizer.code(e)) {
585
+ e = e.substring(r.raw.length);
586
+ let o = t.at(-1);
587
+ (o == null ? void 0 : o.type) === "paragraph" || (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
588
+ `) ? "" : `
589
+ `) + r.raw, o.text += `
590
+ ` + r.text, this.inlineQueue.at(-1).src = o.text) : t.push(r);
591
+ continue;
592
+ }
593
+ if (r = this.tokenizer.fences(e)) {
594
+ e = e.substring(r.raw.length), t.push(r);
595
+ continue;
596
+ }
597
+ if (r = this.tokenizer.heading(e)) {
598
+ e = e.substring(r.raw.length), t.push(r);
599
+ continue;
600
+ }
601
+ if (r = this.tokenizer.hr(e)) {
602
+ e = e.substring(r.raw.length), t.push(r);
603
+ continue;
604
+ }
605
+ if (r = this.tokenizer.blockquote(e)) {
606
+ e = e.substring(r.raw.length), t.push(r);
607
+ continue;
608
+ }
609
+ if (r = this.tokenizer.list(e)) {
610
+ e = e.substring(r.raw.length), t.push(r);
611
+ continue;
612
+ }
613
+ if (r = this.tokenizer.html(e)) {
614
+ e = e.substring(r.raw.length), t.push(r);
615
+ continue;
616
+ }
617
+ if (r = this.tokenizer.def(e)) {
618
+ e = e.substring(r.raw.length);
619
+ let o = t.at(-1);
620
+ (o == null ? void 0 : o.type) === "paragraph" || (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
621
+ `) ? "" : `
622
+ `) + r.raw, o.text += `
623
+ ` + r.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }, t.push(r));
624
+ continue;
625
+ }
626
+ if (r = this.tokenizer.table(e)) {
627
+ e = e.substring(r.raw.length), t.push(r);
628
+ continue;
629
+ }
630
+ if (r = this.tokenizer.lheading(e)) {
631
+ e = e.substring(r.raw.length), t.push(r);
632
+ continue;
633
+ }
634
+ let i = e;
635
+ if ((_c = this.options.extensions) == null ? void 0 : _c.startBlock) {
636
+ let o = 1 / 0, u2 = e.slice(1), a;
637
+ this.options.extensions.startBlock.forEach((c2) => {
638
+ a = c2.call({ lexer: this }, u2), typeof a == "number" && a >= 0 && (o = Math.min(o, a));
639
+ }), o < 1 / 0 && o >= 0 && (i = e.substring(0, o + 1));
640
+ }
641
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
642
+ let o = t.at(-1);
643
+ n && (o == null ? void 0 : o.type) === "paragraph" ? (o.raw += (o.raw.endsWith(`
644
+ `) ? "" : `
645
+ `) + r.raw, o.text += `
646
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
647
+ continue;
648
+ }
649
+ if (r = this.tokenizer.text(e)) {
650
+ e = e.substring(r.raw.length);
651
+ let o = t.at(-1);
652
+ (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
653
+ `) ? "" : `
654
+ `) + r.raw, o.text += `
655
+ ` + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(r);
656
+ continue;
657
+ }
658
+ if (e) {
659
+ this.infiniteLoopError(e.charCodeAt(0));
660
+ break;
661
+ }
662
+ }
663
+ return this.state.top = true, t;
664
+ }
665
+ inline(e, t = []) {
666
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
667
+ }
668
+ inlineTokens(e, t = []) {
669
+ var _a2, _b, _c, _d, _e2, _f;
670
+ this.tokenizer.lexer = this;
671
+ let n = e, s = null;
672
+ if (this.tokens.links) {
673
+ let a = Object.keys(this.tokens.links);
674
+ if (a.length > 0) for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null; ) a.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
675
+ }
676
+ for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null; ) n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
677
+ let r;
678
+ for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null; ) r = s[2] ? s[2].length : 0, n = n.slice(0, s.index + r) + "[" + "a".repeat(s[0].length - r - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
679
+ n = (_c = (_b = (_a2 = this.options.hooks) == null ? void 0 : _a2.emStrongMask) == null ? void 0 : _b.call({ lexer: this }, n)) != null ? _c : n;
680
+ let i = false, o = "", u2 = 1 / 0;
681
+ for (; e; ) {
682
+ if (e.length < u2) u2 = e.length;
683
+ else {
684
+ this.infiniteLoopError(e.charCodeAt(0));
685
+ break;
686
+ }
687
+ i || (o = ""), i = false;
688
+ let a;
689
+ if ((_e2 = (_d = this.options.extensions) == null ? void 0 : _d.inline) == null ? void 0 : _e2.some((p2) => (a = p2.call({ lexer: this }, e, t)) ? (e = e.substring(a.raw.length), t.push(a), true) : false)) continue;
690
+ if (a = this.tokenizer.escape(e)) {
691
+ e = e.substring(a.raw.length), t.push(a);
692
+ continue;
693
+ }
694
+ if (a = this.tokenizer.tag(e)) {
695
+ e = e.substring(a.raw.length), t.push(a);
696
+ continue;
697
+ }
698
+ if (a = this.tokenizer.link(e)) {
699
+ e = e.substring(a.raw.length), t.push(a);
700
+ continue;
701
+ }
702
+ if (a = this.tokenizer.reflink(e, this.tokens.links)) {
703
+ e = e.substring(a.raw.length);
704
+ let p2 = t.at(-1);
705
+ a.type === "text" && (p2 == null ? void 0 : p2.type) === "text" ? (p2.raw += a.raw, p2.text += a.text) : t.push(a);
706
+ continue;
707
+ }
708
+ if (a = this.tokenizer.emStrong(e, n, o)) {
709
+ e = e.substring(a.raw.length), t.push(a);
710
+ continue;
711
+ }
712
+ if (a = this.tokenizer.codespan(e)) {
713
+ e = e.substring(a.raw.length), t.push(a);
714
+ continue;
715
+ }
716
+ if (a = this.tokenizer.br(e)) {
717
+ e = e.substring(a.raw.length), t.push(a);
718
+ continue;
719
+ }
720
+ if (a = this.tokenizer.del(e, n, o)) {
721
+ e = e.substring(a.raw.length), t.push(a);
722
+ continue;
723
+ }
724
+ if (a = this.tokenizer.autolink(e)) {
725
+ e = e.substring(a.raw.length), t.push(a);
726
+ continue;
727
+ }
728
+ if (!this.state.inLink && (a = this.tokenizer.url(e))) {
729
+ e = e.substring(a.raw.length), t.push(a);
730
+ continue;
731
+ }
732
+ let c2 = e;
733
+ if ((_f = this.options.extensions) == null ? void 0 : _f.startInline) {
734
+ let p2 = 1 / 0, k2 = e.slice(1), h2;
735
+ this.options.extensions.startInline.forEach((R2) => {
736
+ h2 = R2.call({ lexer: this }, k2), typeof h2 == "number" && h2 >= 0 && (p2 = Math.min(p2, h2));
737
+ }), p2 < 1 / 0 && p2 >= 0 && (c2 = e.substring(0, p2 + 1));
738
+ }
739
+ if (a = this.tokenizer.inlineText(c2)) {
740
+ e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (o = a.raw.slice(-1)), i = true;
741
+ let p2 = t.at(-1);
742
+ (p2 == null ? void 0 : p2.type) === "text" ? (p2.raw += a.raw, p2.text += a.text) : t.push(a);
743
+ continue;
744
+ }
745
+ if (e) {
746
+ this.infiniteLoopError(e.charCodeAt(0));
747
+ break;
748
+ }
749
+ }
750
+ return t;
751
+ }
752
+ infiniteLoopError(e) {
753
+ let t = "Infinite loop on byte: " + e;
754
+ if (this.options.silent) console.error(t);
755
+ else throw new Error(t);
756
+ }
757
+ };
758
+ var y = class {
759
+ constructor(e) {
760
+ __publicField(this, "options");
761
+ __publicField(this, "parser");
762
+ this.options = e || T;
763
+ }
764
+ space(e) {
765
+ return "";
766
+ }
767
+ code({ text: e, lang: t, escaped: n }) {
768
+ var _a2;
769
+ let s = (_a2 = (t || "").match(m.notSpaceStart)) == null ? void 0 : _a2[0], r = e.replace(m.endingNewline, "") + `
770
+ `;
771
+ return s ? '<pre><code class="language-' + O(s) + '">' + (n ? r : O(r, true)) + `</code></pre>
772
+ ` : "<pre><code>" + (n ? r : O(r, true)) + `</code></pre>
773
+ `;
774
+ }
775
+ blockquote({ tokens: e }) {
776
+ return `<blockquote>
777
+ ${this.parser.parse(e)}</blockquote>
778
+ `;
779
+ }
780
+ html({ text: e }) {
781
+ return e;
782
+ }
783
+ def(e) {
784
+ return "";
785
+ }
786
+ heading({ tokens: e, depth: t }) {
787
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
788
+ `;
789
+ }
790
+ hr(e) {
791
+ return `<hr>
792
+ `;
793
+ }
794
+ list(e) {
795
+ let t = e.ordered, n = e.start, s = "";
796
+ for (let o = 0; o < e.items.length; o++) {
797
+ let u2 = e.items[o];
798
+ s += this.listitem(u2);
799
+ }
800
+ let r = t ? "ol" : "ul", i = t && n !== 1 ? ' start="' + n + '"' : "";
801
+ return "<" + r + i + `>
802
+ ` + s + "</" + r + `>
803
+ `;
804
+ }
805
+ listitem(e) {
806
+ return `<li>${this.parser.parse(e.tokens)}</li>
807
+ `;
808
+ }
809
+ checkbox({ checked: e }) {
810
+ return "<input " + (e ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
811
+ }
812
+ paragraph({ tokens: e }) {
813
+ return `<p>${this.parser.parseInline(e)}</p>
814
+ `;
815
+ }
816
+ table(e) {
817
+ let t = "", n = "";
818
+ for (let r = 0; r < e.header.length; r++) n += this.tablecell(e.header[r]);
819
+ t += this.tablerow({ text: n });
820
+ let s = "";
821
+ for (let r = 0; r < e.rows.length; r++) {
822
+ let i = e.rows[r];
823
+ n = "";
824
+ for (let o = 0; o < i.length; o++) n += this.tablecell(i[o]);
825
+ s += this.tablerow({ text: n });
826
+ }
827
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
828
+ <thead>
829
+ ` + t + `</thead>
830
+ ` + s + `</table>
831
+ `;
832
+ }
833
+ tablerow({ text: e }) {
834
+ return `<tr>
835
+ ${e}</tr>
836
+ `;
837
+ }
838
+ tablecell(e) {
839
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
840
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
841
+ `;
842
+ }
843
+ strong({ tokens: e }) {
844
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
845
+ }
846
+ em({ tokens: e }) {
847
+ return `<em>${this.parser.parseInline(e)}</em>`;
848
+ }
849
+ codespan({ text: e }) {
850
+ return `<code>${O(e, true)}</code>`;
851
+ }
852
+ br(e) {
853
+ return "<br>";
854
+ }
855
+ del({ tokens: e }) {
856
+ return `<del>${this.parser.parseInline(e)}</del>`;
857
+ }
858
+ link({ href: e, title: t, tokens: n }) {
859
+ let s = this.parser.parseInline(n), r = J(e);
860
+ if (r === null) return s;
861
+ e = r;
862
+ let i = '<a href="' + e + '"';
863
+ return t && (i += ' title="' + O(t) + '"'), i += ">" + s + "</a>", i;
864
+ }
865
+ image({ href: e, title: t, text: n, tokens: s }) {
866
+ s && (n = this.parser.parseInline(s, this.parser.textRenderer));
867
+ let r = J(e);
868
+ if (r === null) return O(n);
869
+ e = r;
870
+ let i = `<img src="${e}" alt="${O(n)}"`;
871
+ return t && (i += ` title="${O(t)}"`), i += ">", i;
872
+ }
873
+ text(e) {
874
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : O(e.text);
875
+ }
876
+ };
877
+ var L = class {
878
+ strong({ text: e }) {
879
+ return e;
880
+ }
881
+ em({ text: e }) {
882
+ return e;
883
+ }
884
+ codespan({ text: e }) {
885
+ return e;
886
+ }
887
+ del({ text: e }) {
888
+ return e;
889
+ }
890
+ html({ text: e }) {
891
+ return e;
892
+ }
893
+ text({ text: e }) {
894
+ return e;
895
+ }
896
+ link({ text: e }) {
897
+ return "" + e;
898
+ }
899
+ image({ text: e }) {
900
+ return "" + e;
901
+ }
902
+ br() {
903
+ return "";
904
+ }
905
+ checkbox({ raw: e }) {
906
+ return e;
907
+ }
908
+ };
909
+ var b = class l2 {
910
+ constructor(e) {
911
+ __publicField(this, "options");
912
+ __publicField(this, "renderer");
913
+ __publicField(this, "textRenderer");
914
+ this.options = e || T, this.options.renderer = this.options.renderer || new y(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new L();
915
+ }
916
+ static parse(e, t) {
917
+ return new l2(t).parse(e);
918
+ }
919
+ static parseInline(e, t) {
920
+ return new l2(t).parseInline(e);
921
+ }
922
+ parse(e) {
923
+ var _a2, _b;
924
+ this.renderer.parser = this;
925
+ let t = "";
926
+ for (let n = 0; n < e.length; n++) {
927
+ let s = e[n];
928
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[s.type]) {
929
+ let i = s, o = this.options.extensions.renderers[i.type].call({ parser: this }, i);
930
+ if (o !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
931
+ t += o || "";
932
+ continue;
933
+ }
934
+ }
935
+ let r = s;
936
+ switch (r.type) {
937
+ case "space": {
938
+ t += this.renderer.space(r);
939
+ break;
940
+ }
941
+ case "hr": {
942
+ t += this.renderer.hr(r);
943
+ break;
944
+ }
945
+ case "heading": {
946
+ t += this.renderer.heading(r);
947
+ break;
948
+ }
949
+ case "code": {
950
+ t += this.renderer.code(r);
951
+ break;
952
+ }
953
+ case "table": {
954
+ t += this.renderer.table(r);
955
+ break;
956
+ }
957
+ case "blockquote": {
958
+ t += this.renderer.blockquote(r);
959
+ break;
960
+ }
961
+ case "list": {
962
+ t += this.renderer.list(r);
963
+ break;
964
+ }
965
+ case "checkbox": {
966
+ t += this.renderer.checkbox(r);
967
+ break;
968
+ }
969
+ case "html": {
970
+ t += this.renderer.html(r);
971
+ break;
972
+ }
973
+ case "def": {
974
+ t += this.renderer.def(r);
975
+ break;
976
+ }
977
+ case "paragraph": {
978
+ t += this.renderer.paragraph(r);
979
+ break;
980
+ }
981
+ case "text": {
982
+ t += this.renderer.text(r);
983
+ break;
984
+ }
985
+ default: {
986
+ let i = 'Token with "' + r.type + '" type was not found.';
987
+ if (this.options.silent) return console.error(i), "";
988
+ throw new Error(i);
989
+ }
990
+ }
991
+ }
992
+ return t;
993
+ }
994
+ parseInline(e, t = this.renderer) {
995
+ var _a2, _b;
996
+ this.renderer.parser = this;
997
+ let n = "";
998
+ for (let s = 0; s < e.length; s++) {
999
+ let r = e[s];
1000
+ if ((_b = (_a2 = this.options.extensions) == null ? void 0 : _a2.renderers) == null ? void 0 : _b[r.type]) {
1001
+ let o = this.options.extensions.renderers[r.type].call({ parser: this }, r);
1002
+ if (o !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(r.type)) {
1003
+ n += o || "";
1004
+ continue;
1005
+ }
1006
+ }
1007
+ let i = r;
1008
+ switch (i.type) {
1009
+ case "escape": {
1010
+ n += t.text(i);
1011
+ break;
1012
+ }
1013
+ case "html": {
1014
+ n += t.html(i);
1015
+ break;
1016
+ }
1017
+ case "link": {
1018
+ n += t.link(i);
1019
+ break;
1020
+ }
1021
+ case "image": {
1022
+ n += t.image(i);
1023
+ break;
1024
+ }
1025
+ case "checkbox": {
1026
+ n += t.checkbox(i);
1027
+ break;
1028
+ }
1029
+ case "strong": {
1030
+ n += t.strong(i);
1031
+ break;
1032
+ }
1033
+ case "em": {
1034
+ n += t.em(i);
1035
+ break;
1036
+ }
1037
+ case "codespan": {
1038
+ n += t.codespan(i);
1039
+ break;
1040
+ }
1041
+ case "br": {
1042
+ n += t.br(i);
1043
+ break;
1044
+ }
1045
+ case "del": {
1046
+ n += t.del(i);
1047
+ break;
1048
+ }
1049
+ case "text": {
1050
+ n += t.text(i);
1051
+ break;
1052
+ }
1053
+ default: {
1054
+ let o = 'Token with "' + i.type + '" type was not found.';
1055
+ if (this.options.silent) return console.error(o), "";
1056
+ throw new Error(o);
1057
+ }
1058
+ }
1059
+ }
1060
+ return n;
1061
+ }
1062
+ };
1063
+ var _a;
1064
+ var P = (_a = class {
1065
+ constructor(e) {
1066
+ __publicField(this, "options");
1067
+ __publicField(this, "block");
1068
+ this.options = e || T;
1069
+ }
1070
+ preprocess(e) {
1071
+ return e;
1072
+ }
1073
+ postprocess(e) {
1074
+ return e;
1075
+ }
1076
+ processAllTokens(e) {
1077
+ return e;
1078
+ }
1079
+ emStrongMask(e) {
1080
+ return e;
1081
+ }
1082
+ provideLexer(e = this.block) {
1083
+ return e ? x.lex : x.lexInline;
1084
+ }
1085
+ provideParser(e = this.block) {
1086
+ return e ? b.parse : b.parseInline;
1087
+ }
1088
+ }, __publicField(_a, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), __publicField(_a, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), _a);
1089
+ var D = class {
1090
+ constructor(...e) {
1091
+ __publicField(this, "defaults", z());
1092
+ __publicField(this, "options", this.setOptions);
1093
+ __publicField(this, "parse", this.parseMarkdown(true));
1094
+ __publicField(this, "parseInline", this.parseMarkdown(false));
1095
+ __publicField(this, "Parser", b);
1096
+ __publicField(this, "Renderer", y);
1097
+ __publicField(this, "TextRenderer", L);
1098
+ __publicField(this, "Lexer", x);
1099
+ __publicField(this, "Tokenizer", w);
1100
+ __publicField(this, "Hooks", P);
1101
+ this.use(...e);
1102
+ }
1103
+ walkTokens(e, t) {
1104
+ var _a2, _b;
1105
+ let n = [];
1106
+ for (let s of e) switch (n = n.concat(t.call(this, s)), s.type) {
1107
+ case "table": {
1108
+ let r = s;
1109
+ for (let i of r.header) n = n.concat(this.walkTokens(i.tokens, t));
1110
+ for (let i of r.rows) for (let o of i) n = n.concat(this.walkTokens(o.tokens, t));
1111
+ break;
1112
+ }
1113
+ case "list": {
1114
+ let r = s;
1115
+ n = n.concat(this.walkTokens(r.items, t));
1116
+ break;
1117
+ }
1118
+ default: {
1119
+ let r = s;
1120
+ ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[r.type]) ? this.defaults.extensions.childTokens[r.type].forEach((i) => {
1121
+ let o = r[i].flat(1 / 0);
1122
+ n = n.concat(this.walkTokens(o, t));
1123
+ }) : r.tokens && (n = n.concat(this.walkTokens(r.tokens, t)));
1124
+ }
1125
+ }
1126
+ return n;
1127
+ }
1128
+ use(...e) {
1129
+ let t = this.defaults.extensions || { renderers: {}, childTokens: {} };
1130
+ return e.forEach((n) => {
1131
+ let s = { ...n };
1132
+ if (s.async = this.defaults.async || s.async || false, n.extensions && (n.extensions.forEach((r) => {
1133
+ if (!r.name) throw new Error("extension name required");
1134
+ if ("renderer" in r) {
1135
+ let i = t.renderers[r.name];
1136
+ i ? t.renderers[r.name] = function(...o) {
1137
+ let u2 = r.renderer.apply(this, o);
1138
+ return u2 === false && (u2 = i.apply(this, o)), u2;
1139
+ } : t.renderers[r.name] = r.renderer;
1140
+ }
1141
+ if ("tokenizer" in r) {
1142
+ if (!r.level || r.level !== "block" && r.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
1143
+ let i = t[r.level];
1144
+ i ? i.unshift(r.tokenizer) : t[r.level] = [r.tokenizer], r.start && (r.level === "block" ? t.startBlock ? t.startBlock.push(r.start) : t.startBlock = [r.start] : r.level === "inline" && (t.startInline ? t.startInline.push(r.start) : t.startInline = [r.start]));
1145
+ }
1146
+ "childTokens" in r && r.childTokens && (t.childTokens[r.name] = r.childTokens);
1147
+ }), s.extensions = t), n.renderer) {
1148
+ let r = this.defaults.renderer || new y(this.defaults);
1149
+ for (let i in n.renderer) {
1150
+ if (!(i in r)) throw new Error(`renderer '${i}' does not exist`);
1151
+ if (["options", "parser"].includes(i)) continue;
1152
+ let o = i, u2 = n.renderer[o], a = r[o];
1153
+ r[o] = (...c2) => {
1154
+ let p2 = u2.apply(r, c2);
1155
+ return p2 === false && (p2 = a.apply(r, c2)), p2 || "";
1156
+ };
1157
+ }
1158
+ s.renderer = r;
1159
+ }
1160
+ if (n.tokenizer) {
1161
+ let r = this.defaults.tokenizer || new w(this.defaults);
1162
+ for (let i in n.tokenizer) {
1163
+ if (!(i in r)) throw new Error(`tokenizer '${i}' does not exist`);
1164
+ if (["options", "rules", "lexer"].includes(i)) continue;
1165
+ let o = i, u2 = n.tokenizer[o], a = r[o];
1166
+ r[o] = (...c2) => {
1167
+ let p2 = u2.apply(r, c2);
1168
+ return p2 === false && (p2 = a.apply(r, c2)), p2;
1169
+ };
1170
+ }
1171
+ s.tokenizer = r;
1172
+ }
1173
+ if (n.hooks) {
1174
+ let r = this.defaults.hooks || new P();
1175
+ for (let i in n.hooks) {
1176
+ if (!(i in r)) throw new Error(`hook '${i}' does not exist`);
1177
+ if (["options", "block"].includes(i)) continue;
1178
+ let o = i, u2 = n.hooks[o], a = r[o];
1179
+ P.passThroughHooks.has(i) ? r[o] = (c2) => {
1180
+ if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
1181
+ let k2 = await u2.call(r, c2);
1182
+ return a.call(r, k2);
1183
+ })();
1184
+ let p2 = u2.call(r, c2);
1185
+ return a.call(r, p2);
1186
+ } : r[o] = (...c2) => {
1187
+ if (this.defaults.async) return (async () => {
1188
+ let k2 = await u2.apply(r, c2);
1189
+ return k2 === false && (k2 = await a.apply(r, c2)), k2;
1190
+ })();
1191
+ let p2 = u2.apply(r, c2);
1192
+ return p2 === false && (p2 = a.apply(r, c2)), p2;
1193
+ };
1194
+ }
1195
+ s.hooks = r;
1196
+ }
1197
+ if (n.walkTokens) {
1198
+ let r = this.defaults.walkTokens, i = n.walkTokens;
1199
+ s.walkTokens = function(o) {
1200
+ let u2 = [];
1201
+ return u2.push(i.call(this, o)), r && (u2 = u2.concat(r.call(this, o))), u2;
1202
+ };
1203
+ }
1204
+ this.defaults = { ...this.defaults, ...s };
1205
+ }), this;
1206
+ }
1207
+ setOptions(e) {
1208
+ return this.defaults = { ...this.defaults, ...e }, this;
1209
+ }
1210
+ lexer(e, t) {
1211
+ return x.lex(e, t != null ? t : this.defaults);
1212
+ }
1213
+ parser(e, t) {
1214
+ return b.parse(e, t != null ? t : this.defaults);
1215
+ }
1216
+ parseMarkdown(e) {
1217
+ return (n, s) => {
1218
+ let r = { ...s }, i = { ...this.defaults, ...r }, o = this.onError(!!i.silent, !!i.async);
1219
+ if (this.defaults.async === true && r.async === false) return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1220
+ if (typeof n > "u" || n === null) return o(new Error("marked(): input parameter is undefined or null"));
1221
+ if (typeof n != "string") return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(n) + ", string expected"));
1222
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
1223
+ let u2 = i.hooks ? await i.hooks.preprocess(n) : n, c2 = await (i.hooks ? await i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(u2, i), p2 = i.hooks ? await i.hooks.processAllTokens(c2) : c2;
1224
+ i.walkTokens && await Promise.all(this.walkTokens(p2, i.walkTokens));
1225
+ let h2 = await (i.hooks ? await i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(p2, i);
1226
+ return i.hooks ? await i.hooks.postprocess(h2) : h2;
1227
+ })().catch(o);
1228
+ try {
1229
+ i.hooks && (n = i.hooks.preprocess(n));
1230
+ let a = (i.hooks ? i.hooks.provideLexer(e) : e ? x.lex : x.lexInline)(n, i);
1231
+ i.hooks && (a = i.hooks.processAllTokens(a)), i.walkTokens && this.walkTokens(a, i.walkTokens);
1232
+ let p2 = (i.hooks ? i.hooks.provideParser(e) : e ? b.parse : b.parseInline)(a, i);
1233
+ return i.hooks && (p2 = i.hooks.postprocess(p2)), p2;
1234
+ } catch (u2) {
1235
+ return o(u2);
1236
+ }
1237
+ };
1238
+ }
1239
+ onError(e, t) {
1240
+ return (n) => {
1241
+ if (n.message += `
1242
+ Please report this to https://github.com/markedjs/marked.`, e) {
1243
+ let s = "<p>An error occurred:</p><pre>" + O(n.message + "", true) + "</pre>";
1244
+ return t ? Promise.resolve(s) : s;
1245
+ }
1246
+ if (t) return Promise.reject(n);
1247
+ throw n;
1248
+ };
1249
+ }
1250
+ };
1251
+ var M = new D();
1252
+ function g(l3, e) {
1253
+ return M.parse(l3, e);
1254
+ }
1255
+ g.options = g.setOptions = function(l3) {
1256
+ return M.setOptions(l3), g.defaults = M.defaults, G(g.defaults), g;
1257
+ };
1258
+ g.getDefaults = z;
1259
+ g.defaults = T;
1260
+ g.use = function(...l3) {
1261
+ return M.use(...l3), g.defaults = M.defaults, G(g.defaults), g;
1262
+ };
1263
+ g.walkTokens = function(l3, e) {
1264
+ return M.walkTokens(l3, e);
1265
+ };
1266
+ g.parseInline = M.parseInline;
1267
+ g.Parser = b;
1268
+ g.parser = b.parse;
1269
+ g.Renderer = y;
1270
+ g.TextRenderer = L;
1271
+ g.Lexer = x;
1272
+ g.lexer = x.lex;
1273
+ g.Tokenizer = w;
1274
+ g.Hooks = P;
1275
+ g.parse = g;
1276
+ var jt = g.options;
1277
+ var Ft = g.setOptions;
1278
+ var Ut = g.use;
1279
+ var Kt = g.walkTokens;
1280
+ var Wt = g.parseInline;
1281
+ var Jt = b.parse;
1282
+ var Vt = x.lex;
1283
+
1284
+ // src/plugins/shared/htmlToMiniNodes.ts
1285
+ function htmlToMiniNodes(html, escapeText) {
1286
+ var _a2;
1287
+ const root = { name: "root", children: [] };
1288
+ const stack = [root];
1289
+ let i = 0;
1290
+ function decode(s) {
1291
+ if (!escapeText) return s;
1292
+ return s.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
1293
+ }
1294
+ function mapTag(tag) {
1295
+ switch (tag) {
1296
+ case "div":
1297
+ case "p":
1298
+ return "div";
1299
+ case "span":
1300
+ case "code":
1301
+ return "span";
1302
+ case "br":
1303
+ return "br";
1304
+ case "img":
1305
+ return "img";
1306
+ case "em":
1307
+ case "i":
1308
+ return "em";
1309
+ case "strong":
1310
+ case "b":
1311
+ return "strong";
1312
+ case "sup":
1313
+ return "sup";
1314
+ case "sub":
1315
+ return "sub";
1316
+ default:
1317
+ return "span";
1318
+ }
1319
+ }
1320
+ while (i < html.length) {
1321
+ if (html[i] === "<") {
1322
+ const closeMatch = /^<\/(\w+)\s*>/.exec(html.slice(i));
1323
+ if (closeMatch) {
1324
+ const closeTag = closeMatch[1].toLowerCase();
1325
+ for (let j3 = stack.length - 1; j3 > 0; j3--) {
1326
+ if (stack[j3].name === mapTag(closeTag)) {
1327
+ stack.length = j3;
1328
+ break;
1329
+ }
1330
+ }
1331
+ i += closeMatch[0].length;
1332
+ continue;
1333
+ }
1334
+ const tagMatch = /^<(\w+)((?:\s+[^>]*?)?)(\/?)>/.exec(html.slice(i));
1335
+ if (tagMatch) {
1336
+ const rawTag = tagMatch[1].toLowerCase();
1337
+ const attrStr = tagMatch[2];
1338
+ const selfClose = tagMatch[3] === "/";
1339
+ if (rawTag === "span" && /\bkatex-mathml\b/.test(attrStr)) {
1340
+ let depth = 1;
1341
+ let si = i + tagMatch[0].length;
1342
+ while (si < html.length && depth > 0) {
1343
+ const next = html.indexOf("<", si);
1344
+ if (next === -1) break;
1345
+ const csm = /^<\/span\s*>/i.exec(html.slice(next));
1346
+ const osm = /^<span[\s>]/i.exec(html.slice(next));
1347
+ if (csm) {
1348
+ depth--;
1349
+ si = next + csm[0].length;
1350
+ } else if (osm) {
1351
+ depth++;
1352
+ si = next + osm[0].length;
1353
+ } else {
1354
+ si = next + 1;
1355
+ }
1356
+ }
1357
+ i = si;
1358
+ continue;
1359
+ }
1360
+ const name = mapTag(rawTag);
1361
+ const attrs = {};
1362
+ const classMatch = /\bclass\s*=\s*"([^"]*)"/.exec(attrStr);
1363
+ if (classMatch) attrs.class = classMatch[1];
1364
+ const styleMatch = /\bstyle\s*=\s*"([^"]*)"/.exec(attrStr);
1365
+ if (styleMatch) attrs.style = styleMatch[1];
1366
+ const srcMatch = /\bsrc\s*=\s*"([^"]*)"/.exec(attrStr);
1367
+ if (srcMatch) attrs.src = srcMatch[1];
1368
+ const altMatch = /\balt\s*=\s*"([^"]*)"/.exec(attrStr);
1369
+ if (altMatch) attrs.alt = altMatch[1];
1370
+ const node = { name, attrs: Object.keys(attrs).length ? attrs : void 0, children: [] };
1371
+ if (selfClose || rawTag === "br") {
1372
+ if (rawTag === "br") {
1373
+ const parent = stack[stack.length - 1];
1374
+ parent.children.push({ name: "text", attrs: { value: "\n" } });
1375
+ } else {
1376
+ stack[stack.length - 1].children.push(node);
1377
+ }
1378
+ } else {
1379
+ stack[stack.length - 1].children.push(node);
1380
+ stack.push(node);
1381
+ }
1382
+ i += tagMatch[0].length;
1383
+ continue;
1384
+ }
1385
+ i++;
1386
+ } else {
1387
+ const nextLt = html.indexOf("<", i);
1388
+ const text = nextLt === -1 ? html.slice(i) : html.slice(i, nextLt);
1389
+ if (text) {
1390
+ const parent = stack[stack.length - 1];
1391
+ const last = parent.children[parent.children.length - 1];
1392
+ if (last && last.name === "text") {
1393
+ last.attrs.value += decode(text);
1394
+ } else {
1395
+ parent.children.push({ name: "text", attrs: { value: decode(text) } });
1396
+ }
1397
+ }
1398
+ i = nextLt === -1 ? html.length : nextLt;
1399
+ }
1400
+ }
1401
+ return (_a2 = root.children) != null ? _a2 : [];
1402
+ }
1403
+
1404
+ // src/platforms/shared/customTokenRenderer.ts
1405
+ function makeRendererThis(_ctx) {
1406
+ return { parser: { parseInline: () => "" } };
1407
+ }
1408
+ function renderCustomToken(token, ctx) {
1409
+ var _a2;
1410
+ const exts = ctx.extensions;
1411
+ if (exts && exts.length > 0) {
1412
+ for (let i = 0; i < exts.length; i++) {
1413
+ const inner = (_a2 = exts[i]) == null ? void 0 : _a2.extensions;
1414
+ if (!inner || inner.length === 0) continue;
1415
+ for (let j3 = 0; j3 < inner.length; j3++) {
1416
+ const tok = inner[j3];
1417
+ if (!tok || tok.name !== token.type) continue;
1418
+ if (typeof tok.miniRenderer === "function") {
1419
+ const rendered = tok.miniRenderer(token, ctx);
1420
+ if (!rendered) return [];
1421
+ return Array.isArray(rendered) ? rendered : [rendered];
1422
+ }
1423
+ if (typeof tok.renderer === "function") {
1424
+ const html = tok.renderer.call(makeRendererThis(ctx), token);
1425
+ if (typeof html !== "string" || html.length === 0) return [];
1426
+ return htmlToMiniNodes(html, ctx.escapeText !== false);
1427
+ }
1428
+ break;
1429
+ }
1430
+ }
1431
+ }
1432
+ return [];
1433
+ }
1434
+
1435
+ // src/platforms/shared/miniNodeRenderer.ts
1436
+ function escapeHtml(text) {
1437
+ let out = "";
1438
+ for (let i = 0; i < text.length; i++) {
1439
+ const ch = text.charCodeAt(i);
1440
+ if (ch === 38) out += "&amp;";
1441
+ else if (ch === 60) out += "&lt;";
1442
+ else if (ch === 62) out += "&gt;";
1443
+ else if (ch === 34) out += "&quot;";
1444
+ else out += text[i];
1445
+ }
1446
+ return out;
1447
+ }
1448
+ function block(name, children, animate, adapter, token, extra) {
1449
+ var _a2;
1450
+ const node = { name };
1451
+ if (extra && Object.keys(extra).length > 0) node.attrs = extra;
1452
+ if (children.length) node.children = children;
1453
+ if (animate) node.animate = true;
1454
+ return (_a2 = adaptNode(adapter, node, { role: "block", token })) != null ? _a2 : node;
1455
+ }
1456
+ function inlineNode(adapter, node, token) {
1457
+ return adaptNode(adapter, compactNode(node), { role: "inline", token });
1458
+ }
1459
+ function compactNode(node) {
1460
+ if (node.attrs && Object.keys(node.attrs).length === 0) {
1461
+ const { attrs: _attrs, ...rest } = node;
1462
+ return rest;
1463
+ }
1464
+ return node;
1465
+ }
1466
+ function adaptNode(adapter, node, meta) {
1467
+ var _a2;
1468
+ const adapted = (_a2 = adapter.node) == null ? void 0 : _a2.call(adapter, node, meta);
1469
+ if (adapted === null) return null;
1470
+ return compactNode(adapted != null ? adapted : node);
1471
+ }
1472
+ function supports(adapter, capability) {
1473
+ var _a2;
1474
+ return ((_a2 = adapter.capabilities) == null ? void 0 : _a2[capability]) !== false;
1475
+ }
1476
+ function textBlock(value, animate, adapter, token) {
1477
+ return block("p", value ? [{ name: "text", attrs: { value } }] : [], animate, adapter, token);
1478
+ }
1479
+ function collectText(nodes) {
1480
+ var _a2, _b;
1481
+ let out = "";
1482
+ for (const node of nodes) {
1483
+ if (node.name === "text") out += String((_b = (_a2 = node.attrs) == null ? void 0 : _a2.value) != null ? _b : "");
1484
+ if (node.children) out += collectText(node.children);
1485
+ }
1486
+ return out;
1487
+ }
1488
+ function renderTokensToMiniNodes(tokens, adapter, ctx = {}) {
1489
+ const animate = ctx.animation === true;
1490
+ const enc = ctx.escapeText === false ? (s) => s : escapeHtml;
1491
+ const localCtx = { ...ctx };
1492
+ localCtx.renderInlineTokens = (inner) => inlineTokens(inner, adapter, enc, localCtx);
1493
+ return blockTokens(tokens, adapter, animate, enc, localCtx);
1494
+ }
1495
+ function blockTokens(tokens, adapter, animate, enc, ctx) {
1496
+ const out = [];
1497
+ for (const tok of tokens) {
1498
+ const node = blockTok(tok, adapter, animate, enc, ctx);
1499
+ if (node) out.push(node);
1500
+ }
1501
+ return out;
1502
+ }
1503
+ function blockTok(tok, adapter, animate, enc, ctx) {
1504
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k, _l, _m;
1505
+ switch (tok.type) {
1506
+ case "space":
1507
+ return null;
1508
+ case "heading": {
1509
+ const t = tok;
1510
+ const depth = Math.min(6, Math.max(1, (_a2 = t.depth) != null ? _a2 : 1));
1511
+ return block(`h${depth}`, inlineTokens((_b = t.tokens) != null ? _b : [], adapter, enc, ctx), animate, adapter, tok);
1512
+ }
1513
+ case "paragraph": {
1514
+ const t = tok;
1515
+ return block("p", inlineTokens((_c = t.tokens) != null ? _c : [], adapter, enc, ctx), animate, adapter, tok);
1516
+ }
1517
+ case "code": {
1518
+ const custom = renderCustomToken(tok, ctx);
1519
+ if (custom.length) return block("pre", custom, animate, adapter, tok);
1520
+ const t = tok;
1521
+ if (!supports(adapter, "supportsPre")) {
1522
+ return textBlock(enc((_d = t.text) != null ? _d : ""), animate, adapter, tok);
1523
+ }
1524
+ const codeChild = {
1525
+ name: "code",
1526
+ children: [{ name: "text", attrs: { value: enc((_e2 = t.text) != null ? _e2 : "") } }]
1527
+ };
1528
+ return block("pre", [codeChild], animate, adapter, tok);
1529
+ }
1530
+ case "hr":
1531
+ return block("hr", [], animate, adapter, tok);
1532
+ case "blockquote": {
1533
+ const t = tok;
1534
+ const children = blockTokens((_f = t.tokens) != null ? _f : [], adapter, animate, enc, ctx);
1535
+ if (!supports(adapter, "supportsBlockquote")) {
1536
+ return textBlock(collectText(children), animate, adapter, tok);
1537
+ }
1538
+ return block("blockquote", children, animate, adapter, tok);
1539
+ }
1540
+ case "list": {
1541
+ const t = tok;
1542
+ const ordered = !!t.ordered;
1543
+ const start = typeof t.start === "number" ? t.start : 1;
1544
+ const tag = ordered ? "ol" : "ul";
1545
+ const children = t.items.map((item) => listItemTok(item, adapter, animate, enc, ctx));
1546
+ return block(tag, children, animate, adapter, tok, ordered ? adapter.olAttrs(start, t) : void 0);
1547
+ }
1548
+ case "html": {
1549
+ const t = tok;
1550
+ const raw = ((_h = (_g = t.text) != null ? _g : t.raw) != null ? _h : "").replace(/\s+$/, "");
1551
+ return block("div", raw ? [{ name: "text", attrs: { value: raw } }] : [], animate, adapter, tok);
1552
+ }
1553
+ case "table": {
1554
+ const t = tok;
1555
+ if (!supports(adapter, "supportsTable")) {
1556
+ const rows = [
1557
+ (_i = t.header) != null ? _i : [],
1558
+ ...(_j = t.rows) != null ? _j : []
1559
+ ];
1560
+ const value = rows.map((row) => row.map((cell) => {
1561
+ var _a3;
1562
+ return collectText(inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx));
1563
+ }).join(" ")).join("\n");
1564
+ return textBlock(value, animate, adapter, tok);
1565
+ }
1566
+ const headCells = ((_k = t.header) != null ? _k : []).map((cell) => {
1567
+ var _a3;
1568
+ return {
1569
+ name: "th",
1570
+ children: inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx)
1571
+ };
1572
+ });
1573
+ const rowNodes = ((_l = t.rows) != null ? _l : []).map((row) => ({
1574
+ name: "tr",
1575
+ children: row.map((cell) => {
1576
+ var _a3;
1577
+ return {
1578
+ name: "td",
1579
+ children: inlineTokens((_a3 = cell.tokens) != null ? _a3 : [], adapter, enc, ctx)
1580
+ };
1581
+ })
1582
+ }));
1583
+ const thead = {
1584
+ name: "thead",
1585
+ children: [{ name: "tr", attrs: {}, children: headCells }]
1586
+ };
1587
+ const tbody = { name: "tbody", attrs: {}, children: rowNodes };
1588
+ return block("table", [compactNode(thead), compactNode(tbody)], animate, adapter, tok);
1589
+ }
1590
+ case "text": {
1591
+ const t = tok;
1592
+ const inline = t.tokens ? inlineTokens(t.tokens, adapter, enc, ctx) : [{ name: "text", attrs: { value: enc((_m = t.text) != null ? _m : "") } }];
1593
+ return block("p", inline, animate, adapter, tok);
1594
+ }
1595
+ case "def":
1596
+ return null;
1597
+ default: {
1598
+ const custom = renderCustomToken(tok, ctx);
1599
+ return custom.length ? block("div", custom, animate, adapter, tok) : null;
1600
+ }
1601
+ }
1602
+ }
1603
+ function listItemTok(item, adapter, animate, enc, ctx) {
1604
+ var _a2, _b, _c, _d;
1605
+ const blocks = (_a2 = item.tokens) != null ? _a2 : [];
1606
+ const children = [];
1607
+ if (blocks.length === 1 && blocks[0].type === "paragraph") {
1608
+ const p2 = blocks[0];
1609
+ children.push(...inlineTokens((_b = p2.tokens) != null ? _b : [], adapter, enc, ctx));
1610
+ } else {
1611
+ for (const b3 of blocks) {
1612
+ if (b3.type === "paragraph") {
1613
+ const p2 = b3;
1614
+ children.push(...inlineTokens((_c = p2.tokens) != null ? _c : [], adapter, enc, ctx));
1615
+ } else if (b3.type === "text") {
1616
+ const t = b3;
1617
+ const inline = t.tokens ? inlineTokens(t.tokens, adapter, enc, ctx) : [{ name: "text", attrs: { value: enc((_d = t.text) != null ? _d : "") } }];
1618
+ children.push(...inline);
1619
+ } else {
1620
+ const node = blockTok(b3, adapter, animate, enc, ctx);
1621
+ if (node) children.push(node);
1622
+ }
1623
+ }
1624
+ }
1625
+ return block("li", children, false, adapter, item);
1626
+ }
1627
+ function inlineTokens(tokens, adapter, enc, ctx) {
1628
+ const out = [];
1629
+ for (const tok of tokens) inlineTok(tok, adapter, enc, out, ctx);
1630
+ return out;
1631
+ }
1632
+ function inlineTok(tok, adapter, enc, out, ctx) {
1633
+ var _a2, _b, _c, _d, _e2, _f, _g, _h, _i, _j, _k;
1634
+ switch (tok.type) {
1635
+ case "text": {
1636
+ const t = tok;
1637
+ if (t.tokens && t.tokens.length) {
1638
+ for (const inner of t.tokens) inlineTok(inner, adapter, enc, out, ctx);
1639
+ } else {
1640
+ const value = enc((_a2 = t.text) != null ? _a2 : "");
1641
+ const node = inlineNode(adapter, { name: "text", attrs: { value } }, tok);
1642
+ if (value && node) out.push(node);
1643
+ }
1644
+ return;
1645
+ }
1646
+ case "escape": {
1647
+ const t = tok;
1648
+ const value = enc((_b = t.text) != null ? _b : "");
1649
+ const node = inlineNode(adapter, { name: "text", attrs: { value } }, tok);
1650
+ if (value && node) out.push(node);
1651
+ return;
1652
+ }
1653
+ case "strong": {
1654
+ const t = tok;
1655
+ const inner = [];
1656
+ for (const c2 of (_c = t.tokens) != null ? _c : []) inlineTok(c2, adapter, enc, inner, ctx);
1657
+ const node = inlineNode(adapter, { name: "strong", children: inner }, tok);
1658
+ if (node) out.push(node);
1659
+ return;
1660
+ }
1661
+ case "em": {
1662
+ const t = tok;
1663
+ const inner = [];
1664
+ for (const c2 of (_d = t.tokens) != null ? _d : []) inlineTok(c2, adapter, enc, inner, ctx);
1665
+ const node = inlineNode(adapter, { name: "em", children: inner }, tok);
1666
+ if (node) out.push(node);
1667
+ return;
1668
+ }
1669
+ case "del": {
1670
+ const t = tok;
1671
+ const inner = [];
1672
+ for (const c2 of (_e2 = t.tokens) != null ? _e2 : []) inlineTok(c2, adapter, enc, inner, ctx);
1673
+ const node = inlineNode(adapter, { name: "del", children: inner }, tok);
1674
+ if (node) out.push(node);
1675
+ return;
1676
+ }
1677
+ case "codespan": {
1678
+ const t = tok;
1679
+ const node = inlineNode(adapter, {
1680
+ name: "code",
1681
+ children: [{ name: "text", attrs: { value: enc((_f = t.text) != null ? _f : "") } }]
1682
+ }, tok);
1683
+ if (node) out.push(node);
1684
+ return;
1685
+ }
1686
+ case "br":
1687
+ {
1688
+ const node = inlineNode(adapter, { name: "br" }, tok);
1689
+ if (node) out.push(node);
1690
+ }
1691
+ return;
1692
+ case "link": {
1693
+ const t = tok;
1694
+ const inner = [];
1695
+ for (const c2 of (_g = t.tokens) != null ? _g : []) inlineTok(c2, adapter, enc, inner, ctx);
1696
+ const node = inlineNode(adapter, {
1697
+ name: "a",
1698
+ attrs: adapter.linkAttrs((_h = t.href) != null ? _h : "", t),
1699
+ children: inner.length ? inner : [{ name: "text", attrs: { value: "" } }]
1700
+ }, tok);
1701
+ if (node) out.push(node);
1702
+ return;
1703
+ }
1704
+ case "image": {
1705
+ const t = tok;
1706
+ const node = inlineNode(
1707
+ adapter,
1708
+ { name: "img", attrs: { src: adapter.imageSrc((_i = t.href) != null ? _i : "", t), alt: (_j = t.text) != null ? _j : "" } },
1709
+ tok
1710
+ );
1711
+ if (node) out.push(node);
1712
+ return;
1713
+ }
1714
+ case "html": {
1715
+ const t = tok;
1716
+ const node = inlineNode(adapter, { name: "text", attrs: { value: enc((_k = t.text) != null ? _k : "") } }, tok);
1717
+ if (node) out.push(node);
1718
+ return;
1719
+ }
1720
+ default: {
1721
+ const custom = renderCustomToken(tok, ctx);
1722
+ if (custom.length) out.push(...custom);
1723
+ return;
1724
+ }
1725
+ }
1726
+ }
1727
+
1728
+ // src/platforms/alipay/tokensToAlipay.ts
1729
+ function buildMarkedOptions(opts) {
1730
+ return { gfm: opts.gfm !== false, breaks: !!opts.breaks };
1731
+ }
1732
+ var alipayCapabilities = {
1733
+ supportsOlStart: false,
1734
+ requiresHttpsImage: true,
1735
+ anchorHrefMode: "href",
1736
+ supportsTable: true,
1737
+ supportsPre: true,
1738
+ supportsBlockquote: true
1739
+ };
1740
+ var alipayAdapter = {
1741
+ capabilities: alipayCapabilities,
1742
+ linkAttrs: (href) => ({ href }),
1743
+ imageSrc: (src) => src.replace(/^http:\/\//, "https://"),
1744
+ olAttrs: () => ({})
1745
+ };
1746
+ function tokensToAlipay(content, opts = {}) {
1747
+ const { options, ...ctx } = opts;
1748
+ const tokens = x.lex(content, buildMarkedOptions(options != null ? options : {}));
1749
+ return tokensToAlipayNodes(tokens, ctx);
1750
+ }
1751
+ function tokensToAlipayNodes(tokens, ctx = {}) {
1752
+ return renderTokensToMiniNodes(tokens, alipayAdapter, ctx);
1753
+ }
1754
+
1755
+ // src/platforms/alipay/index.ts
1756
+ var alipayRenderer = {
1757
+ name: "alipay",
1758
+ capabilities: alipayCapabilities,
1759
+ renderTokens: tokensToAlipayNodes
1760
+ };
1761
+
1762
+ // src/platforms/wechat/tokensToWechat.ts
1763
+ function buildMarkedOptions2(opts) {
1764
+ return { gfm: opts.gfm !== false, breaks: !!opts.breaks };
1765
+ }
1766
+ var wechatCapabilities = {
1767
+ supportsOlStart: true,
1768
+ requiresHttpsImage: false,
1769
+ anchorHrefMode: "data-href",
1770
+ supportsTable: true,
1771
+ supportsPre: true,
1772
+ supportsBlockquote: true
1773
+ };
1774
+ var wechatAdapter = {
1775
+ capabilities: wechatCapabilities,
1776
+ linkAttrs: (href) => ({ "data-href": href, class: "md-link" }),
1777
+ imageSrc: (src) => src,
1778
+ olAttrs: (start) => {
1779
+ const attrs = {};
1780
+ if (start !== 1) attrs.start = start;
1781
+ return attrs;
1782
+ }
1783
+ };
1784
+ function tokensToWechat(content, opts = {}) {
1785
+ const { options, ...ctx } = opts;
1786
+ const tokens = x.lex(content, buildMarkedOptions2(options != null ? options : {}));
1787
+ return tokensToWechatNodes(tokens, ctx);
1788
+ }
1789
+ function tokensToWechatNodes(tokens, ctx = {}) {
1790
+ return renderTokensToMiniNodes(tokens, wechatAdapter, ctx);
1791
+ }
1792
+
1793
+ // src/platforms/wechat/index.ts
1794
+ var wechatRenderer = {
1795
+ name: "wechat",
1796
+ capabilities: wechatCapabilities,
1797
+ renderTokens: tokensToWechatNodes
1798
+ };
1799
+
1800
+ // src/platforms/index.ts
1801
+ var DETECTORS = [
1802
+ {
1803
+ name: "my",
1804
+ read: () => typeof my !== "undefined" ? my : void 0,
1805
+ platform: "alipay"
1806
+ },
1807
+ {
1808
+ name: "wx",
1809
+ read: () => typeof wx !== "undefined" ? wx : void 0,
1810
+ platform: "wechat"
1811
+ }
1812
+ ];
1813
+ var DEFAULT_PLATFORM = "alipay";
1814
+ var RENDERERS = {
1815
+ alipay: alipayRenderer,
1816
+ wechat: wechatRenderer
1817
+ };
1818
+ function isRuntimeObject(obj) {
1819
+ if (!obj || typeof obj !== "object") return false;
1820
+ const target = obj;
1821
+ return typeof target.getSystemInfo === "function" || typeof target.getSystemInfoSync === "function";
1822
+ }
1823
+ function detectPlatformRuntime() {
1824
+ for (const { read, platform } of DETECTORS) {
1825
+ let obj;
1826
+ try {
1827
+ obj = read();
1828
+ } catch (e) {
1829
+ continue;
1830
+ }
1831
+ if (isRuntimeObject(obj)) {
1832
+ return platform;
1833
+ }
1834
+ }
1835
+ return DEFAULT_PLATFORM;
1836
+ }
1837
+ function resolvePlatform(platform) {
1838
+ if (!platform || platform === "auto") return detectPlatformRuntime();
1839
+ return platform;
1840
+ }
1841
+ function getPlatformRenderer(platform) {
1842
+ const renderer = RENDERERS[platform];
1843
+ if (!renderer) {
1844
+ throw new Error(`Unknown platform renderer: ${platform}`);
1845
+ }
1846
+ return renderer;
1847
+ }
1848
+ function registerPlatformRenderer(renderer) {
1849
+ RENDERERS[renderer.name] = renderer;
1850
+ }
1851
+
1852
+ // src/streaming/StreamingProcessor.ts
1853
+ var DEFAULT_DELIMITERS = /[。?!……;:——,、\n]/;
1854
+ var DEFAULT_MAX_CHUNK_SIZE = 80;
1855
+ function isZeroDelay(spec) {
1856
+ if (Array.isArray(spec)) return spec.length === 0 || spec.every((d3) => d3 === 0);
1857
+ return spec === 0;
1858
+ }
1859
+ function resolveDelay(spec, index) {
1860
+ if (Array.isArray(spec)) {
1861
+ if (spec.length === 0) return 0;
1862
+ return spec[Math.min(index, spec.length - 1)];
1863
+ }
1864
+ return spec;
1865
+ }
1866
+ var cachedSegmenter = null;
1867
+ var segmenterResolved = false;
1868
+ function splitGraphemes(text) {
1869
+ if (!segmenterResolved) {
1870
+ segmenterResolved = true;
1871
+ try {
1872
+ const Seg = Intl.Segmenter;
1873
+ if (Seg) cachedSegmenter = new Seg();
1874
+ } catch (e) {
1875
+ cachedSegmenter = null;
1876
+ }
1877
+ }
1878
+ if (cachedSegmenter) {
1879
+ const out = [];
1880
+ for (const s of cachedSegmenter.segment(text)) out.push(s.segment);
1881
+ return out;
1882
+ }
1883
+ return Array.from(text);
1884
+ }
1885
+ var StreamingProcessor = class {
1886
+ constructor(cfg) {
1887
+ this.buffer = "";
1888
+ this.renderedText = "";
1889
+ this.previousMarkdown = "";
1890
+ this.stableNodes = [];
1891
+ this.committedLen = 0;
1892
+ /** Whether the character at committedLen is inside a fenced code block (used for incremental scanning). */
1893
+ this.committedInFence = false;
1894
+ this.committedFenceChar = "";
1895
+ this.pendingChunks = [];
1896
+ this.chunkIndex = 0;
1897
+ /** 已渲染块的累计序号,用于数组变速延迟(charDelay/chunkDelay 为数组时按此取值)。 */
1898
+ this.chunkRenderIndex = 0;
1899
+ this.activeChunk = "";
1900
+ this.activeChunkOffset = 0;
1901
+ this.timer = null;
1902
+ this.currentHasNextChunk = false;
1903
+ var _a2, _b, _c, _d, _e2;
1904
+ this.config = {
1905
+ transform: cfg.transform,
1906
+ fixup: cfg.fixup,
1907
+ onUpdate: cfg.onUpdate,
1908
+ onPatch: cfg.onPatch,
1909
+ onComplete: cfg.onComplete,
1910
+ semanticEnabled: (_a2 = cfg.semanticEnabled) != null ? _a2 : true,
1911
+ delimiters: (_b = cfg.delimiters) != null ? _b : DEFAULT_DELIMITERS,
1912
+ maxChunkSize: (_c = cfg.maxChunkSize) != null ? _c : DEFAULT_MAX_CHUNK_SIZE,
1913
+ chunkDelay: (_d = cfg.chunkDelay) != null ? _d : 0,
1914
+ charDelay: (_e2 = cfg.charDelay) != null ? _e2 : 0
1915
+ };
1916
+ }
1917
+ /** 内容更新:增量则追加到 buffer,否则 reset 后整段替换。 */
1918
+ handleContentUpdate(content) {
1919
+ if (content.startsWith(this.previousMarkdown)) {
1920
+ this.buffer += content.slice(this.previousMarkdown.length);
1921
+ } else {
1922
+ this.reset();
1923
+ this.buffer = content;
1924
+ }
1925
+ this.previousMarkdown = content;
1926
+ }
1927
+ reset() {
1928
+ this.buffer = "";
1929
+ this.renderedText = "";
1930
+ this.previousMarkdown = "";
1931
+ this.pendingChunks = [];
1932
+ this.chunkIndex = 0;
1933
+ this.chunkRenderIndex = 0;
1934
+ this.activeChunk = "";
1935
+ this.activeChunkOffset = 0;
1936
+ this.stableNodes = [];
1937
+ this.committedLen = 0;
1938
+ this.committedInFence = false;
1939
+ this.committedFenceChar = "";
1940
+ this.cancelScheduledRender();
1941
+ }
1942
+ /**
1943
+ * 推进渲染。若 chunk/charDelay 都为 0,立即一次性 flush;否则进入打字机循环。
1944
+ */
1945
+ runRenderLoop(hasNextChunk) {
1946
+ this.currentHasNextChunk = hasNextChunk;
1947
+ const { chunkDelay, charDelay } = this.config;
1948
+ this.cancelScheduledRender();
1949
+ if (isZeroDelay(chunkDelay) && isZeroDelay(charDelay)) {
1950
+ if (this.buffer.length > 0) {
1951
+ this.renderedText += this.buffer;
1952
+ this.buffer = "";
1953
+ }
1954
+ this.flushNodes();
1955
+ if (!hasNextChunk) {
1956
+ this.config.onComplete();
1957
+ }
1958
+ return;
1959
+ }
1960
+ this.splitIntoChunks(hasNextChunk);
1961
+ this.chunkIndex = 0;
1962
+ this.scheduleNext();
1963
+ }
1964
+ /** 当前已输出给 UI 的完整 markdown 字符串 */
1965
+ getRenderedText() {
1966
+ return this.renderedText;
1967
+ }
1968
+ /** 是否还有待处理 chunks(外部可据此判断是否完成) */
1969
+ hasPendingChunks() {
1970
+ return this.chunkIndex < this.pendingChunks.length || this.buffer.length > 0;
1971
+ }
1972
+ // --- 内部 ---
1973
+ /** 按 delimiters + maxChunkSize 把 buffer 切成 chunk 序列;hasNext=false 时 flush 末尾。 */
1974
+ splitIntoChunks(hasNextChunk) {
1975
+ const { semanticEnabled, delimiters = DEFAULT_DELIMITERS, maxChunkSize = DEFAULT_MAX_CHUNK_SIZE } = this.config;
1976
+ const pending = [];
1977
+ let remaining = this.buffer;
1978
+ while (remaining.length > 0) {
1979
+ let chunk = "";
1980
+ if (semanticEnabled) {
1981
+ const m3 = remaining.match(delimiters);
1982
+ const cut = m3 ? remaining.indexOf(m3[0]) + 1 : -1;
1983
+ if (cut > 0) {
1984
+ chunk = remaining.slice(0, cut);
1985
+ remaining = remaining.slice(cut);
1986
+ } else if (remaining.length > maxChunkSize && hasNextChunk) {
1987
+ chunk = remaining.slice(0, maxChunkSize);
1988
+ remaining = remaining.slice(maxChunkSize);
1989
+ } else if (!hasNextChunk) {
1990
+ chunk = remaining;
1991
+ remaining = "";
1992
+ } else {
1993
+ break;
1994
+ }
1995
+ } else if (remaining.length > maxChunkSize) {
1996
+ chunk = remaining.slice(0, maxChunkSize);
1997
+ remaining = remaining.slice(maxChunkSize);
1998
+ } else if (!hasNextChunk) {
1999
+ chunk = remaining;
2000
+ remaining = "";
2001
+ } else {
2002
+ break;
2003
+ }
2004
+ if (chunk.length > 0) pending.push(chunk);
2005
+ }
2006
+ this.pendingChunks = pending;
2007
+ this.buffer = remaining;
2008
+ }
2009
+ scheduleNext() {
2010
+ const { chunkDelay, charDelay, onComplete } = this.config;
2011
+ const interChunkDelay = this.chunkIndex === 0 ? 0 : resolveDelay(chunkDelay, this.chunkRenderIndex);
2012
+ this.timer = setTimeout(() => {
2013
+ if (this.chunkIndex >= this.pendingChunks.length) {
2014
+ if (this.buffer.length > 0) {
2015
+ this.splitIntoChunks(this.currentHasNextChunk);
2016
+ this.scheduleNext();
2017
+ return;
2018
+ }
2019
+ this.timer = null;
2020
+ this.activeChunk = "";
2021
+ this.activeChunkOffset = 0;
2022
+ if (!this.currentHasNextChunk) onComplete();
2023
+ return;
2024
+ }
2025
+ const chunk = this.pendingChunks[this.chunkIndex];
2026
+ this.activeChunk = chunk;
2027
+ this.activeChunkOffset = 0;
2028
+ const cd = resolveDelay(charDelay, this.chunkRenderIndex);
2029
+ const graphemes = cd > 0 ? splitGraphemes(chunk) : null;
2030
+ if (cd > 0 && graphemes && graphemes.length > 1) {
2031
+ let gi = 0;
2032
+ let offset = 0;
2033
+ const step = () => {
2034
+ if (gi < graphemes.length) {
2035
+ const g3 = graphemes[gi++];
2036
+ this.renderedText += g3;
2037
+ offset += g3.length;
2038
+ this.activeChunkOffset = offset;
2039
+ this.flushNodes();
2040
+ this.timer = setTimeout(step, cd);
2041
+ } else {
2042
+ this.activeChunk = "";
2043
+ this.activeChunkOffset = 0;
2044
+ this.chunkIndex += 1;
2045
+ this.chunkRenderIndex += 1;
2046
+ this.scheduleNext();
2047
+ }
2048
+ };
2049
+ step();
2050
+ } else {
2051
+ this.renderedText += chunk;
2052
+ this.activeChunk = "";
2053
+ this.activeChunkOffset = 0;
2054
+ this.chunkIndex += 1;
2055
+ this.chunkRenderIndex += 1;
2056
+ this.flushNodes();
2057
+ this.scheduleNext();
2058
+ }
2059
+ }, interChunkDelay);
2060
+ }
2061
+ cancelScheduledRender() {
2062
+ if (this.timer) {
2063
+ clearTimeout(this.timer);
2064
+ this.timer = null;
2065
+ }
2066
+ let remaining = "";
2067
+ let startIndex = this.chunkIndex;
2068
+ if (this.activeChunk) {
2069
+ remaining += this.activeChunk.slice(this.activeChunkOffset);
2070
+ startIndex = this.chunkIndex + 1;
2071
+ }
2072
+ if (startIndex < this.pendingChunks.length) {
2073
+ remaining += this.pendingChunks.slice(startIndex).join("");
2074
+ }
2075
+ if (remaining) this.buffer = remaining + this.buffer;
2076
+ this.pendingChunks = [];
2077
+ this.chunkIndex = 0;
2078
+ this.activeChunk = "";
2079
+ this.activeChunkOffset = 0;
2080
+ }
2081
+ /** 推进 commit 点:从上次 committedLen 开始增量扫描,找 fenced code 之外的最后一段「双换行」位置。 */
2082
+ advanceCommit() {
2083
+ const text = this.renderedText;
2084
+ if (this.committedLen >= text.length) return;
2085
+ let inFence = this.committedInFence;
2086
+ let fenceChar = this.committedFenceChar;
2087
+ let lineStart = this.committedLen;
2088
+ if (this.committedLen > 0) {
2089
+ let ls = this.committedLen;
2090
+ while (ls > 0 && text[ls - 1] !== "\n") ls--;
2091
+ lineStart = ls;
2092
+ }
2093
+ let lastSafe = -1;
2094
+ let lastSafeInFence = false;
2095
+ let lastSafeFenceChar = "";
2096
+ let prevBlank = false;
2097
+ for (let i = lineStart; i <= text.length; i++) {
2098
+ if (i === text.length || text[i] === "\n") {
2099
+ const line = text.slice(lineStart, i);
2100
+ const fence = /^ {0,3}(`{3,}|~{3,})/.exec(line);
2101
+ if (fence) {
2102
+ if (!inFence) {
2103
+ inFence = true;
2104
+ fenceChar = fence[1][0];
2105
+ } else if (fence[1][0] === fenceChar) {
2106
+ inFence = false;
2107
+ fenceChar = "";
2108
+ }
2109
+ }
2110
+ const isBlank = line.trim() === "";
2111
+ if (!inFence && isBlank && prevBlank) {
2112
+ lastSafe = i === text.length ? i : i + 1;
2113
+ lastSafeInFence = inFence;
2114
+ lastSafeFenceChar = fenceChar;
2115
+ }
2116
+ prevBlank = isBlank && !inFence;
2117
+ lineStart = i + 1;
2118
+ }
2119
+ }
2120
+ if (lastSafe > this.committedLen) {
2121
+ const segment = text.slice(this.committedLen, lastSafe);
2122
+ const nodes = this.config.transform(segment);
2123
+ this.stableNodes.push(...nodes);
2124
+ this.committedLen = lastSafe;
2125
+ this.committedInFence = lastSafeInFence;
2126
+ this.committedFenceChar = lastSafeFenceChar;
2127
+ }
2128
+ }
2129
+ /** 重新解析 tail 部分,与 stableNodes 合并后 emit。 */
2130
+ flushNodes() {
2131
+ const { onUpdate, onPatch, transform, fixup } = this.config;
2132
+ onUpdate(this.renderedText);
2133
+ this.advanceCommit();
2134
+ const tail = this.renderedText.slice(this.committedLen);
2135
+ const fixedTail = tail && fixup ? fixup(tail) : tail;
2136
+ const tailNodes = fixedTail ? transform(fixedTail) : [];
2137
+ onPatch(this.stableNodes.concat(tailNodes));
2138
+ }
2139
+ };
2140
+
2141
+ // node_modules/remend/dist/index.js
2142
+ var cn = Object.defineProperty;
2143
+ var un = Object.defineProperties;
2144
+ var fn = Object.getOwnPropertyDescriptors;
2145
+ var $2 = Object.getOwnPropertySymbols;
2146
+ var dn = Object.prototype.hasOwnProperty;
2147
+ var gn = Object.prototype.propertyIsEnumerable;
2148
+ var O2 = (n, r, e) => r in n ? cn(n, r, { enumerable: true, configurable: true, writable: true, value: e }) : n[r] = e;
2149
+ var I2 = (n, r) => {
2150
+ for (var e in r || (r = {})) dn.call(r, e) && O2(n, e, r[e]);
2151
+ if ($2) for (var e of $2(r)) gn.call(r, e) && O2(n, e, r[e]);
2152
+ return n;
2153
+ };
2154
+ var k = (n, r) => un(n, fn(r));
2155
+ var c = (n, r) => {
2156
+ let e = false, i = false;
2157
+ for (let s = 0; s < r; s += 1) {
2158
+ if (n[s] === "\\" && s + 1 < n.length && n[s + 1] === "`") {
2159
+ s += 1;
2160
+ continue;
2161
+ }
2162
+ if (n.substring(s, s + 3) === "```") {
2163
+ i = !i, s += 2;
2164
+ continue;
2165
+ }
2166
+ !i && n[s] === "`" && (e = !e);
2167
+ }
2168
+ return e || i;
2169
+ };
2170
+ var hn = (n, r) => {
2171
+ let e = n.substring(r, r + 3) === "```", i = r > 0 && n.substring(r - 1, r + 2) === "```", s = r > 1 && n.substring(r - 2, r + 1) === "```";
2172
+ return e || i || s;
2173
+ };
2174
+ var L2 = (n) => {
2175
+ let r = 0;
2176
+ for (let e = 0; e < n.length; e += 1) {
2177
+ if (n[e] === "\\" && e + 1 < n.length && n[e + 1] === "`") {
2178
+ e += 1;
2179
+ continue;
2180
+ }
2181
+ n[e] === "`" && !hn(n, e) && (r += 1);
2182
+ }
2183
+ return r;
2184
+ };
2185
+ var f = (n, r) => {
2186
+ let e = false, i = false, s = -1;
2187
+ for (let o = 0; o < n.length; o += 1) {
2188
+ if (n[o] === "\\" && o + 1 < n.length && n[o + 1] === "`") {
2189
+ o += 1;
2190
+ continue;
2191
+ }
2192
+ if (n.substring(o, o + 3) === "```") {
2193
+ i = !i, o += 2;
2194
+ continue;
2195
+ }
2196
+ if (!i && n[o] === "`") if (e) {
2197
+ if (s < r && r < o) return true;
2198
+ e = false, s = -1;
2199
+ } else e = true, s = o;
2200
+ }
2201
+ return false;
2202
+ };
2203
+ var mn = /^(\s*(?:[-*+]|\d+[.)]) +)>(=?\s*[$]?\d)/gm;
2204
+ var E2 = (n) => !n || typeof n != "string" || !n.includes(">") ? n : n.replace(mn, (r, e, i, s) => c(n, s) ? r : `${e}\\>${i}`);
2205
+ var M2 = /(\*\*)([^*]*\*?)$/;
2206
+ var N2 = /(__)([^_]*?)$/;
2207
+ var y2 = /(\*\*\*)([^*]*?)$/;
2208
+ var R = /(\*)([^*]*?)$/;
2209
+ var U2 = /(_)([^_]*?)$/;
2210
+ var W2 = /(`)([^`]*?)$/;
2211
+ var K2 = /(~~)([^~]*?)$/;
2212
+ var d2 = /^[\s_~*`]*$/;
2213
+ var b2 = /^[\s]*[-*+][\s]+$/;
2214
+ var H2 = /[\p{L}\p{N}_]/u;
2215
+ var D2 = /^```[^`\n]*```?$/;
2216
+ var w2 = /^\*{4,}$/;
2217
+ var G2 = /(__)([^_]+)_$/;
2218
+ var F2 = /(~~)([^~]+)~$/;
2219
+ var T2 = /~~/g;
2220
+ var g2 = (n) => {
2221
+ if (!n) return false;
2222
+ let r = n.charCodeAt(0);
2223
+ return r >= 48 && r <= 57 || r >= 65 && r <= 90 || r >= 97 && r <= 122 || r === 95 ? true : H2.test(n);
2224
+ };
2225
+ var X2 = (n, r) => {
2226
+ let e = 1;
2227
+ for (let i = r - 1; i >= 0; i -= 1) if (n[i] === "]") e += 1;
2228
+ else if (n[i] === "[" && (e -= 1, e === 0)) return i;
2229
+ return -1;
2230
+ };
2231
+ var C = (n, r) => {
2232
+ let e = 1;
2233
+ for (let i = r + 1; i < n.length; i += 1) if (n[i] === "[") e += 1;
2234
+ else if (n[i] === "]" && (e -= 1, e === 0)) return i;
2235
+ return -1;
2236
+ };
2237
+ var h = (n, r) => {
2238
+ let e = false, i = false;
2239
+ for (let s = 0; s < n.length && s < r; s += 1) {
2240
+ if (n[s] === "\\" && n[s + 1] === "$") {
2241
+ s += 1;
2242
+ continue;
2243
+ }
2244
+ n[s] === "$" && (n[s + 1] === "$" ? (i = !i, s += 1, e = false) : i || (e = !e));
2245
+ }
2246
+ return e || i;
2247
+ };
2248
+ var In = (n, r) => {
2249
+ for (let e = r; e < n.length; e += 1) {
2250
+ if (n[e] === ")") return true;
2251
+ if (n[e] === `
2252
+ `) return false;
2253
+ }
2254
+ return false;
2255
+ };
2256
+ var m2 = (n, r) => {
2257
+ for (let e = r - 1; e >= 0; e -= 1) {
2258
+ if (n[e] === ")") return false;
2259
+ if (n[e] === "(") return e > 0 && n[e - 1] === "]" ? In(n, r) : false;
2260
+ if (n[e] === `
2261
+ `) return false;
2262
+ }
2263
+ return false;
2264
+ };
2265
+ var z2 = (n, r) => {
2266
+ for (let e = r - 1; e >= 0; e -= 1) {
2267
+ if (n[e] === ">") return false;
2268
+ if (n[e] === "<") {
2269
+ let i = e + 1 < n.length ? n[e + 1] : "";
2270
+ return i >= "a" && i <= "z" || i >= "A" && i <= "Z" || i === "/";
2271
+ }
2272
+ if (n[e] === `
2273
+ `) return false;
2274
+ }
2275
+ return false;
2276
+ };
2277
+ var p = (n, r, e) => {
2278
+ let i = 0;
2279
+ for (let l3 = r - 1; l3 >= 0; l3 -= 1) if (n[l3] === `
2280
+ `) {
2281
+ i = l3 + 1;
2282
+ break;
2283
+ }
2284
+ let s = n.length;
2285
+ for (let l3 = r; l3 < n.length; l3 += 1) if (n[l3] === `
2286
+ `) {
2287
+ s = l3;
2288
+ break;
2289
+ }
2290
+ let o = n.substring(i, s), t = 0, a = false;
2291
+ for (let l3 of o) if (l3 === e) t += 1;
2292
+ else if (l3 !== " " && l3 !== " ") {
2293
+ a = true;
2294
+ break;
2295
+ }
2296
+ return t >= 3 && !a;
2297
+ };
2298
+ var kn = (n, r, e, i) => e === "\\" || n.includes("$") && h(n, r) ? true : e !== "*" && i === "*" ? (r < n.length - 2 ? n[r + 2] : "") !== "*" : !!(e === "*" || e && i && g2(e) && g2(i) || (!e || e === " " || e === " " || e === `
2299
+ `) && (!i || i === " " || i === " " || i === `
2300
+ `));
2301
+ var Y2 = (n) => {
2302
+ let r = 0, e = false, i = n.length;
2303
+ for (let s = 0; s < i; s += 1) {
2304
+ if (n[s] === "`" && s + 2 < i && n[s + 1] === "`" && n[s + 2] === "`") {
2305
+ e = !e, s += 2;
2306
+ continue;
2307
+ }
2308
+ if (e || n[s] !== "*") continue;
2309
+ let o = s > 0 ? n[s - 1] : "", t = s < i - 1 ? n[s + 1] : "";
2310
+ kn(n, s, o, t) || (r += 1);
2311
+ }
2312
+ return r;
2313
+ };
2314
+ var bn = (n, r, e, i) => !!(e === "\\" || n.includes("$") && h(n, r) || m2(n, r) || z2(n, r) || e === "_" || i === "_" || e && i && g2(e) && g2(i));
2315
+ var Tn = (n) => {
2316
+ let r = 0, e = false, i = n.length;
2317
+ for (let s = 0; s < i; s += 1) {
2318
+ if (n[s] === "`" && s + 2 < i && n[s + 1] === "`" && n[s + 2] === "`") {
2319
+ e = !e, s += 2;
2320
+ continue;
2321
+ }
2322
+ if (e || n[s] !== "_") continue;
2323
+ let o = s > 0 ? n[s - 1] : "", t = s < i - 1 ? n[s + 1] : "";
2324
+ bn(n, s, o, t) || (r += 1);
2325
+ }
2326
+ return r;
2327
+ };
2328
+ var Cn = (n) => {
2329
+ let r = 0, e = 0, i = false;
2330
+ for (let s = 0; s < n.length; s += 1) {
2331
+ if (n[s] === "`" && s + 2 < n.length && n[s + 1] === "`" && n[s + 2] === "`") {
2332
+ e >= 3 && (r += Math.floor(e / 3)), e = 0, i = !i, s += 2;
2333
+ continue;
2334
+ }
2335
+ i || (n[s] === "*" ? e += 1 : (e >= 3 && (r += Math.floor(e / 3)), e = 0));
2336
+ }
2337
+ return e >= 3 && (r += Math.floor(e / 3)), r;
2338
+ };
2339
+ var A2 = (n) => {
2340
+ let r = 0, e = false;
2341
+ for (let i = 0; i < n.length; i += 1) {
2342
+ if (n[i] === "`" && i + 2 < n.length && n[i + 1] === "`" && n[i + 2] === "`") {
2343
+ e = !e, i += 2;
2344
+ continue;
2345
+ }
2346
+ e || n[i] === "*" && i + 1 < n.length && n[i + 1] === "*" && (r += 1, i += 1);
2347
+ }
2348
+ return r;
2349
+ };
2350
+ var v2 = (n) => {
2351
+ let r = 0, e = false;
2352
+ for (let i = 0; i < n.length; i += 1) {
2353
+ if (n[i] === "`" && i + 2 < n.length && n[i + 1] === "`" && n[i + 2] === "`") {
2354
+ e = !e, i += 2;
2355
+ continue;
2356
+ }
2357
+ e || n[i] === "_" && i + 1 < n.length && n[i + 1] === "_" && (r += 1, i += 1);
2358
+ }
2359
+ return r;
2360
+ };
2361
+ var An = (n, r, e) => {
2362
+ if (!r || d2.test(r)) return true;
2363
+ let s = n.substring(0, e).lastIndexOf(`
2364
+ `), o = s === -1 ? 0 : s + 1, t = n.substring(o, e);
2365
+ return b2.test(t) && r.includes(`
2366
+ `) ? true : p(n, e, "*");
2367
+ };
2368
+ var j2 = (n) => {
2369
+ let r = n.match(M2);
2370
+ if (!r) return n;
2371
+ let e = r[2], i = n.lastIndexOf(r[1]);
2372
+ return c(n, i) || f(n, i) || An(n, e, i) ? n : A2(n) % 2 === 1 ? e.endsWith("*") ? `${n}*` : `${n}**` : n;
2373
+ };
2374
+ var Bn = (n, r, e) => {
2375
+ if (!r || d2.test(r)) return true;
2376
+ let s = n.substring(0, e).lastIndexOf(`
2377
+ `), o = s === -1 ? 0 : s + 1, t = n.substring(o, e);
2378
+ return b2.test(t) && r.includes(`
2379
+ `) ? true : p(n, e, "_");
2380
+ };
2381
+ var Q2 = (n) => {
2382
+ let r = n.match(N2);
2383
+ if (!r) {
2384
+ let o = n.match(G2);
2385
+ if (o) {
2386
+ let t = n.lastIndexOf(o[1]);
2387
+ if (!(c(n, t) || f(n, t)) && v2(n) % 2 === 1) return `${n}_`;
2388
+ }
2389
+ return n;
2390
+ }
2391
+ let e = r[2], i = n.lastIndexOf(r[1]);
2392
+ return c(n, i) || f(n, i) || Bn(n, e, i) ? n : v2(n) % 2 === 1 ? `${n}__` : n;
2393
+ };
2394
+ var Sn = (n) => {
2395
+ let r = false;
2396
+ for (let e = 0; e < n.length; e += 1) {
2397
+ if (n[e] === "`" && e + 2 < n.length && n[e + 1] === "`" && n[e + 2] === "`") {
2398
+ r = !r, e += 2;
2399
+ continue;
2400
+ }
2401
+ if (!r && n[e] === "*" && n[e - 1] !== "*" && n[e + 1] !== "*" && n[e - 1] !== "\\" && !h(n, e)) {
2402
+ let i = e > 0 ? n[e - 1] : "", s = e < n.length - 1 ? n[e + 1] : "";
2403
+ if ((!i || i === " " || i === " " || i === `
2404
+ `) && (!s || s === " " || s === " " || s === `
2405
+ `) || i && s && g2(i) && g2(s)) continue;
2406
+ return e;
2407
+ }
2408
+ }
2409
+ return -1;
2410
+ };
2411
+ var Z = (n) => {
2412
+ if (!n.match(R)) return n;
2413
+ let e = Sn(n);
2414
+ if (e === -1 || c(n, e) || f(n, e)) return n;
2415
+ let i = n.substring(e + 1);
2416
+ return !i || d2.test(i) ? n : Y2(n) % 2 === 1 ? `${n}*` : n;
2417
+ };
2418
+ var q2 = (n) => {
2419
+ let r = false;
2420
+ for (let e = 0; e < n.length; e += 1) {
2421
+ if (n[e] === "`" && e + 2 < n.length && n[e + 1] === "`" && n[e + 2] === "`") {
2422
+ r = !r, e += 2;
2423
+ continue;
2424
+ }
2425
+ if (!r && n[e] === "_" && n[e - 1] !== "_" && n[e + 1] !== "_" && n[e - 1] !== "\\" && !h(n, e) && !m2(n, e)) {
2426
+ let i = e > 0 ? n[e - 1] : "", s = e < n.length - 1 ? n[e + 1] : "";
2427
+ if (i && s && g2(i) && g2(s)) continue;
2428
+ return e;
2429
+ }
2430
+ }
2431
+ return -1;
2432
+ };
2433
+ var _n = (n) => {
2434
+ let r = n.length;
2435
+ for (; r > 0 && n[r - 1] === `
2436
+ `; ) r -= 1;
2437
+ if (r < n.length) {
2438
+ let e = n.slice(0, r), i = n.slice(r);
2439
+ return `${e}_${i}`;
2440
+ }
2441
+ return `${n}_`;
2442
+ };
2443
+ var Pn = (n) => {
2444
+ if (!n.endsWith("**")) return null;
2445
+ let r = n.slice(0, -2);
2446
+ if (A2(r) % 2 !== 1) return null;
2447
+ let i = r.indexOf("**"), s = q2(r);
2448
+ return i !== -1 && s !== -1 && i < s ? `${r}_**` : null;
2449
+ };
2450
+ var J2 = (n) => {
2451
+ if (!n.match(U2)) return n;
2452
+ let e = q2(n);
2453
+ if (e === -1) return n;
2454
+ let i = n.substring(e + 1);
2455
+ if (!i || d2.test(i) || c(n, e) || f(n, e)) return n;
2456
+ if (Tn(n) % 2 === 1) {
2457
+ let o = Pn(n);
2458
+ return o !== null ? o : _n(n);
2459
+ }
2460
+ return n;
2461
+ };
2462
+ var $n = (n) => {
2463
+ let r = A2(n), e = Y2(n);
2464
+ return r % 2 === 0 && e % 2 === 0;
2465
+ };
2466
+ var On = (n, r, e) => !r || d2.test(r) || c(n, e) || f(n, e) ? true : p(n, e, "*");
2467
+ var V2 = (n) => {
2468
+ if (w2.test(n)) return n;
2469
+ let r = n.match(y2);
2470
+ if (!r) return n;
2471
+ let e = r[2], i = n.lastIndexOf(r[1]);
2472
+ return On(n, e, i) ? n : Cn(n) % 2 === 1 ? $n(n) ? n : `${n}***` : n;
2473
+ };
2474
+ var Ln = /<[a-zA-Z/][^>]*$/;
2475
+ var x2 = (n) => {
2476
+ let r = n.match(Ln);
2477
+ return !r || r.index === void 0 || c(n, r.index) ? n : n.substring(0, r.index).trimEnd();
2478
+ };
2479
+ var En = (n) => !n.match(D2) || n.includes(`
2480
+ `) ? null : n.endsWith("``") && !n.endsWith("```") ? `${n}\`` : n;
2481
+ var Mn = (n) => (n.match(/```/g) || []).length % 2 === 1;
2482
+ var nn = (n) => {
2483
+ let r = En(n);
2484
+ if (r !== null) return r;
2485
+ let e = n.match(W2);
2486
+ if (e && !Mn(n)) {
2487
+ let i = e[2];
2488
+ if (!i || d2.test(i)) return n;
2489
+ if (L2(n) % 2 === 1) return `${n}\``;
2490
+ }
2491
+ return n;
2492
+ };
2493
+ var en = (n, r) => r >= 2 && n.substring(r - 2, r + 1) === "```" || r >= 1 && n.substring(r - 1, r + 2) === "```" || r <= n.length - 3 && n.substring(r, r + 3) === "```";
2494
+ var Nn = (n) => {
2495
+ let r = 0, e = false;
2496
+ for (let i = 0; i < n.length - 1; i += 1) n[i] === "`" && !en(n, i) && (e = !e), !e && n[i] === "$" && n[i + 1] === "$" && (r += 1, i += 1);
2497
+ return r;
2498
+ };
2499
+ var yn = (n) => {
2500
+ let r = 0, e = false;
2501
+ for (let i = 0; i < n.length; i += 1) {
2502
+ if (n[i] === "\\") {
2503
+ i += 1;
2504
+ continue;
2505
+ }
2506
+ if (n[i] === "`" && !en(n, i)) {
2507
+ e = !e;
2508
+ continue;
2509
+ }
2510
+ !e && n[i] === "$" && (i + 1 < n.length && n[i + 1] === "$" ? i += 1 : r += 1);
2511
+ }
2512
+ return r;
2513
+ };
2514
+ var Rn = (n) => {
2515
+ if (n.endsWith("$") && !n.endsWith("$$")) return `${n}$`;
2516
+ let r = n.indexOf("$$");
2517
+ return r !== -1 && n.indexOf(`
2518
+ `, r) !== -1 && !n.endsWith(`
2519
+ `) ? `${n}
2520
+ $$` : `${n}$$`;
2521
+ };
2522
+ var rn = (n) => Nn(n) % 2 === 0 ? n : Rn(n);
2523
+ var sn = (n) => yn(n) % 2 === 1 ? `${n}$` : n;
2524
+ var Un = (n, r, e) => {
2525
+ if (n.substring(r + 2).includes(")")) return null;
2526
+ let s = X2(n, r);
2527
+ if (s === -1 || c(n, s)) return null;
2528
+ let o = s > 0 && n[s - 1] === "!", t = o ? s - 1 : s, a = n.substring(0, t);
2529
+ if (o) return a;
2530
+ let l3 = n.substring(s + 1, r);
2531
+ return e === "text-only" ? `${a}${l3}` : `${a}[${l3}](streamdown:incomplete-link)`;
2532
+ };
2533
+ var on = (n, r) => {
2534
+ for (let e = 0; e < r; e++) if (n[e] === "[" && !c(n, e)) {
2535
+ if (e > 0 && n[e - 1] === "!") continue;
2536
+ let i = C(n, e);
2537
+ if (i === -1) return e;
2538
+ if (i + 1 < n.length && n[i + 1] === "(") {
2539
+ let s = n.indexOf(")", i + 2);
2540
+ s !== -1 && (e = s);
2541
+ }
2542
+ }
2543
+ return r;
2544
+ };
2545
+ var Wn = (n, r, e) => {
2546
+ let i = r > 0 && n[r - 1] === "!", s = i ? r - 1 : r;
2547
+ if (!n.substring(r + 1).includes("]")) {
2548
+ let a = n.substring(0, s);
2549
+ if (i) return a;
2550
+ if (e === "text-only") {
2551
+ let l3 = on(n, r);
2552
+ return n.substring(0, l3) + n.substring(l3 + 1);
2553
+ }
2554
+ return `${n}](streamdown:incomplete-link)`;
2555
+ }
2556
+ if (C(n, r) === -1) {
2557
+ let a = n.substring(0, s);
2558
+ if (i) return a;
2559
+ if (e === "text-only") {
2560
+ let l3 = on(n, r);
2561
+ return n.substring(0, l3) + n.substring(l3 + 1);
2562
+ }
2563
+ return `${n}](streamdown:incomplete-link)`;
2564
+ }
2565
+ return null;
2566
+ };
2567
+ var B2 = (n, r = "protocol") => {
2568
+ let e = n.lastIndexOf("](");
2569
+ if (e !== -1 && !c(n, e)) {
2570
+ let i = Un(n, e, r);
2571
+ if (i !== null) return i;
2572
+ }
2573
+ for (let i = n.length - 1; i >= 0; i -= 1) if (n[i] === "[" && !c(n, i)) {
2574
+ let s = Wn(n, i, r);
2575
+ if (s !== null) return s;
2576
+ }
2577
+ return n;
2578
+ };
2579
+ var Kn = /^-{1,2}$/;
2580
+ var Hn = /^[\s]*-{1,2}[\s]+$/;
2581
+ var Dn = /^={1,2}$/;
2582
+ var wn = /^[\s]*={1,2}[\s]+$/;
2583
+ var ln = (n) => {
2584
+ if (!n || typeof n != "string") return n;
2585
+ let r = n.lastIndexOf(`
2586
+ `);
2587
+ if (r === -1) return n;
2588
+ let e = n.substring(r + 1), i = n.substring(0, r), s = e.trim();
2589
+ if (Kn.test(s) && !e.match(Hn)) {
2590
+ let t = i.split(`
2591
+ `).at(-1);
2592
+ if (t && t.trim().length > 0) return `${n}\u200B`;
2593
+ }
2594
+ if (Dn.test(s) && !e.match(wn)) {
2595
+ let t = i.split(`
2596
+ `).at(-1);
2597
+ if (t && t.trim().length > 0) return `${n}\u200B`;
2598
+ }
2599
+ return n;
2600
+ };
2601
+ var Gn = new RegExp("(?<=[\\p{L}\\p{N}_])~(?!~)(?=[\\p{L}\\p{N}_])", "gu");
2602
+ var tn = (n) => !n || typeof n != "string" || !n.includes("~") ? n : n.replace(Gn, (r, e) => c(n, e) ? r : "\\~");
2603
+ var an = (n) => {
2604
+ var e, i;
2605
+ let r = n.match(K2);
2606
+ if (r) {
2607
+ let s = r[2];
2608
+ if (!s || d2.test(s)) return n;
2609
+ let o = n.lastIndexOf(r[1]);
2610
+ if (c(n, o) || f(n, o)) return n;
2611
+ if (((e = n.match(T2)) == null ? void 0 : e.length) % 2 === 1) return `${n}~~`;
2612
+ } else {
2613
+ let s = n.match(F2);
2614
+ if (s) {
2615
+ let o = n.lastIndexOf(s[0].slice(0, 2));
2616
+ if (c(n, o) || f(n, o)) return n;
2617
+ if (((i = n.match(T2)) == null ? void 0 : i.length) % 2 === 1) return `${n}~`;
2618
+ }
2619
+ }
2620
+ return n;
2621
+ };
2622
+ var S = (n) => n !== false;
2623
+ var Fn = (n) => n === true;
2624
+ var u = { SINGLE_TILDE: 0, COMPARISON_OPERATORS: 5, HTML_TAGS: 10, SETEXT_HEADINGS: 15, LINKS: 20, BOLD_ITALIC: 30, BOLD: 35, ITALIC_DOUBLE_UNDERSCORE: 40, ITALIC_SINGLE_ASTERISK: 41, ITALIC_SINGLE_UNDERSCORE: 42, INLINE_CODE: 50, STRIKETHROUGH: 60, KATEX: 70, INLINE_KATEX: 75, DEFAULT: 100 };
2625
+ var Xn = [{ handler: { name: "singleTilde", handle: tn, priority: u.SINGLE_TILDE }, optionKey: "singleTilde" }, { handler: { name: "comparisonOperators", handle: E2, priority: u.COMPARISON_OPERATORS }, optionKey: "comparisonOperators" }, { handler: { name: "htmlTags", handle: x2, priority: u.HTML_TAGS }, optionKey: "htmlTags" }, { handler: { name: "setextHeadings", handle: ln, priority: u.SETEXT_HEADINGS }, optionKey: "setextHeadings" }, { handler: { name: "links", handle: B2, priority: u.LINKS }, optionKey: "links", earlyReturn: (n) => n.endsWith("](streamdown:incomplete-link)") }, { handler: { name: "boldItalic", handle: V2, priority: u.BOLD_ITALIC }, optionKey: "boldItalic" }, { handler: { name: "bold", handle: j2, priority: u.BOLD }, optionKey: "bold" }, { handler: { name: "italicDoubleUnderscore", handle: Q2, priority: u.ITALIC_DOUBLE_UNDERSCORE }, optionKey: "italic" }, { handler: { name: "italicSingleAsterisk", handle: Z, priority: u.ITALIC_SINGLE_ASTERISK }, optionKey: "italic" }, { handler: { name: "italicSingleUnderscore", handle: J2, priority: u.ITALIC_SINGLE_UNDERSCORE }, optionKey: "italic" }, { handler: { name: "inlineCode", handle: nn, priority: u.INLINE_CODE }, optionKey: "inlineCode" }, { handler: { name: "strikethrough", handle: an, priority: u.STRIKETHROUGH }, optionKey: "strikethrough" }, { handler: { name: "katex", handle: rn, priority: u.KATEX }, optionKey: "katex" }, { handler: { name: "inlineKatex", handle: sn, priority: u.INLINE_KATEX }, optionKey: "inlineKatex" }];
2626
+ var zn = (n) => {
2627
+ var e;
2628
+ let r = (e = n == null ? void 0 : n.linkMode) != null ? e : "protocol";
2629
+ return Xn.filter(({ handler: i, optionKey: s }) => i.name === "links" ? S(n == null ? void 0 : n.links) || S(n == null ? void 0 : n.images) : i.name === "inlineKatex" ? Fn(n == null ? void 0 : n.inlineKatex) : S(n == null ? void 0 : n[s])).map(({ handler: i, earlyReturn: s }) => i.name === "links" ? { handler: k(I2({}, i), { handle: (o) => B2(o, r) }), earlyReturn: r === "protocol" ? s : void 0 } : { handler: i, earlyReturn: s });
2630
+ };
2631
+ var vn = (n, r) => {
2632
+ var t;
2633
+ if (!n || typeof n != "string") return n;
2634
+ let e = n.endsWith(" ") && !n.endsWith(" ") ? n.slice(0, -1) : n, i = zn(r), s = ((t = r == null ? void 0 : r.handlers) != null ? t : []).map((a) => {
2635
+ var l3;
2636
+ return { handler: k(I2({}, a), { priority: (l3 = a.priority) != null ? l3 : u.DEFAULT }), earlyReturn: void 0 };
2637
+ }), o = [...i, ...s].sort((a, l3) => {
2638
+ var _2, P2;
2639
+ return ((_2 = a.handler.priority) != null ? _2 : 0) - ((P2 = l3.handler.priority) != null ? P2 : 0);
2640
+ });
2641
+ for (let { handler: a, earlyReturn: l3 } of o) if (e = a.handle(e), l3 != null && l3(e)) return e;
2642
+ return e;
2643
+ };
2644
+ var $e2 = vn;
2645
+
2646
+ // src/streaming/config.ts
2647
+ function resolveStreamingFixup(fixup) {
2648
+ if (fixup === false) return void 0;
2649
+ if (fixup === "remend") return (s) => $e2(s);
2650
+ return fixup;
2651
+ }
2652
+ function normalizeStreamingConfig(streaming) {
2653
+ var _a2, _b;
2654
+ if (!streaming) return null;
2655
+ if (streaming === true) {
2656
+ return {
2657
+ hasNextChunk: true,
2658
+ semanticEnabled: true,
2659
+ semanticConfig: {},
2660
+ enableAnimation: true
2661
+ };
2662
+ }
2663
+ const semantic = (_a2 = streaming.semantic) != null ? _a2 : true;
2664
+ return {
2665
+ hasNextChunk: streaming.hasNextChunk,
2666
+ semanticEnabled: semantic !== false,
2667
+ semanticConfig: typeof semantic === "object" ? semantic : {},
2668
+ enableAnimation: (_b = streaming.enableAnimation) != null ? _b : true
2669
+ };
2670
+ }
2671
+
2672
+ // src/XMarkdownMini.ts
2673
+ var ATTR_RE = /([a-zA-Z_][a-zA-Z0-9_:-]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;
2674
+ function parseAttrs(src) {
2675
+ var _a2, _b;
2676
+ const out = {};
2677
+ if (!src) return out;
2678
+ ATTR_RE.lastIndex = 0;
2679
+ let m3;
2680
+ while ((m3 = ATTR_RE.exec(src)) !== null) {
2681
+ const name = m3[1];
2682
+ const value = (_b = (_a2 = m3[2]) != null ? _a2 : m3[3]) != null ? _b : m3[4];
2683
+ out[name] = value === void 0 ? true : value;
2684
+ }
2685
+ return out;
2686
+ }
2687
+ function synthesizeComponentsExtension(tags) {
2688
+ const entries = tags.map((tag) => {
2689
+ const safeTag = tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2690
+ const tagRe = new RegExp(
2691
+ `^<${safeTag}(?:\\s+([^>]*?))?\\s*(\\/)?>(?:([\\s\\S]*?)<\\/${safeTag}>)?`
2692
+ );
2693
+ return {
2694
+ name: `customTag:${tag}`,
2695
+ level: "inline",
2696
+ start(src) {
2697
+ const i = src.indexOf(`<${tag}`);
2698
+ return i < 0 ? void 0 : i;
2699
+ },
2700
+ tokenizer(src) {
2701
+ var _a2, _b, _c;
2702
+ const m3 = tagRe.exec(src);
2703
+ if (!m3) return void 0;
2704
+ const attrsStr = (_a2 = m3[1]) != null ? _a2 : "";
2705
+ const selfClosing = m3[2] === "/";
2706
+ const inner = selfClosing ? "" : (_b = m3[3]) != null ? _b : "";
2707
+ if (!selfClosing && m3[3] === void 0) return void 0;
2708
+ const attrs = parseAttrs(attrsStr);
2709
+ const innerTokens = [];
2710
+ if (inner.length > 0 && typeof ((_c = this == null ? void 0 : this.lexer) == null ? void 0 : _c.inlineTokens) === "function") {
2711
+ this.lexer.inlineTokens(inner, innerTokens);
2712
+ }
2713
+ return {
2714
+ type: `customTag:${tag}`,
2715
+ raw: m3[0],
2716
+ tag,
2717
+ attrs,
2718
+ tokens: innerTokens
2719
+ };
2720
+ },
2721
+ miniRenderer(token, ctx) {
2722
+ var _a2, _b;
2723
+ const t = token;
2724
+ const node = { name: t.tag, tag: t.tag };
2725
+ if (t.attrs && Object.keys(t.attrs).length > 0) {
2726
+ node.attrs = t.attrs;
2727
+ }
2728
+ const inner = t.tokens && t.tokens.length > 0 ? (_b = (_a2 = ctx.renderInlineTokens) == null ? void 0 : _a2.call(ctx, t.tokens)) != null ? _b : [] : [];
2729
+ if (inner.length > 0) node.children = inner;
2730
+ return node;
2731
+ }
2732
+ };
2733
+ });
2734
+ return { extensions: entries };
2735
+ }
2736
+ var XMarkdownMini = class {
2737
+ constructor(opts = {}) {
2738
+ this.tokenStreamProcessor = null;
2739
+ this.nodeStreamProcessor = null;
2740
+ this.activeTokenStreamDefaults = null;
2741
+ this.activeNodeStreamDefaults = null;
2742
+ var _a2, _b, _c;
2743
+ this.escapeText = (_a2 = opts.escapeText) != null ? _a2 : true;
2744
+ this.fixup = resolveStreamingFixup((_b = opts.streamingFixup) != null ? _b : "remend");
2745
+ this.gfm = opts.gfm;
2746
+ this.breaks = opts.breaks;
2747
+ const directExtensions = (_c = opts.extensions) != null ? _c : [];
2748
+ this.componentsExtension = opts.components && opts.components.length > 0 ? synthesizeComponentsExtension(opts.components) : void 0;
2749
+ const allMarkedExtensions = [
2750
+ ...directExtensions,
2751
+ ...this.componentsExtension ? [this.componentsExtension] : []
2752
+ ];
2753
+ this.extensions = directExtensions;
2754
+ this.marked = new D(...allMarkedExtensions);
2755
+ }
2756
+ /**
2757
+ * Build the full RenderContext.extensions list for a render call.
2758
+ * Per-call extensions replace instance-level user extensions; the
2759
+ * components extension is always appended so that `<custom-tag>` sugar
2760
+ * continues to work regardless of per-call overrides.
2761
+ */
2762
+ resolveExtensions(perCall) {
2763
+ if (!perCall || perCall.length === 0) {
2764
+ return [
2765
+ ...this.extensions,
2766
+ ...this.componentsExtension ? [this.componentsExtension] : []
2767
+ ];
2768
+ }
2769
+ return [
2770
+ ...perCall,
2771
+ ...this.componentsExtension ? [this.componentsExtension] : []
2772
+ ];
2773
+ }
2774
+ /**
2775
+ * Register per-call extensions with the Marked instance and return a
2776
+ * snapshot of the previous defaults so they can be restored after the call.
2777
+ * Returns `null` if nothing to apply (no per-call extensions).
2778
+ */
2779
+ applyPerCallExtensions(perCall) {
2780
+ if (!perCall || perCall.length === 0) return null;
2781
+ const saved = { ...this.marked.defaults };
2782
+ this.marked.use(...perCall);
2783
+ return saved;
2784
+ }
2785
+ restoreDefaults(saved) {
2786
+ if (saved) this.marked.defaults = saved;
2787
+ }
2788
+ buildMarkedOptions(perCall) {
2789
+ var _a2, _b;
2790
+ const gfm = (_a2 = perCall == null ? void 0 : perCall.gfm) != null ? _a2 : this.gfm;
2791
+ const breaks = (_b = perCall == null ? void 0 : perCall.breaks) != null ? _b : this.breaks;
2792
+ return {
2793
+ ...this.marked.defaults,
2794
+ ...gfm !== void 0 ? { gfm: gfm !== false } : {},
2795
+ ...breaks !== void 0 ? { breaks: !!breaks } : {}
2796
+ };
2797
+ }
2798
+ lex(content, opts) {
2799
+ const tokens = this.marked.lexer(content, opts != null ? opts : this.buildMarkedOptions());
2800
+ const walkFn = this.marked.defaults.walkTokens;
2801
+ if (typeof walkFn === "function") {
2802
+ this.marked.walkTokens(tokens, walkFn);
2803
+ }
2804
+ return tokens;
2805
+ }
2806
+ /**
2807
+ * Parses markdown into marked's native Token[] without platform rendering.
2808
+ */
2809
+ parse(content) {
2810
+ return this.lex(content, this.buildMarkedOptions());
2811
+ }
2812
+ render(input) {
2813
+ if (typeof input === "string") return this.parse(input);
2814
+ return this.renderTokens(input);
2815
+ }
2816
+ /**
2817
+ * Token streaming entry. AI streaming fixup runs on markdown text before lex.
2818
+ */
2819
+ renderTokens(props) {
2820
+ var _a2, _b, _c, _d;
2821
+ const { content, gfm, breaks, extensions: perCallExts } = props;
2822
+ const stream = normalizeStreamingConfig(props.streaming);
2823
+ if (!stream) {
2824
+ this.tokenStreamProcessor = null;
2825
+ this.restoreDefaults(this.activeTokenStreamDefaults);
2826
+ this.activeTokenStreamDefaults = null;
2827
+ const saved = this.applyPerCallExtensions(perCallExts);
2828
+ try {
2829
+ const markedOpts = this.buildMarkedOptions({ gfm, breaks });
2830
+ (_a2 = props.onRenderStart) == null ? void 0 : _a2.call(props);
2831
+ const tokens = this.lex(content, markedOpts);
2832
+ (_b = props.onPatch) == null ? void 0 : _b.call(props, tokens);
2833
+ (_c = props.onRenderComplete) == null ? void 0 : _c.call(props);
2834
+ return tokens;
2835
+ } finally {
2836
+ this.restoreDefaults(saved);
2837
+ }
2838
+ }
2839
+ if (!this.tokenStreamProcessor) {
2840
+ this.activeTokenStreamDefaults = this.applyPerCallExtensions(perCallExts);
2841
+ const markedOpts = this.buildMarkedOptions({ gfm, breaks });
2842
+ const transform = (md) => this.lex(md, markedOpts);
2843
+ this.tokenStreamProcessor = new StreamingProcessor({
2844
+ transform,
2845
+ fixup: this.fixup,
2846
+ semanticEnabled: stream.semanticEnabled,
2847
+ ...stream.semanticConfig,
2848
+ onUpdate: (markdown) => {
2849
+ var _a3;
2850
+ return (_a3 = props.onRenderProgress) == null ? void 0 : _a3.call(props, { markdown });
2851
+ },
2852
+ onPatch: (tokens) => {
2853
+ var _a3;
2854
+ return (_a3 = props.onPatch) == null ? void 0 : _a3.call(props, tokens);
2855
+ },
2856
+ onComplete: () => {
2857
+ var _a3;
2858
+ (_a3 = props.onRenderComplete) == null ? void 0 : _a3.call(props);
2859
+ this.tokenStreamProcessor = null;
2860
+ this.restoreDefaults(this.activeTokenStreamDefaults);
2861
+ this.activeTokenStreamDefaults = null;
2862
+ }
2863
+ });
2864
+ (_d = props.onRenderStart) == null ? void 0 : _d.call(props);
2865
+ }
2866
+ this.tokenStreamProcessor.handleContentUpdate(content);
2867
+ this.tokenStreamProcessor.runRenderLoop(stream.hasNextChunk);
2868
+ return [];
2869
+ }
2870
+ /**
2871
+ * Component/node entry. Tokens are rendered by the selected platform renderer.
2872
+ */
2873
+ renderNodes(props) {
2874
+ var _a2, _b, _c, _d;
2875
+ const { content, platform = "auto", selectable = true, gfm, breaks, extensions: perCallExts } = props;
2876
+ const target = resolvePlatform(platform);
2877
+ const renderer = getPlatformRenderer(target);
2878
+ const stream = normalizeStreamingConfig(props.streaming);
2879
+ const ctxExtensions = this.resolveExtensions(perCallExts);
2880
+ if (!stream) {
2881
+ this.nodeStreamProcessor = null;
2882
+ this.restoreDefaults(this.activeNodeStreamDefaults);
2883
+ this.activeNodeStreamDefaults = null;
2884
+ const saved = this.applyPerCallExtensions(perCallExts);
2885
+ try {
2886
+ const markedOpts = this.buildMarkedOptions({ gfm, breaks });
2887
+ (_a2 = props.onRenderStart) == null ? void 0 : _a2.call(props);
2888
+ const ctx = {
2889
+ animation: false,
2890
+ selectable,
2891
+ escapeText: this.escapeText,
2892
+ extensions: ctxExtensions
2893
+ };
2894
+ const tokens = this.lex(content, markedOpts);
2895
+ const nodes = renderer.renderTokens(tokens, ctx);
2896
+ (_b = props.onPatch) == null ? void 0 : _b.call(props, nodes);
2897
+ (_c = props.onRenderComplete) == null ? void 0 : _c.call(props);
2898
+ return nodes;
2899
+ } finally {
2900
+ this.restoreDefaults(saved);
2901
+ }
2902
+ }
2903
+ if (!this.nodeStreamProcessor) {
2904
+ this.activeNodeStreamDefaults = this.applyPerCallExtensions(perCallExts);
2905
+ const markedOpts = this.buildMarkedOptions({ gfm, breaks });
2906
+ const ctx = {
2907
+ animation: stream.enableAnimation,
2908
+ selectable,
2909
+ escapeText: this.escapeText,
2910
+ extensions: ctxExtensions
2911
+ };
2912
+ const transform = (md) => renderer.renderTokens(this.lex(md, markedOpts), ctx);
2913
+ this.nodeStreamProcessor = new StreamingProcessor({
2914
+ transform,
2915
+ fixup: this.fixup,
2916
+ semanticEnabled: stream.semanticEnabled,
2917
+ ...stream.semanticConfig,
2918
+ onUpdate: (markdown) => {
2919
+ var _a3;
2920
+ return (_a3 = props.onRenderProgress) == null ? void 0 : _a3.call(props, { markdown });
2921
+ },
2922
+ onPatch: (nodes) => {
2923
+ var _a3;
2924
+ return (_a3 = props.onPatch) == null ? void 0 : _a3.call(props, nodes);
2925
+ },
2926
+ onComplete: () => {
2927
+ var _a3;
2928
+ (_a3 = props.onRenderComplete) == null ? void 0 : _a3.call(props);
2929
+ this.nodeStreamProcessor = null;
2930
+ this.restoreDefaults(this.activeNodeStreamDefaults);
2931
+ this.activeNodeStreamDefaults = null;
2932
+ }
2933
+ });
2934
+ (_d = props.onRenderStart) == null ? void 0 : _d.call(props);
2935
+ }
2936
+ this.nodeStreamProcessor.handleContentUpdate(content);
2937
+ this.nodeStreamProcessor.runRenderLoop(stream.hasNextChunk);
2938
+ return [];
2939
+ }
2940
+ /** Resets streaming state, usually during component detach/unmount. */
2941
+ reset() {
2942
+ var _a2, _b;
2943
+ (_a2 = this.tokenStreamProcessor) == null ? void 0 : _a2.reset();
2944
+ (_b = this.nodeStreamProcessor) == null ? void 0 : _b.reset();
2945
+ this.tokenStreamProcessor = null;
2946
+ this.nodeStreamProcessor = null;
2947
+ this.restoreDefaults(this.activeTokenStreamDefaults);
2948
+ this.restoreDefaults(this.activeNodeStreamDefaults);
2949
+ this.activeTokenStreamDefaults = null;
2950
+ this.activeNodeStreamDefaults = null;
2951
+ }
2952
+ };
2953
+
2954
+ // src/plugins/Footnote/index.ts
2955
+ var RULE = /^\[\^(?:([^\]:]+):)?([\s\S]+?)\]/;
2956
+ function Footnote(options = {}) {
2957
+ var _a2;
2958
+ const defaultLabel = (_a2 = options.defaultLabel) != null ? _a2 : "\u6CE8";
2959
+ return {
2960
+ extensions: [
2961
+ {
2962
+ name: "footnote",
2963
+ level: "inline",
2964
+ start(src) {
2965
+ const i = src.indexOf("[^");
2966
+ return i < 0 ? void 0 : i;
2967
+ },
2968
+ tokenizer(src) {
2969
+ var _a3;
2970
+ const m3 = RULE.exec(src);
2971
+ if (!m3) return void 0;
2972
+ return {
2973
+ type: "footnote",
2974
+ raw: m3[0],
2975
+ label: ((_a3 = m3[1]) != null ? _a3 : defaultLabel).trim(),
2976
+ content: m3[2].trim()
2977
+ };
2978
+ },
2979
+ miniRenderer(token, _ctx) {
2980
+ const t = token;
2981
+ return {
2982
+ name: "footnote",
2983
+ tag: "footnote",
2984
+ attrs: { label: t.label, content: t.content, class: "md-footnote" }
2985
+ };
2986
+ }
2987
+ }
2988
+ ]
2989
+ };
2990
+ }
2991
+
2992
+ // src/components/shared/flattenInlineTokens.ts
2993
+ var TAG_CLASS = {
2994
+ strong: "md-strong",
2995
+ em: "md-em",
2996
+ del: "md-del",
2997
+ codespan: "md-inline-code"
2998
+ };
2999
+ function escapeHtml2(text) {
3000
+ let out = "";
3001
+ for (let i = 0; i < text.length; i++) {
3002
+ const ch = text.charCodeAt(i);
3003
+ if (ch === 38) out += "&amp;";
3004
+ else if (ch === 60) out += "&lt;";
3005
+ else if (ch === 62) out += "&gt;";
3006
+ else if (ch === 34) out += "&quot;";
3007
+ else out += text[i];
3008
+ }
3009
+ return out;
3010
+ }
3011
+ function mergeClass(...parts) {
3012
+ const seen = /* @__PURE__ */ new Set();
3013
+ for (const p2 of parts) {
3014
+ if (!p2) continue;
3015
+ for (const tok of p2.split(/\s+/)) if (tok) seen.add(tok);
3016
+ }
3017
+ return Array.from(seen).join(" ");
3018
+ }
3019
+ function tokensToText(tokens) {
3020
+ var _a2;
3021
+ if (!tokens) return "";
3022
+ let out = "";
3023
+ for (const t of tokens) {
3024
+ const u2 = t;
3025
+ if (u2.type === "text" || u2.type === "escape") {
3026
+ out += (_a2 = u2.text) != null ? _a2 : "";
3027
+ } else if (u2.tokens) {
3028
+ out += tokensToText(u2.tokens);
3029
+ } else if (typeof u2.text === "string") {
3030
+ out += u2.text;
3031
+ }
3032
+ }
3033
+ return out;
3034
+ }
3035
+ function flattenInlineTokens(tokens, opts) {
3036
+ const out = [];
3037
+ const enc = opts.escapeText ? escapeHtml2 : (s) => s;
3038
+ walk(tokens, "", out, enc);
3039
+ return out;
3040
+ }
3041
+ function walk(tokens, classChain, out, enc) {
3042
+ var _a2, _b, _c, _d, _e2, _f, _g, _h;
3043
+ for (const tok of tokens) {
3044
+ const t = tok;
3045
+ switch (t.type) {
3046
+ case "text":
3047
+ case "escape": {
3048
+ const node = t;
3049
+ if (node.tokens && node.tokens.length) {
3050
+ walk(node.tokens, classChain, out, enc);
3051
+ } else {
3052
+ const v3 = enc((_a2 = node.text) != null ? _a2 : "");
3053
+ if (v3) out.push({ kind: "text", value: v3, classes: classChain });
3054
+ }
3055
+ break;
3056
+ }
3057
+ case "strong":
3058
+ case "em":
3059
+ case "del":
3060
+ walk(
3061
+ (_b = t.tokens) != null ? _b : [],
3062
+ mergeClass(classChain, TAG_CLASS[t.type]),
3063
+ out,
3064
+ enc
3065
+ );
3066
+ break;
3067
+ case "codespan": {
3068
+ const node = t;
3069
+ const v3 = enc((_c = node.text) != null ? _c : "");
3070
+ if (v3)
3071
+ out.push({
3072
+ kind: "text",
3073
+ value: v3,
3074
+ classes: mergeClass(classChain, TAG_CLASS.codespan)
3075
+ });
3076
+ break;
3077
+ }
3078
+ case "br":
3079
+ out.push({ kind: "br", value: "", classes: classChain });
3080
+ break;
3081
+ case "link": {
3082
+ const node = t;
3083
+ const label = tokensToText(node.tokens) || node.text || "";
3084
+ const run = {
3085
+ kind: "link",
3086
+ value: enc(label),
3087
+ classes: classChain,
3088
+ attrs: { href: (_d = node.href) != null ? _d : "" }
3089
+ };
3090
+ if (node.title) run.attrs.title = node.title;
3091
+ out.push(run);
3092
+ break;
3093
+ }
3094
+ case "image": {
3095
+ const node = t;
3096
+ const run = {
3097
+ kind: "image",
3098
+ value: enc((_e2 = node.text) != null ? _e2 : ""),
3099
+ classes: classChain,
3100
+ attrs: { src: (_f = node.href) != null ? _f : "", alt: (_g = node.text) != null ? _g : "" }
3101
+ };
3102
+ if (node.title) run.attrs.title = node.title;
3103
+ out.push(run);
3104
+ break;
3105
+ }
3106
+ case "html": {
3107
+ const node = t;
3108
+ const v3 = enc((_h = node.text) != null ? _h : "");
3109
+ if (v3) out.push({ kind: "text", value: v3, classes: classChain });
3110
+ break;
3111
+ }
3112
+ default: {
3113
+ if (typeof t.text === "string") {
3114
+ const v3 = enc(t.text);
3115
+ if (v3) out.push({ kind: "text", value: v3, classes: classChain });
3116
+ }
3117
+ }
3118
+ }
3119
+ }
3120
+ }
3121
+
3122
+ // src/index.ts
3123
+ var defaultInstance = new XMarkdownMini();
3124
+ function parse(content) {
3125
+ return defaultInstance.parse(content);
3126
+ }
3127
+ function render(input) {
3128
+ return typeof input === "string" ? defaultInstance.render(input) : defaultInstance.render(input);
3129
+ }
3130
+ function renderNodes(props) {
3131
+ return defaultInstance.renderNodes(props);
3132
+ }
3133
+ // Annotate the CommonJS export names for ESM import in node:
3134
+ 0 && (module.exports = {
3135
+ Footnote,
3136
+ StreamingProcessor,
3137
+ XMarkdownMini,
3138
+ alipayRenderer,
3139
+ flattenInlineTokens,
3140
+ getPlatformRenderer,
3141
+ parse,
3142
+ registerPlatformRenderer,
3143
+ render,
3144
+ renderNodes,
3145
+ resolvePlatform,
3146
+ tokensToAlipay,
3147
+ tokensToAlipayNodes,
3148
+ tokensToWechat,
3149
+ tokensToWechatNodes,
3150
+ wechatRenderer
3151
+ });