@gui-chat-plugin/markdown 0.0.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.js CHANGED
@@ -1,1250 +1,1509 @@
1
- import { samples as Te, pluginCore as _e } from "./core.js";
2
- import { TOOL_DEFINITION as Qt, executeMarkdown as jt } from "./core.js";
3
- import { defineComponent as pe, ref as ze, computed as N, watch as ne, nextTick as Ae, openBlock as C, createElementBlock as E, createElementVNode as x, Fragment as ve, toDisplayString as ue, createTextVNode as Pe, withDirectives as Ie, vModelText as Le } from "vue";
4
- function G() {
5
- return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
1
+ import { a as e, n as t, r as n, t as r } from "./samples-Cjla_vcD.js";
2
+ import { Fragment as i, computed as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, defineComponent as l, nextTick as u, openBlock as d, ref as ee, toDisplayString as f, vModelText as p, watch as te, withDirectives as ne } from "vue";
3
+ //#region node_modules/marked/lib/marked.esm.js
4
+ function m() {
5
+ return {
6
+ async: !1,
7
+ breaks: !1,
8
+ extensions: null,
9
+ gfm: !0,
10
+ hooks: null,
11
+ pedantic: !1,
12
+ renderer: null,
13
+ silent: !1,
14
+ tokenizer: null,
15
+ walkTokens: null
16
+ };
6
17
  }
7
- var T = G();
8
- function de(n) {
9
- T = n;
18
+ var h = m();
19
+ function g(e) {
20
+ h = e;
10
21
  }
11
- var $ = { exec: () => null };
12
- function d(n, e = "") {
13
- let r = typeof n == "string" ? n : n.source, s = { replace: (t, i) => {
14
- let l = typeof i == "string" ? i : i.source;
15
- return l = l.replace(b.caret, "$1"), r = r.replace(t, l), s;
16
- }, getRegex: () => new RegExp(r, e) };
17
- return s;
22
+ var _ = { exec: () => null };
23
+ function v(e, t = "") {
24
+ let n = typeof e == "string" ? e : e.source, r = {
25
+ replace: (e, t) => {
26
+ let i = typeof t == "string" ? t : t.source;
27
+ return i = i.replace(y.caret, "$1"), n = n.replace(e, i), r;
28
+ },
29
+ getRegex: () => new RegExp(n, t)
30
+ };
31
+ return r;
18
32
  }
19
- var Ce = (() => {
20
- try {
21
- return !!new RegExp("(?<=1)(?<!1)");
22
- } catch {
23
- return !1;
24
- }
25
- })(), b = { 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: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`), htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i"), blockquoteBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}>`) }, Ee = /^(?:[ \t]*(?:\n|$))+/, Be = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, qe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, I = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, De = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, U = / {0,3}(?:[*+-]|\d{1,9}[.)])/, ge = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ke = d(ge).replace(/bull/g, U).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(), Me = d(ge).replace(/bull/g, U).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(), F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Ze = /^[^\n]+/, V = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Oe = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", V).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Ne = d(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, U).getRegex(), M = "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]*?(?:-->|$))/, Qe = d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", M).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), fe = d(F).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), je = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", fe).getRegex(), W = { blockquote: je, code: Be, def: Oe, fences: qe, heading: De, hr: I, html: Qe, lheading: ke, list: Ne, newline: Ee, paragraph: fe, table: $, text: Ze }, se = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3} )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", M).getRegex(), He = { ...W, lheading: Me, table: se, paragraph: d(F).replace("hr", I).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", se).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", M).getRegex() }, Ge = { ...W, html: d(`^ *(?: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: $, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(F).replace("hr", I).replace("heading", ` *#{1,6} *[^
26
- ]`).replace("lheading", ke).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Ue = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Fe = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, xe = /^( {2,}|\\)\n(?!\s*$)/, Ve = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, _ = /[\p{P}\p{S}]/u, Z = /[\s\p{P}\p{S}]/u, Y = /[^\s\p{P}\p{S}]/u, Xe = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Z).getRegex(), be = /(?!~)[\p{P}\p{S}]/u, We = /(?!~)[\s\p{P}\p{S}]/u, Ye = /(?:[^\s\p{P}\p{S}]|~)/u, Je = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Ce ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), me = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, Ke = d(me, "u").replace(/punct/g, _).getRegex(), et = d(me, "u").replace(/punct/g, be).getRegex(), we = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", tt = d(we, "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, Z).replace(/punct/g, _).getRegex(), rt = d(we, "gu").replace(/notPunctSpace/g, Ye).replace(/punctSpace/g, We).replace(/punct/g, be).getRegex(), nt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, Z).replace(/punct/g, _).getRegex(), st = d(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, _).getRegex(), lt = "^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", it = d(lt, "gu").replace(/notPunctSpace/g, Y).replace(/punctSpace/g, Z).replace(/punct/g, _).getRegex(), at = d(/\\(punct)/, "gu").replace(/punct/g, _).getRegex(), ot = d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(), ct = d(X).replace("(?:-->|$)", "-->").getRegex(), ht = d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", ct).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), B = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, pt = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", B).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), ye = d(/^!?\[(label)\]\[(ref)\]/).replace("label", B).replace("ref", V).getRegex(), Re = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", V).getRegex(), ut = d("reflink|nolink(?!\\()", "g").replace("reflink", ye).replace("nolink", Re).getRegex(), le = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, J = { _backpedal: $, anyPunctuation: at, autolink: ot, blockSkip: Je, br: xe, code: Fe, del: $, delLDelim: $, delRDelim: $, emStrongLDelim: Ke, emStrongRDelimAst: tt, emStrongRDelimUnd: nt, escape: Ue, link: pt, nolink: Re, punctuation: Xe, reflink: ye, reflinkSearch: ut, tag: ht, text: Ve, url: $ }, dt = { ...J, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", B).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", B).getRegex() }, Q = { ...J, emStrongRDelimAst: rt, emStrongLDelim: et, delLDelim: st, delRDelim: it, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", le).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", le).getRegex() }, gt = { ...Q, br: d(xe).replace("{2,}", "*").getRegex(), text: d(Q.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, L = { normal: W, gfm: He, pedantic: Ge }, A = { normal: J, gfm: Q, breaks: gt, pedantic: dt }, kt = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, ie = (n) => kt[n];
27
- function y(n, e) {
28
- if (e) {
29
- if (b.escapeTest.test(n)) return n.replace(b.escapeReplace, ie);
30
- } else if (b.escapeTestNoEncode.test(n)) return n.replace(b.escapeReplaceNoEncode, ie);
31
- return n;
33
+ var re = (() => {
34
+ try {
35
+ return !0;
36
+ } catch {
37
+ return !1;
38
+ }
39
+ })(), y = {
40
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
41
+ outputLinkReplace: /\\([\[\]])/g,
42
+ indentCodeCompensation: /^(\s+)(?:```)/,
43
+ beginningSpace: /^\s+/,
44
+ endingHash: /#$/,
45
+ startingSpaceChar: /^ /,
46
+ endingSpaceChar: / $/,
47
+ nonSpaceChar: /[^ ]/,
48
+ newLineCharGlobal: /\n/g,
49
+ tabCharGlobal: /\t/g,
50
+ multipleSpaceGlobal: /\s+/g,
51
+ blankLine: /^[ \t]*$/,
52
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
53
+ blockquoteStart: /^ {0,3}>/,
54
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
55
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
56
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
57
+ listIsTask: /^\[[ xX]\] +\S/,
58
+ listReplaceTask: /^\[[ xX]\] +/,
59
+ listTaskCheckbox: /\[[ xX]\]/,
60
+ anyLine: /\n.*\n/,
61
+ hrefBrackets: /^<(.*)>$/,
62
+ tableDelimiter: /[:|]/,
63
+ tableAlignChars: /^\||\| *$/g,
64
+ tableRowBlankLine: /\n[ \t]*$/,
65
+ tableAlignRight: /^ *-+: *$/,
66
+ tableAlignCenter: /^ *:-+: *$/,
67
+ tableAlignLeft: /^ *:-+ *$/,
68
+ startATag: /^<a /i,
69
+ endATag: /^<\/a>/i,
70
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
71
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
72
+ startAngleBracket: /^</,
73
+ endAngleBracket: />$/,
74
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
75
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
76
+ escapeTest: /[&<>"']/,
77
+ escapeReplace: /[&<>"']/g,
78
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
79
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
80
+ caret: /(^|[^\[])\^/g,
81
+ percentDecode: /%25/g,
82
+ findPipe: /\|/g,
83
+ splitPipe: / \|/,
84
+ slashPipe: /\\\|/g,
85
+ carriageReturn: /\r\n|\r/g,
86
+ spaceLine: /^ +$/gm,
87
+ notSpaceStart: /^\S*/,
88
+ endingNewline: /\n$/,
89
+ listItemRegex: (e) => RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),
90
+ nextBulletRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
91
+ hrRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
92
+ fencesBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}(?:\`\`\`|~~~)`),
93
+ headingBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}#`),
94
+ htmlBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}<(?:[a-z].*>|!--)`, "i"),
95
+ blockquoteBeginRegex: (e) => RegExp(`^ {0,${Math.min(3, e - 1)}}>`)
96
+ }, ie = /^(?:[ \t]*(?:\n|$))+/, ae = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, oe = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, b = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, se = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, x = / {0,3}(?:[*+-]|\d{1,9}[.)])/, S = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, C = v(S).replace(/bull/g, x).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(), ce = v(S).replace(/bull/g, x).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(), w = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, le = /^[^\n]+/, T = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, ue = v(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", T).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), de = v(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, x).getRegex(), E = "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", D = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, fe = v("^ {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", D).replace("tag", E).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), pe = v(w).replace("hr", b).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", E).getRegex(), O = {
97
+ blockquote: v(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", pe).getRegex(),
98
+ code: ae,
99
+ def: ue,
100
+ fences: oe,
101
+ heading: se,
102
+ hr: b,
103
+ html: fe,
104
+ lheading: C,
105
+ list: de,
106
+ newline: ie,
107
+ paragraph: pe,
108
+ table: _,
109
+ text: le
110
+ }, me = v("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", b).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", E).getRegex(), he = {
111
+ ...O,
112
+ lheading: ce,
113
+ table: me,
114
+ paragraph: v(w).replace("hr", b).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", me).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", E).getRegex()
115
+ }, ge = {
116
+ ...O,
117
+ html: v("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", D).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(),
118
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
119
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
120
+ fences: _,
121
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
122
+ paragraph: v(w).replace("hr", b).replace("heading", " *#{1,6} *[^\n]").replace("lheading", C).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
123
+ }, _e = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ve = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, ye = /^( {2,}|\\)\n(?!\s*$)/, be = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, k = /[\p{P}\p{S}]/u, A = /[\s\p{P}\p{S}]/u, j = /[^\s\p{P}\p{S}]/u, xe = v(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, A).getRegex(), M = /(?!~)[\p{P}\p{S}]/u, Se = /(?!~)[\s\p{P}\p{S}]/u, Ce = /(?:[^\s\p{P}\p{S}]|~)/u, we = v(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", re ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), N = /^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/, Te = v(N, "u").replace(/punct/g, k).getRegex(), Ee = v(N, "u").replace(/punct/g, M).getRegex(), P = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", De = v(P, "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, A).replace(/punct/g, k).getRegex(), Oe = v(P, "gu").replace(/notPunctSpace/g, Ce).replace(/punctSpace/g, Se).replace(/punct/g, M).getRegex(), ke = v("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, A).replace(/punct/g, k).getRegex(), Ae = v(/^~~?(?:((?!~)punct)|[^\s~])/, "u").replace(/punct/g, k).getRegex(), je = v("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)", "gu").replace(/notPunctSpace/g, j).replace(/punctSpace/g, A).replace(/punct/g, k).getRegex(), Me = v(/\\(punct)/, "gu").replace(/punct/g, k).getRegex(), Ne = v(/^<(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(), Pe = v(D).replace("(?:-->|$)", "-->").getRegex(), Fe = v("^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", Pe).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), F = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/, Ie = v(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label", F).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), I = v(/^!?\[(label)\]\[(ref)\]/).replace("label", F).replace("ref", T).getRegex(), L = v(/^!?\[(ref)\](?:\[\])?/).replace("ref", T).getRegex(), Le = v("reflink|nolink(?!\\()", "g").replace("reflink", I).replace("nolink", L).getRegex(), R = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, z = {
124
+ _backpedal: _,
125
+ anyPunctuation: Me,
126
+ autolink: Ne,
127
+ blockSkip: we,
128
+ br: ye,
129
+ code: ve,
130
+ del: _,
131
+ delLDelim: _,
132
+ delRDelim: _,
133
+ emStrongLDelim: Te,
134
+ emStrongRDelimAst: De,
135
+ emStrongRDelimUnd: ke,
136
+ escape: _e,
137
+ link: Ie,
138
+ nolink: L,
139
+ punctuation: xe,
140
+ reflink: I,
141
+ reflinkSearch: Le,
142
+ tag: Fe,
143
+ text: be,
144
+ url: _
145
+ }, Re = {
146
+ ...z,
147
+ link: v(/^!?\[(label)\]\((.*?)\)/).replace("label", F).getRegex(),
148
+ reflink: v(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", F).getRegex()
149
+ }, B = {
150
+ ...z,
151
+ emStrongRDelimAst: Oe,
152
+ emStrongLDelim: Ee,
153
+ delLDelim: Ae,
154
+ delRDelim: je,
155
+ url: v(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", R).replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
156
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
157
+ del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,
158
+ text: v(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol", R).getRegex()
159
+ }, ze = {
160
+ ...B,
161
+ br: v(ye).replace("{2,}", "*").getRegex(),
162
+ text: v(B.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
163
+ }, V = {
164
+ normal: O,
165
+ gfm: he,
166
+ pedantic: ge
167
+ }, H = {
168
+ normal: z,
169
+ gfm: B,
170
+ breaks: ze,
171
+ pedantic: Re
172
+ }, Be = {
173
+ "&": "&amp;",
174
+ "<": "&lt;",
175
+ ">": "&gt;",
176
+ "\"": "&quot;",
177
+ "'": "&#39;"
178
+ }, Ve = (e) => Be[e];
179
+ function U(e, t) {
180
+ if (t) {
181
+ if (y.escapeTest.test(e)) return e.replace(y.escapeReplace, Ve);
182
+ } else if (y.escapeTestNoEncode.test(e)) return e.replace(y.escapeReplaceNoEncode, Ve);
183
+ return e;
32
184
  }
33
- function ae(n) {
34
- try {
35
- n = encodeURI(n).replace(b.percentDecode, "%");
36
- } catch {
37
- return null;
38
- }
39
- return n;
185
+ function He(e) {
186
+ try {
187
+ e = encodeURI(e).replace(y.percentDecode, "%");
188
+ } catch {
189
+ return null;
190
+ }
191
+ return e;
40
192
  }
41
- function oe(n, e) {
42
- let r = n.replace(b.findPipe, (i, l, c) => {
43
- let a = !1, h = l;
44
- for (; --h >= 0 && c[h] === "\\"; ) a = !a;
45
- return a ? "|" : " |";
46
- }), s = r.split(b.splitPipe), t = 0;
47
- if (s[0].trim() || s.shift(), s.length > 0 && !s.at(-1)?.trim() && s.pop(), e) if (s.length > e) s.splice(e);
48
- else for (; s.length < e; ) s.push("");
49
- for (; t < s.length; t++) s[t] = s[t].trim().replace(b.slashPipe, "|");
50
- return s;
193
+ function Ue(e, t) {
194
+ let n = e.replace(y.findPipe, (e, t, n) => {
195
+ let r = !1, i = t;
196
+ for (; --i >= 0 && n[i] === "\\";) r = !r;
197
+ return r ? "|" : " |";
198
+ }).split(y.splitPipe), r = 0;
199
+ if (n[0].trim() || n.shift(), n.length > 0 && !n.at(-1)?.trim() && n.pop(), t) if (n.length > t) n.splice(t);
200
+ else for (; n.length < t;) n.push("");
201
+ for (; r < n.length; r++) n[r] = n[r].trim().replace(y.slashPipe, "|");
202
+ return n;
51
203
  }
52
- function v(n, e, r) {
53
- let s = n.length;
54
- if (s === 0) return "";
55
- let t = 0;
56
- for (; t < s && n.charAt(s - t - 1) === e; )
57
- t++;
58
- return n.slice(0, s - t);
204
+ function W(e, t, n) {
205
+ let r = e.length;
206
+ if (r === 0) return "";
207
+ let i = 0;
208
+ for (; i < r;) {
209
+ let a = e.charAt(r - i - 1);
210
+ if (a === t && !n) i++;
211
+ else if (a !== t && n) i++;
212
+ else break;
213
+ }
214
+ return e.slice(0, r - i);
59
215
  }
60
- function ft(n, e) {
61
- if (n.indexOf(e[1]) === -1) return -1;
62
- let r = 0;
63
- for (let s = 0; s < n.length; s++) if (n[s] === "\\") s++;
64
- else if (n[s] === e[0]) r++;
65
- else if (n[s] === e[1] && (r--, r < 0)) return s;
66
- return r > 0 ? -2 : -1;
216
+ function We(e, t) {
217
+ if (e.indexOf(t[1]) === -1) return -1;
218
+ let n = 0;
219
+ for (let r = 0; r < e.length; r++) if (e[r] === "\\") r++;
220
+ else if (e[r] === t[0]) n++;
221
+ else if (e[r] === t[1] && (n--, n < 0)) return r;
222
+ return n > 0 ? -2 : -1;
67
223
  }
68
- function xt(n, e = 0) {
69
- let r = e, s = "";
70
- for (let t of n) if (t === " ") {
71
- let i = 4 - r % 4;
72
- s += " ".repeat(i), r += i;
73
- } else s += t, r++;
74
- return s;
224
+ function Ge(e, t = 0) {
225
+ let n = t, r = "";
226
+ for (let t of e) if (t === " ") {
227
+ let e = 4 - n % 4;
228
+ r += " ".repeat(e), n += e;
229
+ } else r += t, n++;
230
+ return r;
75
231
  }
76
- function ce(n, e, r, s, t) {
77
- let i = e.href, l = e.title || null, c = n[1].replace(t.other.outputLinkReplace, "$1");
78
- s.state.inLink = !0;
79
- let a = { type: n[0].charAt(0) === "!" ? "image" : "link", raw: r, href: i, title: l, text: c, tokens: s.inlineTokens(c) };
80
- return s.state.inLink = !1, a;
232
+ function Ke(e, t, n, r, i) {
233
+ let a = t.href, o = t.title || null, s = e[1].replace(i.other.outputLinkReplace, "$1");
234
+ r.state.inLink = !0;
235
+ let c = {
236
+ type: e[0].charAt(0) === "!" ? "image" : "link",
237
+ raw: n,
238
+ href: a,
239
+ title: o,
240
+ text: s,
241
+ tokens: r.inlineTokens(s)
242
+ };
243
+ return r.state.inLink = !1, c;
81
244
  }
82
- function bt(n, e, r) {
83
- let s = n.match(r.other.indentCodeCompensation);
84
- if (s === null) return e;
85
- let t = s[1];
86
- return e.split(`
87
- `).map((i) => {
88
- let l = i.match(r.other.beginningSpace);
89
- if (l === null) return i;
90
- let [c] = l;
91
- return c.length >= t.length ? i.slice(t.length) : i;
92
- }).join(`
93
- `);
245
+ function qe(e, t, n) {
246
+ let r = e.match(n.other.indentCodeCompensation);
247
+ if (r === null) return t;
248
+ let i = r[1];
249
+ return t.split("\n").map((e) => {
250
+ let t = e.match(n.other.beginningSpace);
251
+ if (t === null) return e;
252
+ let [r] = t;
253
+ return r.length >= i.length ? e.slice(i.length) : e;
254
+ }).join("\n");
94
255
  }
95
- var q = class {
96
- options;
97
- rules;
98
- lexer;
99
- constructor(n) {
100
- this.options = n || T;
101
- }
102
- space(n) {
103
- let e = this.rules.block.newline.exec(n);
104
- if (e && e[0].length > 0) return { type: "space", raw: e[0] };
105
- }
106
- code(n) {
107
- let e = this.rules.block.code.exec(n);
108
- if (e) {
109
- let r = e[0].replace(this.rules.other.codeRemoveIndent, "");
110
- return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? r : v(r, `
111
- `) };
112
- }
113
- }
114
- fences(n) {
115
- let e = this.rules.block.fences.exec(n);
116
- if (e) {
117
- let r = e[0], s = bt(r, e[3] || "", this.rules);
118
- return { type: "code", raw: r, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s };
119
- }
120
- }
121
- heading(n) {
122
- let e = this.rules.block.heading.exec(n);
123
- if (e) {
124
- let r = e[2].trim();
125
- if (this.rules.other.endingHash.test(r)) {
126
- let s = v(r, "#");
127
- (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (r = s.trim());
128
- }
129
- return { type: "heading", raw: e[0], depth: e[1].length, text: r, tokens: this.lexer.inline(r) };
130
- }
131
- }
132
- hr(n) {
133
- let e = this.rules.block.hr.exec(n);
134
- if (e) return { type: "hr", raw: v(e[0], `
135
- `) };
136
- }
137
- blockquote(n) {
138
- let e = this.rules.block.blockquote.exec(n);
139
- if (e) {
140
- let r = v(e[0], `
141
- `).split(`
142
- `), s = "", t = "", i = [];
143
- for (; r.length > 0; ) {
144
- let l = !1, c = [], a;
145
- for (a = 0; a < r.length; a++) if (this.rules.other.blockquoteStart.test(r[a])) c.push(r[a]), l = !0;
146
- else if (!l) c.push(r[a]);
147
- else break;
148
- r = r.slice(a);
149
- let h = c.join(`
150
- `), o = h.replace(this.rules.other.blockquoteSetextReplace, `
151
- $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
152
- s = s ? `${s}
153
- ${h}` : h, t = t ? `${t}
154
- ${o}` : o;
155
- let p = this.lexer.state.top;
156
- if (this.lexer.state.top = !0, this.lexer.blockTokens(o, i, !0), this.lexer.state.top = p, r.length === 0) break;
157
- let u = i.at(-1);
158
- if (u?.type === "code") break;
159
- if (u?.type === "blockquote") {
160
- let f = u, k = f.raw + `
161
- ` + r.join(`
162
- `), R = this.blockquote(k);
163
- i[i.length - 1] = R, s = s.substring(0, s.length - f.raw.length) + R.raw, t = t.substring(0, t.length - f.text.length) + R.text;
164
- break;
165
- } else if (u?.type === "list") {
166
- let f = u, k = f.raw + `
167
- ` + r.join(`
168
- `), R = this.list(k);
169
- i[i.length - 1] = R, s = s.substring(0, s.length - u.raw.length) + R.raw, t = t.substring(0, t.length - f.raw.length) + R.raw, r = k.substring(i.at(-1).raw.length).split(`
170
- `);
171
- continue;
172
- }
173
- }
174
- return { type: "blockquote", raw: s, tokens: i, text: t };
175
- }
176
- }
177
- list(n) {
178
- let e = this.rules.block.list.exec(n);
179
- if (e) {
180
- let r = e[1].trim(), s = r.length > 1, t = { type: "list", raw: "", ordered: s, start: s ? +r.slice(0, -1) : "", loose: !1, items: [] };
181
- r = s ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = s ? r : "[*+-]");
182
- let i = this.rules.other.listItemRegex(r), l = !1;
183
- for (; n; ) {
184
- let a = !1, h = "", o = "";
185
- if (!(e = i.exec(n)) || this.rules.block.hr.test(n)) break;
186
- h = e[0], n = n.substring(h.length);
187
- let p = xt(e[2].split(`
188
- `, 1)[0], e[1].length), u = n.split(`
189
- `, 1)[0], f = !p.trim(), k = 0;
190
- if (this.options.pedantic ? (k = 2, o = p.trimStart()) : f ? k = e[1].length + 1 : (k = p.search(this.rules.other.nonSpaceChar), k = k > 4 ? 1 : k, o = p.slice(k), k += e[1].length), f && this.rules.other.blankLine.test(u) && (h += u + `
191
- `, n = n.substring(u.length + 1), a = !0), !a) {
192
- let R = this.rules.other.nextBulletRegex(k), ee = this.rules.other.hrRegex(k), te = this.rules.other.fencesBeginRegex(k), re = this.rules.other.headingBeginRegex(k), $e = this.rules.other.htmlBeginRegex(k), Se = this.rules.other.blockquoteBeginRegex(k);
193
- for (; n; ) {
194
- let O = n.split(`
195
- `, 1)[0], z;
196
- if (u = O, this.options.pedantic ? (u = u.replace(this.rules.other.listReplaceNesting, " "), z = u) : z = u.replace(this.rules.other.tabCharGlobal, " "), te.test(u) || re.test(u) || $e.test(u) || Se.test(u) || R.test(u) || ee.test(u)) break;
197
- if (z.search(this.rules.other.nonSpaceChar) >= k || !u.trim()) o += `
198
- ` + z.slice(k);
199
- else {
200
- if (f || p.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || te.test(p) || re.test(p) || ee.test(p)) break;
201
- o += `
202
- ` + u;
203
- }
204
- f = !u.trim(), h += O + `
205
- `, n = n.substring(O.length + 1), p = z.slice(k);
206
- }
207
- }
208
- t.loose || (l ? t.loose = !0 : this.rules.other.doubleBlankLine.test(h) && (l = !0)), t.items.push({ type: "list_item", raw: h, task: !!this.options.gfm && this.rules.other.listIsTask.test(o), loose: !1, text: o, tokens: [] }), t.raw += h;
209
- }
210
- let c = t.items.at(-1);
211
- if (c) c.raw = c.raw.trimEnd(), c.text = c.text.trimEnd();
212
- else return;
213
- t.raw = t.raw.trimEnd();
214
- for (let a of t.items) {
215
- if (this.lexer.state.top = !1, a.tokens = this.lexer.blockTokens(a.text, []), a.task) {
216
- if (a.text = a.text.replace(this.rules.other.listReplaceTask, ""), a.tokens[0]?.type === "text" || a.tokens[0]?.type === "paragraph") {
217
- a.tokens[0].raw = a.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), a.tokens[0].text = a.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
218
- for (let o = this.lexer.inlineQueue.length - 1; o >= 0; o--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[o].src)) {
219
- this.lexer.inlineQueue[o].src = this.lexer.inlineQueue[o].src.replace(this.rules.other.listReplaceTask, "");
220
- break;
221
- }
222
- }
223
- let h = this.rules.other.listTaskCheckbox.exec(a.raw);
224
- if (h) {
225
- let o = { type: "checkbox", raw: h[0] + " ", checked: h[0] !== "[ ]" };
226
- a.checked = o.checked, t.loose ? a.tokens[0] && ["paragraph", "text"].includes(a.tokens[0].type) && "tokens" in a.tokens[0] && a.tokens[0].tokens ? (a.tokens[0].raw = o.raw + a.tokens[0].raw, a.tokens[0].text = o.raw + a.tokens[0].text, a.tokens[0].tokens.unshift(o)) : a.tokens.unshift({ type: "paragraph", raw: o.raw, text: o.raw, tokens: [o] }) : a.tokens.unshift(o);
227
- }
228
- }
229
- if (!t.loose) {
230
- let h = a.tokens.filter((p) => p.type === "space"), o = h.length > 0 && h.some((p) => this.rules.other.anyLine.test(p.raw));
231
- t.loose = o;
232
- }
233
- }
234
- if (t.loose) for (let a of t.items) {
235
- a.loose = !0;
236
- for (let h of a.tokens) h.type === "text" && (h.type = "paragraph");
237
- }
238
- return t;
239
- }
240
- }
241
- html(n) {
242
- let e = this.rules.block.html.exec(n);
243
- if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
244
- }
245
- def(n) {
246
- let e = this.rules.block.def.exec(n);
247
- if (e) {
248
- 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") : "", t = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
249
- return { type: "def", tag: r, raw: e[0], href: s, title: t };
250
- }
251
- }
252
- table(n) {
253
- let e = this.rules.block.table.exec(n);
254
- if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
255
- let r = oe(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), t = e[3]?.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
256
- `) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] };
257
- if (r.length === s.length) {
258
- for (let l of s) this.rules.other.tableAlignRight.test(l) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? i.align.push("left") : i.align.push(null);
259
- for (let l = 0; l < r.length; l++) i.header.push({ text: r[l], tokens: this.lexer.inline(r[l]), header: !0, align: i.align[l] });
260
- for (let l of t) i.rows.push(oe(l, i.header.length).map((c, a) => ({ text: c, tokens: this.lexer.inline(c), header: !1, align: i.align[a] })));
261
- return i;
262
- }
263
- }
264
- lheading(n) {
265
- let e = this.rules.block.lheading.exec(n);
266
- if (e) {
267
- let r = e[1].trim();
268
- return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: r, tokens: this.lexer.inline(r) };
269
- }
270
- }
271
- paragraph(n) {
272
- let e = this.rules.block.paragraph.exec(n);
273
- if (e) {
274
- let r = e[1].charAt(e[1].length - 1) === `
275
- ` ? e[1].slice(0, -1) : e[1];
276
- return { type: "paragraph", raw: e[0], text: r, tokens: this.lexer.inline(r) };
277
- }
278
- }
279
- text(n) {
280
- let e = this.rules.block.text.exec(n);
281
- if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
282
- }
283
- escape(n) {
284
- let e = this.rules.inline.escape.exec(n);
285
- if (e) return { type: "escape", raw: e[0], text: e[1] };
286
- }
287
- tag(n) {
288
- let e = this.rules.inline.tag.exec(n);
289
- 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] };
290
- }
291
- link(n) {
292
- let e = this.rules.inline.link.exec(n);
293
- if (e) {
294
- let r = e[2].trim();
295
- if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
296
- if (!this.rules.other.endAngleBracket.test(r)) return;
297
- let i = v(r.slice(0, -1), "\\");
298
- if ((r.length - i.length) % 2 === 0) return;
299
- } else {
300
- let i = ft(e[2], "()");
301
- if (i === -2) return;
302
- if (i > -1) {
303
- let l = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
304
- e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, l).trim(), e[3] = "";
305
- }
306
- }
307
- let s = e[2], t = "";
308
- if (this.options.pedantic) {
309
- let i = this.rules.other.pedanticHrefTitle.exec(s);
310
- i && (s = i[1], t = i[3]);
311
- } else t = e[3] ? e[3].slice(1, -1) : "";
312
- 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)), ce(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);
313
- }
314
- }
315
- reflink(n, e) {
316
- let r;
317
- if ((r = this.rules.inline.reflink.exec(n)) || (r = this.rules.inline.nolink.exec(n))) {
318
- let s = (r[2] || r[1]).replace(this.rules.other.multipleSpaceGlobal, " "), t = e[s.toLowerCase()];
319
- if (!t) {
320
- let i = r[0].charAt(0);
321
- return { type: "text", raw: i, text: i };
322
- }
323
- return ce(r, t, r[0], this.lexer, this.rules);
324
- }
325
- }
326
- emStrong(n, e, r = "") {
327
- let s = this.rules.inline.emStrongLDelim.exec(n);
328
- 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))) {
329
- let t = [...s[0]].length - 1, i, l, c = t, a = 0, h = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
330
- for (h.lastIndex = 0, e = e.slice(-1 * n.length + t); (s = h.exec(e)) != null; ) {
331
- if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
332
- if (l = [...i].length, s[3] || s[4]) {
333
- c += l;
334
- continue;
335
- } else if ((s[5] || s[6]) && t % 3 && !((t + l) % 3)) {
336
- a += l;
337
- continue;
338
- }
339
- if (c -= l, c > 0) continue;
340
- l = Math.min(l, l + c + a);
341
- let o = [...s[0]][0].length, p = n.slice(0, t + s.index + o + l);
342
- if (Math.min(t, l) % 2) {
343
- let f = p.slice(1, -1);
344
- return { type: "em", raw: p, text: f, tokens: this.lexer.inlineTokens(f) };
345
- }
346
- let u = p.slice(2, -2);
347
- return { type: "strong", raw: p, text: u, tokens: this.lexer.inlineTokens(u) };
348
- }
349
- }
350
- }
351
- codespan(n) {
352
- let e = this.rules.inline.code.exec(n);
353
- if (e) {
354
- let r = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(r), t = this.rules.other.startingSpaceChar.test(r) && this.rules.other.endingSpaceChar.test(r);
355
- return s && t && (r = r.substring(1, r.length - 1)), { type: "codespan", raw: e[0], text: r };
356
- }
357
- }
358
- br(n) {
359
- let e = this.rules.inline.br.exec(n);
360
- if (e) return { type: "br", raw: e[0] };
361
- }
362
- del(n, e, r = "") {
363
- let s = this.rules.inline.delLDelim.exec(n);
364
- if (s && (!s[1] || !r || this.rules.inline.punctuation.exec(r))) {
365
- let t = [...s[0]].length - 1, i, l, c = t, a = this.rules.inline.delRDelim;
366
- for (a.lastIndex = 0, e = e.slice(-1 * n.length + t); (s = a.exec(e)) != null; ) {
367
- if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i || (l = [...i].length, l !== t)) continue;
368
- if (s[3] || s[4]) {
369
- c += l;
370
- continue;
371
- }
372
- if (c -= l, c > 0) continue;
373
- l = Math.min(l, l + c);
374
- let h = [...s[0]][0].length, o = n.slice(0, t + s.index + h + l), p = o.slice(t, -t);
375
- return { type: "del", raw: o, text: p, tokens: this.lexer.inlineTokens(p) };
376
- }
377
- }
378
- }
379
- autolink(n) {
380
- let e = this.rules.inline.autolink.exec(n);
381
- if (e) {
382
- let r, s;
383
- 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 }] };
384
- }
385
- }
386
- url(n) {
387
- let e;
388
- if (e = this.rules.inline.url.exec(n)) {
389
- let r, s;
390
- if (e[2] === "@") r = e[0], s = "mailto:" + r;
391
- else {
392
- let t;
393
- do
394
- t = e[0], e[0] = this.rules.inline._backpedal.exec(e[0])?.[0] ?? "";
395
- while (t !== e[0]);
396
- r = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
397
- }
398
- return { type: "link", raw: e[0], text: r, href: s, tokens: [{ type: "text", raw: r, text: r }] };
399
- }
400
- }
401
- inlineText(n) {
402
- let e = this.rules.inline.text.exec(n);
403
- if (e) {
404
- let r = this.lexer.state.inRawBlock;
405
- return { type: "text", raw: e[0], text: e[0], escaped: r };
406
- }
407
- }
408
- }, m = class j {
409
- tokens;
410
- options;
411
- state;
412
- inlineQueue;
413
- tokenizer;
414
- constructor(e) {
415
- this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new q(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
416
- let r = { other: b, block: L.normal, inline: A.normal };
417
- this.options.pedantic ? (r.block = L.pedantic, r.inline = A.pedantic) : this.options.gfm && (r.block = L.gfm, this.options.breaks ? r.inline = A.breaks : r.inline = A.gfm), this.tokenizer.rules = r;
418
- }
419
- static get rules() {
420
- return { block: L, inline: A };
421
- }
422
- static lex(e, r) {
423
- return new j(r).lex(e);
424
- }
425
- static lexInline(e, r) {
426
- return new j(r).inlineTokens(e);
427
- }
428
- lex(e) {
429
- e = e.replace(b.carriageReturn, `
430
- `), this.blockTokens(e, this.tokens);
431
- for (let r = 0; r < this.inlineQueue.length; r++) {
432
- let s = this.inlineQueue[r];
433
- this.inlineTokens(s.src, s.tokens);
434
- }
435
- return this.inlineQueue = [], this.tokens;
436
- }
437
- blockTokens(e, r = [], s = !1) {
438
- for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(b.tabCharGlobal, " ").replace(b.spaceLine, "")); e; ) {
439
- let t;
440
- if (this.options.extensions?.block?.some((l) => (t = l.call({ lexer: this }, e, r)) ? (e = e.substring(t.raw.length), r.push(t), !0) : !1)) continue;
441
- if (t = this.tokenizer.space(e)) {
442
- e = e.substring(t.raw.length);
443
- let l = r.at(-1);
444
- t.raw.length === 1 && l !== void 0 ? l.raw += `
445
- ` : r.push(t);
446
- continue;
447
- }
448
- if (t = this.tokenizer.code(e)) {
449
- e = e.substring(t.raw.length);
450
- let l = r.at(-1);
451
- l?.type === "paragraph" || l?.type === "text" ? (l.raw += (l.raw.endsWith(`
452
- `) ? "" : `
453
- `) + t.raw, l.text += `
454
- ` + t.text, this.inlineQueue.at(-1).src = l.text) : r.push(t);
455
- continue;
456
- }
457
- if (t = this.tokenizer.fences(e)) {
458
- e = e.substring(t.raw.length), r.push(t);
459
- continue;
460
- }
461
- if (t = this.tokenizer.heading(e)) {
462
- e = e.substring(t.raw.length), r.push(t);
463
- continue;
464
- }
465
- if (t = this.tokenizer.hr(e)) {
466
- e = e.substring(t.raw.length), r.push(t);
467
- continue;
468
- }
469
- if (t = this.tokenizer.blockquote(e)) {
470
- e = e.substring(t.raw.length), r.push(t);
471
- continue;
472
- }
473
- if (t = this.tokenizer.list(e)) {
474
- e = e.substring(t.raw.length), r.push(t);
475
- continue;
476
- }
477
- if (t = this.tokenizer.html(e)) {
478
- e = e.substring(t.raw.length), r.push(t);
479
- continue;
480
- }
481
- if (t = this.tokenizer.def(e)) {
482
- e = e.substring(t.raw.length);
483
- let l = r.at(-1);
484
- l?.type === "paragraph" || l?.type === "text" ? (l.raw += (l.raw.endsWith(`
485
- `) ? "" : `
486
- `) + t.raw, l.text += `
487
- ` + t.raw, this.inlineQueue.at(-1).src = l.text) : this.tokens.links[t.tag] || (this.tokens.links[t.tag] = { href: t.href, title: t.title }, r.push(t));
488
- continue;
489
- }
490
- if (t = this.tokenizer.table(e)) {
491
- e = e.substring(t.raw.length), r.push(t);
492
- continue;
493
- }
494
- if (t = this.tokenizer.lheading(e)) {
495
- e = e.substring(t.raw.length), r.push(t);
496
- continue;
497
- }
498
- let i = e;
499
- if (this.options.extensions?.startBlock) {
500
- let l = 1 / 0, c = e.slice(1), a;
501
- this.options.extensions.startBlock.forEach((h) => {
502
- a = h.call({ lexer: this }, c), typeof a == "number" && a >= 0 && (l = Math.min(l, a));
503
- }), l < 1 / 0 && l >= 0 && (i = e.substring(0, l + 1));
504
- }
505
- if (this.state.top && (t = this.tokenizer.paragraph(i))) {
506
- let l = r.at(-1);
507
- s && l?.type === "paragraph" ? (l.raw += (l.raw.endsWith(`
508
- `) ? "" : `
509
- `) + t.raw, l.text += `
510
- ` + t.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : r.push(t), s = i.length !== e.length, e = e.substring(t.raw.length);
511
- continue;
512
- }
513
- if (t = this.tokenizer.text(e)) {
514
- e = e.substring(t.raw.length);
515
- let l = r.at(-1);
516
- l?.type === "text" ? (l.raw += (l.raw.endsWith(`
517
- `) ? "" : `
518
- `) + t.raw, l.text += `
519
- ` + t.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = l.text) : r.push(t);
520
- continue;
521
- }
522
- if (e) {
523
- let l = "Infinite loop on byte: " + e.charCodeAt(0);
524
- if (this.options.silent) {
525
- console.error(l);
526
- break;
527
- } else throw new Error(l);
528
- }
529
- }
530
- return this.state.top = !0, r;
531
- }
532
- inline(e, r = []) {
533
- return this.inlineQueue.push({ src: e, tokens: r }), r;
534
- }
535
- inlineTokens(e, r = []) {
536
- this.tokenizer.lexer = this;
537
- let s = e, t = null;
538
- if (this.tokens.links) {
539
- let a = Object.keys(this.tokens.links);
540
- if (a.length > 0) for (; (t = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; ) a.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));
541
- }
542
- for (; (t = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; ) s = s.slice(0, t.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
543
- let i;
544
- for (; (t = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; ) i = t[2] ? t[2].length : 0, s = s.slice(0, t.index + i) + "[" + "a".repeat(t[0].length - i - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
545
- s = this.options.hooks?.emStrongMask?.call({ lexer: this }, s) ?? s;
546
- let l = !1, c = "";
547
- for (; e; ) {
548
- l || (c = ""), l = !1;
549
- let a;
550
- if (this.options.extensions?.inline?.some((o) => (a = o.call({ lexer: this }, e, r)) ? (e = e.substring(a.raw.length), r.push(a), !0) : !1)) continue;
551
- if (a = this.tokenizer.escape(e)) {
552
- e = e.substring(a.raw.length), r.push(a);
553
- continue;
554
- }
555
- if (a = this.tokenizer.tag(e)) {
556
- e = e.substring(a.raw.length), r.push(a);
557
- continue;
558
- }
559
- if (a = this.tokenizer.link(e)) {
560
- e = e.substring(a.raw.length), r.push(a);
561
- continue;
562
- }
563
- if (a = this.tokenizer.reflink(e, this.tokens.links)) {
564
- e = e.substring(a.raw.length);
565
- let o = r.at(-1);
566
- a.type === "text" && o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : r.push(a);
567
- continue;
568
- }
569
- if (a = this.tokenizer.emStrong(e, s, c)) {
570
- e = e.substring(a.raw.length), r.push(a);
571
- continue;
572
- }
573
- if (a = this.tokenizer.codespan(e)) {
574
- e = e.substring(a.raw.length), r.push(a);
575
- continue;
576
- }
577
- if (a = this.tokenizer.br(e)) {
578
- e = e.substring(a.raw.length), r.push(a);
579
- continue;
580
- }
581
- if (a = this.tokenizer.del(e, s, c)) {
582
- e = e.substring(a.raw.length), r.push(a);
583
- continue;
584
- }
585
- if (a = this.tokenizer.autolink(e)) {
586
- e = e.substring(a.raw.length), r.push(a);
587
- continue;
588
- }
589
- if (!this.state.inLink && (a = this.tokenizer.url(e))) {
590
- e = e.substring(a.raw.length), r.push(a);
591
- continue;
592
- }
593
- let h = e;
594
- if (this.options.extensions?.startInline) {
595
- let o = 1 / 0, p = e.slice(1), u;
596
- this.options.extensions.startInline.forEach((f) => {
597
- u = f.call({ lexer: this }, p), typeof u == "number" && u >= 0 && (o = Math.min(o, u));
598
- }), o < 1 / 0 && o >= 0 && (h = e.substring(0, o + 1));
599
- }
600
- if (a = this.tokenizer.inlineText(h)) {
601
- e = e.substring(a.raw.length), a.raw.slice(-1) !== "_" && (c = a.raw.slice(-1)), l = !0;
602
- let o = r.at(-1);
603
- o?.type === "text" ? (o.raw += a.raw, o.text += a.text) : r.push(a);
604
- continue;
605
- }
606
- if (e) {
607
- let o = "Infinite loop on byte: " + e.charCodeAt(0);
608
- if (this.options.silent) {
609
- console.error(o);
610
- break;
611
- } else throw new Error(o);
612
- }
613
- }
614
- return r;
615
- }
616
- }, D = class {
617
- options;
618
- parser;
619
- constructor(n) {
620
- this.options = n || T;
621
- }
622
- space(n) {
623
- return "";
624
- }
625
- code({ text: n, lang: e, escaped: r }) {
626
- let s = (e || "").match(b.notSpaceStart)?.[0], t = n.replace(b.endingNewline, "") + `
256
+ var G = class {
257
+ options;
258
+ rules;
259
+ lexer;
260
+ constructor(e) {
261
+ this.options = e || h;
262
+ }
263
+ space(e) {
264
+ let t = this.rules.block.newline.exec(e);
265
+ if (t && t[0].length > 0) return {
266
+ type: "space",
267
+ raw: t[0]
268
+ };
269
+ }
270
+ code(e) {
271
+ let t = this.rules.block.code.exec(e);
272
+ if (t) {
273
+ let e = t[0].replace(this.rules.other.codeRemoveIndent, "");
274
+ return {
275
+ type: "code",
276
+ raw: t[0],
277
+ codeBlockStyle: "indented",
278
+ text: this.options.pedantic ? e : W(e, "\n")
279
+ };
280
+ }
281
+ }
282
+ fences(e) {
283
+ let t = this.rules.block.fences.exec(e);
284
+ if (t) {
285
+ let e = t[0], n = qe(e, t[3] || "", this.rules);
286
+ return {
287
+ type: "code",
288
+ raw: e,
289
+ lang: t[2] ? t[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : t[2],
290
+ text: n
291
+ };
292
+ }
293
+ }
294
+ heading(e) {
295
+ let t = this.rules.block.heading.exec(e);
296
+ if (t) {
297
+ let e = t[2].trim();
298
+ if (this.rules.other.endingHash.test(e)) {
299
+ let t = W(e, "#");
300
+ (this.options.pedantic || !t || this.rules.other.endingSpaceChar.test(t)) && (e = t.trim());
301
+ }
302
+ return {
303
+ type: "heading",
304
+ raw: t[0],
305
+ depth: t[1].length,
306
+ text: e,
307
+ tokens: this.lexer.inline(e)
308
+ };
309
+ }
310
+ }
311
+ hr(e) {
312
+ let t = this.rules.block.hr.exec(e);
313
+ if (t) return {
314
+ type: "hr",
315
+ raw: W(t[0], "\n")
316
+ };
317
+ }
318
+ blockquote(e) {
319
+ let t = this.rules.block.blockquote.exec(e);
320
+ if (t) {
321
+ let e = W(t[0], "\n").split("\n"), n = "", r = "", i = [];
322
+ for (; e.length > 0;) {
323
+ let t = !1, a = [], o;
324
+ for (o = 0; o < e.length; o++) if (this.rules.other.blockquoteStart.test(e[o])) a.push(e[o]), t = !0;
325
+ else if (!t) a.push(e[o]);
326
+ else break;
327
+ e = e.slice(o);
328
+ let s = a.join("\n"), c = s.replace(this.rules.other.blockquoteSetextReplace, "\n $1").replace(this.rules.other.blockquoteSetextReplace2, "");
329
+ n = n ? `${n}
330
+ ${s}` : s, r = r ? `${r}
331
+ ${c}` : c;
332
+ let l = this.lexer.state.top;
333
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(c, i, !0), this.lexer.state.top = l, e.length === 0) break;
334
+ let u = i.at(-1);
335
+ if (u?.type === "code") break;
336
+ if (u?.type === "blockquote") {
337
+ let t = u, a = t.raw + "\n" + e.join("\n"), o = this.blockquote(a);
338
+ i[i.length - 1] = o, n = n.substring(0, n.length - t.raw.length) + o.raw, r = r.substring(0, r.length - t.text.length) + o.text;
339
+ break;
340
+ } else if (u?.type === "list") {
341
+ let t = u, a = t.raw + "\n" + e.join("\n"), o = this.list(a);
342
+ i[i.length - 1] = o, n = n.substring(0, n.length - u.raw.length) + o.raw, r = r.substring(0, r.length - t.raw.length) + o.raw, e = a.substring(i.at(-1).raw.length).split("\n");
343
+ continue;
344
+ }
345
+ }
346
+ return {
347
+ type: "blockquote",
348
+ raw: n,
349
+ tokens: i,
350
+ text: r
351
+ };
352
+ }
353
+ }
354
+ list(e) {
355
+ let t = this.rules.block.list.exec(e);
356
+ if (t) {
357
+ let n = t[1].trim(), r = n.length > 1, i = {
358
+ type: "list",
359
+ raw: "",
360
+ ordered: r,
361
+ start: r ? +n.slice(0, -1) : "",
362
+ loose: !1,
363
+ items: []
364
+ };
365
+ n = r ? `\\d{1,9}\\${n.slice(-1)}` : `\\${n}`, this.options.pedantic && (n = r ? n : "[*+-]");
366
+ let a = this.rules.other.listItemRegex(n), o = !1;
367
+ for (; e;) {
368
+ let n = !1, r = "", s = "";
369
+ if (!(t = a.exec(e)) || this.rules.block.hr.test(e)) break;
370
+ r = t[0], e = e.substring(r.length);
371
+ let c = Ge(t[2].split("\n", 1)[0], t[1].length), l = e.split("\n", 1)[0], u = !c.trim(), d = 0;
372
+ if (this.options.pedantic ? (d = 2, s = c.trimStart()) : u ? d = t[1].length + 1 : (d = c.search(this.rules.other.nonSpaceChar), d = d > 4 ? 1 : d, s = c.slice(d), d += t[1].length), u && this.rules.other.blankLine.test(l) && (r += l + "\n", e = e.substring(l.length + 1), n = !0), !n) {
373
+ let t = this.rules.other.nextBulletRegex(d), n = this.rules.other.hrRegex(d), i = this.rules.other.fencesBeginRegex(d), a = this.rules.other.headingBeginRegex(d), o = this.rules.other.htmlBeginRegex(d), ee = this.rules.other.blockquoteBeginRegex(d);
374
+ for (; e;) {
375
+ let f = e.split("\n", 1)[0], p;
376
+ if (l = f, this.options.pedantic ? (l = l.replace(this.rules.other.listReplaceNesting, " "), p = l) : p = l.replace(this.rules.other.tabCharGlobal, " "), i.test(l) || a.test(l) || o.test(l) || ee.test(l) || t.test(l) || n.test(l)) break;
377
+ if (p.search(this.rules.other.nonSpaceChar) >= d || !l.trim()) s += "\n" + p.slice(d);
378
+ else {
379
+ if (u || c.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || i.test(c) || a.test(c) || n.test(c)) break;
380
+ s += "\n" + l;
381
+ }
382
+ u = !l.trim(), r += f + "\n", e = e.substring(f.length + 1), c = p.slice(d);
383
+ }
384
+ }
385
+ i.loose || (o ? i.loose = !0 : this.rules.other.doubleBlankLine.test(r) && (o = !0)), i.items.push({
386
+ type: "list_item",
387
+ raw: r,
388
+ task: !!this.options.gfm && this.rules.other.listIsTask.test(s),
389
+ loose: !1,
390
+ text: s,
391
+ tokens: []
392
+ }), i.raw += r;
393
+ }
394
+ let s = i.items.at(-1);
395
+ if (s) s.raw = s.raw.trimEnd(), s.text = s.text.trimEnd();
396
+ else return;
397
+ i.raw = i.raw.trimEnd();
398
+ for (let e of i.items) {
399
+ if (this.lexer.state.top = !1, e.tokens = this.lexer.blockTokens(e.text, []), e.task) {
400
+ if (e.text = e.text.replace(this.rules.other.listReplaceTask, ""), e.tokens[0]?.type === "text" || e.tokens[0]?.type === "paragraph") {
401
+ e.tokens[0].raw = e.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), e.tokens[0].text = e.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
402
+ for (let e = this.lexer.inlineQueue.length - 1; e >= 0; e--) if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)) {
403
+ this.lexer.inlineQueue[e].src = this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask, "");
404
+ break;
405
+ }
406
+ }
407
+ let t = this.rules.other.listTaskCheckbox.exec(e.raw);
408
+ if (t) {
409
+ let n = {
410
+ type: "checkbox",
411
+ raw: t[0] + " ",
412
+ checked: t[0] !== "[ ]"
413
+ };
414
+ e.checked = n.checked, i.loose ? e.tokens[0] && ["paragraph", "text"].includes(e.tokens[0].type) && "tokens" in e.tokens[0] && e.tokens[0].tokens ? (e.tokens[0].raw = n.raw + e.tokens[0].raw, e.tokens[0].text = n.raw + e.tokens[0].text, e.tokens[0].tokens.unshift(n)) : e.tokens.unshift({
415
+ type: "paragraph",
416
+ raw: n.raw,
417
+ text: n.raw,
418
+ tokens: [n]
419
+ }) : e.tokens.unshift(n);
420
+ }
421
+ }
422
+ if (!i.loose) {
423
+ let t = e.tokens.filter((e) => e.type === "space");
424
+ i.loose = t.length > 0 && t.some((e) => this.rules.other.anyLine.test(e.raw));
425
+ }
426
+ }
427
+ if (i.loose) for (let e of i.items) {
428
+ e.loose = !0;
429
+ for (let t of e.tokens) t.type === "text" && (t.type = "paragraph");
430
+ }
431
+ return i;
432
+ }
433
+ }
434
+ html(e) {
435
+ let t = this.rules.block.html.exec(e);
436
+ if (t) return {
437
+ type: "html",
438
+ block: !0,
439
+ raw: t[0],
440
+ pre: t[1] === "pre" || t[1] === "script" || t[1] === "style",
441
+ text: t[0]
442
+ };
443
+ }
444
+ def(e) {
445
+ let t = this.rules.block.def.exec(e);
446
+ if (t) {
447
+ let e = t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), n = t[2] ? t[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = t[3] ? t[3].substring(1, t[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : t[3];
448
+ return {
449
+ type: "def",
450
+ tag: e,
451
+ raw: t[0],
452
+ href: n,
453
+ title: r
454
+ };
455
+ }
456
+ }
457
+ table(e) {
458
+ let t = this.rules.block.table.exec(e);
459
+ if (!t || !this.rules.other.tableDelimiter.test(t[2])) return;
460
+ let n = Ue(t[1]), r = t[2].replace(this.rules.other.tableAlignChars, "").split("|"), i = t[3]?.trim() ? t[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [], a = {
461
+ type: "table",
462
+ raw: t[0],
463
+ header: [],
464
+ align: [],
465
+ rows: []
466
+ };
467
+ if (n.length === r.length) {
468
+ for (let e of r) this.rules.other.tableAlignRight.test(e) ? a.align.push("right") : this.rules.other.tableAlignCenter.test(e) ? a.align.push("center") : this.rules.other.tableAlignLeft.test(e) ? a.align.push("left") : a.align.push(null);
469
+ for (let e = 0; e < n.length; e++) a.header.push({
470
+ text: n[e],
471
+ tokens: this.lexer.inline(n[e]),
472
+ header: !0,
473
+ align: a.align[e]
474
+ });
475
+ for (let e of i) a.rows.push(Ue(e, a.header.length).map((e, t) => ({
476
+ text: e,
477
+ tokens: this.lexer.inline(e),
478
+ header: !1,
479
+ align: a.align[t]
480
+ })));
481
+ return a;
482
+ }
483
+ }
484
+ lheading(e) {
485
+ let t = this.rules.block.lheading.exec(e);
486
+ if (t) {
487
+ let e = t[1].trim();
488
+ return {
489
+ type: "heading",
490
+ raw: t[0],
491
+ depth: t[2].charAt(0) === "=" ? 1 : 2,
492
+ text: e,
493
+ tokens: this.lexer.inline(e)
494
+ };
495
+ }
496
+ }
497
+ paragraph(e) {
498
+ let t = this.rules.block.paragraph.exec(e);
499
+ if (t) {
500
+ let e = t[1].charAt(t[1].length - 1) === "\n" ? t[1].slice(0, -1) : t[1];
501
+ return {
502
+ type: "paragraph",
503
+ raw: t[0],
504
+ text: e,
505
+ tokens: this.lexer.inline(e)
506
+ };
507
+ }
508
+ }
509
+ text(e) {
510
+ let t = this.rules.block.text.exec(e);
511
+ if (t) return {
512
+ type: "text",
513
+ raw: t[0],
514
+ text: t[0],
515
+ tokens: this.lexer.inline(t[0])
516
+ };
517
+ }
518
+ escape(e) {
519
+ let t = this.rules.inline.escape.exec(e);
520
+ if (t) return {
521
+ type: "escape",
522
+ raw: t[0],
523
+ text: t[1]
524
+ };
525
+ }
526
+ tag(e) {
527
+ let t = this.rules.inline.tag.exec(e);
528
+ if (t) return !this.lexer.state.inLink && this.rules.other.startATag.test(t[0]) ? this.lexer.state.inLink = !0 : this.lexer.state.inLink && this.rules.other.endATag.test(t[0]) && (this.lexer.state.inLink = !1), !this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(t[0]) ? this.lexer.state.inRawBlock = !0 : this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(t[0]) && (this.lexer.state.inRawBlock = !1), {
529
+ type: "html",
530
+ raw: t[0],
531
+ inLink: this.lexer.state.inLink,
532
+ inRawBlock: this.lexer.state.inRawBlock,
533
+ block: !1,
534
+ text: t[0]
535
+ };
536
+ }
537
+ link(e) {
538
+ let t = this.rules.inline.link.exec(e);
539
+ if (t) {
540
+ let e = t[2].trim();
541
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(e)) {
542
+ if (!this.rules.other.endAngleBracket.test(e)) return;
543
+ let t = W(e.slice(0, -1), "\\");
544
+ if ((e.length - t.length) % 2 == 0) return;
545
+ } else {
546
+ let e = We(t[2], "()");
547
+ if (e === -2) return;
548
+ if (e > -1) {
549
+ let n = (t[0].indexOf("!") === 0 ? 5 : 4) + t[1].length + e;
550
+ t[2] = t[2].substring(0, e), t[0] = t[0].substring(0, n).trim(), t[3] = "";
551
+ }
552
+ }
553
+ let n = t[2], r = "";
554
+ if (this.options.pedantic) {
555
+ let e = this.rules.other.pedanticHrefTitle.exec(n);
556
+ e && (n = e[1], r = e[3]);
557
+ } else r = t[3] ? t[3].slice(1, -1) : "";
558
+ return n = n.trim(), this.rules.other.startAngleBracket.test(n) && (n = this.options.pedantic && !this.rules.other.endAngleBracket.test(e) ? n.slice(1) : n.slice(1, -1)), Ke(t, {
559
+ href: n && n.replace(this.rules.inline.anyPunctuation, "$1"),
560
+ title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
561
+ }, t[0], this.lexer, this.rules);
562
+ }
563
+ }
564
+ reflink(e, t) {
565
+ let n;
566
+ if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) {
567
+ let e = t[(n[2] || n[1]).replace(this.rules.other.multipleSpaceGlobal, " ").toLowerCase()];
568
+ if (!e) {
569
+ let e = n[0].charAt(0);
570
+ return {
571
+ type: "text",
572
+ raw: e,
573
+ text: e
574
+ };
575
+ }
576
+ return Ke(n, e, n[0], this.lexer, this.rules);
577
+ }
578
+ }
579
+ emStrong(e, t, n = "") {
580
+ let r = this.rules.inline.emStrongLDelim.exec(e);
581
+ if (!(!r || !r[1] && !r[2] && !r[3] && !r[4] || r[4] && n.match(this.rules.other.unicodeAlphaNumeric)) && (!(r[1] || r[3]) || !n || this.rules.inline.punctuation.exec(n))) {
582
+ let n = [...r[0]].length - 1, i, a, o = n, s = 0, c = r[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
583
+ for (c.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = c.exec(t)) !== null;) {
584
+ if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i) continue;
585
+ if (a = [...i].length, r[3] || r[4]) {
586
+ o += a;
587
+ continue;
588
+ } else if ((r[5] || r[6]) && n % 3 && !((n + a) % 3)) {
589
+ s += a;
590
+ continue;
591
+ }
592
+ if (o -= a, o > 0) continue;
593
+ a = Math.min(a, a + o + s);
594
+ let t = [...r[0]][0].length, c = e.slice(0, n + r.index + t + a);
595
+ if (Math.min(n, a) % 2) {
596
+ let e = c.slice(1, -1);
597
+ return {
598
+ type: "em",
599
+ raw: c,
600
+ text: e,
601
+ tokens: this.lexer.inlineTokens(e)
602
+ };
603
+ }
604
+ let l = c.slice(2, -2);
605
+ return {
606
+ type: "strong",
607
+ raw: c,
608
+ text: l,
609
+ tokens: this.lexer.inlineTokens(l)
610
+ };
611
+ }
612
+ }
613
+ }
614
+ codespan(e) {
615
+ let t = this.rules.inline.code.exec(e);
616
+ if (t) {
617
+ let e = t[2].replace(this.rules.other.newLineCharGlobal, " "), n = this.rules.other.nonSpaceChar.test(e), r = this.rules.other.startingSpaceChar.test(e) && this.rules.other.endingSpaceChar.test(e);
618
+ return n && r && (e = e.substring(1, e.length - 1)), {
619
+ type: "codespan",
620
+ raw: t[0],
621
+ text: e
622
+ };
623
+ }
624
+ }
625
+ br(e) {
626
+ let t = this.rules.inline.br.exec(e);
627
+ if (t) return {
628
+ type: "br",
629
+ raw: t[0]
630
+ };
631
+ }
632
+ del(e, t, n = "") {
633
+ let r = this.rules.inline.delLDelim.exec(e);
634
+ if (r && (!r[1] || !n || this.rules.inline.punctuation.exec(n))) {
635
+ let n = [...r[0]].length - 1, i, a, o = n, s = this.rules.inline.delRDelim;
636
+ for (s.lastIndex = 0, t = t.slice(-1 * e.length + n); (r = s.exec(t)) !== null;) {
637
+ if (i = r[1] || r[2] || r[3] || r[4] || r[5] || r[6], !i || (a = [...i].length, a !== n)) continue;
638
+ if (r[3] || r[4]) {
639
+ o += a;
640
+ continue;
641
+ }
642
+ if (o -= a, o > 0) continue;
643
+ a = Math.min(a, a + o);
644
+ let t = [...r[0]][0].length, s = e.slice(0, n + r.index + t + a), c = s.slice(n, -n);
645
+ return {
646
+ type: "del",
647
+ raw: s,
648
+ text: c,
649
+ tokens: this.lexer.inlineTokens(c)
650
+ };
651
+ }
652
+ }
653
+ }
654
+ autolink(e) {
655
+ let t = this.rules.inline.autolink.exec(e);
656
+ if (t) {
657
+ let e, n;
658
+ return t[2] === "@" ? (e = t[1], n = "mailto:" + e) : (e = t[1], n = e), {
659
+ type: "link",
660
+ raw: t[0],
661
+ text: e,
662
+ href: n,
663
+ tokens: [{
664
+ type: "text",
665
+ raw: e,
666
+ text: e
667
+ }]
668
+ };
669
+ }
670
+ }
671
+ url(e) {
672
+ let t;
673
+ if (t = this.rules.inline.url.exec(e)) {
674
+ let e, n;
675
+ if (t[2] === "@") e = t[0], n = "mailto:" + e;
676
+ else {
677
+ let r;
678
+ do
679
+ r = t[0], t[0] = this.rules.inline._backpedal.exec(t[0])?.[0] ?? "";
680
+ while (r !== t[0]);
681
+ e = t[0], n = t[1] === "www." ? "http://" + t[0] : t[0];
682
+ }
683
+ return {
684
+ type: "link",
685
+ raw: t[0],
686
+ text: e,
687
+ href: n,
688
+ tokens: [{
689
+ type: "text",
690
+ raw: e,
691
+ text: e
692
+ }]
693
+ };
694
+ }
695
+ }
696
+ inlineText(e) {
697
+ let t = this.rules.inline.text.exec(e);
698
+ if (t) {
699
+ let e = this.lexer.state.inRawBlock;
700
+ return {
701
+ type: "text",
702
+ raw: t[0],
703
+ text: t[0],
704
+ escaped: e
705
+ };
706
+ }
707
+ }
708
+ }, K = class e {
709
+ tokens;
710
+ options;
711
+ state;
712
+ inlineQueue;
713
+ tokenizer;
714
+ constructor(e) {
715
+ this.tokens = [], this.tokens.links = Object.create(null), this.options = e || h, this.options.tokenizer = this.options.tokenizer || new G(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
716
+ inLink: !1,
717
+ inRawBlock: !1,
718
+ top: !0
719
+ };
720
+ let t = {
721
+ other: y,
722
+ block: V.normal,
723
+ inline: H.normal
724
+ };
725
+ this.options.pedantic ? (t.block = V.pedantic, t.inline = H.pedantic) : this.options.gfm && (t.block = V.gfm, this.options.breaks ? t.inline = H.breaks : t.inline = H.gfm), this.tokenizer.rules = t;
726
+ }
727
+ static get rules() {
728
+ return {
729
+ block: V,
730
+ inline: H
731
+ };
732
+ }
733
+ static lex(t, n) {
734
+ return new e(n).lex(t);
735
+ }
736
+ static lexInline(t, n) {
737
+ return new e(n).inlineTokens(t);
738
+ }
739
+ lex(e) {
740
+ e = e.replace(y.carriageReturn, "\n"), this.blockTokens(e, this.tokens);
741
+ for (let e = 0; e < this.inlineQueue.length; e++) {
742
+ let t = this.inlineQueue[e];
743
+ this.inlineTokens(t.src, t.tokens);
744
+ }
745
+ return this.inlineQueue = [], this.tokens;
746
+ }
747
+ blockTokens(e, t = [], n = !1) {
748
+ for (this.tokenizer.lexer = this, this.options.pedantic && (e = e.replace(y.tabCharGlobal, " ").replace(y.spaceLine, "")); e;) {
749
+ let r;
750
+ if (this.options.extensions?.block?.some((n) => (r = n.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1)) continue;
751
+ if (r = this.tokenizer.space(e)) {
752
+ e = e.substring(r.raw.length);
753
+ let n = t.at(-1);
754
+ r.raw.length === 1 && n !== void 0 ? n.raw += "\n" : t.push(r);
755
+ continue;
756
+ }
757
+ if (r = this.tokenizer.code(e)) {
758
+ e = e.substring(r.raw.length);
759
+ let n = t.at(-1);
760
+ n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + r.raw, n.text += "\n" + r.text, this.inlineQueue.at(-1).src = n.text) : t.push(r);
761
+ continue;
762
+ }
763
+ if (r = this.tokenizer.fences(e)) {
764
+ e = e.substring(r.raw.length), t.push(r);
765
+ continue;
766
+ }
767
+ if (r = this.tokenizer.heading(e)) {
768
+ e = e.substring(r.raw.length), t.push(r);
769
+ continue;
770
+ }
771
+ if (r = this.tokenizer.hr(e)) {
772
+ e = e.substring(r.raw.length), t.push(r);
773
+ continue;
774
+ }
775
+ if (r = this.tokenizer.blockquote(e)) {
776
+ e = e.substring(r.raw.length), t.push(r);
777
+ continue;
778
+ }
779
+ if (r = this.tokenizer.list(e)) {
780
+ e = e.substring(r.raw.length), t.push(r);
781
+ continue;
782
+ }
783
+ if (r = this.tokenizer.html(e)) {
784
+ e = e.substring(r.raw.length), t.push(r);
785
+ continue;
786
+ }
787
+ if (r = this.tokenizer.def(e)) {
788
+ e = e.substring(r.raw.length);
789
+ let n = t.at(-1);
790
+ n?.type === "paragraph" || n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + r.raw, n.text += "\n" + r.raw, this.inlineQueue.at(-1).src = n.text) : this.tokens.links[r.tag] || (this.tokens.links[r.tag] = {
791
+ href: r.href,
792
+ title: r.title
793
+ }, t.push(r));
794
+ continue;
795
+ }
796
+ if (r = this.tokenizer.table(e)) {
797
+ e = e.substring(r.raw.length), t.push(r);
798
+ continue;
799
+ }
800
+ if (r = this.tokenizer.lheading(e)) {
801
+ e = e.substring(r.raw.length), t.push(r);
802
+ continue;
803
+ }
804
+ let i = e;
805
+ if (this.options.extensions?.startBlock) {
806
+ let t = Infinity, n = e.slice(1), r;
807
+ this.options.extensions.startBlock.forEach((e) => {
808
+ r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
809
+ }), t < Infinity && t >= 0 && (i = e.substring(0, t + 1));
810
+ }
811
+ if (this.state.top && (r = this.tokenizer.paragraph(i))) {
812
+ let a = t.at(-1);
813
+ n && a?.type === "paragraph" ? (a.raw += (a.raw.endsWith("\n") ? "" : "\n") + r.raw, a.text += "\n" + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(r), n = i.length !== e.length, e = e.substring(r.raw.length);
814
+ continue;
815
+ }
816
+ if (r = this.tokenizer.text(e)) {
817
+ e = e.substring(r.raw.length);
818
+ let n = t.at(-1);
819
+ n?.type === "text" ? (n.raw += (n.raw.endsWith("\n") ? "" : "\n") + r.raw, n.text += "\n" + r.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = n.text) : t.push(r);
820
+ continue;
821
+ }
822
+ if (e) {
823
+ let t = "Infinite loop on byte: " + e.charCodeAt(0);
824
+ if (this.options.silent) {
825
+ console.error(t);
826
+ break;
827
+ } else throw Error(t);
828
+ }
829
+ }
830
+ return this.state.top = !0, t;
831
+ }
832
+ inline(e, t = []) {
833
+ return this.inlineQueue.push({
834
+ src: e,
835
+ tokens: t
836
+ }), t;
837
+ }
838
+ inlineTokens(e, t = []) {
839
+ this.tokenizer.lexer = this;
840
+ let n = e, r = null;
841
+ if (this.tokens.links) {
842
+ let e = Object.keys(this.tokens.links);
843
+ if (e.length > 0) for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(n)) !== null;) e.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
844
+ }
845
+ for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(n)) !== null;) n = n.slice(0, r.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
846
+ let i;
847
+ for (; (r = this.tokenizer.rules.inline.blockSkip.exec(n)) !== null;) i = r[2] ? r[2].length : 0, n = n.slice(0, r.index + i) + "[" + "a".repeat(r[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
848
+ n = this.options.hooks?.emStrongMask?.call({ lexer: this }, n) ?? n;
849
+ let a = !1, o = "";
850
+ for (; e;) {
851
+ a || (o = ""), a = !1;
852
+ let r;
853
+ if (this.options.extensions?.inline?.some((n) => (r = n.call({ lexer: this }, e, t)) ? (e = e.substring(r.raw.length), t.push(r), !0) : !1)) continue;
854
+ if (r = this.tokenizer.escape(e)) {
855
+ e = e.substring(r.raw.length), t.push(r);
856
+ continue;
857
+ }
858
+ if (r = this.tokenizer.tag(e)) {
859
+ e = e.substring(r.raw.length), t.push(r);
860
+ continue;
861
+ }
862
+ if (r = this.tokenizer.link(e)) {
863
+ e = e.substring(r.raw.length), t.push(r);
864
+ continue;
865
+ }
866
+ if (r = this.tokenizer.reflink(e, this.tokens.links)) {
867
+ e = e.substring(r.raw.length);
868
+ let n = t.at(-1);
869
+ r.type === "text" && n?.type === "text" ? (n.raw += r.raw, n.text += r.text) : t.push(r);
870
+ continue;
871
+ }
872
+ if (r = this.tokenizer.emStrong(e, n, o)) {
873
+ e = e.substring(r.raw.length), t.push(r);
874
+ continue;
875
+ }
876
+ if (r = this.tokenizer.codespan(e)) {
877
+ e = e.substring(r.raw.length), t.push(r);
878
+ continue;
879
+ }
880
+ if (r = this.tokenizer.br(e)) {
881
+ e = e.substring(r.raw.length), t.push(r);
882
+ continue;
883
+ }
884
+ if (r = this.tokenizer.del(e, n, o)) {
885
+ e = e.substring(r.raw.length), t.push(r);
886
+ continue;
887
+ }
888
+ if (r = this.tokenizer.autolink(e)) {
889
+ e = e.substring(r.raw.length), t.push(r);
890
+ continue;
891
+ }
892
+ if (!this.state.inLink && (r = this.tokenizer.url(e))) {
893
+ e = e.substring(r.raw.length), t.push(r);
894
+ continue;
895
+ }
896
+ let i = e;
897
+ if (this.options.extensions?.startInline) {
898
+ let t = Infinity, n = e.slice(1), r;
899
+ this.options.extensions.startInline.forEach((e) => {
900
+ r = e.call({ lexer: this }, n), typeof r == "number" && r >= 0 && (t = Math.min(t, r));
901
+ }), t < Infinity && t >= 0 && (i = e.substring(0, t + 1));
902
+ }
903
+ if (r = this.tokenizer.inlineText(i)) {
904
+ e = e.substring(r.raw.length), r.raw.slice(-1) !== "_" && (o = r.raw.slice(-1)), a = !0;
905
+ let n = t.at(-1);
906
+ n?.type === "text" ? (n.raw += r.raw, n.text += r.text) : t.push(r);
907
+ continue;
908
+ }
909
+ if (e) {
910
+ let t = "Infinite loop on byte: " + e.charCodeAt(0);
911
+ if (this.options.silent) {
912
+ console.error(t);
913
+ break;
914
+ } else throw Error(t);
915
+ }
916
+ }
917
+ return t;
918
+ }
919
+ }, q = class {
920
+ options;
921
+ parser;
922
+ constructor(e) {
923
+ this.options = e || h;
924
+ }
925
+ space(e) {
926
+ return "";
927
+ }
928
+ code({ text: e, lang: t, escaped: n }) {
929
+ let r = (t || "").match(y.notSpaceStart)?.[0], i = e.replace(y.endingNewline, "") + "\n";
930
+ return r ? "<pre><code class=\"language-" + U(r) + "\">" + (n ? i : U(i, !0)) + "</code></pre>\n" : "<pre><code>" + (n ? i : U(i, !0)) + "</code></pre>\n";
931
+ }
932
+ blockquote({ tokens: e }) {
933
+ return `<blockquote>
934
+ ${this.parser.parse(e)}</blockquote>
627
935
  `;
628
- return s ? '<pre><code class="language-' + y(s) + '">' + (r ? t : y(t, !0)) + `</code></pre>
629
- ` : "<pre><code>" + (r ? t : y(t, !0)) + `</code></pre>
936
+ }
937
+ html({ text: e }) {
938
+ return e;
939
+ }
940
+ def(e) {
941
+ return "";
942
+ }
943
+ heading({ tokens: e, depth: t }) {
944
+ return `<h${t}>${this.parser.parseInline(e)}</h${t}>
630
945
  `;
631
- }
632
- blockquote({ tokens: n }) {
633
- return `<blockquote>
634
- ${this.parser.parse(n)}</blockquote>
946
+ }
947
+ hr(e) {
948
+ return "<hr>\n";
949
+ }
950
+ list(e) {
951
+ let t = e.ordered, n = e.start, r = "";
952
+ for (let t = 0; t < e.items.length; t++) {
953
+ let n = e.items[t];
954
+ r += this.listitem(n);
955
+ }
956
+ let i = t ? "ol" : "ul", a = t && n !== 1 ? " start=\"" + n + "\"" : "";
957
+ return "<" + i + a + ">\n" + r + "</" + i + ">\n";
958
+ }
959
+ listitem(e) {
960
+ return `<li>${this.parser.parse(e.tokens)}</li>
635
961
  `;
636
- }
637
- html({ text: n }) {
638
- return n;
639
- }
640
- def(n) {
641
- return "";
642
- }
643
- heading({ tokens: n, depth: e }) {
644
- return `<h${e}>${this.parser.parseInline(n)}</h${e}>
962
+ }
963
+ checkbox({ checked: e }) {
964
+ return "<input " + (e ? "checked=\"\" " : "") + "disabled=\"\" type=\"checkbox\"> ";
965
+ }
966
+ paragraph({ tokens: e }) {
967
+ return `<p>${this.parser.parseInline(e)}</p>
645
968
  `;
646
- }
647
- hr(n) {
648
- return `<hr>
969
+ }
970
+ table(e) {
971
+ let t = "", n = "";
972
+ for (let t = 0; t < e.header.length; t++) n += this.tablecell(e.header[t]);
973
+ t += this.tablerow({ text: n });
974
+ let r = "";
975
+ for (let t = 0; t < e.rows.length; t++) {
976
+ let i = e.rows[t];
977
+ n = "";
978
+ for (let e = 0; e < i.length; e++) n += this.tablecell(i[e]);
979
+ r += this.tablerow({ text: n });
980
+ }
981
+ return r &&= `<tbody>${r}</tbody>`, "<table>\n<thead>\n" + t + "</thead>\n" + r + "</table>\n";
982
+ }
983
+ tablerow({ text: e }) {
984
+ return `<tr>
985
+ ${e}</tr>
649
986
  `;
650
- }
651
- list(n) {
652
- let e = n.ordered, r = n.start, s = "";
653
- for (let l = 0; l < n.items.length; l++) {
654
- let c = n.items[l];
655
- s += this.listitem(c);
656
- }
657
- let t = e ? "ol" : "ul", i = e && r !== 1 ? ' start="' + r + '"' : "";
658
- return "<" + t + i + `>
659
- ` + s + "</" + t + `>
987
+ }
988
+ tablecell(e) {
989
+ let t = this.parser.parseInline(e.tokens), n = e.header ? "th" : "td";
990
+ return (e.align ? `<${n} align="${e.align}">` : `<${n}>`) + t + `</${n}>
660
991
  `;
661
- }
662
- listitem(n) {
663
- return `<li>${this.parser.parse(n.tokens)}</li>
664
- `;
665
- }
666
- checkbox({ checked: n }) {
667
- return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
668
- }
669
- paragraph({ tokens: n }) {
670
- return `<p>${this.parser.parseInline(n)}</p>
671
- `;
672
- }
673
- table(n) {
674
- let e = "", r = "";
675
- for (let t = 0; t < n.header.length; t++) r += this.tablecell(n.header[t]);
676
- e += this.tablerow({ text: r });
677
- let s = "";
678
- for (let t = 0; t < n.rows.length; t++) {
679
- let i = n.rows[t];
680
- r = "";
681
- for (let l = 0; l < i.length; l++) r += this.tablecell(i[l]);
682
- s += this.tablerow({ text: r });
683
- }
684
- return s && (s = `<tbody>${s}</tbody>`), `<table>
685
- <thead>
686
- ` + e + `</thead>
687
- ` + s + `</table>
688
- `;
689
- }
690
- tablerow({ text: n }) {
691
- return `<tr>
692
- ${n}</tr>
693
- `;
694
- }
695
- tablecell(n) {
696
- let e = this.parser.parseInline(n.tokens), r = n.header ? "th" : "td";
697
- return (n.align ? `<${r} align="${n.align}">` : `<${r}>`) + e + `</${r}>
698
- `;
699
- }
700
- strong({ tokens: n }) {
701
- return `<strong>${this.parser.parseInline(n)}</strong>`;
702
- }
703
- em({ tokens: n }) {
704
- return `<em>${this.parser.parseInline(n)}</em>`;
705
- }
706
- codespan({ text: n }) {
707
- return `<code>${y(n, !0)}</code>`;
708
- }
709
- br(n) {
710
- return "<br>";
711
- }
712
- del({ tokens: n }) {
713
- return `<del>${this.parser.parseInline(n)}</del>`;
714
- }
715
- link({ href: n, title: e, tokens: r }) {
716
- let s = this.parser.parseInline(r), t = ae(n);
717
- if (t === null) return s;
718
- n = t;
719
- let i = '<a href="' + n + '"';
720
- return e && (i += ' title="' + y(e) + '"'), i += ">" + s + "</a>", i;
721
- }
722
- image({ href: n, title: e, text: r, tokens: s }) {
723
- s && (r = this.parser.parseInline(s, this.parser.textRenderer));
724
- let t = ae(n);
725
- if (t === null) return y(r);
726
- n = t;
727
- let i = `<img src="${n}" alt="${y(r)}"`;
728
- return e && (i += ` title="${y(e)}"`), i += ">", i;
729
- }
730
- text(n) {
731
- return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : y(n.text);
732
- }
733
- }, K = class {
734
- strong({ text: n }) {
735
- return n;
736
- }
737
- em({ text: n }) {
738
- return n;
739
- }
740
- codespan({ text: n }) {
741
- return n;
742
- }
743
- del({ text: n }) {
744
- return n;
745
- }
746
- html({ text: n }) {
747
- return n;
748
- }
749
- text({ text: n }) {
750
- return n;
751
- }
752
- link({ text: n }) {
753
- return "" + n;
754
- }
755
- image({ text: n }) {
756
- return "" + n;
757
- }
758
- br() {
759
- return "";
760
- }
761
- checkbox({ raw: n }) {
762
- return n;
763
- }
764
- }, w = class H {
765
- options;
766
- renderer;
767
- textRenderer;
768
- constructor(e) {
769
- this.options = e || T, this.options.renderer = this.options.renderer || new D(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new K();
770
- }
771
- static parse(e, r) {
772
- return new H(r).parse(e);
773
- }
774
- static parseInline(e, r) {
775
- return new H(r).parseInline(e);
776
- }
777
- parse(e) {
778
- this.renderer.parser = this;
779
- let r = "";
780
- for (let s = 0; s < e.length; s++) {
781
- let t = e[s];
782
- if (this.options.extensions?.renderers?.[t.type]) {
783
- let l = t, c = this.options.extensions.renderers[l.type].call({ parser: this }, l);
784
- if (c !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(l.type)) {
785
- r += c || "";
786
- continue;
787
- }
788
- }
789
- let i = t;
790
- switch (i.type) {
791
- case "space": {
792
- r += this.renderer.space(i);
793
- break;
794
- }
795
- case "hr": {
796
- r += this.renderer.hr(i);
797
- break;
798
- }
799
- case "heading": {
800
- r += this.renderer.heading(i);
801
- break;
802
- }
803
- case "code": {
804
- r += this.renderer.code(i);
805
- break;
806
- }
807
- case "table": {
808
- r += this.renderer.table(i);
809
- break;
810
- }
811
- case "blockquote": {
812
- r += this.renderer.blockquote(i);
813
- break;
814
- }
815
- case "list": {
816
- r += this.renderer.list(i);
817
- break;
818
- }
819
- case "checkbox": {
820
- r += this.renderer.checkbox(i);
821
- break;
822
- }
823
- case "html": {
824
- r += this.renderer.html(i);
825
- break;
826
- }
827
- case "def": {
828
- r += this.renderer.def(i);
829
- break;
830
- }
831
- case "paragraph": {
832
- r += this.renderer.paragraph(i);
833
- break;
834
- }
835
- case "text": {
836
- r += this.renderer.text(i);
837
- break;
838
- }
839
- default: {
840
- let l = 'Token with "' + i.type + '" type was not found.';
841
- if (this.options.silent) return console.error(l), "";
842
- throw new Error(l);
843
- }
844
- }
845
- }
846
- return r;
847
- }
848
- parseInline(e, r = this.renderer) {
849
- this.renderer.parser = this;
850
- let s = "";
851
- for (let t = 0; t < e.length; t++) {
852
- let i = e[t];
853
- if (this.options.extensions?.renderers?.[i.type]) {
854
- let c = this.options.extensions.renderers[i.type].call({ parser: this }, i);
855
- if (c !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(i.type)) {
856
- s += c || "";
857
- continue;
858
- }
859
- }
860
- let l = i;
861
- switch (l.type) {
862
- case "escape": {
863
- s += r.text(l);
864
- break;
865
- }
866
- case "html": {
867
- s += r.html(l);
868
- break;
869
- }
870
- case "link": {
871
- s += r.link(l);
872
- break;
873
- }
874
- case "image": {
875
- s += r.image(l);
876
- break;
877
- }
878
- case "checkbox": {
879
- s += r.checkbox(l);
880
- break;
881
- }
882
- case "strong": {
883
- s += r.strong(l);
884
- break;
885
- }
886
- case "em": {
887
- s += r.em(l);
888
- break;
889
- }
890
- case "codespan": {
891
- s += r.codespan(l);
892
- break;
893
- }
894
- case "br": {
895
- s += r.br(l);
896
- break;
897
- }
898
- case "del": {
899
- s += r.del(l);
900
- break;
901
- }
902
- case "text": {
903
- s += r.text(l);
904
- break;
905
- }
906
- default: {
907
- let c = 'Token with "' + l.type + '" type was not found.';
908
- if (this.options.silent) return console.error(c), "";
909
- throw new Error(c);
910
- }
911
- }
912
- }
913
- return s;
914
- }
915
- }, P = class {
916
- options;
917
- block;
918
- constructor(n) {
919
- this.options = n || T;
920
- }
921
- static passThroughHooks = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"]);
922
- static passThroughHooksRespectAsync = /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"]);
923
- preprocess(n) {
924
- return n;
925
- }
926
- postprocess(n) {
927
- return n;
928
- }
929
- processAllTokens(n) {
930
- return n;
931
- }
932
- emStrongMask(n) {
933
- return n;
934
- }
935
- provideLexer() {
936
- return this.block ? m.lex : m.lexInline;
937
- }
938
- provideParser() {
939
- return this.block ? w.parse : w.parseInline;
940
- }
941
- }, mt = class {
942
- defaults = G();
943
- options = this.setOptions;
944
- parse = this.parseMarkdown(!0);
945
- parseInline = this.parseMarkdown(!1);
946
- Parser = w;
947
- Renderer = D;
948
- TextRenderer = K;
949
- Lexer = m;
950
- Tokenizer = q;
951
- Hooks = P;
952
- constructor(...n) {
953
- this.use(...n);
954
- }
955
- walkTokens(n, e) {
956
- let r = [];
957
- for (let s of n) switch (r = r.concat(e.call(this, s)), s.type) {
958
- case "table": {
959
- let t = s;
960
- for (let i of t.header) r = r.concat(this.walkTokens(i.tokens, e));
961
- for (let i of t.rows) for (let l of i) r = r.concat(this.walkTokens(l.tokens, e));
962
- break;
963
- }
964
- case "list": {
965
- let t = s;
966
- r = r.concat(this.walkTokens(t.items, e));
967
- break;
968
- }
969
- default: {
970
- let t = s;
971
- this.defaults.extensions?.childTokens?.[t.type] ? this.defaults.extensions.childTokens[t.type].forEach((i) => {
972
- let l = t[i].flat(1 / 0);
973
- r = r.concat(this.walkTokens(l, e));
974
- }) : t.tokens && (r = r.concat(this.walkTokens(t.tokens, e)));
975
- }
976
- }
977
- return r;
978
- }
979
- use(...n) {
980
- let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
981
- return n.forEach((r) => {
982
- let s = { ...r };
983
- if (s.async = this.defaults.async || s.async || !1, r.extensions && (r.extensions.forEach((t) => {
984
- if (!t.name) throw new Error("extension name required");
985
- if ("renderer" in t) {
986
- let i = e.renderers[t.name];
987
- i ? e.renderers[t.name] = function(...l) {
988
- let c = t.renderer.apply(this, l);
989
- return c === !1 && (c = i.apply(this, l)), c;
990
- } : e.renderers[t.name] = t.renderer;
991
- }
992
- if ("tokenizer" in t) {
993
- if (!t.level || t.level !== "block" && t.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
994
- let i = e[t.level];
995
- 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]));
996
- }
997
- "childTokens" in t && t.childTokens && (e.childTokens[t.name] = t.childTokens);
998
- }), s.extensions = e), r.renderer) {
999
- let t = this.defaults.renderer || new D(this.defaults);
1000
- for (let i in r.renderer) {
1001
- if (!(i in t)) throw new Error(`renderer '${i}' does not exist`);
1002
- if (["options", "parser"].includes(i)) continue;
1003
- let l = i, c = r.renderer[l], a = t[l];
1004
- t[l] = (...h) => {
1005
- let o = c.apply(t, h);
1006
- return o === !1 && (o = a.apply(t, h)), o || "";
1007
- };
1008
- }
1009
- s.renderer = t;
1010
- }
1011
- if (r.tokenizer) {
1012
- let t = this.defaults.tokenizer || new q(this.defaults);
1013
- for (let i in r.tokenizer) {
1014
- if (!(i in t)) throw new Error(`tokenizer '${i}' does not exist`);
1015
- if (["options", "rules", "lexer"].includes(i)) continue;
1016
- let l = i, c = r.tokenizer[l], a = t[l];
1017
- t[l] = (...h) => {
1018
- let o = c.apply(t, h);
1019
- return o === !1 && (o = a.apply(t, h)), o;
1020
- };
1021
- }
1022
- s.tokenizer = t;
1023
- }
1024
- if (r.hooks) {
1025
- let t = this.defaults.hooks || new P();
1026
- for (let i in r.hooks) {
1027
- if (!(i in t)) throw new Error(`hook '${i}' does not exist`);
1028
- if (["options", "block"].includes(i)) continue;
1029
- let l = i, c = r.hooks[l], a = t[l];
1030
- P.passThroughHooks.has(i) ? t[l] = (h) => {
1031
- if (this.defaults.async && P.passThroughHooksRespectAsync.has(i)) return (async () => {
1032
- let p = await c.call(t, h);
1033
- return a.call(t, p);
1034
- })();
1035
- let o = c.call(t, h);
1036
- return a.call(t, o);
1037
- } : t[l] = (...h) => {
1038
- if (this.defaults.async) return (async () => {
1039
- let p = await c.apply(t, h);
1040
- return p === !1 && (p = await a.apply(t, h)), p;
1041
- })();
1042
- let o = c.apply(t, h);
1043
- return o === !1 && (o = a.apply(t, h)), o;
1044
- };
1045
- }
1046
- s.hooks = t;
1047
- }
1048
- if (r.walkTokens) {
1049
- let t = this.defaults.walkTokens, i = r.walkTokens;
1050
- s.walkTokens = function(l) {
1051
- let c = [];
1052
- return c.push(i.call(this, l)), t && (c = c.concat(t.call(this, l))), c;
1053
- };
1054
- }
1055
- this.defaults = { ...this.defaults, ...s };
1056
- }), this;
1057
- }
1058
- setOptions(n) {
1059
- return this.defaults = { ...this.defaults, ...n }, this;
1060
- }
1061
- lexer(n, e) {
1062
- return m.lex(n, e ?? this.defaults);
1063
- }
1064
- parser(n, e) {
1065
- return w.parse(n, e ?? this.defaults);
1066
- }
1067
- parseMarkdown(n) {
1068
- return (e, r) => {
1069
- let s = { ...r }, t = { ...this.defaults, ...s }, i = this.onError(!!t.silent, !!t.async);
1070
- 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."));
1071
- if (typeof e > "u" || e === null) return i(new Error("marked(): input parameter is undefined or null"));
1072
- if (typeof e != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
1073
- if (t.hooks && (t.hooks.options = t, t.hooks.block = n), t.async) return (async () => {
1074
- let l = t.hooks ? await t.hooks.preprocess(e) : e, c = await (t.hooks ? await t.hooks.provideLexer() : n ? m.lex : m.lexInline)(l, t), a = t.hooks ? await t.hooks.processAllTokens(c) : c;
1075
- t.walkTokens && await Promise.all(this.walkTokens(a, t.walkTokens));
1076
- let h = await (t.hooks ? await t.hooks.provideParser() : n ? w.parse : w.parseInline)(a, t);
1077
- return t.hooks ? await t.hooks.postprocess(h) : h;
1078
- })().catch(i);
1079
- try {
1080
- t.hooks && (e = t.hooks.preprocess(e));
1081
- let l = (t.hooks ? t.hooks.provideLexer() : n ? m.lex : m.lexInline)(e, t);
1082
- t.hooks && (l = t.hooks.processAllTokens(l)), t.walkTokens && this.walkTokens(l, t.walkTokens);
1083
- let c = (t.hooks ? t.hooks.provideParser() : n ? w.parse : w.parseInline)(l, t);
1084
- return t.hooks && (c = t.hooks.postprocess(c)), c;
1085
- } catch (l) {
1086
- return i(l);
1087
- }
1088
- };
1089
- }
1090
- onError(n, e) {
1091
- return (r) => {
1092
- if (r.message += `
1093
- Please report this to https://github.com/markedjs/marked.`, n) {
1094
- let s = "<p>An error occurred:</p><pre>" + y(r.message + "", !0) + "</pre>";
1095
- return e ? Promise.resolve(s) : s;
1096
- }
1097
- if (e) return Promise.reject(r);
1098
- throw r;
1099
- };
1100
- }
1101
- }, S = new mt();
1102
- function g(n, e) {
1103
- return S.parse(n, e);
992
+ }
993
+ strong({ tokens: e }) {
994
+ return `<strong>${this.parser.parseInline(e)}</strong>`;
995
+ }
996
+ em({ tokens: e }) {
997
+ return `<em>${this.parser.parseInline(e)}</em>`;
998
+ }
999
+ codespan({ text: e }) {
1000
+ return `<code>${U(e, !0)}</code>`;
1001
+ }
1002
+ br(e) {
1003
+ return "<br>";
1004
+ }
1005
+ del({ tokens: e }) {
1006
+ return `<del>${this.parser.parseInline(e)}</del>`;
1007
+ }
1008
+ link({ href: e, title: t, tokens: n }) {
1009
+ let r = this.parser.parseInline(n), i = He(e);
1010
+ if (i === null) return r;
1011
+ e = i;
1012
+ let a = "<a href=\"" + e + "\"";
1013
+ return t && (a += " title=\"" + U(t) + "\""), a += ">" + r + "</a>", a;
1014
+ }
1015
+ image({ href: e, title: t, text: n, tokens: r }) {
1016
+ r && (n = this.parser.parseInline(r, this.parser.textRenderer));
1017
+ let i = He(e);
1018
+ if (i === null) return U(n);
1019
+ e = i;
1020
+ let a = `<img src="${e}" alt="${U(n)}"`;
1021
+ return t && (a += ` title="${U(t)}"`), a += ">", a;
1022
+ }
1023
+ text(e) {
1024
+ return "tokens" in e && e.tokens ? this.parser.parseInline(e.tokens) : "escaped" in e && e.escaped ? e.text : U(e.text);
1025
+ }
1026
+ }, J = class {
1027
+ strong({ text: e }) {
1028
+ return e;
1029
+ }
1030
+ em({ text: e }) {
1031
+ return e;
1032
+ }
1033
+ codespan({ text: e }) {
1034
+ return e;
1035
+ }
1036
+ del({ text: e }) {
1037
+ return e;
1038
+ }
1039
+ html({ text: e }) {
1040
+ return e;
1041
+ }
1042
+ text({ text: e }) {
1043
+ return e;
1044
+ }
1045
+ link({ text: e }) {
1046
+ return "" + e;
1047
+ }
1048
+ image({ text: e }) {
1049
+ return "" + e;
1050
+ }
1051
+ br() {
1052
+ return "";
1053
+ }
1054
+ checkbox({ raw: e }) {
1055
+ return e;
1056
+ }
1057
+ }, Y = class e {
1058
+ options;
1059
+ renderer;
1060
+ textRenderer;
1061
+ constructor(e) {
1062
+ this.options = e || h, 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 J();
1063
+ }
1064
+ static parse(t, n) {
1065
+ return new e(n).parse(t);
1066
+ }
1067
+ static parseInline(t, n) {
1068
+ return new e(n).parseInline(t);
1069
+ }
1070
+ parse(e) {
1071
+ this.renderer.parser = this;
1072
+ let t = "";
1073
+ for (let n = 0; n < e.length; n++) {
1074
+ let r = e[n];
1075
+ if (this.options.extensions?.renderers?.[r.type]) {
1076
+ let e = r, n = this.options.extensions.renderers[e.type].call({ parser: this }, e);
1077
+ if (n !== !1 || ![
1078
+ "space",
1079
+ "hr",
1080
+ "heading",
1081
+ "code",
1082
+ "table",
1083
+ "blockquote",
1084
+ "list",
1085
+ "html",
1086
+ "def",
1087
+ "paragraph",
1088
+ "text"
1089
+ ].includes(e.type)) {
1090
+ t += n || "";
1091
+ continue;
1092
+ }
1093
+ }
1094
+ let i = r;
1095
+ switch (i.type) {
1096
+ case "space":
1097
+ t += this.renderer.space(i);
1098
+ break;
1099
+ case "hr":
1100
+ t += this.renderer.hr(i);
1101
+ break;
1102
+ case "heading":
1103
+ t += this.renderer.heading(i);
1104
+ break;
1105
+ case "code":
1106
+ t += this.renderer.code(i);
1107
+ break;
1108
+ case "table":
1109
+ t += this.renderer.table(i);
1110
+ break;
1111
+ case "blockquote":
1112
+ t += this.renderer.blockquote(i);
1113
+ break;
1114
+ case "list":
1115
+ t += this.renderer.list(i);
1116
+ break;
1117
+ case "checkbox":
1118
+ t += this.renderer.checkbox(i);
1119
+ break;
1120
+ case "html":
1121
+ t += this.renderer.html(i);
1122
+ break;
1123
+ case "def":
1124
+ t += this.renderer.def(i);
1125
+ break;
1126
+ case "paragraph":
1127
+ t += this.renderer.paragraph(i);
1128
+ break;
1129
+ case "text":
1130
+ t += this.renderer.text(i);
1131
+ break;
1132
+ default: {
1133
+ let e = "Token with \"" + i.type + "\" type was not found.";
1134
+ if (this.options.silent) return console.error(e), "";
1135
+ throw Error(e);
1136
+ }
1137
+ }
1138
+ }
1139
+ return t;
1140
+ }
1141
+ parseInline(e, t = this.renderer) {
1142
+ this.renderer.parser = this;
1143
+ let n = "";
1144
+ for (let r = 0; r < e.length; r++) {
1145
+ let i = e[r];
1146
+ if (this.options.extensions?.renderers?.[i.type]) {
1147
+ let e = this.options.extensions.renderers[i.type].call({ parser: this }, i);
1148
+ if (e !== !1 || ![
1149
+ "escape",
1150
+ "html",
1151
+ "link",
1152
+ "image",
1153
+ "strong",
1154
+ "em",
1155
+ "codespan",
1156
+ "br",
1157
+ "del",
1158
+ "text"
1159
+ ].includes(i.type)) {
1160
+ n += e || "";
1161
+ continue;
1162
+ }
1163
+ }
1164
+ let a = i;
1165
+ switch (a.type) {
1166
+ case "escape":
1167
+ n += t.text(a);
1168
+ break;
1169
+ case "html":
1170
+ n += t.html(a);
1171
+ break;
1172
+ case "link":
1173
+ n += t.link(a);
1174
+ break;
1175
+ case "image":
1176
+ n += t.image(a);
1177
+ break;
1178
+ case "checkbox":
1179
+ n += t.checkbox(a);
1180
+ break;
1181
+ case "strong":
1182
+ n += t.strong(a);
1183
+ break;
1184
+ case "em":
1185
+ n += t.em(a);
1186
+ break;
1187
+ case "codespan":
1188
+ n += t.codespan(a);
1189
+ break;
1190
+ case "br":
1191
+ n += t.br(a);
1192
+ break;
1193
+ case "del":
1194
+ n += t.del(a);
1195
+ break;
1196
+ case "text":
1197
+ n += t.text(a);
1198
+ break;
1199
+ default: {
1200
+ let e = "Token with \"" + a.type + "\" type was not found.";
1201
+ if (this.options.silent) return console.error(e), "";
1202
+ throw Error(e);
1203
+ }
1204
+ }
1205
+ }
1206
+ return n;
1207
+ }
1208
+ }, X = class {
1209
+ options;
1210
+ block;
1211
+ constructor(e) {
1212
+ this.options = e || h;
1213
+ }
1214
+ static passThroughHooks = new Set([
1215
+ "preprocess",
1216
+ "postprocess",
1217
+ "processAllTokens",
1218
+ "emStrongMask"
1219
+ ]);
1220
+ static passThroughHooksRespectAsync = new Set([
1221
+ "preprocess",
1222
+ "postprocess",
1223
+ "processAllTokens"
1224
+ ]);
1225
+ preprocess(e) {
1226
+ return e;
1227
+ }
1228
+ postprocess(e) {
1229
+ return e;
1230
+ }
1231
+ processAllTokens(e) {
1232
+ return e;
1233
+ }
1234
+ emStrongMask(e) {
1235
+ return e;
1236
+ }
1237
+ provideLexer(e = this.block) {
1238
+ return e ? K.lex : K.lexInline;
1239
+ }
1240
+ provideParser(e = this.block) {
1241
+ return e ? Y.parse : Y.parseInline;
1242
+ }
1243
+ }, Z = new class {
1244
+ defaults = m();
1245
+ options = this.setOptions;
1246
+ parse = this.parseMarkdown(!0);
1247
+ parseInline = this.parseMarkdown(!1);
1248
+ Parser = Y;
1249
+ Renderer = q;
1250
+ TextRenderer = J;
1251
+ Lexer = K;
1252
+ Tokenizer = G;
1253
+ Hooks = X;
1254
+ constructor(...e) {
1255
+ this.use(...e);
1256
+ }
1257
+ walkTokens(e, t) {
1258
+ let n = [];
1259
+ for (let r of e) switch (n = n.concat(t.call(this, r)), r.type) {
1260
+ case "table": {
1261
+ let e = r;
1262
+ for (let r of e.header) n = n.concat(this.walkTokens(r.tokens, t));
1263
+ for (let r of e.rows) for (let e of r) n = n.concat(this.walkTokens(e.tokens, t));
1264
+ break;
1265
+ }
1266
+ case "list": {
1267
+ let e = r;
1268
+ n = n.concat(this.walkTokens(e.items, t));
1269
+ break;
1270
+ }
1271
+ default: {
1272
+ let e = r;
1273
+ this.defaults.extensions?.childTokens?.[e.type] ? this.defaults.extensions.childTokens[e.type].forEach((r) => {
1274
+ let i = e[r].flat(Infinity);
1275
+ n = n.concat(this.walkTokens(i, t));
1276
+ }) : e.tokens && (n = n.concat(this.walkTokens(e.tokens, t)));
1277
+ }
1278
+ }
1279
+ return n;
1280
+ }
1281
+ use(...e) {
1282
+ let t = this.defaults.extensions || {
1283
+ renderers: {},
1284
+ childTokens: {}
1285
+ };
1286
+ return e.forEach((e) => {
1287
+ let n = { ...e };
1288
+ if (n.async = this.defaults.async || n.async || !1, e.extensions && (e.extensions.forEach((e) => {
1289
+ if (!e.name) throw Error("extension name required");
1290
+ if ("renderer" in e) {
1291
+ let n = t.renderers[e.name];
1292
+ n ? t.renderers[e.name] = function(...t) {
1293
+ let r = e.renderer.apply(this, t);
1294
+ return r === !1 && (r = n.apply(this, t)), r;
1295
+ } : t.renderers[e.name] = e.renderer;
1296
+ }
1297
+ if ("tokenizer" in e) {
1298
+ if (!e.level || e.level !== "block" && e.level !== "inline") throw Error("extension level must be 'block' or 'inline'");
1299
+ let n = t[e.level];
1300
+ n ? n.unshift(e.tokenizer) : t[e.level] = [e.tokenizer], e.start && (e.level === "block" ? t.startBlock ? t.startBlock.push(e.start) : t.startBlock = [e.start] : e.level === "inline" && (t.startInline ? t.startInline.push(e.start) : t.startInline = [e.start]));
1301
+ }
1302
+ "childTokens" in e && e.childTokens && (t.childTokens[e.name] = e.childTokens);
1303
+ }), n.extensions = t), e.renderer) {
1304
+ let t = this.defaults.renderer || new q(this.defaults);
1305
+ for (let n in e.renderer) {
1306
+ if (!(n in t)) throw Error(`renderer '${n}' does not exist`);
1307
+ if (["options", "parser"].includes(n)) continue;
1308
+ let r = n, i = e.renderer[r], a = t[r];
1309
+ t[r] = (...e) => {
1310
+ let n = i.apply(t, e);
1311
+ return n === !1 && (n = a.apply(t, e)), n || "";
1312
+ };
1313
+ }
1314
+ n.renderer = t;
1315
+ }
1316
+ if (e.tokenizer) {
1317
+ let t = this.defaults.tokenizer || new G(this.defaults);
1318
+ for (let n in e.tokenizer) {
1319
+ if (!(n in t)) throw Error(`tokenizer '${n}' does not exist`);
1320
+ if ([
1321
+ "options",
1322
+ "rules",
1323
+ "lexer"
1324
+ ].includes(n)) continue;
1325
+ let r = n, i = e.tokenizer[r], a = t[r];
1326
+ t[r] = (...e) => {
1327
+ let n = i.apply(t, e);
1328
+ return n === !1 && (n = a.apply(t, e)), n;
1329
+ };
1330
+ }
1331
+ n.tokenizer = t;
1332
+ }
1333
+ if (e.hooks) {
1334
+ let t = this.defaults.hooks || new X();
1335
+ for (let n in e.hooks) {
1336
+ if (!(n in t)) throw Error(`hook '${n}' does not exist`);
1337
+ if (["options", "block"].includes(n)) continue;
1338
+ let r = n, i = e.hooks[r], a = t[r];
1339
+ X.passThroughHooks.has(n) ? t[r] = (e) => {
1340
+ if (this.defaults.async && X.passThroughHooksRespectAsync.has(n)) return (async () => {
1341
+ let n = await i.call(t, e);
1342
+ return a.call(t, n);
1343
+ })();
1344
+ let r = i.call(t, e);
1345
+ return a.call(t, r);
1346
+ } : t[r] = (...e) => {
1347
+ if (this.defaults.async) return (async () => {
1348
+ let n = await i.apply(t, e);
1349
+ return n === !1 && (n = await a.apply(t, e)), n;
1350
+ })();
1351
+ let n = i.apply(t, e);
1352
+ return n === !1 && (n = a.apply(t, e)), n;
1353
+ };
1354
+ }
1355
+ n.hooks = t;
1356
+ }
1357
+ if (e.walkTokens) {
1358
+ let t = this.defaults.walkTokens, r = e.walkTokens;
1359
+ n.walkTokens = function(e) {
1360
+ let n = [];
1361
+ return n.push(r.call(this, e)), t && (n = n.concat(t.call(this, e))), n;
1362
+ };
1363
+ }
1364
+ this.defaults = {
1365
+ ...this.defaults,
1366
+ ...n
1367
+ };
1368
+ }), this;
1369
+ }
1370
+ setOptions(e) {
1371
+ return this.defaults = {
1372
+ ...this.defaults,
1373
+ ...e
1374
+ }, this;
1375
+ }
1376
+ lexer(e, t) {
1377
+ return K.lex(e, t ?? this.defaults);
1378
+ }
1379
+ parser(e, t) {
1380
+ return Y.parse(e, t ?? this.defaults);
1381
+ }
1382
+ parseMarkdown(e) {
1383
+ return (t, n) => {
1384
+ let r = { ...n }, i = {
1385
+ ...this.defaults,
1386
+ ...r
1387
+ }, a = this.onError(!!i.silent, !!i.async);
1388
+ if (this.defaults.async === !0 && r.async === !1) return a(/* @__PURE__ */ Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1389
+ if (typeof t > "u" || t === null) return a(/* @__PURE__ */ Error("marked(): input parameter is undefined or null"));
1390
+ if (typeof t != "string") return a(/* @__PURE__ */ Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1391
+ if (i.hooks && (i.hooks.options = i, i.hooks.block = e), i.async) return (async () => {
1392
+ let n = i.hooks ? await i.hooks.preprocess(t) : t, r = await (i.hooks ? await i.hooks.provideLexer(e) : e ? K.lex : K.lexInline)(n, i), a = i.hooks ? await i.hooks.processAllTokens(r) : r;
1393
+ i.walkTokens && await Promise.all(this.walkTokens(a, i.walkTokens));
1394
+ let o = await (i.hooks ? await i.hooks.provideParser(e) : e ? Y.parse : Y.parseInline)(a, i);
1395
+ return i.hooks ? await i.hooks.postprocess(o) : o;
1396
+ })().catch(a);
1397
+ try {
1398
+ i.hooks && (t = i.hooks.preprocess(t));
1399
+ let n = (i.hooks ? i.hooks.provideLexer(e) : e ? K.lex : K.lexInline)(t, i);
1400
+ i.hooks && (n = i.hooks.processAllTokens(n)), i.walkTokens && this.walkTokens(n, i.walkTokens);
1401
+ let r = (i.hooks ? i.hooks.provideParser(e) : e ? Y.parse : Y.parseInline)(n, i);
1402
+ return i.hooks && (r = i.hooks.postprocess(r)), r;
1403
+ } catch (e) {
1404
+ return a(e);
1405
+ }
1406
+ };
1407
+ }
1408
+ onError(e, t) {
1409
+ return (n) => {
1410
+ if (n.message += "\nPlease report this to https://github.com/markedjs/marked.", e) {
1411
+ let e = "<p>An error occurred:</p><pre>" + U(n.message + "", !0) + "</pre>";
1412
+ return t ? Promise.resolve(e) : e;
1413
+ }
1414
+ if (t) return Promise.reject(n);
1415
+ throw n;
1416
+ };
1417
+ }
1418
+ }();
1419
+ function Q(e, t) {
1420
+ return Z.parse(e, t);
1104
1421
  }
1105
- g.options = g.setOptions = function(n) {
1106
- return S.setOptions(n), g.defaults = S.defaults, de(g.defaults), g;
1107
- };
1108
- g.getDefaults = G;
1109
- g.defaults = T;
1110
- g.use = function(...n) {
1111
- return S.use(...n), g.defaults = S.defaults, de(g.defaults), g;
1112
- };
1113
- g.walkTokens = function(n, e) {
1114
- return S.walkTokens(n, e);
1115
- };
1116
- g.parseInline = S.parseInline;
1117
- g.Parser = w;
1118
- g.parser = w.parse;
1119
- g.Renderer = D;
1120
- g.TextRenderer = K;
1121
- g.Lexer = m;
1122
- g.lexer = m.lex;
1123
- g.Tokenizer = q;
1124
- g.Hooks = P;
1125
- g.parse = g;
1126
- g.options;
1127
- g.setOptions;
1128
- g.use;
1129
- g.walkTokens;
1130
- g.parseInline;
1131
- w.parse;
1132
- m.lex;
1133
- const wt = { class: "markdown-container" }, yt = {
1134
- key: 0,
1135
- class: "min-h-full p-8 flex items-center justify-center"
1136
- }, Rt = { class: "markdown-content-wrapper" }, $t = { class: "p-4" }, St = { class: "header-row" }, Tt = { class: "document-title" }, _t = ["innerHTML"], zt = { class: "markdown-source" }, At = ["disabled"], vt = /* @__PURE__ */ pe({
1137
- __name: "View",
1138
- props: {
1139
- selectedResult: {}
1140
- },
1141
- emits: ["updateResult"],
1142
- setup(n, { emit: e }) {
1143
- const r = n, s = e, t = ze(r.selectedResult.data?.markdown || ""), i = N(() => t.value !== r.selectedResult.data?.markdown), l = N(() => r.selectedResult.data?.markdown ? g(r.selectedResult.data.markdown) : (console.error("No markdown data in result:", r.selectedResult), ""));
1144
- ne(
1145
- () => r.selectedResult?.viewState?.scrollToAnchor,
1146
- (h) => {
1147
- h && Ae(() => {
1148
- const o = document.getElementById(h);
1149
- o ? o.scrollIntoView({ behavior: "smooth", block: "start" }) : console.warn(`Anchor element with id "${h}" not found`);
1150
- });
1151
- }
1152
- );
1153
- const c = () => {
1154
- if (!r.selectedResult?.data?.markdown) return;
1155
- const h = new Blob([r.selectedResult.data.markdown], {
1156
- type: "text/markdown"
1157
- }), o = URL.createObjectURL(h), p = document.createElement("a");
1158
- p.href = o;
1159
- const u = r.selectedResult.title ? `${r.selectedResult.title.replace(/[^a-z0-9]/gi, "_").toLowerCase()}.md` : "document.md";
1160
- p.download = u, document.body.appendChild(p), p.click(), document.body.removeChild(p), URL.revokeObjectURL(o);
1161
- };
1162
- function a() {
1163
- const h = {
1164
- ...r.selectedResult,
1165
- data: {
1166
- ...r.selectedResult.data,
1167
- markdown: t.value,
1168
- // Reset pdfPath since markdown has changed
1169
- pdfPath: void 0
1170
- }
1171
- };
1172
- s("updateResult", h);
1173
- }
1174
- return ne(
1175
- () => r.selectedResult.data?.markdown,
1176
- (h) => {
1177
- t.value = h || "";
1178
- }
1179
- ), (h, o) => (C(), E("div", wt, [
1180
- n.selectedResult.data?.markdown ? (C(), E(ve, { key: 1 }, [
1181
- x("div", Rt, [
1182
- x("div", $t, [
1183
- x("div", St, [
1184
- x("h1", Tt, ue(n.selectedResult.title || "Document"), 1),
1185
- x("div", { class: "button-group" }, [
1186
- x("button", {
1187
- onClick: c,
1188
- class: "download-btn download-btn-green"
1189
- }, [...o[2] || (o[2] = [
1190
- x("span", { class: "material-icons" }, "download", -1),
1191
- Pe(" MD ", -1)
1192
- ])])
1193
- ])
1194
- ]),
1195
- x("div", {
1196
- class: "markdown-content prose prose-slate max-w-none",
1197
- innerHTML: l.value
1198
- }, null, 8, _t)
1199
- ])
1200
- ]),
1201
- x("details", zt, [
1202
- o[3] || (o[3] = x("summary", null, "Edit Markdown Source", -1)),
1203
- Ie(x("textarea", {
1204
- "onUpdate:modelValue": o[0] || (o[0] = (p) => t.value = p),
1205
- class: "markdown-editor",
1206
- spellcheck: "false"
1207
- }, null, 512), [
1208
- [Le, t.value]
1209
- ]),
1210
- x("button", {
1211
- onClick: a,
1212
- class: "apply-btn",
1213
- disabled: !i.value
1214
- }, " Apply Changes ", 8, At)
1215
- ])
1216
- ], 64)) : (C(), E("div", yt, [...o[1] || (o[1] = [
1217
- x("div", { class: "text-gray-500" }, "No markdown content available", -1)
1218
- ])]))
1219
- ]));
1220
- }
1221
- }), Pt = (n, e) => {
1222
- const r = n.__vccOpts || n;
1223
- for (const [s, t] of e)
1224
- r[s] = t;
1225
- return r;
1226
- }, It = /* @__PURE__ */ Pt(vt, [["__scopeId", "data-v-7bea9557"]]), Lt = { class: "text-center p-4 bg-purple-100 rounded" }, Ct = { class: "text-sm text-gray-800 mt-1 font-medium truncate" }, Et = /* @__PURE__ */ pe({
1227
- __name: "Preview",
1228
- props: {
1229
- result: {}
1230
- },
1231
- setup(n) {
1232
- const e = n, r = N(() => {
1233
- if (e.result.title)
1234
- return e.result.title;
1235
- if (e.result.data?.markdown) {
1236
- const s = e.result.data.markdown.match(/^#\s+(.+)$/m);
1237
- if (s)
1238
- return s[1];
1239
- }
1240
- return "Markdown Document";
1241
- });
1242
- return (s, t) => (C(), E("div", Lt, [
1243
- t[0] || (t[0] = x("div", { class: "text-purple-600 font-medium" }, "Document", -1)),
1244
- x("div", Ct, ue(r.value), 1)
1245
- ]));
1246
- }
1247
- }), he = "presentDocument", Bt = `Use the ${he} tool to create structured documents with text and embedded images. This tool is ideal for:
1422
+ Q.options = Q.setOptions = function(e) {
1423
+ return Z.setOptions(e), Q.defaults = Z.defaults, g(Q.defaults), Q;
1424
+ }, Q.getDefaults = m, Q.defaults = h, Q.use = function(...e) {
1425
+ return Z.use(...e), Q.defaults = Z.defaults, g(Q.defaults), Q;
1426
+ }, Q.walkTokens = function(e, t) {
1427
+ return Z.walkTokens(e, t);
1428
+ }, Q.parseInline = Z.parseInline, Q.Parser = Y, Q.parser = Y.parse, Q.Renderer = q, Q.TextRenderer = J, Q.Lexer = K, Q.lexer = K.lex, Q.Tokenizer = G, Q.Hooks = X, Q.parse = Q, Q.options, Q.setOptions, Q.use, Q.walkTokens, Q.parseInline, Y.parse, K.lex;
1429
+ //#endregion
1430
+ //#region src/vue/View.vue?vue&type=script&setup=true&lang.ts
1431
+ var Je = { class: "markdown-container" }, Ye = {
1432
+ key: 0,
1433
+ class: "min-h-full p-8 flex items-center justify-center"
1434
+ }, Xe = { class: "markdown-content-wrapper" }, Ze = { class: "p-4" }, Qe = { class: "header-row" }, $e = { class: "document-title" }, et = ["innerHTML"], tt = { class: "markdown-source" }, nt = ["disabled"], rt = /* @__PURE__ */ ((e, t) => {
1435
+ let n = e.__vccOpts || e;
1436
+ for (let [e, r] of t) n[e] = r;
1437
+ return n;
1438
+ })(/* @__PURE__ */ l({
1439
+ __name: "View",
1440
+ props: { selectedResult: {} },
1441
+ emits: ["updateResult"],
1442
+ setup(e, { emit: t }) {
1443
+ let n = e, r = t, l = ee(n.selectedResult.data?.markdown || ""), m = a(() => l.value !== n.selectedResult.data?.markdown), h = a(() => n.selectedResult.data?.markdown ? Q(n.selectedResult.data.markdown) : (console.error("No markdown data in result:", n.selectedResult), ""));
1444
+ te(() => n.selectedResult?.viewState?.scrollToAnchor, (e) => {
1445
+ e && u(() => {
1446
+ let t = document.getElementById(e);
1447
+ t ? t.scrollIntoView({
1448
+ behavior: "smooth",
1449
+ block: "start"
1450
+ }) : console.warn(`Anchor element with id "${e}" not found`);
1451
+ });
1452
+ });
1453
+ let g = () => {
1454
+ if (!n.selectedResult?.data?.markdown) return;
1455
+ let e = new Blob([n.selectedResult.data.markdown], { type: "text/markdown" }), t = URL.createObjectURL(e), r = document.createElement("a");
1456
+ r.href = t;
1457
+ let i = n.selectedResult.data?.filenameHint;
1458
+ r.download = i ? `${i.replace(/[/\\:*?"<>|]/g, "_")}.md` : n.selectedResult.title ? `${n.selectedResult.title.replace(/[/\\:*?"<>|]/g, "_")}.md` : "document.md", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(t);
1459
+ };
1460
+ function _() {
1461
+ r("updateResult", {
1462
+ ...n.selectedResult,
1463
+ data: {
1464
+ ...n.selectedResult.data,
1465
+ markdown: l.value,
1466
+ pdfPath: void 0
1467
+ }
1468
+ });
1469
+ }
1470
+ return te(() => n.selectedResult.data?.markdown, (e) => {
1471
+ l.value = e || "";
1472
+ }), (t, n) => (d(), o("div", Je, [e.selectedResult.data?.markdown ? (d(), o(i, { key: 1 }, [s("div", Xe, [s("div", Ze, [s("div", Qe, [s("h1", $e, f(e.selectedResult.title || "Document"), 1), s("div", { class: "button-group" }, [s("button", {
1473
+ onClick: g,
1474
+ class: "download-btn download-btn-green"
1475
+ }, [...n[2] ||= [s("span", { class: "material-icons" }, "download", -1), c(" MD ", -1)]])])]), s("div", {
1476
+ class: "markdown-content prose prose-slate max-w-none",
1477
+ innerHTML: h.value
1478
+ }, null, 8, et)])]), s("details", tt, [
1479
+ n[3] ||= s("summary", null, "Edit Markdown Source", -1),
1480
+ ne(s("textarea", {
1481
+ "onUpdate:modelValue": n[0] ||= (e) => l.value = e,
1482
+ class: "markdown-editor",
1483
+ spellcheck: "false"
1484
+ }, null, 512), [[p, l.value]]),
1485
+ s("button", {
1486
+ onClick: _,
1487
+ class: "apply-btn",
1488
+ disabled: !m.value
1489
+ }, " Apply Changes ", 8, nt)
1490
+ ])], 64)) : (d(), o("div", Ye, [...n[1] ||= [s("div", { class: "text-gray-500" }, "No markdown content available", -1)]]))]));
1491
+ }
1492
+ }), [["__scopeId", "data-v-3606105b"]]), it = { class: "text-center p-4 bg-purple-100 rounded" }, at = { class: "text-sm text-gray-800 mt-1 font-medium truncate" }, ot = /* @__PURE__ */ l({
1493
+ __name: "Preview",
1494
+ props: { result: {} },
1495
+ setup(e) {
1496
+ let t = e, n = a(() => {
1497
+ if (t.result.title) return t.result.title;
1498
+ if (t.result.data?.markdown) {
1499
+ let e = t.result.data.markdown.match(/^#\s+(.+)$/m);
1500
+ if (e) return e[1];
1501
+ }
1502
+ return "Markdown Document";
1503
+ });
1504
+ return (e, t) => (d(), o("div", it, [t[0] ||= s("div", { class: "text-purple-600 font-medium" }, "Document", -1), s("div", at, f(n.value), 1)]));
1505
+ }
1506
+ }), $ = "presentDocument", st = `Use the ${$} tool to create structured documents with text and embedded images. This tool is ideal for:
1248
1507
  - Guides, tutorials, and how-to content ("create a guide about...", "explain how to...")
1249
1508
  - Educational content (lessons, explanations, timelines, concept visualizations)
1250
1509
  - Reports and presentations (business reports, data analysis, infographics)
@@ -1255,24 +1514,14 @@ const wt = { class: "markdown-container" }, yt = {
1255
1514
  - Product presentations or lookbooks
1256
1515
  - Any content that combines written information with supporting visuals
1257
1516
 
1258
- IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${he} to create a full guide with explanatory text and the diagram embedded, rather than just generating the diagram image alone.
1517
+ IMPORTANT: Use this tool instead of just generating standalone images when the user wants informational or educational content with visuals. This creates a cohesive document with formatted text (markdown) AND images embedded at appropriate locations. For example, if asked to "create a guide about photosynthesis with a diagram", use ${$} to create a full guide with explanatory text and the diagram embedded, rather than just generating the diagram image alone.
1259
1518
 
1260
- Format embedded images as: ![Detailed image prompt](__too_be_replaced_image_path__)`, qt = {
1261
- ..._e,
1262
- viewComponent: It,
1263
- previewComponent: Et,
1264
- samples: Te,
1265
- systemPrompt: Bt
1266
- }, Zt = { plugin: qt };
1267
- export {
1268
- Et as Preview,
1269
- Bt as SYSTEM_PROMPT,
1270
- Qt as TOOL_DEFINITION,
1271
- he as TOOL_NAME,
1272
- It as View,
1273
- Zt as default,
1274
- jt as executeMarkdown,
1275
- qt as plugin,
1276
- _e as pluginCore,
1277
- Te as samples
1278
- };
1519
+ Format embedded images as: ![Detailed image prompt](__too_be_replaced_image_path__)`, ct = {
1520
+ ...n,
1521
+ viewComponent: rt,
1522
+ previewComponent: ot,
1523
+ samples: r,
1524
+ systemPrompt: st
1525
+ }, lt = { plugin: ct };
1526
+ //#endregion
1527
+ export { ot as Preview, st as SYSTEM_PROMPT, e as TOOL_DEFINITION, $ as TOOL_NAME, rt as View, lt as default, t as executeMarkdown, ct as plugin, n as pluginCore, r as samples };