@floegence/floe-webapp-core 0.86.53 → 0.86.55

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.
@@ -0,0 +1,1602 @@
1
+ function ke() {
2
+ return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
3
+ }
4
+ var Q = ke();
5
+ function Be(t) {
6
+ Q = t;
7
+ }
8
+ var N = { exec: () => null };
9
+ function x(t, e = "") {
10
+ let r = typeof t == "string" ? t : t.source, s = { replace: (n, l) => {
11
+ let i = typeof l == "string" ? l : l.source;
12
+ return i = i.replace(P.caret, "$1"), r = r.replace(n, i), s;
13
+ }, getRegex: () => new RegExp(r, e) };
14
+ return s;
15
+ }
16
+ var it = (() => {
17
+ try {
18
+ return !!new RegExp("(?<=1)(?<!1)");
19
+ } catch {
20
+ return !1;
21
+ }
22
+ })(), P = { 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: (t) => new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}#`), htmlBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}>`) }, lt = /^(?:[ \t]*(?:\n|$))+/, ot = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, at = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, te = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, ct = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, xe = / {0,3}(?:[*+-]|\d{1,9}[.)])/, Me = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, De = x(Me).replace(/bull/g, xe).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(), ut = x(Me).replace(/bull/g, xe).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(), be = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, ht = /^[^\n]+/, we = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, pt = x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", we).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), ft = x(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, xe).getRegex(), oe = "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", me = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, gt = x("^ {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", me).replace("tag", oe).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), Oe = x(be).replace("hr", te).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", oe).getRegex(), dt = x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", Oe).getRegex(), ye = { blockquote: dt, code: ot, def: pt, fences: at, heading: ct, hr: te, html: gt, lheading: De, list: ft, newline: lt, paragraph: Oe, table: N, text: ht }, _e = x("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", te).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", oe).getRegex(), kt = { ...ye, lheading: ut, table: _e, paragraph: x(be).replace("hr", te).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", _e).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", oe).getRegex() }, xt = { ...ye, html: x(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", me).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: N, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: x(be).replace("hr", te).replace("heading", ` *#{1,6} *[^
23
+ ]`).replace("lheading", De).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, bt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, wt = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, Ne = /^( {2,}|\\)\n(?!\s*$)/, mt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, J = /[\p{P}\p{S}]/u, ae = /[\s\p{P}\p{S}]/u, $e = /[^\s\p{P}\p{S}]/u, yt = x(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, ae).getRegex(), Ze = /(?!~)[\p{P}\p{S}]/u, $t = /(?!~)[\s\p{P}\p{S}]/u, St = /(?:[^\s\p{P}\p{S}]|~)/u, Rt = x(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", it ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), Qe = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, Tt = x(Qe, "u").replace(/punct/g, J).getRegex(), zt = x(Qe, "u").replace(/punct/g, Ze).getRegex(), Ge = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", At = x(Ge, "gu").replace(/notPunctSpace/g, $e).replace(/punctSpace/g, ae).replace(/punct/g, J).getRegex(), _t = x(Ge, "gu").replace(/notPunctSpace/g, St).replace(/punctSpace/g, $t).replace(/punct/g, Ze).getRegex(), Pt = x("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, $e).replace(/punctSpace/g, ae).replace(/punct/g, J).getRegex(), Lt = x(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, J).getRegex(), Ct = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", It = x(Ct, "gu").replace(/notPunctSpace/g, $e).replace(/punctSpace/g, ae).replace(/punct/g, J).getRegex(), vt = x(/\\(punct)/, "gu").replace(/punct/g, J).getRegex(), Et = x(/^<(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(), qt = x(me).replace("(?:-->|$)", "-->").getRegex(), jt = x("^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", qt).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), se = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, Bt = x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", se).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), He = x(/^!?\[(label)\]\[(ref)\]/).replace("label", se).replace("ref", we).getRegex(), We = x(/^!?\[(ref)\](?:\[\])?/).replace("ref", we).getRegex(), Mt = x("reflink|nolink(?!\\()", "g").replace("reflink", He).replace("nolink", We).getRegex(), Pe = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, Se = { _backpedal: N, anyPunctuation: vt, autolink: Et, blockSkip: Rt, br: Ne, code: wt, del: N, delLDelim: N, delRDelim: N, emStrongLDelim: Tt, emStrongRDelimAst: At, emStrongRDelimUnd: Pt, escape: bt, link: Bt, nolink: We, punctuation: yt, reflink: He, reflinkSearch: Mt, tag: jt, text: mt, url: N }, Dt = { ...Se, link: x(/^!?\[(label)\]\((.*?)\)/).replace("label", se).getRegex(), reflink: x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", se).getRegex() }, fe = { ...Se, emStrongRDelimAst: _t, emStrongLDelim: zt, delLDelim: Lt, delRDelim: It, url: x(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", Pe).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: x(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", Pe).getRegex() }, Ot = { ...fe, br: x(Ne).replace("{2,}", "*").getRegex(), text: x(fe.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, re = { normal: ye, gfm: kt, pedantic: xt }, V = { normal: Se, gfm: fe, breaks: Ot, pedantic: Dt }, Nt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, Le = (t) => Nt[t];
24
+ function M(t, e) {
25
+ if (e) {
26
+ if (P.escapeTest.test(t)) return t.replace(P.escapeReplace, Le);
27
+ } else if (P.escapeTestNoEncode.test(t)) return t.replace(P.escapeReplaceNoEncode, Le);
28
+ return t;
29
+ }
30
+ function Ce(t) {
31
+ try {
32
+ t = encodeURI(t).replace(P.percentDecode, "%");
33
+ } catch {
34
+ return null;
35
+ }
36
+ return t;
37
+ }
38
+ function Ie(t, e) {
39
+ let r = t.replace(P.findPipe, (l, i, a) => {
40
+ let o = !1, c = i;
41
+ for (; --c >= 0 && a[c] === "\\"; ) o = !o;
42
+ return o ? "|" : " |";
43
+ }), s = r.split(P.splitPipe), n = 0;
44
+ if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e) if (s.length > e) s.splice(e);
45
+ else for (; s.length < e; ) s.push("");
46
+ for (; n < s.length; n++) s[n] = s[n].trim().replace(P.slashPipe, "|");
47
+ return s;
48
+ }
49
+ function Y(t, e, r) {
50
+ let s = t.length;
51
+ if (s === 0) return "";
52
+ let n = 0;
53
+ for (; n < s && t.charAt(s - n - 1) === e; )
54
+ n++;
55
+ return t.slice(0, s - n);
56
+ }
57
+ function Zt(t, e) {
58
+ if (t.indexOf(e[1]) === -1) return -1;
59
+ let r = 0;
60
+ for (let s = 0; s < t.length; s++) if (t[s] === "\\") s++;
61
+ else if (t[s] === e[0]) r++;
62
+ else if (t[s] === e[1] && (r--, r < 0)) return s;
63
+ return r > 0 ? -2 : -1;
64
+ }
65
+ function Qt(t, e = 0) {
66
+ let r = e, s = "";
67
+ for (let n of t) if (n === " ") {
68
+ let l = 4 - r % 4;
69
+ s += " ".repeat(l), r += l;
70
+ } else s += n, r++;
71
+ return s;
72
+ }
73
+ function ve(t, e, r, s, n) {
74
+ let l = e.href, i = e.title || null, a = t[1].replace(n.other.outputLinkReplace, "$1");
75
+ s.state.inLink = !0;
76
+ let o = { type: t[0].charAt(0) === "!" ? "image" : "link", raw: r, href: l, title: i, text: a, tokens: s.inlineTokens(a) };
77
+ return s.state.inLink = !1, o;
78
+ }
79
+ function Gt(t, e, r) {
80
+ let s = t.match(r.other.indentCodeCompensation);
81
+ if (s === null) return e;
82
+ let n = s[1];
83
+ return e.split(`
84
+ `).map((l) => {
85
+ let i = l.match(r.other.beginningSpace);
86
+ if (i === null) return l;
87
+ let [a] = i;
88
+ return a.length >= n.length ? l.slice(n.length) : l;
89
+ }).join(`
90
+ `);
91
+ }
92
+ var ie = class {
93
+ options;
94
+ rules;
95
+ lexer;
96
+ constructor(t) {
97
+ this.options = t || Q;
98
+ }
99
+ space(t) {
100
+ let e = this.rules.block.newline.exec(t);
101
+ if (e && e[0].length > 0) return { type: "space", raw: e[0] };
102
+ }
103
+ code(t) {
104
+ let e = this.rules.block.code.exec(t);
105
+ if (e) {
106
+ let r = e[0].replace(this.rules.other.codeRemoveIndent, "");
107
+ return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? r : Y(r, `
108
+ `) };
109
+ }
110
+ }
111
+ fences(t) {
112
+ let e = this.rules.block.fences.exec(t);
113
+ if (e) {
114
+ let r = e[0], s = Gt(r, e[3] || "", this.rules);
115
+ return { type: "code", raw: r, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s };
116
+ }
117
+ }
118
+ heading(t) {
119
+ let e = this.rules.block.heading.exec(t);
120
+ if (e) {
121
+ let r = e[2].trim();
122
+ if (this.rules.other.endingHash.test(r)) {
123
+ let s = Y(r, "#");
124
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (r = s.trim());
125
+ }
126
+ return { type: "heading", raw: e[0], depth: e[1].length, text: r, tokens: this.lexer.inline(r) };
127
+ }
128
+ }
129
+ hr(t) {
130
+ let e = this.rules.block.hr.exec(t);
131
+ if (e) return { type: "hr", raw: Y(e[0], `
132
+ `) };
133
+ }
134
+ blockquote(t) {
135
+ let e = this.rules.block.blockquote.exec(t);
136
+ if (e) {
137
+ let r = Y(e[0], `
138
+ `).split(`
139
+ `), s = "", n = "", l = [];
140
+ for (; r.length > 0; ) {
141
+ let i = !1, a = [], o;
142
+ for (o = 0; o < r.length; o++) if (this.rules.other.blockquoteStart.test(r[o])) a.push(r[o]), i = !0;
143
+ else if (!i) a.push(r[o]);
144
+ else break;
145
+ r = r.slice(o);
146
+ let c = a.join(`
147
+ `), u = c.replace(this.rules.other.blockquoteSetextReplace, `
148
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
149
+ s = s ? `${s}
150
+ ${c}` : c, n = n ? `${n}
151
+ ${u}` : u;
152
+ let g = this.lexer.state.top;
153
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(u, l, !0), this.lexer.state.top = g, r.length === 0) break;
154
+ let f = l.at(-1);
155
+ if (f?.type === "code") break;
156
+ if (f?.type === "blockquote") {
157
+ let $ = f, w = $.raw + `
158
+ ` + r.join(`
159
+ `), S = this.blockquote(w);
160
+ l[l.length - 1] = S, s = s.substring(0, s.length - $.raw.length) + S.raw, n = n.substring(0, n.length - $.text.length) + S.text;
161
+ break;
162
+ } else if (f?.type === "list") {
163
+ let $ = f, w = $.raw + `
164
+ ` + r.join(`
165
+ `), S = this.list(w);
166
+ l[l.length - 1] = S, s = s.substring(0, s.length - f.raw.length) + S.raw, n = n.substring(0, n.length - $.raw.length) + S.raw, r = w.substring(l.at(-1).raw.length).split(`
167
+ `);
168
+ continue;
169
+ }
170
+ }
171
+ return { type: "blockquote", raw: s, tokens: l, text: n };
172
+ }
173
+ }
174
+ list(t) {
175
+ let e = this.rules.block.list.exec(t);
176
+ if (e) {
177
+ let r = e[1].trim(), s = r.length > 1, n = { type: "list", raw: "", ordered: s, start: s ? +r.slice(0, -1) : "", loose: !1, items: [] };
178
+ r = s ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = s ? r : "[*+-]");
179
+ let l = this.rules.other.listItemRegex(r), i = !1;
180
+ for (; t; ) {
181
+ let o = !1, c = "", u = "";
182
+ if (!(e = l.exec(t)) || this.rules.block.hr.test(t)) break;
183
+ c = e[0], t = t.substring(c.length);
184
+ let g = Qt(e[2].split(`
185
+ `, 1)[0], e[1].length), f = t.split(`
186
+ `, 1)[0], $ = !g.trim(), w = 0;
187
+ if (this.options.pedantic ? (w = 2, u = g.trimStart()) : $ ? w = e[1].length + 1 : (w = g.search(this.rules.other.nonSpaceChar), w = w > 4 ? 1 : w, u = g.slice(w), w += e[1].length), $ && this.rules.other.blankLine.test(f) && (c += f + `
188
+ `, t = t.substring(f.length + 1), o = !0), !o) {
189
+ let S = this.rules.other.nextBulletRegex(w), j = this.rules.other.hrRegex(w), z = this.rules.other.fencesBeginRegex(w), C = this.rules.other.headingBeginRegex(w), G = this.rules.other.htmlBeginRegex(w), H = this.rules.other.blockquoteBeginRegex(w);
190
+ for (; t; ) {
191
+ let O = t.split(`
192
+ `, 1)[0], L;
193
+ if (f = O, this.options.pedantic ? (f = f.replace(this.rules.other.listReplaceNesting, " "), L = f) : L = f.replace(this.rules.other.tabCharGlobal, " "), z.test(f) || C.test(f) || G.test(f) || H.test(f) || S.test(f) || j.test(f)) break;
194
+ if (L.search(this.rules.other.nonSpaceChar) >= w || !f.trim()) u += `
195
+ ` + L.slice(w);
196
+ else {
197
+ if ($ || g.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || z.test(g) || C.test(g) || j.test(g)) break;
198
+ u += `
199
+ ` + f;
200
+ }
201
+ $ = !f.trim(), c += O + `
202
+ `, t = t.substring(O.length + 1), g = L.slice(w);
203
+ }
204
+ }
205
+ n.loose || (i ? n.loose = !0 : this.rules.other.doubleBlankLine.test(c) && (i = !0)), n.items.push({ type: "list_item", raw: c, task: !!this.options.gfm && this.rules.other.listIsTask.test(u), loose: !1, text: u, tokens: [] }), n.raw += c;
206
+ }
207
+ let a = n.items.at(-1);
208
+ if (a) a.raw = a.raw.trimEnd(), a.text = a.text.trimEnd();
209
+ else return;
210
+ n.raw = n.raw.trimEnd();
211
+ for (let o of n.items) {
212
+ if (this.lexer.state.top = !1, o.tokens = this.lexer.blockTokens(o.text, []), o.task) {
213
+ if (o.text = o.text.replace(this.rules.other.listReplaceTask, ""), o.tokens[0]?.type === "text" || o.tokens[0]?.type === "paragraph") {
214
+ o.tokens[0].raw = o.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), o.tokens[0].text = o.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
215
+ for (let u = this.lexer.inlineQueue.length - 1; u >= 0; u--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)) {
216
+ this.lexer.inlineQueue[u].src = this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask, "");
217
+ break;
218
+ }
219
+ }
220
+ let c = this.rules.other.listTaskCheckbox.exec(o.raw);
221
+ if (c) {
222
+ let u = { type: "checkbox", raw: c[0] + " ", checked: c[0] !== "[ ]" };
223
+ o.checked = u.checked, n.loose ? o.tokens[0] && ["paragraph", "text"].includes(o.tokens[0].type) && "tokens" in o.tokens[0] && o.tokens[0].tokens ? (o.tokens[0].raw = u.raw + o.tokens[0].raw, o.tokens[0].text = u.raw + o.tokens[0].text, o.tokens[0].tokens.unshift(u)) : o.tokens.unshift({ type: "paragraph", raw: u.raw, text: u.raw, tokens: [u] }) : o.tokens.unshift(u);
224
+ }
225
+ }
226
+ if (!n.loose) {
227
+ let c = o.tokens.filter((g) => g.type === "space"), u = c.length > 0 && c.some((g) => this.rules.other.anyLine.test(g.raw));
228
+ n.loose = u;
229
+ }
230
+ }
231
+ if (n.loose) for (let o of n.items) {
232
+ o.loose = !0;
233
+ for (let c of o.tokens) c.type === "text" && (c.type = "paragraph");
234
+ }
235
+ return n;
236
+ }
237
+ }
238
+ html(t) {
239
+ let e = this.rules.block.html.exec(t);
240
+ if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
241
+ }
242
+ def(t) {
243
+ let e = this.rules.block.def.exec(t);
244
+ if (e) {
245
+ let r = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", n = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
246
+ return { type: "def", tag: r, raw: e[0], href: s, title: n };
247
+ }
248
+ }
249
+ table(t) {
250
+ let e = this.rules.block.table.exec(t);
251
+ if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
252
+ let r = Ie(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), n = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
253
+ `) : [], l = { type: "table", raw: e[0], header: [], align: [], rows: [] };
254
+ if (r.length === s.length) {
255
+ for (let i of s) this.rules.other.tableAlignRight.test(i) ? l.align.push("right") : this.rules.other.tableAlignCenter.test(i) ? l.align.push("center") : this.rules.other.tableAlignLeft.test(i) ? l.align.push("left") : l.align.push(null);
256
+ for (let i = 0; i < r.length; i++) l.header.push({ text: r[i], tokens: this.lexer.inline(r[i]), header: !0, align: l.align[i] });
257
+ for (let i of n) l.rows.push(Ie(i, l.header.length).map((a, o) => ({ text: a, tokens: this.lexer.inline(a), header: !1, align: l.align[o] })));
258
+ return l;
259
+ }
260
+ }
261
+ lheading(t) {
262
+ let e = this.rules.block.lheading.exec(t);
263
+ if (e) {
264
+ let r = e[1].trim();
265
+ return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: r, tokens: this.lexer.inline(r) };
266
+ }
267
+ }
268
+ paragraph(t) {
269
+ let e = this.rules.block.paragraph.exec(t);
270
+ if (e) {
271
+ let r = e[1].charAt(e[1].length - 1) === `
272
+ ` ? e[1].slice(0, -1) : e[1];
273
+ return { type: "paragraph", raw: e[0], text: r, tokens: this.lexer.inline(r) };
274
+ }
275
+ }
276
+ text(t) {
277
+ let e = this.rules.block.text.exec(t);
278
+ if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
279
+ }
280
+ escape(t) {
281
+ let e = this.rules.inline.escape.exec(t);
282
+ if (e) return { type: "escape", raw: e[0], text: e[1] };
283
+ }
284
+ tag(t) {
285
+ let e = this.rules.inline.tag.exec(t);
286
+ if (e) return !this.lexer.state.inLink && this.rules.other.startATag.test(e[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(e[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(e[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(e[0]) && (this.lexer.state.inRawBlock = !1), { type: "html", raw: e[0], inLink: this.lexer.state.inLink, inRawBlock: this.lexer.state.inRawBlock, block: !1, text: e[0] };
287
+ }
288
+ link(t) {
289
+ let e = this.rules.inline.link.exec(t);
290
+ if (e) {
291
+ let r = e[2].trim();
292
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
293
+ if (!this.rules.other.endAngleBracket.test(r)) return;
294
+ let l = Y(r.slice(0, -1), "\\");
295
+ if ((r.length - l.length) % 2 === 0) return;
296
+ } else {
297
+ let l = Zt(e[2], "()");
298
+ if (l === -2) return;
299
+ if (l > -1) {
300
+ let i = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + l;
301
+ e[2] = e[2].substring(0, l), e[0] = e[0].substring(0, i).trim(), e[3] = "";
302
+ }
303
+ }
304
+ let s = e[2], n = "";
305
+ if (this.options.pedantic) {
306
+ let l = this.rules.other.pedanticHrefTitle.exec(s);
307
+ l && (s = l[1], n = l[3]);
308
+ } else n = e[3] ? e[3].slice(1, -1) : "";
309
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? s = s.slice(1) : s = s.slice(1, -1)), ve(e, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: n && n.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
310
+ }
311
+ }
312
+ reflink(t, e) {
313
+ let r;
314
+ if ((r = this.rules.inline.reflink.exec(t)) || (r = this.rules.inline.nolink.exec(t))) {
315
+ let s = (r[2] || r[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = e[s.toLowerCase()];
316
+ if (!n) {
317
+ let l = r[0].charAt(0);
318
+ return { type: "text", raw: l, text: l };
319
+ }
320
+ return ve(r, n, r[0], this.lexer, this.rules);
321
+ }
322
+ }
323
+ emStrong(t, e, r = "") {
324
+ let s = this.rules.inline.emStrongLDelim.exec(t);
325
+ if (!(!s || !s[1] && !s[2] && !s[3] && !s[4] || s[4] && r.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[3]) || !r || this.rules.inline.punctuation.exec(r))) {
326
+ let n = [...s[0]].length - 1, l, i, a = n, o = 0, c = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
327
+ for (c.lastIndex = 0, e = e.slice(-1 * t.length + n); (s = c.exec(e)) !== null; ) {
328
+ if (l = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !l) continue;
329
+ if (i = [...l].length, s[3] || s[4]) {
330
+ a += i;
331
+ continue;
332
+ } else if ((s[5] || s[6]) && n % 3 && !((n + i) % 3)) {
333
+ o += i;
334
+ continue;
335
+ }
336
+ if (a -= i, a > 0) continue;
337
+ i = Math.min(i, i + a + o);
338
+ let u = [...s[0]][0].length, g = t.slice(0, n + s.index + u + i);
339
+ if (Math.min(n, i) % 2) {
340
+ let $ = g.slice(1, -1);
341
+ return { type: "em", raw: g, text: $, tokens: this.lexer.inlineTokens($) };
342
+ }
343
+ let f = g.slice(2, -2);
344
+ return { type: "strong", raw: g, text: f, tokens: this.lexer.inlineTokens(f) };
345
+ }
346
+ }
347
+ }
348
+ codespan(t) {
349
+ let e = this.rules.inline.code.exec(t);
350
+ if (e) {
351
+ let r = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(r), n = this.rules.other.startingSpaceChar.test(r) && this.rules.other.endingSpaceChar.test(r);
352
+ return s && n && (r = r.substring(1, r.length - 1)), { type: "codespan", raw: e[0], text: r };
353
+ }
354
+ }
355
+ br(t) {
356
+ let e = this.rules.inline.br.exec(t);
357
+ if (e) return { type: "br", raw: e[0] };
358
+ }
359
+ del(t, e, r = "") {
360
+ let s = this.rules.inline.delLDelim.exec(t);
361
+ if (s && (!s[1] || !r || this.rules.inline.punctuation.exec(r))) {
362
+ let n = [...s[0]].length - 1, l, i, a = n, o = this.rules.inline.delRDelim;
363
+ for (o.lastIndex = 0, e = e.slice(-1 * t.length + n); (s = o.exec(e)) !== null; ) {
364
+ if (l = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !l || (i = [...l].length, i !== n)) continue;
365
+ if (s[3] || s[4]) {
366
+ a += i;
367
+ continue;
368
+ }
369
+ if (a -= i, a > 0) continue;
370
+ i = Math.min(i, i + a);
371
+ let c = [...s[0]][0].length, u = t.slice(0, n + s.index + c + i), g = u.slice(n, -n);
372
+ return { type: "del", raw: u, text: g, tokens: this.lexer.inlineTokens(g) };
373
+ }
374
+ }
375
+ }
376
+ autolink(t) {
377
+ let e = this.rules.inline.autolink.exec(t);
378
+ if (e) {
379
+ let r, s;
380
+ return e[2] === "@" ? (r = e[1], s = "mailto:" + r) : (r = e[1], s = r), { type: "link", raw: e[0], text: r, href: s, tokens: [{ type: "text", raw: r, text: r }] };
381
+ }
382
+ }
383
+ url(t) {
384
+ let e;
385
+ if (e = this.rules.inline.url.exec(t)) {
386
+ let r, s;
387
+ if (e[2] === "@") r = e[0], s = "mailto:" + r;
388
+ else {
389
+ let n;
390
+ do
391
+ n = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
392
+ while (n !== e[0]);
393
+ r = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
394
+ }
395
+ return { type: "link", raw: e[0], text: r, href: s, tokens: [{ type: "text", raw: r, text: r }] };
396
+ }
397
+ }
398
+ inlineText(t) {
399
+ let e = this.rules.inline.text.exec(t);
400
+ if (e) {
401
+ let r = this.lexer.state.inRawBlock;
402
+ return { type: "text", raw: e[0], text: e[0], escaped: r };
403
+ }
404
+ }
405
+ }, v = class ge {
406
+ tokens;
407
+ options;
408
+ state;
409
+ inlineQueue;
410
+ tokenizer;
411
+ constructor(e) {
412
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || Q, this.options.tokenizer = this.options.tokenizer || new ie(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
413
+ let r = { other: P, block: re.normal, inline: V.normal };
414
+ this.options.pedantic ? (r.block = re.pedantic, r.inline = V.pedantic) : this.options.gfm && (r.block = re.gfm, this.options.breaks ? r.inline = V.breaks : r.inline = V.gfm), this.tokenizer.rules = r;
415
+ }
416
+ static get rules() {
417
+ return { block: re, inline: V };
418
+ }
419
+ static lex(e, r) {
420
+ return new ge(r).lex(e);
421
+ }
422
+ static lexInline(e, r) {
423
+ return new ge(r).inlineTokens(e);
424
+ }
425
+ lex(e) {
426
+ e = e.replace(P.carriageReturn, `
427
+ `), this.blockTokens(e, this.tokens);
428
+ for (let r = 0; r < this.inlineQueue.length; r++) {
429
+ let s = this.inlineQueue[r];
430
+ this.inlineTokens(s.src, s.tokens);
431
+ }
432
+ return this.inlineQueue = [], this.tokens;
433
+ }
434
+ blockTokens(e, r = [], s = !1) {
435
+ for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(P.tabCharGlobal, " ").replace(P.spaceLine, "")); e; ) {
436
+ let n;
437
+ if (this.options.extensions?.block?.some((i) => (n = i.call({ lexer: this }, e, r)) ? (e = e.substring(n.raw.length), r.push(n), !0) : !1)) continue;
438
+ if (n = this.tokenizer.space(e)) {
439
+ e = e.substring(n.raw.length);
440
+ let i = r.at(-1);
441
+ n.raw.length === 1 && i !== void 0 ? i.raw += `
442
+ ` : r.push(n);
443
+ continue;
444
+ }
445
+ if (n = this.tokenizer.code(e)) {
446
+ e = e.substring(n.raw.length);
447
+ let i = r.at(-1);
448
+ i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
449
+ `) ? "" : `
450
+ `) + n.raw, i.text += `
451
+ ` + n.text, this.inlineQueue.at(-1).src = i.text) : r.push(n);
452
+ continue;
453
+ }
454
+ if (n = this.tokenizer.fences(e)) {
455
+ e = e.substring(n.raw.length), r.push(n);
456
+ continue;
457
+ }
458
+ if (n = this.tokenizer.heading(e)) {
459
+ e = e.substring(n.raw.length), r.push(n);
460
+ continue;
461
+ }
462
+ if (n = this.tokenizer.hr(e)) {
463
+ e = e.substring(n.raw.length), r.push(n);
464
+ continue;
465
+ }
466
+ if (n = this.tokenizer.blockquote(e)) {
467
+ e = e.substring(n.raw.length), r.push(n);
468
+ continue;
469
+ }
470
+ if (n = this.tokenizer.list(e)) {
471
+ e = e.substring(n.raw.length), r.push(n);
472
+ continue;
473
+ }
474
+ if (n = this.tokenizer.html(e)) {
475
+ e = e.substring(n.raw.length), r.push(n);
476
+ continue;
477
+ }
478
+ if (n = this.tokenizer.def(e)) {
479
+ e = e.substring(n.raw.length);
480
+ let i = r.at(-1);
481
+ i?.type === "paragraph" || i?.type === "text" ? (i.raw += (i.raw.endsWith(`
482
+ `) ? "" : `
483
+ `) + n.raw, i.text += `
484
+ ` + n.raw, this.inlineQueue.at(-1).src = i.text) : this.tokens.links[n.tag] || (this.tokens.links[n.tag] = { href: n.href, title: n.title }, r.push(n));
485
+ continue;
486
+ }
487
+ if (n = this.tokenizer.table(e)) {
488
+ e = e.substring(n.raw.length), r.push(n);
489
+ continue;
490
+ }
491
+ if (n = this.tokenizer.lheading(e)) {
492
+ e = e.substring(n.raw.length), r.push(n);
493
+ continue;
494
+ }
495
+ let l = e;
496
+ if (this.options.extensions?.startBlock) {
497
+ let i = 1 / 0, a = e.slice(1), o;
498
+ this.options.extensions.startBlock.forEach((c) => {
499
+ o = c.call({ lexer: this }, a), typeof o == "number" && o >= 0 && (i = Math.min(i, o));
500
+ }), i < 1 / 0 && i >= 0 && (l = e.substring(0, i + 1));
501
+ }
502
+ if (this.state.top && (n = this.tokenizer.paragraph(l))) {
503
+ let i = r.at(-1);
504
+ s && i?.type === "paragraph" ? (i.raw += (i.raw.endsWith(`
505
+ `) ? "" : `
506
+ `) + n.raw, i.text += `
507
+ ` + n.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : r.push(n), s = l.length !== e.length, e = e.substring(n.raw.length);
508
+ continue;
509
+ }
510
+ if (n = this.tokenizer.text(e)) {
511
+ e = e.substring(n.raw.length);
512
+ let i = r.at(-1);
513
+ i?.type === "text" ? (i.raw += (i.raw.endsWith(`
514
+ `) ? "" : `
515
+ `) + n.raw, i.text += `
516
+ ` + n.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = i.text) : r.push(n);
517
+ continue;
518
+ }
519
+ if (e) {
520
+ let i = "Infinite loop on byte: " + e.charCodeAt(0);
521
+ if (this.options.silent) {
522
+ console.error(i);
523
+ break;
524
+ } else throw new Error(i);
525
+ }
526
+ }
527
+ return this.state.top = !0, r;
528
+ }
529
+ inline(e, r = []) {
530
+ return this.inlineQueue.push({ src: e, tokens: r }), r;
531
+ }
532
+ inlineTokens(e, r = []) {
533
+ this.tokenizer.lexer = this;
534
+ let s = e, n = null;
535
+ if (this.tokens.links) {
536
+ let o = Object.keys(this.tokens.links);
537
+ if (o.length > 0) for (; (n = this.tokenizer.rules.inline.reflinkSearch.exec(s)) !== null; ) o.includes(n[0].slice(n[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, n.index) + "[" + "a".repeat(n[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
538
+ }
539
+ for (; (n = this.tokenizer.rules.inline.anyPunctuation.exec(s)) !== null; ) s = s.slice(0, n.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
540
+ let l;
541
+ for (; (n = this.tokenizer.rules.inline.blockSkip.exec(s)) !== null; ) l = n[2] ? n[2].length : 0, s = s.slice(0, n.index + l) + "[" + "a".repeat(n[0].length - l - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
542
+ s = this.options.hooks?.emStrongMask?.call({ lexer: this }, s) ?? s;
543
+ let i = !1, a = "";
544
+ for (; e; ) {
545
+ i || (a = ""), i = !1;
546
+ let o;
547
+ if (this.options.extensions?.inline?.some((u) => (o = u.call({ lexer: this }, e, r)) ? (e = e.substring(o.raw.length), r.push(o), !0) : !1)) continue;
548
+ if (o = this.tokenizer.escape(e)) {
549
+ e = e.substring(o.raw.length), r.push(o);
550
+ continue;
551
+ }
552
+ if (o = this.tokenizer.tag(e)) {
553
+ e = e.substring(o.raw.length), r.push(o);
554
+ continue;
555
+ }
556
+ if (o = this.tokenizer.link(e)) {
557
+ e = e.substring(o.raw.length), r.push(o);
558
+ continue;
559
+ }
560
+ if (o = this.tokenizer.reflink(e, this.tokens.links)) {
561
+ e = e.substring(o.raw.length);
562
+ let u = r.at(-1);
563
+ o.type === "text" && u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : r.push(o);
564
+ continue;
565
+ }
566
+ if (o = this.tokenizer.emStrong(e, s, a)) {
567
+ e = e.substring(o.raw.length), r.push(o);
568
+ continue;
569
+ }
570
+ if (o = this.tokenizer.codespan(e)) {
571
+ e = e.substring(o.raw.length), r.push(o);
572
+ continue;
573
+ }
574
+ if (o = this.tokenizer.br(e)) {
575
+ e = e.substring(o.raw.length), r.push(o);
576
+ continue;
577
+ }
578
+ if (o = this.tokenizer.del(e, s, a)) {
579
+ e = e.substring(o.raw.length), r.push(o);
580
+ continue;
581
+ }
582
+ if (o = this.tokenizer.autolink(e)) {
583
+ e = e.substring(o.raw.length), r.push(o);
584
+ continue;
585
+ }
586
+ if (!this.state.inLink && (o = this.tokenizer.url(e))) {
587
+ e = e.substring(o.raw.length), r.push(o);
588
+ continue;
589
+ }
590
+ let c = e;
591
+ if (this.options.extensions?.startInline) {
592
+ let u = 1 / 0, g = e.slice(1), f;
593
+ this.options.extensions.startInline.forEach(($) => {
594
+ f = $.call({ lexer: this }, g), typeof f == "number" && f >= 0 && (u = Math.min(u, f));
595
+ }), u < 1 / 0 && u >= 0 && (c = e.substring(0, u + 1));
596
+ }
597
+ if (o = this.tokenizer.inlineText(c)) {
598
+ e = e.substring(o.raw.length), o.raw.slice(-1) !== "_" && (a = o.raw.slice(-1)), i = !0;
599
+ let u = r.at(-1);
600
+ u?.type === "text" ? (u.raw += o.raw, u.text += o.text) : r.push(o);
601
+ continue;
602
+ }
603
+ if (e) {
604
+ let u = "Infinite loop on byte: " + e.charCodeAt(0);
605
+ if (this.options.silent) {
606
+ console.error(u);
607
+ break;
608
+ } else throw new Error(u);
609
+ }
610
+ }
611
+ return r;
612
+ }
613
+ }, le = class {
614
+ options;
615
+ parser;
616
+ constructor(t) {
617
+ this.options = t || Q;
618
+ }
619
+ space(t) {
620
+ return "";
621
+ }
622
+ code({ text: t, lang: e, escaped: r }) {
623
+ let s = (e || "").match(P.notSpaceStart)?.[0], n = t.replace(P.endingNewline, "") + `
624
+ `;
625
+ return s ? '<pre><code class="language-' + M(s) + '">' + (r ? n : M(n, !0)) + `</code></pre>
626
+ ` : "<pre><code>" + (r ? n : M(n, !0)) + `</code></pre>
627
+ `;
628
+ }
629
+ blockquote({ tokens: t }) {
630
+ return `<blockquote>
631
+ ${this.parser.parse(t)}</blockquote>
632
+ `;
633
+ }
634
+ html({ text: t }) {
635
+ return t;
636
+ }
637
+ def(t) {
638
+ return "";
639
+ }
640
+ heading({ tokens: t, depth: e }) {
641
+ return `<h${e}>${this.parser.parseInline(t)}</h${e}>
642
+ `;
643
+ }
644
+ hr(t) {
645
+ return `<hr>
646
+ `;
647
+ }
648
+ list(t) {
649
+ let e = t.ordered, r = t.start, s = "";
650
+ for (let i = 0; i < t.items.length; i++) {
651
+ let a = t.items[i];
652
+ s += this.listitem(a);
653
+ }
654
+ let n = e ? "ol" : "ul", l = e && r !== 1 ? ' start="' + r + '"' : "";
655
+ return "<" + n + l + `>
656
+ ` + s + "</" + n + `>
657
+ `;
658
+ }
659
+ listitem(t) {
660
+ return `<li>${this.parser.parse(t.tokens)}</li>
661
+ `;
662
+ }
663
+ checkbox({ checked: t }) {
664
+ return "<input " + (t ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
665
+ }
666
+ paragraph({ tokens: t }) {
667
+ return `<p>${this.parser.parseInline(t)}</p>
668
+ `;
669
+ }
670
+ table(t) {
671
+ let e = "", r = "";
672
+ for (let n = 0; n < t.header.length; n++) r += this.tablecell(t.header[n]);
673
+ e += this.tablerow({ text: r });
674
+ let s = "";
675
+ for (let n = 0; n < t.rows.length; n++) {
676
+ let l = t.rows[n];
677
+ r = "";
678
+ for (let i = 0; i < l.length; i++) r += this.tablecell(l[i]);
679
+ s += this.tablerow({ text: r });
680
+ }
681
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
682
+ <thead>
683
+ ` + e + `</thead>
684
+ ` + s + `</table>
685
+ `;
686
+ }
687
+ tablerow({ text: t }) {
688
+ return `<tr>
689
+ ${t}</tr>
690
+ `;
691
+ }
692
+ tablecell(t) {
693
+ let e = this.parser.parseInline(t.tokens), r = t.header ? "th" : "td";
694
+ return (t.align ? `<${r} align="${t.align}">` : `<${r}>`) + e + `</${r}>
695
+ `;
696
+ }
697
+ strong({ tokens: t }) {
698
+ return `<strong>${this.parser.parseInline(t)}</strong>`;
699
+ }
700
+ em({ tokens: t }) {
701
+ return `<em>${this.parser.parseInline(t)}</em>`;
702
+ }
703
+ codespan({ text: t }) {
704
+ return `<code>${M(t, !0)}</code>`;
705
+ }
706
+ br(t) {
707
+ return "<br>";
708
+ }
709
+ del({ tokens: t }) {
710
+ return `<del>${this.parser.parseInline(t)}</del>`;
711
+ }
712
+ link({ href: t, title: e, tokens: r }) {
713
+ let s = this.parser.parseInline(r), n = Ce(t);
714
+ if (n === null) return s;
715
+ t = n;
716
+ let l = '<a href="' + t + '"';
717
+ return e && (l += ' title="' + M(e) + '"'), l += ">" + s + "</a>", l;
718
+ }
719
+ image({ href: t, title: e, text: r, tokens: s }) {
720
+ s && (r = this.parser.parseInline(s, this.parser.textRenderer));
721
+ let n = Ce(t);
722
+ if (n === null) return M(r);
723
+ t = n;
724
+ let l = `<img src="${t}" alt="${M(r)}"`;
725
+ return e && (l += ` title="${M(e)}"`), l += ">", l;
726
+ }
727
+ text(t) {
728
+ return "tokens" in t && t.tokens ? this.parser.parseInline(t.tokens) : "escaped" in t && t.escaped ? t.text : M(t.text);
729
+ }
730
+ }, Re = class {
731
+ strong({ text: t }) {
732
+ return t;
733
+ }
734
+ em({ text: t }) {
735
+ return t;
736
+ }
737
+ codespan({ text: t }) {
738
+ return t;
739
+ }
740
+ del({ text: t }) {
741
+ return t;
742
+ }
743
+ html({ text: t }) {
744
+ return t;
745
+ }
746
+ text({ text: t }) {
747
+ return t;
748
+ }
749
+ link({ text: t }) {
750
+ return "" + t;
751
+ }
752
+ image({ text: t }) {
753
+ return "" + t;
754
+ }
755
+ br() {
756
+ return "";
757
+ }
758
+ checkbox({ raw: t }) {
759
+ return t;
760
+ }
761
+ }, E = class de {
762
+ options;
763
+ renderer;
764
+ textRenderer;
765
+ constructor(e) {
766
+ this.options = e || Q, this.options.renderer = this.options.renderer || new le(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Re();
767
+ }
768
+ static parse(e, r) {
769
+ return new de(r).parse(e);
770
+ }
771
+ static parseInline(e, r) {
772
+ return new de(r).parseInline(e);
773
+ }
774
+ parse(e) {
775
+ this.renderer.parser = this;
776
+ let r = "";
777
+ for (let s = 0; s < e.length; s++) {
778
+ let n = e[s];
779
+ if (this.options.extensions?.renderers?.[n.type]) {
780
+ let i = n, a = this.options.extensions.renderers[i.type].call({ parser: this }, i);
781
+ if (a !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(i.type)) {
782
+ r += a || "";
783
+ continue;
784
+ }
785
+ }
786
+ let l = n;
787
+ switch (l.type) {
788
+ case "space": {
789
+ r += this.renderer.space(l);
790
+ break;
791
+ }
792
+ case "hr": {
793
+ r += this.renderer.hr(l);
794
+ break;
795
+ }
796
+ case "heading": {
797
+ r += this.renderer.heading(l);
798
+ break;
799
+ }
800
+ case "code": {
801
+ r += this.renderer.code(l);
802
+ break;
803
+ }
804
+ case "table": {
805
+ r += this.renderer.table(l);
806
+ break;
807
+ }
808
+ case "blockquote": {
809
+ r += this.renderer.blockquote(l);
810
+ break;
811
+ }
812
+ case "list": {
813
+ r += this.renderer.list(l);
814
+ break;
815
+ }
816
+ case "checkbox": {
817
+ r += this.renderer.checkbox(l);
818
+ break;
819
+ }
820
+ case "html": {
821
+ r += this.renderer.html(l);
822
+ break;
823
+ }
824
+ case "def": {
825
+ r += this.renderer.def(l);
826
+ break;
827
+ }
828
+ case "paragraph": {
829
+ r += this.renderer.paragraph(l);
830
+ break;
831
+ }
832
+ case "text": {
833
+ r += this.renderer.text(l);
834
+ break;
835
+ }
836
+ default: {
837
+ let i = 'Token with "' + l.type + '" type was not found.';
838
+ if (this.options.silent) return console.error(i), "";
839
+ throw new Error(i);
840
+ }
841
+ }
842
+ }
843
+ return r;
844
+ }
845
+ parseInline(e, r = this.renderer) {
846
+ this.renderer.parser = this;
847
+ let s = "";
848
+ for (let n = 0; n < e.length; n++) {
849
+ let l = e[n];
850
+ if (this.options.extensions?.renderers?.[l.type]) {
851
+ let a = this.options.extensions.renderers[l.type].call({ parser: this }, l);
852
+ if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
853
+ s += a || "";
854
+ continue;
855
+ }
856
+ }
857
+ let i = l;
858
+ switch (i.type) {
859
+ case "escape": {
860
+ s += r.text(i);
861
+ break;
862
+ }
863
+ case "html": {
864
+ s += r.html(i);
865
+ break;
866
+ }
867
+ case "link": {
868
+ s += r.link(i);
869
+ break;
870
+ }
871
+ case "image": {
872
+ s += r.image(i);
873
+ break;
874
+ }
875
+ case "checkbox": {
876
+ s += r.checkbox(i);
877
+ break;
878
+ }
879
+ case "strong": {
880
+ s += r.strong(i);
881
+ break;
882
+ }
883
+ case "em": {
884
+ s += r.em(i);
885
+ break;
886
+ }
887
+ case "codespan": {
888
+ s += r.codespan(i);
889
+ break;
890
+ }
891
+ case "br": {
892
+ s += r.br(i);
893
+ break;
894
+ }
895
+ case "del": {
896
+ s += r.del(i);
897
+ break;
898
+ }
899
+ case "text": {
900
+ s += r.text(i);
901
+ break;
902
+ }
903
+ default: {
904
+ let a = 'Token with "' + i.type + '" type was not found.';
905
+ if (this.options.silent) return console.error(a), "";
906
+ throw new Error(a);
907
+ }
908
+ }
909
+ }
910
+ return s;
911
+ }
912
+ }, ee = class {
913
+ options;
914
+ block;
915
+ constructor(t) {
916
+ this.options = t || Q;
917
+ }
918
+ static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
919
+ static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
920
+ preprocess(t) {
921
+ return t;
922
+ }
923
+ postprocess(t) {
924
+ return t;
925
+ }
926
+ processAllTokens(t) {
927
+ return t;
928
+ }
929
+ emStrongMask(t) {
930
+ return t;
931
+ }
932
+ provideLexer(t = this.block) {
933
+ return t ? v.lex : v.lexInline;
934
+ }
935
+ provideParser(t = this.block) {
936
+ return t ? E.parse : E.parseInline;
937
+ }
938
+ }, Fe = class {
939
+ defaults = ke();
940
+ options = this.setOptions;
941
+ parse = this.parseMarkdown(!0);
942
+ parseInline = this.parseMarkdown(!1);
943
+ Parser = E;
944
+ Renderer = le;
945
+ TextRenderer = Re;
946
+ Lexer = v;
947
+ Tokenizer = ie;
948
+ Hooks = ee;
949
+ constructor(...t) {
950
+ this.use(...t);
951
+ }
952
+ walkTokens(t, e) {
953
+ let r = [];
954
+ for (let s of t) switch (r = r.concat(e.call(this, s)), s.type) {
955
+ case "table": {
956
+ let n = s;
957
+ for (let l of n.header) r = r.concat(this.walkTokens(l.tokens, e));
958
+ for (let l of n.rows) for (let i of l) r = r.concat(this.walkTokens(i.tokens, e));
959
+ break;
960
+ }
961
+ case "list": {
962
+ let n = s;
963
+ r = r.concat(this.walkTokens(n.items, e));
964
+ break;
965
+ }
966
+ default: {
967
+ let n = s;
968
+ this.defaults.extensions?.childTokens?.[n.type] ? this.defaults.extensions.childTokens[n.type].forEach((l) => {
969
+ let i = n[l].flat(1 / 0);
970
+ r = r.concat(this.walkTokens(i, e));
971
+ }) : n.tokens && (r = r.concat(this.walkTokens(n.tokens, e)));
972
+ }
973
+ }
974
+ return r;
975
+ }
976
+ use(...t) {
977
+ let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
978
+ return t.forEach((r) => {
979
+ let s = { ...r };
980
+ if (s.async = this.defaults.async || s.async || !1, r.extensions && (r.extensions.forEach((n) => {
981
+ if (!n.name) throw new Error("extension name required");
982
+ if ("renderer" in n) {
983
+ let l = e.renderers[n.name];
984
+ l ? e.renderers[n.name] = function(...i) {
985
+ let a = n.renderer.apply(this, i);
986
+ return a === !1 && (a = l.apply(this, i)), a;
987
+ } : e.renderers[n.name] = n.renderer;
988
+ }
989
+ if ("tokenizer" in n) {
990
+ if (!n.level || n.level !== "block" && n.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
991
+ let l = e[n.level];
992
+ l ? l.unshift(n.tokenizer) : e[n.level] = [n.tokenizer], n.start && (n.level === "block" ? e.startBlock ? e.startBlock.push(n.start) : e.startBlock = [n.start] : n.level === "inline" && (e.startInline ? e.startInline.push(n.start) : e.startInline = [n.start]));
993
+ }
994
+ "childTokens" in n && n.childTokens && (e.childTokens[n.name] = n.childTokens);
995
+ }), s.extensions = e), r.renderer) {
996
+ let n = this.defaults.renderer || new le(this.defaults);
997
+ for (let l in r.renderer) {
998
+ if (!(l in n)) throw new Error(`renderer '${l}' does not exist`);
999
+ if (["options", "parser"].includes(l)) continue;
1000
+ let i = l, a = r.renderer[i], o = n[i];
1001
+ n[i] = (...c) => {
1002
+ let u = a.apply(n, c);
1003
+ return u === !1 && (u = o.apply(n, c)), u || "";
1004
+ };
1005
+ }
1006
+ s.renderer = n;
1007
+ }
1008
+ if (r.tokenizer) {
1009
+ let n = this.defaults.tokenizer || new ie(this.defaults);
1010
+ for (let l in r.tokenizer) {
1011
+ if (!(l in n)) throw new Error(`tokenizer '${l}' does not exist`);
1012
+ if (["options", "rules", "lexer"].includes(l)) continue;
1013
+ let i = l, a = r.tokenizer[i], o = n[i];
1014
+ n[i] = (...c) => {
1015
+ let u = a.apply(n, c);
1016
+ return u === !1 && (u = o.apply(n, c)), u;
1017
+ };
1018
+ }
1019
+ s.tokenizer = n;
1020
+ }
1021
+ if (r.hooks) {
1022
+ let n = this.defaults.hooks || new ee();
1023
+ for (let l in r.hooks) {
1024
+ if (!(l in n)) throw new Error(`hook '${l}' does not exist`);
1025
+ if (["options", "block"].includes(l)) continue;
1026
+ let i = l, a = r.hooks[i], o = n[i];
1027
+ ee.passThroughHooks.has(l) ? n[i] = (c) => {
1028
+ if (this.defaults.async && ee.passThroughHooksRespectAsync.has(l)) return (async () => {
1029
+ let g = await a.call(n, c);
1030
+ return o.call(n, g);
1031
+ })();
1032
+ let u = a.call(n, c);
1033
+ return o.call(n, u);
1034
+ } : n[i] = (...c) => {
1035
+ if (this.defaults.async) return (async () => {
1036
+ let g = await a.apply(n, c);
1037
+ return g === !1 && (g = await o.apply(n, c)), g;
1038
+ })();
1039
+ let u = a.apply(n, c);
1040
+ return u === !1 && (u = o.apply(n, c)), u;
1041
+ };
1042
+ }
1043
+ s.hooks = n;
1044
+ }
1045
+ if (r.walkTokens) {
1046
+ let n = this.defaults.walkTokens, l = r.walkTokens;
1047
+ s.walkTokens = function(i) {
1048
+ let a = [];
1049
+ return a.push(l.call(this, i)), n && (a = a.concat(n.call(this, i))), a;
1050
+ };
1051
+ }
1052
+ this.defaults = { ...this.defaults, ...s };
1053
+ }), this;
1054
+ }
1055
+ setOptions(t) {
1056
+ return this.defaults = { ...this.defaults, ...t }, this;
1057
+ }
1058
+ lexer(t, e) {
1059
+ return v.lex(t, e ?? this.defaults);
1060
+ }
1061
+ parser(t, e) {
1062
+ return E.parse(t, e ?? this.defaults);
1063
+ }
1064
+ parseMarkdown(t) {
1065
+ return (e, r) => {
1066
+ let s = { ...r }, n = { ...this.defaults, ...s }, l = this.onError(!!n.silent, !!n.async);
1067
+ if (this.defaults.async === !0 && s.async === !1) return l(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."));
1068
+ if (typeof e > "u" || e === null) return l(new Error("marked(): input parameter is undefined or null"));
1069
+ if (typeof e != "string") return l(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
1070
+ if (n.hooks && (n.hooks.options = n, n.hooks.block = t), n.async) return (async () => {
1071
+ let i = n.hooks ? await n.hooks.preprocess(e) : e, a = await (n.hooks ? await n.hooks.provideLexer(t) : t ? v.lex : v.lexInline)(i, n), o = n.hooks ? await n.hooks.processAllTokens(a) : a;
1072
+ n.walkTokens && await Promise.all(this.walkTokens(o, n.walkTokens));
1073
+ let c = await (n.hooks ? await n.hooks.provideParser(t) : t ? E.parse : E.parseInline)(o, n);
1074
+ return n.hooks ? await n.hooks.postprocess(c) : c;
1075
+ })().catch(l);
1076
+ try {
1077
+ n.hooks && (e = n.hooks.preprocess(e));
1078
+ let i = (n.hooks ? n.hooks.provideLexer(t) : t ? v.lex : v.lexInline)(e, n);
1079
+ n.hooks && (i = n.hooks.processAllTokens(i)), n.walkTokens && this.walkTokens(i, n.walkTokens);
1080
+ let a = (n.hooks ? n.hooks.provideParser(t) : t ? E.parse : E.parseInline)(i, n);
1081
+ return n.hooks && (a = n.hooks.postprocess(a)), a;
1082
+ } catch (i) {
1083
+ return l(i);
1084
+ }
1085
+ };
1086
+ }
1087
+ onError(t, e) {
1088
+ return (r) => {
1089
+ if (r.message += `
1090
+ Please report this to https://github.com/markedjs/marked.`, t) {
1091
+ let s = "<p>An error occurred:</p><pre>" + M(r.message + "", !0) + "</pre>";
1092
+ return e ? Promise.resolve(s) : s;
1093
+ }
1094
+ if (e) return Promise.reject(r);
1095
+ throw r;
1096
+ };
1097
+ }
1098
+ }, Z = new Fe();
1099
+ function y(t, e) {
1100
+ return Z.parse(t, e);
1101
+ }
1102
+ y.options = y.setOptions = function(t) {
1103
+ return Z.setOptions(t), y.defaults = Z.defaults, Be(y.defaults), y;
1104
+ };
1105
+ y.getDefaults = ke;
1106
+ y.defaults = Q;
1107
+ y.use = function(...t) {
1108
+ return Z.use(...t), y.defaults = Z.defaults, Be(y.defaults), y;
1109
+ };
1110
+ y.walkTokens = function(t, e) {
1111
+ return Z.walkTokens(t, e);
1112
+ };
1113
+ y.parseInline = Z.parseInline;
1114
+ y.Parser = E;
1115
+ y.parser = E.parse;
1116
+ y.Renderer = le;
1117
+ y.TextRenderer = Re;
1118
+ y.Lexer = v;
1119
+ y.lexer = v.lex;
1120
+ y.Tokenizer = ie;
1121
+ y.Hooks = ee;
1122
+ y.parse = y;
1123
+ y.options;
1124
+ y.setOptions;
1125
+ y.use;
1126
+ y.walkTokens;
1127
+ y.parseInline;
1128
+ E.parse;
1129
+ v.lex;
1130
+ const q = "\\u1100-\\u11ff\\u20a9\\u2329-\\u232a\\u2630-\\u2637\\u268a-\\u268f\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303e\\u3041-\\u3096\\u3099-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u31e5\\u31ef-\\u321e\\u3220-\\u3247\\u3250-\\ua48c\\ua490-\\ua4c6\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufaff\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe66\\ufe68-\\ufe6b\\uff01-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\\uffe0-\\uffe6\\uffe8-\\uffee\\u{16fe0}-\\u{16fe4}\\u{16ff0}-\\u{16ff6}\\u{17000}-\\u{18cda}\\u{18cff}-\\u{18d20}\\u{18d80}-\\u{18df2}\\u{18e00}-\\u{19191}\\u{191a0}-\\u{191d2}\\u{1aff0}-\\u{1aff3}\\u{1aff5}-\\u{1affb}\\u{1affd}-\\u{1affe}\\u{1b000}-\\u{1b128}\\u{1b132}\\u{1b150}-\\u{1b152}\\u{1b155}\\u{1b164}-\\u{1b168}\\u{1b170}-\\u{1b2fb}\\u{1d300}-\\u{1d356}\\u{1d360}-\\u{1d376}\\u{1f1ae}\\u{1f200}\\u{1f202}\\u{1f210}-\\u{1f219}\\u{1f21b}-\\u{1f22e}\\u{1f230}-\\u{1f231}\\u{1f237}\\u{1f23b}\\u{1f240}-\\u{1f248}\\u{1f260}-\\u{1f265}\\u{1f7da}\\u{20000}-\\u{3fffd}", X = new RegExp(`[${q}]`, "u"), Ht = new RegExp(`^((?![*_])[\\s\\p{P}\\p{S}${q}])`, "u");
1131
+ function Ue(t, e, r) {
1132
+ return new RegExp(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)${t}(\\*+)(?=[\\s]|$)|${r}(\\*+)(?!\\*)(?=${e}|$)|(?!\\*)${e}(\\*+)(?=${r})|[\\s](\\*+)(?!\\*)(?=${t})|(?!\\*)${t}(\\*+)(?!\\*)(?=${t})|${r}(\\*+)(?=${r})`, "gu");
1133
+ }
1134
+ function Wt(t, e, r) {
1135
+ return new RegExp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)${t}(_+)(?=[\\s]|$)|${r}(_+)(?!_)(?=${e}|$)|(?!_)${e}(_+)(?=${r})|[\\s](_+)(?!_)(?=${t})|(?!_)${t}(_+)(?!_)(?=${t})`, "gu");
1136
+ }
1137
+ function Ft(t, e, r) {
1138
+ return new RegExp(`^[^~]+(?=[^~])|(?!~)${t}(~~?)(?=[\\s]|$)|${r}(~~?)(?!~)(?=${e}|$)|(?!~)${e}(~~?)(?=${r})|[\\s](~~?)(?!~)(?=${t})|(?!~)${t}(~~?)(?!~)(?=${t})|${r}(~~?)(?=${r})`, "gu");
1139
+ }
1140
+ const Xe = `[\\p{P}\\p{S}${q}]`, Je = `[\\s\\p{P}\\p{S}${q}]`, Ke = `[^\\s\\p{P}\\p{S}${q}]`, Ut = `(?![*_])[\\p{P}\\p{S}${q}]`, Xt = `(?![*_])[\\s\\p{P}\\p{S}${q}]`, Jt = `(?:[^\\s\\p{P}\\p{S}${q}]|[*_])`, Kt = `(?!~)[\\p{P}\\p{S}${q}]`, Vt = `(?!~)[\\s\\p{P}\\p{S}${q}]`, Yt = `(?:[^\\s\\p{P}\\p{S}${q}]|~)`, en = Ue(Xe, Je, Ke), tn = Ue(Kt, Vt, Yt), nn = Wt(Xe, Je, Ke), Ee = Ft(Ut, Xt, Jt);
1141
+ function qe(t, e, r) {
1142
+ let s = Ht.test(t);
1143
+ if (!s && t) {
1144
+ const n = e.length - r.length;
1145
+ if (n >= 1) {
1146
+ let l = n - 1, i = e.charCodeAt(l);
1147
+ if (i >= 65024 && i <= 65038 && l >= 1 && (l--, i = e.charCodeAt(l)), (i & 64512) === 56320 && l >= 1) {
1148
+ const a = e.codePointAt(l - 1);
1149
+ a !== void 0 && a > 65535 && (a >= 917760 && a <= 917999 ? s = !0 : s = X.test(String.fromCodePoint(a)));
1150
+ } else s = X.test(String.fromCharCode(i));
1151
+ }
1152
+ }
1153
+ return s;
1154
+ }
1155
+ function je(t, e) {
1156
+ if (!(t[1] || t[2] || t[3] || t[4])) return !1;
1157
+ const r = String.fromCodePoint(t[0].codePointAt(0)), s = t.index + t[0].length, n = s < e.length ? String.fromCodePoint(e.codePointAt(s)) : "";
1158
+ return X.test(r) || X.test(n);
1159
+ }
1160
+ function Te(t) {
1161
+ return t.length >= 5;
1162
+ }
1163
+ function rn(t) {
1164
+ return !!(t[1] || t[2] || t[3] || t[4]);
1165
+ }
1166
+ function sn(t) {
1167
+ return Te(t) ? !!t[4] : !!t[3];
1168
+ }
1169
+ function ln(t) {
1170
+ return Te(t) ? t[1] || t[3] || "" : t[1] || t[2] || "";
1171
+ }
1172
+ function on() {
1173
+ return { tokenizer: {
1174
+ emStrong(t, e, r = "") {
1175
+ const { rules: s } = this, n = s.inline.emStrongLDelim.exec(t);
1176
+ if (!n) return !1;
1177
+ const l = Te(n);
1178
+ if (l && !rn(n)) return;
1179
+ if (sn(n) && r.match(s.other.unicodeAlphaNumeric)) return !1;
1180
+ const i = ln(n), a = qe(r, e, t);
1181
+ if (!i || !r || s.inline.punctuation.exec(r) || a || X.test(i)) {
1182
+ const o = [...n[0]].length - 1;
1183
+ let c, u, g = o, f = 0;
1184
+ const $ = l && r === n[0][0], w = s.inline.emStrongRDelimAst.source.includes("(?!~)");
1185
+ let S;
1186
+ n[0][0] === "*" ? S = w ? tn : en : S = nn, S.lastIndex = 0;
1187
+ const j = e.slice(-1 * t.length + o);
1188
+ let z;
1189
+ for (; (z = S.exec(j)) != null; ) {
1190
+ if (c = z[1] || z[2] || z[3] || z[4] || z[5] || z[6], !c) continue;
1191
+ u = [...c].length;
1192
+ const C = je(z, j), G = !!(z[3] || z[4]), H = !!(z[5] || z[6]);
1193
+ if (G && !C) {
1194
+ g += u;
1195
+ continue;
1196
+ }
1197
+ if (H || C) {
1198
+ if (o % 3 && !((o + u) % 3)) {
1199
+ f += u;
1200
+ continue;
1201
+ }
1202
+ if ($ && H) break;
1203
+ }
1204
+ if (g -= u, g > 0) continue;
1205
+ u = Math.min(u, u + g + f);
1206
+ const O = z[0].codePointAt(0) > 65535 ? 2 : 1, L = t.slice(0, o + z.index + O + u);
1207
+ if (Math.min(o, u) % 2) {
1208
+ const F = L.slice(1, -1);
1209
+ return {
1210
+ type: "em",
1211
+ raw: L,
1212
+ text: F,
1213
+ tokens: this.lexer.inlineTokens(F)
1214
+ };
1215
+ }
1216
+ const W = L.slice(2, -2);
1217
+ return {
1218
+ type: "strong",
1219
+ raw: L,
1220
+ text: W,
1221
+ tokens: this.lexer.inlineTokens(W)
1222
+ };
1223
+ }
1224
+ }
1225
+ },
1226
+ del(t, e, r = "") {
1227
+ const { rules: s } = this, n = s.inline.delLDelim.exec(t);
1228
+ if (!n) return !1;
1229
+ const l = n[1] || "", i = qe(r, e, t);
1230
+ if (!l || !r || s.inline.punctuation.exec(r) || i || X.test(l)) {
1231
+ const a = [...n[0]].length - 1;
1232
+ let o, c, u = a;
1233
+ Ee.lastIndex = 0;
1234
+ const g = e.slice(-1 * t.length + a);
1235
+ let f;
1236
+ for (; (f = Ee.exec(g)) != null; ) {
1237
+ if (o = f[1] || f[2] || f[3] || f[4] || f[5] || f[6], !o || (c = [...o].length, c !== a)) continue;
1238
+ const $ = je(f, g);
1239
+ if ((f[3] || f[4]) && !$) {
1240
+ u += c;
1241
+ continue;
1242
+ }
1243
+ if (u -= c, u > 0) continue;
1244
+ c = Math.min(c, c + u);
1245
+ const w = f[0].codePointAt(0) > 65535 ? 2 : 1, S = t.slice(0, a + f.index + w + c), j = S.slice(a, -a);
1246
+ return {
1247
+ type: "del",
1248
+ raw: S,
1249
+ text: j,
1250
+ tokens: this.lexer.inlineTokens(j)
1251
+ };
1252
+ }
1253
+ }
1254
+ }
1255
+ } };
1256
+ }
1257
+ function Ve(t = {}) {
1258
+ const e = on().tokenizer.emStrong;
1259
+ return new Fe({ tokenizer: {
1260
+ emStrong(r, s, n) {
1261
+ const l = e.call(this, r, s, n);
1262
+ return l && /^\s|\s$/u.test(l.text) ? !1 : l;
1263
+ }
1264
+ } }).setOptions({ gfm: !0, breaks: !0, ...t });
1265
+ }
1266
+ const Ye = Ve(), K = new y.Renderer();
1267
+ K.code = function(t) {
1268
+ const e = t.lang || "text", r = t.text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1269
+ return `<pre class="chat-md-code-block" data-language="${e}"><code>${r}</code></pre>`;
1270
+ };
1271
+ K.codespan = function(t) {
1272
+ return `<code class="chat-md-inline-code">${t.text}</code>`;
1273
+ };
1274
+ K.link = function(t) {
1275
+ const e = t.title ? ` title="${t.title}"` : "";
1276
+ return `<a href="${t.href}"${e} target="_blank" rel="noopener noreferrer" class="chat-md-link">${t.text}</a>`;
1277
+ };
1278
+ K.image = function(t) {
1279
+ const e = t.title ? ` title="${t.title}"` : "";
1280
+ return `<img src="${t.href}" alt="${t.text}"${e} class="chat-md-image" loading="lazy" />`;
1281
+ };
1282
+ K.blockquote = function(t) {
1283
+ return `<blockquote class="chat-md-blockquote">${t.text}</blockquote>`;
1284
+ };
1285
+ Ye.use({ renderer: K });
1286
+ function an(t) {
1287
+ return Ye.parse(t, { async: !1 });
1288
+ }
1289
+ function cn(t) {
1290
+ let e = 0, r = [], s = 0, n = !1;
1291
+ const l = [];
1292
+ let i = /* @__PURE__ */ Object.create(null), a = /* @__PURE__ */ Object.create(null), o = 1, c = 0, u, g, f = !1, $ = 0, w = 0;
1293
+ const S = /* @__PURE__ */ new Map();
1294
+ function j(h) {
1295
+ let p = 0, d = r.length;
1296
+ for (; p < d; ) {
1297
+ const k = p + d >>> 1;
1298
+ r[k].start <= h ? p = k + 1 : d = k;
1299
+ }
1300
+ const b = Math.max(0, p - 1);
1301
+ return r.slice(b).map((k, T) => T === 0 ? k.text.slice(h - k.start) : k.text).join("");
1302
+ }
1303
+ function z(h, p) {
1304
+ w += h.length;
1305
+ const d = new t.Lexer({ ...t.defaults });
1306
+ return d.tokens.links = { ...p }, d.lex(h);
1307
+ }
1308
+ function C(h) {
1309
+ return { changes: h, links: i, sourceLength: s };
1310
+ }
1311
+ function G(h) {
1312
+ return { id: h.id, start: h.start, token: structuredClone(h.token) };
1313
+ }
1314
+ function H(h) {
1315
+ for (const p of h.token.raw.matchAll(/\[((?:\\[^\n]|[^\]\n\\])+)\]/g)) {
1316
+ const d = p[1].toLowerCase().replace(/\s+/g, " ");
1317
+ h.references.add(d);
1318
+ let b = S.get(d);
1319
+ b || S.set(d, b = /* @__PURE__ */ new Set()), b.add(h);
1320
+ }
1321
+ }
1322
+ function O(h) {
1323
+ for (const p of h.references) {
1324
+ const d = S.get(p);
1325
+ d?.delete(h), d?.size || S.delete(p);
1326
+ }
1327
+ }
1328
+ function L(h, p) {
1329
+ for (const d of h)
1330
+ if (d === `
1331
+ `) {
1332
+ if (p.candidate && p.count >= p.minimum) return !0;
1333
+ p.count = 0, p.indent = 0, p.candidate = !0;
1334
+ } else p.candidate && (d === p.mark && p.indent <= 3 ? p.count++ : d === " " && p.count === 0 && p.indent < 3 ? p.indent++ : (d !== " " && d !== " " || p.count === 0) && (p.candidate = !1));
1335
+ return p.candidate && p.count >= p.minimum;
1336
+ }
1337
+ function W(h) {
1338
+ const p = t.defaults.extensions;
1339
+ if (!p || !p.inline?.length) return !1;
1340
+ const d = p.startInline ?? [];
1341
+ if (d.length < p.inline.length) return !0;
1342
+ const b = new t.Lexer({ ...t.defaults });
1343
+ return d.some((k) => {
1344
+ const T = k.call({ lexer: b }, h);
1345
+ return typeof T == "number" && T >= 0;
1346
+ });
1347
+ }
1348
+ function F(h, p = 0) {
1349
+ const d = h.tokens;
1350
+ let b = -1;
1351
+ for (let A = p; A < d.length; A++) {
1352
+ const _ = d[A];
1353
+ if (_.type === "text" && (/[\\\x60*_[<~]/u.test(_.raw) || W(_.raw))) {
1354
+ b = A;
1355
+ break;
1356
+ }
1357
+ }
1358
+ let k = b >= 0 ? b : Math.max(p, d.length - 1);
1359
+ k > p && d[k]?.type === "text" && !/\s/u.test(d[k].raw) && d[k - 1]?.type === "link" && k--;
1360
+ const T = d[k];
1361
+ if (b < 0 && T?.type === "text" && T.raw === T.text) {
1362
+ const A = T.raw.lastIndexOf(" ");
1363
+ if (A > 0) {
1364
+ const _ = T;
1365
+ d.splice(
1366
+ k,
1367
+ 1,
1368
+ { ..._, raw: _.raw.slice(0, A), text: _.text.slice(0, A) },
1369
+ { ..._, raw: _.raw.slice(A), text: _.text.slice(A) }
1370
+ ), k++;
1371
+ }
1372
+ }
1373
+ const I = d.slice(k).map((A) => A.raw).join("");
1374
+ g = {
1375
+ from: k,
1376
+ source: I,
1377
+ unresolved: b >= 0,
1378
+ extensionPending: W(I),
1379
+ lastChar: I.slice(-1)
1380
+ };
1381
+ }
1382
+ function et() {
1383
+ u = void 0, g = void 0, f = !1;
1384
+ const h = l.at(-1)?.token;
1385
+ if (h?.type === "paragraph") {
1386
+ F(h);
1387
+ const T = h.raw.lastIndexOf(`
1388
+ `) + 1, I = h.raw.slice(T, T + 32);
1389
+ f = !h.raw.endsWith(`
1390
+ `) && !/^(?: {0,3}(?:[-+*_]+|[0-9]{1,9}[.)]?)[ \t]*$| {0,3}[[<\x60~#|=])/u.test(I);
1391
+ }
1392
+ if (h?.type !== "code") return;
1393
+ const p = /^(\x60{3,}|~{3,})[^\n]*\n/.exec(h.raw);
1394
+ if (!p) return;
1395
+ const d = p[1], b = h.raw.slice(p[0].length), k = {
1396
+ mark: d[0],
1397
+ minimum: d.length,
1398
+ count: 0,
1399
+ indent: 0,
1400
+ candidate: !0,
1401
+ pendingNewline: b.endsWith(`
1402
+ `)
1403
+ };
1404
+ L(b, k) || (u = k);
1405
+ }
1406
+ function ce(h = !1) {
1407
+ const p = l[c]?.start ?? 0, d = l.splice(c);
1408
+ for (const m of d) O(m);
1409
+ const b = z(j(p), a), k = i;
1410
+ i = Object.freeze(
1411
+ Object.fromEntries(
1412
+ Object.entries(b.links).map(([m, R]) => [m, Object.freeze({ ...R })])
1413
+ )
1414
+ );
1415
+ const T = [];
1416
+ let I = p;
1417
+ for (let m = 0; m < b.length; m++) {
1418
+ const R = b[m], B = d[m], D = {
1419
+ id: B?.start === I ? B.id : o++,
1420
+ start: I,
1421
+ token: R,
1422
+ references: /* @__PURE__ */ new Set()
1423
+ };
1424
+ l.push(D), H(D), m === b.length - 1 && R.type === "paragraph" && F(R), (!h || !B || JSON.stringify(B.token) !== JSON.stringify(R)) && T.push({ kind: "replace", block: G(D) }), I += R.raw.length;
1425
+ }
1426
+ const A = new Set(l.slice(c).map((m) => m.id));
1427
+ for (const m of d)
1428
+ A.has(m.id) || T.push({ kind: "remove", id: m.id });
1429
+ const _ = /* @__PURE__ */ new Set();
1430
+ for (const m of /* @__PURE__ */ new Set([...Object.keys(k), ...Object.keys(i)]))
1431
+ if (!(k[m]?.href === i[m]?.href && k[m]?.title === i[m]?.title))
1432
+ for (const R of S.get(m) ?? [])
1433
+ R.start < p && _.add(R);
1434
+ for (const m of _) {
1435
+ const R = z(m.token.raw, i);
1436
+ R.length === 1 && (m.token = R[0], T.push({ kind: "replace", block: G(m) }));
1437
+ }
1438
+ const ue = c;
1439
+ c = Math.max(0, l.length - 1), l[c]?.token.type === "space" ? c = Math.max(0, c - 1) : c > 0 && !l[c - 1].token.raw.endsWith(`
1440
+
1441
+ `) && (l[c - 1]?.token.type !== "space" ? c-- : /\n[ \t]*\n/u.test(l[c - 1].token.raw) || (c = Math.max(0, c - 2)));
1442
+ const U = l.at(-1)?.token;
1443
+ c > 1 && l[c - 1]?.token.type === "space" && l[c - 2]?.token.type === "list" && (U?.type === "list" || U?.type === "paragraph" && /^ {0,3}(?:[0-9]{1,9}[.)]?|[-+*])[ \t]*$/u.test(U.raw)) && (c -= 2);
1444
+ for (let m = ue; m < c; m++) {
1445
+ const R = l[m].token;
1446
+ R.type === "def" && !a[R.tag] && (a[R.tag] = { href: R.href, title: R.title });
1447
+ }
1448
+ return et(), C(T);
1449
+ }
1450
+ function ze(h) {
1451
+ const p = n && h.startsWith(`
1452
+ `);
1453
+ return n = h.endsWith("\r"), (p ? h.slice(1) : h).replace(/\r\n?/g, `
1454
+ `);
1455
+ }
1456
+ function tt(h) {
1457
+ if (!h) return C([]);
1458
+ if (s += h.length, h = ze(h), !h) return C([]);
1459
+ r.push({ start: e, text: h }), e += h.length;
1460
+ const p = l.at(-1), d = p?.token;
1461
+ if (p && c === l.length - 1 && d?.type === "code" && u && !h.includes("\r") && !L(h, u)) {
1462
+ const k = (u.pendingNewline ? `
1463
+ ` : "") + (h.endsWith(`
1464
+ `) ? h.slice(0, -1) : h);
1465
+ return u.pendingNewline = h.endsWith(`
1466
+ `), d.raw += h, d.text += k, C(k ? [{ kind: "append_text", id: p.id, text: k, code: !0 }] : []);
1467
+ }
1468
+ const b = d?.type === "paragraph" ? d : void 0;
1469
+ if (p && c === l.length - 1 && b && g && f && !/[\n\r]/u.test(h)) {
1470
+ const k = g, T = b.tokens.at(-1), I = T?.type === "text" && k.from === b.tokens.length - 1 && !W(h) && !k.extensionPending && !/[\\\x60*_[\]<>~&:/.@;|="'()-]/u.test(h) && !/[\\\x60*_[\]<>~&:/.@;|="'()-]$/u.test(k.lastChar);
1471
+ if (b.raw += h, b.text += h, I) {
1472
+ const R = T, B = k.unresolved ? -1 : h.lastIndexOf(" "), D = B > 0 ? h.slice(0, B) : B === 0 ? "" : h, he = [], pe = b.tokens.length - 1;
1473
+ if (D && (R.raw += D, R.text += D, he.push({
1474
+ kind: "append_text",
1475
+ id: p.id,
1476
+ text: D,
1477
+ code: !1,
1478
+ inlineIndex: pe
1479
+ })), B >= 0) {
1480
+ const ne = h.slice(B), Ae = { type: "text", raw: ne, text: ne };
1481
+ b.tokens.push(Ae), he.push({
1482
+ kind: "inline",
1483
+ id: p.id,
1484
+ from: pe + 1,
1485
+ deleteCount: 0,
1486
+ tokens: [structuredClone(Ae)]
1487
+ }), g = {
1488
+ from: pe + 1,
1489
+ source: ne,
1490
+ unresolved: !1,
1491
+ extensionPending: !1,
1492
+ lastChar: ne.slice(-1)
1493
+ };
1494
+ } else
1495
+ k.source += h, k.lastChar = h.slice(-1);
1496
+ return C(he);
1497
+ }
1498
+ const A = new t.Lexer({ ...t.defaults });
1499
+ A.tokens.links = i;
1500
+ const _ = k.source + h;
1501
+ w += _.length;
1502
+ const ue = A.inlineTokens(_), U = b.tokens.length - k.from;
1503
+ b.tokens.splice(k.from, U, ...ue), F(b, k.from);
1504
+ const m = b.tokens.slice(k.from);
1505
+ return C([
1506
+ {
1507
+ kind: "inline",
1508
+ id: p.id,
1509
+ from: k.from,
1510
+ deleteCount: U,
1511
+ tokens: structuredClone(m)
1512
+ }
1513
+ ]);
1514
+ }
1515
+ return ce();
1516
+ }
1517
+ function nt(h = "") {
1518
+ s = h.length, n = !1;
1519
+ const p = ze(h);
1520
+ return e = p.length, r = p ? [{ start: 0, text: p }] : [], i = /* @__PURE__ */ Object.create(null), a = /* @__PURE__ */ Object.create(null), S.clear(), c = 0, u = void 0, $++, ce(!0);
1521
+ }
1522
+ function rt() {
1523
+ const h = l.map((p) => structuredClone(p.token));
1524
+ return h.links = { ...i }, h;
1525
+ }
1526
+ function st() {
1527
+ return $++, c = 0, a = /* @__PURE__ */ Object.create(null), ce(!0);
1528
+ }
1529
+ return {
1530
+ append: tt,
1531
+ reset: nt,
1532
+ finish: st,
1533
+ snapshot: rt,
1534
+ get sourceLength() {
1535
+ return s;
1536
+ },
1537
+ diagnostics: () => ({ fullParses: $, parsedCharacters: w, blocks: l.length })
1538
+ };
1539
+ }
1540
+ function un(t, e = { maxSessions: 32, maxSourceLength: 8 * 1024 * 1024 }) {
1541
+ if (!Number.isSafeInteger(e.maxSessions) || e.maxSessions <= 0 || !Number.isSafeInteger(e.maxSourceLength) || e.maxSourceLength <= 0)
1542
+ throw new Error("Markdown session limits must be positive integers");
1543
+ const r = /* @__PURE__ */ new Map();
1544
+ let s = 0;
1545
+ function n(i) {
1546
+ const a = r.get(i);
1547
+ a && (s -= a.accountedLength), r.delete(i);
1548
+ }
1549
+ function l(i) {
1550
+ const a = { type: "markdown-session", request: i?.request ?? 0, session: i?.session ?? 0, sequence: i?.sequence ?? 0 };
1551
+ try {
1552
+ if (i?.type !== "markdown-session" || !Number.isSafeInteger(i.request) || i.request < 1 || !Number.isSafeInteger(i.session) || i.session < 1 || !Number.isSafeInteger(i.sequence) || i.sequence < 0 || !Number.isSafeInteger(i.offset) || i.offset < 0)
1553
+ throw new Error("Invalid Markdown session identity");
1554
+ if (i.operation === "open") {
1555
+ if (r.has(i.session) || i.sequence !== 0 || i.offset !== 0 || i.text !== void 0)
1556
+ throw new Error("Invalid Markdown session admission");
1557
+ if (r.size >= e.maxSessions) throw new Error("Markdown session limit exceeded");
1558
+ const f = cn(t(i.config));
1559
+ return r.set(i.session, { parser: f, sequence: 0, accountedLength: 0 }), a;
1560
+ }
1561
+ const o = r.get(i.session);
1562
+ if (!o || i.sequence !== o.sequence + 1 || i.offset !== o.parser.sourceLength)
1563
+ throw new Error("Markdown session continuity lost");
1564
+ if (i.operation === "close")
1565
+ return n(i.session), a;
1566
+ if (i.operation !== "reset" && i.operation !== "append" && i.operation !== "finish")
1567
+ throw new Error("Unknown Markdown session operation");
1568
+ if (i.operation !== "finish" && typeof i.text != "string") throw new Error("Markdown source is required");
1569
+ if (i.operation === "finish" && i.text !== void 0) throw new Error("Markdown finish cannot append source");
1570
+ const c = o.parser.sourceLength, u = i.operation === "reset" ? i.text.length : c + (i.text?.length ?? 0);
1571
+ if (s - c + u > e.maxSourceLength) throw new Error("Markdown source budget exceeded");
1572
+ const g = i.operation === "reset" ? o.parser.reset(i.text) : i.operation === "append" ? o.parser.append(i.text) : o.parser.finish();
1573
+ return s += o.parser.sourceLength - c, o.accountedLength = o.parser.sourceLength, o.sequence = i.sequence, { ...a, update: g };
1574
+ } catch (o) {
1575
+ return n(a.session), { ...a, error: o instanceof Error ? o.message : "Markdown session failed" };
1576
+ }
1577
+ }
1578
+ return { handle: l, close: () => {
1579
+ r.clear(), s = 0;
1580
+ }, diagnostics: () => ({ sessions: r.size, sourceLength: s }) };
1581
+ }
1582
+ const hn = un((t) => Ve(t));
1583
+ postMessage({ type: "ready" });
1584
+ addEventListener("message", (t) => {
1585
+ if (!t.data || typeof t.data != "object") return;
1586
+ if ("type" in t.data && t.data.type === "markdown-session") {
1587
+ postMessage(hn.handle(t.data));
1588
+ return;
1589
+ }
1590
+ const { id: e, content: r } = t.data;
1591
+ try {
1592
+ const s = an(r);
1593
+ postMessage({ id: e, html: s });
1594
+ } catch (s) {
1595
+ const n = {
1596
+ id: e,
1597
+ html: "",
1598
+ error: s instanceof Error ? s.message : "Failed to render markdown"
1599
+ };
1600
+ postMessage(n);
1601
+ }
1602
+ });