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