@asicupv/paella-extra-plugins
Version:
Extra plugins for Paella Player.
1,067 lines • 76.6 kB
JavaScript
function C() {
return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
}
var y = C();
function le(r) {
y = r;
}
var T = { exec: () => null };
function u(r, e = "") {
let n = typeof r == "string" ? r : r.source, s = { replace: (t, i) => {
let a = typeof i == "string" ? i : i.source;
return a = a.replace(m.caret, "$1"), n = n.replace(t, a), s;
}, getRegex: () => new RegExp(n, e) };
return s;
}
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, listReplaceTabs: /^\t+/, listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g, listIsTask: /^\[[ xX]\] /, listReplaceTask: /^\[[ 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, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (r) => new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}#`), htmlBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}<(?:[a-z].*>|!--)`, "i") }, Re = /^(?:[ \t]*(?:\n|$))+/, Se = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, ze = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, P = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Te = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, Q = /(?:[*+-]|\d{1,9}[.)])/, oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ce = u(oe).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(), Ae = u(oe).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(), G = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, je = /^[^\n]+/, U = /(?!\s*\])(?:\\.|[^\[\]\\])+/, qe = u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", U).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Pe = u(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, Q).getRegex(), L = "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", X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Ee = u("^ {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", X).replace("tag", L).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), he = u(G).replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex(), Ze = u(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", he).getRegex(), F = { blockquote: Ze, code: Se, def: qe, fences: ze, heading: Te, hr: P, html: Ee, lheading: ce, list: Pe, newline: Re, paragraph: he, table: T, text: je }, ee = u("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex(), Ce = { ...F, lheading: Ae, table: ee, paragraph: u(G).replace("hr", P).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", ee).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", L).getRegex() }, Le = { ...F, html: u(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).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: T, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: u(G).replace("hr", P).replace("heading", ` *#{1,6} *[^
]`).replace("lheading", ce).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Ie = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Be = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, pe = /^( {2,}|\\)\n(?!\s*$)/, Me = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, I = /[\p{P}\p{S}]/u, V = /[\s\p{P}\p{S}]/u, ue = /[^\s\p{P}\p{S}]/u, Oe = u(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, V).getRegex(), ge = /(?!~)[\p{P}\p{S}]/u, Ne = /(?!~)[\s\p{P}\p{S}]/u, De = /(?:[^\s\p{P}\p{S}]|~)/u, He = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g, de = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Qe = u(de, "u").replace(/punct/g, I).getRegex(), Ge = u(de, "u").replace(/punct/g, ge).getRegex(), _e = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Ue = u(_e, "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, V).replace(/punct/g, I).getRegex(), Xe = u(_e, "gu").replace(/notPunctSpace/g, De).replace(/punctSpace/g, Ne).replace(/punct/g, ge).getRegex(), Fe = u("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, V).replace(/punct/g, I).getRegex(), Ve = u(/\\(punct)/, "gu").replace(/punct/g, I).getRegex(), Je = u(/^<(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(), Ke = u(X).replace("(?:-->|$)", "-->").getRegex(), We = u("^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", Ke).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), Z = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, Ye = u(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", Z).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ke = u(/^!?\[(label)\]\[(ref)\]/).replace("label", Z).replace("ref", U).getRegex(), be = u(/^!?\[(ref)\](?:\[\])?/).replace("ref", U).getRegex(), et = u("reflink|nolink(?!\\()", "g").replace("reflink", ke).replace("nolink", be).getRegex(), J = { _backpedal: T, anyPunctuation: Ve, autolink: Je, blockSkip: He, br: pe, code: Be, del: T, emStrongLDelim: Qe, emStrongRDelimAst: Ue, emStrongRDelimUnd: Fe, escape: Ie, link: Ye, nolink: be, punctuation: Oe, reflink: ke, reflinkSearch: et, tag: We, text: Me, url: T }, tt = { ...J, link: u(/^!?\[(label)\]\((.*?)\)/).replace("label", Z).getRegex(), reflink: u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", Z).getRegex() }, N = { ...J, emStrongRDelimAst: Xe, emStrongLDelim: Ge, url: u(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/ }, rt = { ...N, br: u(pe).replace("{2,}", "*").getRegex(), text: u(N.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, E = { normal: F, gfm: Ce, pedantic: Le }, S = { normal: J, gfm: N, breaks: rt, pedantic: tt }, nt = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, te = (r) => nt[r];
function f(r, e) {
if (e) {
if (m.escapeTest.test(r)) return r.replace(m.escapeReplace, te);
} else if (m.escapeTestNoEncode.test(r)) return r.replace(m.escapeReplaceNoEncode, te);
return r;
}
function re(r) {
try {
r = encodeURI(r).replace(m.percentDecode, "%");
} catch {
return null;
}
return r;
}
function ne(r, e) {
let n = r.replace(m.findPipe, (i, a, l) => {
let o = !1, c = a;
for (; --c >= 0 && l[c] === "\\"; ) o = !o;
return o ? "|" : " |";
}), s = n.split(m.splitPipe), t = 0;
if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e) if (s.length > e) s.splice(e);
else for (; s.length < e; ) s.push("");
for (; t < s.length; t++) s[t] = s[t].trim().replace(m.slashPipe, "|");
return s;
}
function z(r, e, n) {
let s = r.length;
if (s === 0) return "";
let t = 0;
for (; t < s && r.charAt(s - t - 1) === e; )
t++;
return r.slice(0, s - t);
}
function st(r, e) {
if (r.indexOf(e[1]) === -1) return -1;
let n = 0;
for (let s = 0; s < r.length; s++) if (r[s] === "\\") s++;
else if (r[s] === e[0]) n++;
else if (r[s] === e[1] && (n--, n < 0)) return s;
return n > 0 ? -2 : -1;
}
function se(r, e, n, s, t) {
let i = e.href, a = e.title || null, l = r[1].replace(t.other.outputLinkReplace, "$1");
s.state.inLink = !0;
let o = { type: r[0].charAt(0) === "!" ? "image" : "link", raw: n, href: i, title: a, text: l, tokens: s.inlineTokens(l) };
return s.state.inLink = !1, o;
}
function at(r, e, n) {
let s = r.match(n.other.indentCodeCompensation);
if (s === null) return e;
let t = s[1];
return e.split(`
`).map((i) => {
let a = i.match(n.other.beginningSpace);
if (a === null) return i;
let [l] = a;
return l.length >= t.length ? i.slice(t.length) : i;
}).join(`
`);
}
var j = class {
options;
rules;
lexer;
constructor(r) {
this.options = r || y;
}
space(r) {
let e = this.rules.block.newline.exec(r);
if (e && e[0].length > 0) return { type: "space", raw: e[0] };
}
code(r) {
let e = this.rules.block.code.exec(r);
if (e) {
let n = e[0].replace(this.rules.other.codeRemoveIndent, "");
return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : z(n, `
`) };
}
}
fences(r) {
let e = this.rules.block.fences.exec(r);
if (e) {
let n = e[0], s = at(n, e[3] || "", this.rules);
return { type: "code", raw: n, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s };
}
}
heading(r) {
let e = this.rules.block.heading.exec(r);
if (e) {
let n = e[2].trim();
if (this.rules.other.endingHash.test(n)) {
let s = z(n, "#");
(this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (n = s.trim());
}
return { type: "heading", raw: e[0], depth: e[1].length, text: n, tokens: this.lexer.inline(n) };
}
}
hr(r) {
let e = this.rules.block.hr.exec(r);
if (e) return { type: "hr", raw: z(e[0], `
`) };
}
blockquote(r) {
let e = this.rules.block.blockquote.exec(r);
if (e) {
let n = z(e[0], `
`).split(`
`), s = "", t = "", i = [];
for (; n.length > 0; ) {
let a = !1, l = [], o;
for (o = 0; o < n.length; o++) if (this.rules.other.blockquoteStart.test(n[o])) l.push(n[o]), a = !0;
else if (!a) l.push(n[o]);
else break;
n = n.slice(o);
let c = l.join(`
`), h = c.replace(this.rules.other.blockquoteSetextReplace, `
$1`).replace(this.rules.other.blockquoteSetextReplace2, "");
s = s ? `${s}
${c}` : c, t = t ? `${t}
${h}` : h;
let d = this.lexer.state.top;
if (this.lexer.state.top = !0, this.lexer.blockTokens(h, i, !0), this.lexer.state.top = d, n.length === 0) break;
let p = i.at(-1);
if (p?.type === "code") break;
if (p?.type === "blockquote") {
let k = p, _ = k.raw + `
` + n.join(`
`), b = this.blockquote(_);
i[i.length - 1] = b, s = s.substring(0, s.length - k.raw.length) + b.raw, t = t.substring(0, t.length - k.text.length) + b.text;
break;
} else if (p?.type === "list") {
let k = p, _ = k.raw + `
` + n.join(`
`), b = this.list(_);
i[i.length - 1] = b, s = s.substring(0, s.length - p.raw.length) + b.raw, t = t.substring(0, t.length - k.raw.length) + b.raw, n = _.substring(i.at(-1).raw.length).split(`
`);
continue;
}
}
return { type: "blockquote", raw: s, tokens: i, text: t };
}
}
list(r) {
let e = this.rules.block.list.exec(r);
if (e) {
let n = e[1].trim(), s = n.length > 1, t = { type: "list", raw: "", ordered: s, start: s ? +n.slice(0, -1) : "", loose: !1, items: [] };
n = s ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = s ? n : "[*+-]");
let i = this.rules.other.listItemRegex(n), a = !1;
for (; r; ) {
let o = !1, c = "", h = "";
if (!(e = i.exec(r)) || this.rules.block.hr.test(r)) break;
c = e[0], r = r.substring(c.length);
let d = e[2].split(`
`, 1)[0].replace(this.rules.other.listReplaceTabs, (M) => " ".repeat(3 * M.length)), p = r.split(`
`, 1)[0], k = !d.trim(), _ = 0;
if (this.options.pedantic ? (_ = 2, h = d.trimStart()) : k ? _ = e[1].length + 1 : (_ = e[2].search(this.rules.other.nonSpaceChar), _ = _ > 4 ? 1 : _, h = d.slice(_), _ += e[1].length), k && this.rules.other.blankLine.test(p) && (c += p + `
`, r = r.substring(p.length + 1), o = !0), !o) {
let M = this.rules.other.nextBulletRegex(_), K = this.rules.other.hrRegex(_), W = this.rules.other.fencesBeginRegex(_), Y = this.rules.other.headingBeginRegex(_), $e = this.rules.other.htmlBeginRegex(_);
for (; r; ) {
let O = r.split(`
`, 1)[0], R;
if (p = O, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), R = p) : R = p.replace(this.rules.other.tabCharGlobal, " "), W.test(p) || Y.test(p) || $e.test(p) || M.test(p) || K.test(p)) break;
if (R.search(this.rules.other.nonSpaceChar) >= _ || !p.trim()) h += `
` + R.slice(_);
else {
if (k || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || W.test(d) || Y.test(d) || K.test(d)) break;
h += `
` + p;
}
!k && !p.trim() && (k = !0), c += O + `
`, r = r.substring(O.length + 1), d = R.slice(_);
}
}
t.loose || (a ? t.loose = !0 : this.rules.other.doubleBlankLine.test(c) && (a = !0));
let b = null, $;
this.options.gfm && (b = this.rules.other.listIsTask.exec(h), b && ($ = b[0] !== "[ ] ", h = h.replace(this.rules.other.listReplaceTask, ""))), t.items.push({ type: "list_item", raw: c, task: !!b, checked: $, loose: !1, text: h, tokens: [] }), t.raw += c;
}
let l = t.items.at(-1);
if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
else return;
t.raw = t.raw.trimEnd();
for (let o = 0; o < t.items.length; o++) if (this.lexer.state.top = !1, t.items[o].tokens = this.lexer.blockTokens(t.items[o].text, []), !t.loose) {
let c = t.items[o].tokens.filter((d) => d.type === "space"), h = c.length > 0 && c.some((d) => this.rules.other.anyLine.test(d.raw));
t.loose = h;
}
if (t.loose) for (let o = 0; o < t.items.length; o++) t.items[o].loose = !0;
return t;
}
}
html(r) {
let e = this.rules.block.html.exec(r);
if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
}
def(r) {
let e = this.rules.block.def.exec(r);
if (e) {
let n = 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") : "", t = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
return { type: "def", tag: n, raw: e[0], href: s, title: t };
}
}
table(r) {
let e = this.rules.block.table.exec(r);
if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
let n = ne(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), t = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
`) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] };
if (n.length === s.length) {
for (let a of s) this.rules.other.tableAlignRight.test(a) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(a) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(a) ? i.align.push("left") : i.align.push(null);
for (let a = 0; a < n.length; a++) i.header.push({ text: n[a], tokens: this.lexer.inline(n[a]), header: !0, align: i.align[a] });
for (let a of t) i.rows.push(ne(a, i.header.length).map((l, o) => ({ text: l, tokens: this.lexer.inline(l), header: !1, align: i.align[o] })));
return i;
}
}
lheading(r) {
let e = this.rules.block.lheading.exec(r);
if (e) return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: e[1], tokens: this.lexer.inline(e[1]) };
}
paragraph(r) {
let e = this.rules.block.paragraph.exec(r);
if (e) {
let n = e[1].charAt(e[1].length - 1) === `
` ? e[1].slice(0, -1) : e[1];
return { type: "paragraph", raw: e[0], text: n, tokens: this.lexer.inline(n) };
}
}
text(r) {
let e = this.rules.block.text.exec(r);
if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
}
escape(r) {
let e = this.rules.inline.escape.exec(r);
if (e) return { type: "escape", raw: e[0], text: e[1] };
}
tag(r) {
let e = this.rules.inline.tag.exec(r);
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] };
}
link(r) {
let e = this.rules.inline.link.exec(r);
if (e) {
let n = e[2].trim();
if (!this.options.pedantic && this.rules.other.startAngleBracket.test(n)) {
if (!this.rules.other.endAngleBracket.test(n)) return;
let i = z(n.slice(0, -1), "\\");
if ((n.length - i.length) % 2 === 0) return;
} else {
let i = st(e[2], "()");
if (i === -2) return;
if (i > -1) {
let a = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, a).trim(), e[3] = "";
}
}
let s = e[2], t = "";
if (this.options.pedantic) {
let i = this.rules.other.pedanticHrefTitle.exec(s);
i && (s = i[1], t = i[3]);
} else t = e[3] ? e[3].slice(1, -1) : "";
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)), se(e, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: t && t.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
}
}
reflink(r, e) {
let n;
if ((n = this.rules.inline.reflink.exec(r)) || (n = this.rules.inline.nolink.exec(r))) {
let s = (n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " "), t = e[s.toLowerCase()];
if (!t) {
let i = n[0].charAt(0);
return { type: "text", raw: i, text: i };
}
return se(n, t, n[0], this.lexer, this.rules);
}
}
emStrong(r, e, n = "") {
let s = this.rules.inline.emStrongLDelim.exec(r);
if (!(!s || s[3] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[2]) || !n || this.rules.inline.punctuation.exec(n))) {
let t = [...s[0]].length - 1, i, a, l = t, o = 0, c = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
for (c.lastIndex = 0, e = e.slice(-1 * r.length + t); (s = c.exec(e)) != null; ) {
if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
if (a = [...i].length, s[3] || s[4]) {
l += a;
continue;
} else if ((s[5] || s[6]) && t % 3 && !((t + a) % 3)) {
o += a;
continue;
}
if (l -= a, l > 0) continue;
a = Math.min(a, a + l + o);
let h = [...s[0]][0].length, d = r.slice(0, t + s.index + h + a);
if (Math.min(t, a) % 2) {
let k = d.slice(1, -1);
return { type: "em", raw: d, text: k, tokens: this.lexer.inlineTokens(k) };
}
let p = d.slice(2, -2);
return { type: "strong", raw: d, text: p, tokens: this.lexer.inlineTokens(p) };
}
}
}
codespan(r) {
let e = this.rules.inline.code.exec(r);
if (e) {
let n = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(n), t = this.rules.other.startingSpaceChar.test(n) && this.rules.other.endingSpaceChar.test(n);
return s && t && (n = n.substring(1, n.length - 1)), { type: "codespan", raw: e[0], text: n };
}
}
br(r) {
let e = this.rules.inline.br.exec(r);
if (e) return { type: "br", raw: e[0] };
}
del(r) {
let e = this.rules.inline.del.exec(r);
if (e) return { type: "del", raw: e[0], text: e[2], tokens: this.lexer.inlineTokens(e[2]) };
}
autolink(r) {
let e = this.rules.inline.autolink.exec(r);
if (e) {
let n, s;
return e[2] === "@" ? (n = e[1], s = "mailto:" + n) : (n = e[1], s = n), { type: "link", raw: e[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
}
}
url(r) {
let e;
if (e = this.rules.inline.url.exec(r)) {
let n, s;
if (e[2] === "@") n = e[0], s = "mailto:" + n;
else {
let t;
do
t = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
while (t !== e[0]);
n = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
}
return { type: "link", raw: e[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
}
}
inlineText(r) {
let e = this.rules.inline.text.exec(r);
if (e) {
let n = this.lexer.state.inRawBlock;
return { type: "text", raw: e[0], text: e[0], escaped: n };
}
}
}, w = class D {
tokens;
options;
state;
tokenizer;
inlineQueue;
constructor(e) {
this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || y, this.options.tokenizer = this.options.tokenizer || new j(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
let n = { other: m, block: E.normal, inline: S.normal };
this.options.pedantic ? (n.block = E.pedantic, n.inline = S.pedantic) : this.options.gfm && (n.block = E.gfm, this.options.breaks ? n.inline = S.breaks : n.inline = S.gfm), this.tokenizer.rules = n;
}
static get rules() {
return { block: E, inline: S };
}
static lex(e, n) {
return new D(n).lex(e);
}
static lexInline(e, n) {
return new D(n).inlineTokens(e);
}
lex(e) {
e = e.replace(m.carriageReturn, `
`), this.blockTokens(e, this.tokens);
for (let n = 0; n < this.inlineQueue.length; n++) {
let s = this.inlineQueue[n];
this.inlineTokens(s.src, s.tokens);
}
return this.inlineQueue = [], this.tokens;
}
blockTokens(e, n = [], s = !1) {
for (this.options.pedantic && (e = e.replace(m.tabCharGlobal, " ").replace(m.spaceLine, "")); e; ) {
let t;
if (this.options.extensions?.block?.some((a) => (t = a.call({ lexer: this }, e, n)) ? (e = e.substring(t.raw.length), n.push(t), !0) : !1)) continue;
if (t = this.tokenizer.space(e)) {
e = e.substring(t.raw.length);
let a = n.at(-1);
t.raw.length === 1 && a !== void 0 ? a.raw += `
` : n.push(t);
continue;
}
if (t = this.tokenizer.code(e)) {
e = e.substring(t.raw.length);
let a = n.at(-1);
a?.type === "paragraph" || a?.type === "text" ? (a.raw += `
` + t.raw, a.text += `
` + t.text, this.inlineQueue.at(-1).src = a.text) : n.push(t);
continue;
}
if (t = this.tokenizer.fences(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.heading(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.hr(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.blockquote(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.list(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.html(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.def(e)) {
e = e.substring(t.raw.length);
let a = n.at(-1);
a?.type === "paragraph" || a?.type === "text" ? (a.raw += `
` + t.raw, a.text += `
` + t.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[t.tag] || (this.tokens.links[t.tag] = { href: t.href, title: t.title });
continue;
}
if (t = this.tokenizer.table(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
if (t = this.tokenizer.lheading(e)) {
e = e.substring(t.raw.length), n.push(t);
continue;
}
let i = e;
if (this.options.extensions?.startBlock) {
let a = 1 / 0, l = e.slice(1), o;
this.options.extensions.startBlock.forEach((c) => {
o = c.call({ lexer: this }, l), typeof o == "number" && o >= 0 && (a = Math.min(a, o));
}), a < 1 / 0 && a >= 0 && (i = e.substring(0, a + 1));
}
if (this.state.top && (t = this.tokenizer.paragraph(i))) {
let a = n.at(-1);
s && a?.type === "paragraph" ? (a.raw += `
` + t.raw, a.text += `
` + t.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : n.push(t), s = i.length !== e.length, e = e.substring(t.raw.length);
continue;
}
if (t = this.tokenizer.text(e)) {
e = e.substring(t.raw.length);
let a = n.at(-1);
a?.type === "text" ? (a.raw += `
` + t.raw, a.text += `
` + t.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : n.push(t);
continue;
}
if (e) {
let a = "Infinite loop on byte: " + e.charCodeAt(0);
if (this.options.silent) {
console.error(a);
break;
} else throw new Error(a);
}
}
return this.state.top = !0, n;
}
inline(e, n = []) {
return this.inlineQueue.push({ src: e, tokens: n }), n;
}
inlineTokens(e, n = []) {
let s = e, t = null;
if (this.tokens.links) {
let l = Object.keys(this.tokens.links);
if (l.length > 0) for (; (t = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; ) l.includes(t[0].slice(t[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, t.index) + "[" + "a".repeat(t[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
}
for (; (t = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; ) s = s.slice(0, t.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
for (; (t = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; ) s = s.slice(0, t.index) + "[" + "a".repeat(t[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
let i = !1, a = "";
for (; e; ) {
i || (a = ""), i = !1;
let l;
if (this.options.extensions?.inline?.some((c) => (l = c.call({ lexer: this }, e, n)) ? (e = e.substring(l.raw.length), n.push(l), !0) : !1)) continue;
if (l = this.tokenizer.escape(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.tag(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.link(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.reflink(e, this.tokens.links)) {
e = e.substring(l.raw.length);
let c = n.at(-1);
l.type === "text" && c?.type === "text" ? (c.raw += l.raw, c.text += l.text) : n.push(l);
continue;
}
if (l = this.tokenizer.emStrong(e, s, a)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.codespan(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.br(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.del(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (l = this.tokenizer.autolink(e)) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
if (!this.state.inLink && (l = this.tokenizer.url(e))) {
e = e.substring(l.raw.length), n.push(l);
continue;
}
let o = e;
if (this.options.extensions?.startInline) {
let c = 1 / 0, h = e.slice(1), d;
this.options.extensions.startInline.forEach((p) => {
d = p.call({ lexer: this }, h), typeof d == "number" && d >= 0 && (c = Math.min(c, d));
}), c < 1 / 0 && c >= 0 && (o = e.substring(0, c + 1));
}
if (l = this.tokenizer.inlineText(o)) {
e = e.substring(l.raw.length), l.raw.slice(-1) !== "_" && (a = l.raw.slice(-1)), i = !0;
let c = n.at(-1);
c?.type === "text" ? (c.raw += l.raw, c.text += l.text) : n.push(l);
continue;
}
if (e) {
let c = "Infinite loop on byte: " + e.charCodeAt(0);
if (this.options.silent) {
console.error(c);
break;
} else throw new Error(c);
}
}
return n;
}
}, q = class {
options;
parser;
constructor(r) {
this.options = r || y;
}
space(r) {
return "";
}
code({ text: r, lang: e, escaped: n }) {
let s = (e || "").match(m.notSpaceStart)?.[0], t = r.replace(m.endingNewline, "") + `
`;
return s ? '<pre><code class="language-' + f(s) + '">' + (n ? t : f(t, !0)) + `</code></pre>
` : "<pre><code>" + (n ? t : f(t, !0)) + `</code></pre>
`;
}
blockquote({ tokens: r }) {
return `<blockquote>
${this.parser.parse(r)}</blockquote>
`;
}
html({ text: r }) {
return r;
}
heading({ tokens: r, depth: e }) {
return `<h${e}>${this.parser.parseInline(r)}</h${e}>
`;
}
hr(r) {
return `<hr>
`;
}
list(r) {
let e = r.ordered, n = r.start, s = "";
for (let a = 0; a < r.items.length; a++) {
let l = r.items[a];
s += this.listitem(l);
}
let t = e ? "ol" : "ul", i = e && n !== 1 ? ' start="' + n + '"' : "";
return "<" + t + i + `>
` + s + "</" + t + `>
`;
}
listitem(r) {
let e = "";
if (r.task) {
let n = this.checkbox({ checked: !!r.checked });
r.loose ? r.tokens[0]?.type === "paragraph" ? (r.tokens[0].text = n + " " + r.tokens[0].text, r.tokens[0].tokens && r.tokens[0].tokens.length > 0 && r.tokens[0].tokens[0].type === "text" && (r.tokens[0].tokens[0].text = n + " " + f(r.tokens[0].tokens[0].text), r.tokens[0].tokens[0].escaped = !0)) : r.tokens.unshift({ type: "text", raw: n + " ", text: n + " ", escaped: !0 }) : e += n + " ";
}
return e += this.parser.parse(r.tokens, !!r.loose), `<li>${e}</li>
`;
}
checkbox({ checked: r }) {
return "<input " + (r ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
}
paragraph({ tokens: r }) {
return `<p>${this.parser.parseInline(r)}</p>
`;
}
table(r) {
let e = "", n = "";
for (let t = 0; t < r.header.length; t++) n += this.tablecell(r.header[t]);
e += this.tablerow({ text: n });
let s = "";
for (let t = 0; t < r.rows.length; t++) {
let i = r.rows[t];
n = "";
for (let a = 0; a < i.length; a++) n += this.tablecell(i[a]);
s += this.tablerow({ text: n });
}
return s && (s = `<tbody>${s}</tbody>`), `<table>
<thead>
` + e + `</thead>
` + s + `</table>
`;
}
tablerow({ text: r }) {
return `<tr>
${r}</tr>
`;
}
tablecell(r) {
let e = this.parser.parseInline(r.tokens), n = r.header ? "th" : "td";
return (r.align ? `<${n} align="${r.align}">` : `<${n}>`) + e + `</${n}>
`;
}
strong({ tokens: r }) {
return `<strong>${this.parser.parseInline(r)}</strong>`;
}
em({ tokens: r }) {
return `<em>${this.parser.parseInline(r)}</em>`;
}
codespan({ text: r }) {
return `<code>${f(r, !0)}</code>`;
}
br(r) {
return "<br>";
}
del({ tokens: r }) {
return `<del>${this.parser.parseInline(r)}</del>`;
}
link({ href: r, title: e, tokens: n }) {
let s = this.parser.parseInline(n), t = re(r);
if (t === null) return s;
r = t;
let i = '<a href="' + r + '"';
return e && (i += ' title="' + f(e) + '"'), i += ">" + s + "</a>", i;
}
image({ href: r, title: e, text: n, tokens: s }) {
s && (n = this.parser.parseInline(s, this.parser.textRenderer));
let t = re(r);
if (t === null) return f(n);
r = t;
let i = `<img src="${r}" alt="${n}"`;
return e && (i += ` title="${f(e)}"`), i += ">", i;
}
text(r) {
return "tokens" in r && r.tokens ? this.parser.parseInline(r.tokens) : "escaped" in r && r.escaped ? r.text : f(r.text);
}
}, B = class {
strong({ text: r }) {
return r;
}
em({ text: r }) {
return r;
}
codespan({ text: r }) {
return r;
}
del({ text: r }) {
return r;
}
html({ text: r }) {
return r;
}
text({ text: r }) {
return r;
}
link({ text: r }) {
return "" + r;
}
image({ text: r }) {
return "" + r;
}
br() {
return "";
}
}, x = class H {
options;
renderer;
textRenderer;
constructor(e) {
this.options = e || y, this.options.renderer = this.options.renderer || new q(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new B();
}
static parse(e, n) {
return new H(n).parse(e);
}
static parseInline(e, n) {
return new H(n).parseInline(e);
}
parse(e, n = !0) {
let s = "";
for (let t = 0; t < e.length; t++) {
let i = e[t];
if (this.options.extensions?.renderers?.[i.type]) {
let l = i, o = this.options.extensions.renderers[l.type].call({ parser: this }, l);
if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(l.type)) {
s += o || "";
continue;
}
}
let a = i;
switch (a.type) {
case "space": {
s += this.renderer.space(a);
continue;
}
case "hr": {
s += this.renderer.hr(a);
continue;
}
case "heading": {
s += this.renderer.heading(a);
continue;
}
case "code": {
s += this.renderer.code(a);
continue;
}
case "table": {
s += this.renderer.table(a);
continue;
}
case "blockquote": {
s += this.renderer.blockquote(a);
continue;
}
case "list": {
s += this.renderer.list(a);
continue;
}
case "html": {
s += this.renderer.html(a);
continue;
}
case "paragraph": {
s += this.renderer.paragraph(a);
continue;
}
case "text": {
let l = a, o = this.renderer.text(l);
for (; t + 1 < e.length && e[t + 1].type === "text"; ) l = e[++t], o += `
` + this.renderer.text(l);
n ? s += this.renderer.paragraph({ type: "paragraph", raw: o, text: o, tokens: [{ type: "text", raw: o, text: o, escaped: !0 }] }) : s += o;
continue;
}
default: {
let l = 'Token with "' + a.type + '" type was not found.';
if (this.options.silent) return console.error(l), "";
throw new Error(l);
}
}
}
return s;
}
parseInline(e, n = this.renderer) {
let s = "";
for (let t = 0; t < e.length; t++) {
let i = e[t];
if (this.options.extensions?.renderers?.[i.type]) {
let l = this.options.extensions.renderers[i.type].call({ parser: this }, i);
if (l !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
s += l || "";
continue;
}
}
let a = i;
switch (a.type) {
case "escape": {
s += n.text(a);
break;
}
case "html": {
s += n.html(a);
break;
}
case "link": {
s += n.link(a);
break;
}
case "image": {
s += n.image(a);
break;
}
case "strong": {
s += n.strong(a);
break;
}
case "em": {
s += n.em(a);
break;
}
case "codespan": {
s += n.codespan(a);
break;
}
case "br": {
s += n.br(a);
break;
}
case "del": {
s += n.del(a);
break;
}
case "text": {
s += n.text(a);
break;
}
default: {
let l = 'Token with "' + a.type + '" type was not found.';
if (this.options.silent) return console.error(l), "";
throw new Error(l);
}
}
}
return s;
}
}, A = class {
options;
block;
constructor(r) {
this.options = r || y;
}
static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
preprocess(r) {
return r;
}
postprocess(r) {
return r;
}
processAllTokens(r) {
return r;
}
provideLexer() {
return this.block ? w.lex : w.lexInline;
}
provideParser() {
return this.block ? x.parse : x.parseInline;
}
}, me = class {
defaults = C();
options = this.setOptions;
parse = this.parseMarkdown(!0);
parseInline = this.parseMarkdown(!1);
Parser = x;
Renderer = q;
TextRenderer = B;
Lexer = w;
Tokenizer = j;
Hooks = A;
constructor(...r) {
this.use(...r);
}
walkTokens(r, e) {
let n = [];
for (let s of r) switch (n = n.concat(e.call(this, s)), s.type) {
case "table": {
let t = s;
for (let i of t.header) n = n.concat(this.walkTokens(i.tokens, e));
for (let i of t.rows) for (let a of i) n = n.concat(this.walkTokens(a.tokens, e));
break;
}
case "list": {
let t = s;
n = n.concat(this.walkTokens(t.items, e));
break;
}
default: {
let t = s;
this.defaults.extensions?.childTokens?.[t.type] ? this.defaults.extensions.childTokens[t.type].forEach((i) => {
let a = t[i].flat(1 / 0);
n = n.concat(this.walkTokens(a, e));
}) : t.tokens && (n = n.concat(this.walkTokens(t.tokens, e)));
}
}
return n;
}
use(...r) {
let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
return r.forEach((n) => {
let s = { ...n };
if (s.async = this.defaults.async || s.async || !1, n.extensions && (n.extensions.forEach((t) => {
if (!t.name) throw new Error("extension name required");
if ("renderer" in t) {
let i = e.renderers[t.name];
i ? e.renderers[t.name] = function(...a) {
let l = t.renderer.apply(this, a);
return l === !1 && (l = i.apply(this, a)), l;
} : e.renderers[t.name] = t.renderer;
}
if ("tokenizer" in t) {
if (!t.level || t.level !== "block" && t.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
let i = e[t.level];
i ? i.unshift(t.tokenizer) : e[t.level] = [t.tokenizer], t.start && (t.level === "block" ? e.startBlock ? e.startBlock.push(t.start) : e.startBlock = [t.start] : t.level === "inline" && (e.startInline ? e.startInline.push(t.start) : e.startInline = [t.start]));
}
"childTokens" in t && t.childTokens && (e.childTokens[t.name] = t.childTokens);
}), s.extensions = e), n.renderer) {
let t = this.defaults.renderer || new q(this.defaults);
for (let i in n.renderer) {
if (!(i in t)) throw new Error(`renderer '${i}' does not exist`);
if (["options", "parser"].includes(i)) continue;
let a = i, l = n.renderer[a], o = t[a];
t[a] = (...c) => {
let h = l.apply(t, c);
return h === !1 && (h = o.apply(t, c)), h || "";
};
}
s.renderer = t;
}
if (n.tokenizer) {
let t = this.defaults.tokenizer || new j(this.defaults);
for (let i in n.tokenizer) {
if (!(i in t)) throw new Error(`tokenizer '${i}' does not exist`);
if (["options", "rules", "lexer"].includes(i)) continue;
let a = i, l = n.tokenizer[a], o = t[a];
t[a] = (...c) => {
let h = l.apply(t, c);
return h === !1 && (h = o.apply(t, c)), h;
};
}
s.tokenizer = t;
}
if (n.hooks) {
let t = this.defaults.hooks || new A();
for (let i in n.hooks) {
if (!(i in t)) throw new Error(`hook '${i}' does not exist`);
if (["options", "block"].includes(i)) continue;
let a = i, l = n.hooks[a], o = t[a];
A.passThroughHooks.has(i) ? t[a] = (c) => {
if (this.defaults.async) return Promise.resolve(l.call(t, c)).then((d) => o.call(t, d));
let h = l.call(t, c);
return o.call(t, h);
} : t[a] = (...c) => {
let h = l.apply(t, c);
return h === !1 && (h = o.apply(t, c)), h;
};
}
s.hooks = t;
}
if (n.walkTokens) {
let t = this.defaults.walkTokens, i = n.walkTokens;
s.walkTokens = function(a) {
let l = [];
return l.push(i.call(this, a)), t && (l = l.concat(t.call(this, a))), l;
};
}
this.defaults = { ...this.defaults, ...s };
}), this;
}
setOptions(r) {
return this.defaults = { ...this.defaults, ...r }, this;
}
lexer(r, e) {
return w.lex(r, e ?? this.defaults);
}
parser(r, e) {
return x.parse(r, e ?? this.defaults);
}
parseMarkdown(r) {
return (e, n) => {
let s = { ...n }, t = { ...this.defaults, ...s }, i = this.onError(!!t.silent, !!t.async);
if (this.defaults.async === !0 && s.async === !1) return i(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."));
if (typeof e > "u" || e === null) return i(new Error("marked(): input parameter is undefined or null"));
if (typeof e != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
t.hooks && (t.hooks.options = t, t.hooks.block = r);
let a = t.hooks ? t.hooks.provideLexer() : r ? w.lex : w.lexInline, l = t.hooks ? t.hooks.provideParser() : r ? x.parse : x.parseInline;
if (t.async) return Promise.resolve(t.hooks ? t.hooks.preprocess(e) : e).then((o) => a(o, t)).then((o) => t.hooks ? t.hooks.processAllTokens(o) : o).then((o) => t.walkTokens ? Promise.all(this.walkTokens(o, t.walkTokens)).then(() => o) : o).then((o) => l(o, t)).then((o) => t.hooks ? t.hooks.postprocess(o) : o).catch(i);
try {
t.hooks && (e = t.hooks.preprocess(e));
let o = a(e, t);
t.hooks && (o = t.hooks.processAllTokens(o)), t.walkTokens && this.walkTokens(o, t.walkTokens);
let c = l(o, t);
return t.hooks && (c = t.hooks.postprocess(c)), c;
} catch (o) {
return i(o);
}
};
}
onError(r, e) {
return (n) => {
if (n.message += `
Please report this to https://github.com/markedjs/marked.`, r) {
let s = "<p>An error occurred:</p><pre>" + f(n.message + "", !0) + "</pre>";
return e ? Promise.resolve(s) : s;
}
if (e) return Promise.reject(n);
throw n;
};
}
}, v = new me();
function g(r, e) {
return v.parse(r, e);
}
g.options = g.setOptions = function(r) {
return v.setOptions(r), g.defaults = v.defaults, le(g.defaults), g;
};
g.getDefaults = C;
g.defaults = y;
g.use = function(...r) {
return v.use(...r), g.defaults = v.defaults, le(g.defaults), g;
};
g.walkTokens = function(r, e) {
return v.walkTokens(r, e);
};
g.parseInline = v.parseInline;
g.Parser = x;
g.parser = x.parse;
g.Renderer = q;
g.TextRenderer = B;
g.Lexer = w;
g.lexer = w.lex;
g.Tokenizer = j;
g.Hooks = A;
g.parse = g;
g.options;
g.setOptions;
g.use;
g.walkTokens;
g.parseInline;
x.parse;
w.lex;
const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
Hooks: A,
Lexer: w,
Marked: me,
Parser: x,
Renderer: q,
TextRenderer: B,
Tokenizer: j,
get defaults() {
return y;
},
getDefaults: C,
marked: g
}, Symbol.toStringTag, { value: "Module" })), ae = [
{
type: "note",
icon: '<svg class="octicon octicon-info mr-2" viewBox="0 0 16 16" width="16" height="16" aria-hidden="true"><path d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8Zm8-6.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13ZM6.5 7.75A.75.75 0 0 1 7.25 7h1a.75.75 0 0 1 .75.75v2.75h.25a.75.75 0 0 1 0 1.5h-2a.75.75 0 0 1 0-1.5h.25v-2h-.25a.75.75 0 0 1-.75-.75ZM8 6a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z">