@automattic/agenttic-client 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1090 @@
1
+ var we = Object.defineProperty;
2
+ var me = (t, e, r) => e in t ? we(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
+ var d = (t, e, r) => me(t, typeof e != "symbol" ? e + "" : e, r);
4
+ function j() {
5
+ return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
6
+ }
7
+ var T = j();
8
+ function ae(t) {
9
+ T = t;
10
+ }
11
+ var L = { exec: () => null };
12
+ function g(t, e = "") {
13
+ let r = typeof t == "string" ? t : t.source, s = { replace: (n, i) => {
14
+ let c = typeof i == "string" ? i : i.source;
15
+ return c = c.replace(b.caret, "$1"), r = r.replace(n, c), s;
16
+ }, getRegex: () => new RegExp(r, e) };
17
+ return s;
18
+ }
19
+ var 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]\] /, listReplaceTask: /^\[[ xX]\] +/, anyLine: /\n.*\n/, hrefBrackets: /^<(.*)>$/, tableDelimiter: /[:|]/, tableAlignChars: /^\||\| *$/g, tableRowBlankLine: /\n[ \t]*$/, tableAlignRight: /^ *-+: *$/, tableAlignCenter: /^ *:-+: *$/, tableAlignLeft: /^ *:-+ *$/, startATag: /^<a /i, endATag: /^<\/a>/i, startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i, endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i, startAngleBracket: /^</, endAngleBracket: />$/, pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/, unicodeAlphaNumeric: /[\p{L}\p{N}]/u, escapeTest: /[&<>"']/, escapeReplace: /[&<>"']/g, escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/, escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g, unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, caret: /(^|[^\[])\^/g, percentDecode: /%25/g, findPipe: /\|/g, splitPipe: / \|/, slashPipe: /\\\|/g, carriageReturn: /\r\n|\r/g, spaceLine: /^ +$/gm, notSpaceStart: /^\S*/, endingNewline: /\n$/, listItemRegex: (t) => new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}#`), htmlBeginRegex: (t) => new RegExp(`^ {0,${Math.min(3, t - 1)}}<(?:[a-z].*>|!--)`, "i") }, ye = /^(?:[ \t]*(?:\n|$))+/, $e = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Se = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, v = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, Re = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, G = /(?:[*+-]|\d{1,9}[.)])/, oe = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ce = g(oe).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(), Te = g(oe).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(), F = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, ze = /^[^\n]+/, W = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, Ae = g(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", W).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), _e = g(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, G).getRegex(), D = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", X = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Pe = g("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))", "i").replace("comment", X).replace("tag", D).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), he = g(F).replace("hr", v).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", D).getRegex(), Ie = g(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", he).getRegex(), U = { blockquote: Ie, code: $e, def: Ae, fences: Se, heading: Re, hr: v, html: Pe, lheading: ce, list: _e, newline: ye, paragraph: he, table: L, text: ze }, re = g("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", v).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", D).getRegex(), Le = { ...U, lheading: Te, table: re, paragraph: g(F).replace("hr", v).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", re).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", D).getRegex() }, ve = { ...U, html: g(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", X).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: L, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: g(F).replace("hr", v).replace("heading", ` *#{1,6} *[^
20
+ ]`).replace("lheading", ce).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, Be = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Ce = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, pe = /^( {2,}|\\)\n(?!\s*$)/, qe = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, M = /[\p{P}\p{S}]/u, J = /[\s\p{P}\p{S}]/u, ue = /[^\s\p{P}\p{S}]/u, Ee = g(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, J).getRegex(), ge = /(?!~)[\p{P}\p{S}]/u, Ze = /(?!~)[\s\p{P}\p{S}]/u, De = /(?:[^\s\p{P}\p{S}]|~)/u, Me = /\[[^\[\]]*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g, ke = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Qe = g(ke, "u").replace(/punct/g, M).getRegex(), He = g(ke, "u").replace(/punct/g, ge).getRegex(), fe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", Ne = g(fe, "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, J).replace(/punct/g, M).getRegex(), Oe = g(fe, "gu").replace(/notPunctSpace/g, De).replace(/punctSpace/g, Ze).replace(/punct/g, ge).getRegex(), je = g("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ue).replace(/punctSpace/g, J).replace(/punct/g, M).getRegex(), Ge = g(/\\(punct)/, "gu").replace(/punct/g, M).getRegex(), Fe = g(/^<(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(), We = g(X).replace("(?:-->|$)", "-->").getRegex(), Xe = g("^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", We).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), q = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`[^`]*`|[^\[\]\\`])*?/, Ue = g(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", q).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), de = g(/^!?\[(label)\]\[(ref)\]/).replace("label", q).replace("ref", W).getRegex(), xe = g(/^!?\[(ref)\](?:\[\])?/).replace("ref", W).getRegex(), Je = g("reflink|nolink(?!\\()", "g").replace("reflink", de).replace("nolink", xe).getRegex(), K = { _backpedal: L, anyPunctuation: Ge, autolink: Fe, blockSkip: Me, br: pe, code: Ce, del: L, emStrongLDelim: Qe, emStrongRDelimAst: Ne, emStrongRDelimUnd: je, escape: Be, link: Ue, nolink: xe, punctuation: Ee, reflink: de, reflinkSearch: Je, tag: Xe, text: qe, url: L }, Ke = { ...K, link: g(/^!?\[(label)\]\((.*?)\)/).replace("label", q).getRegex(), reflink: g(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q).getRegex() }, H = { ...K, emStrongRDelimAst: Oe, emStrongLDelim: He, url: g(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(), _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/ }, Ve = { ...H, br: g(pe).replace("{2,}", "*").getRegex(), text: g(H.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, B = { normal: U, gfm: Le, pedantic: ve }, _ = { normal: K, gfm: H, breaks: Ve, pedantic: Ke }, Ye = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, ne = (t) => Ye[t];
21
+ function m(t, e) {
22
+ if (e) {
23
+ if (b.escapeTest.test(t)) return t.replace(b.escapeReplace, ne);
24
+ } else if (b.escapeTestNoEncode.test(t)) return t.replace(b.escapeReplaceNoEncode, ne);
25
+ return t;
26
+ }
27
+ function se(t) {
28
+ try {
29
+ t = encodeURI(t).replace(b.percentDecode, "%");
30
+ } catch {
31
+ return null;
32
+ }
33
+ return t;
34
+ }
35
+ function le(t, e) {
36
+ var i;
37
+ let r = t.replace(b.findPipe, (c, l, o) => {
38
+ let a = !1, p = l;
39
+ for (; --p >= 0 && o[p] === "\\"; ) a = !a;
40
+ return a ? "|" : " |";
41
+ }), s = r.split(b.splitPipe), n = 0;
42
+ if (s[0].trim() || s.shift(), s.length > 0 && !((i = s.at(-1)) != null && i.trim()) && s.pop(), e) if (s.length > e) s.splice(e);
43
+ else for (; s.length < e; ) s.push("");
44
+ for (; n < s.length; n++) s[n] = s[n].trim().replace(b.slashPipe, "|");
45
+ return s;
46
+ }
47
+ function P(t, e, r) {
48
+ let s = t.length;
49
+ if (s === 0) return "";
50
+ let n = 0;
51
+ for (; n < s && t.charAt(s - n - 1) === e; )
52
+ n++;
53
+ return t.slice(0, s - n);
54
+ }
55
+ function et(t, e) {
56
+ if (t.indexOf(e[1]) === -1) return -1;
57
+ let r = 0;
58
+ for (let s = 0; s < t.length; s++) if (t[s] === "\\") s++;
59
+ else if (t[s] === e[0]) r++;
60
+ else if (t[s] === e[1] && (r--, r < 0)) return s;
61
+ return r > 0 ? -2 : -1;
62
+ }
63
+ function ie(t, e, r, s, n) {
64
+ let i = e.href, c = e.title || null, l = t[1].replace(n.other.outputLinkReplace, "$1");
65
+ s.state.inLink = !0;
66
+ let o = { type: t[0].charAt(0) === "!" ? "image" : "link", raw: r, href: i, title: c, text: l, tokens: s.inlineTokens(l) };
67
+ return s.state.inLink = !1, o;
68
+ }
69
+ function tt(t, e, r) {
70
+ let s = t.match(r.other.indentCodeCompensation);
71
+ if (s === null) return e;
72
+ let n = s[1];
73
+ return e.split(`
74
+ `).map((i) => {
75
+ let c = i.match(r.other.beginningSpace);
76
+ if (c === null) return i;
77
+ let [l] = c;
78
+ return l.length >= n.length ? i.slice(n.length) : i;
79
+ }).join(`
80
+ `);
81
+ }
82
+ var E = class {
83
+ constructor(t) {
84
+ d(this, "options");
85
+ d(this, "rules");
86
+ d(this, "lexer");
87
+ this.options = t || T;
88
+ }
89
+ space(t) {
90
+ let e = this.rules.block.newline.exec(t);
91
+ if (e && e[0].length > 0) return { type: "space", raw: e[0] };
92
+ }
93
+ code(t) {
94
+ let e = this.rules.block.code.exec(t);
95
+ if (e) {
96
+ let r = e[0].replace(this.rules.other.codeRemoveIndent, "");
97
+ return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? r : P(r, `
98
+ `) };
99
+ }
100
+ }
101
+ fences(t) {
102
+ let e = this.rules.block.fences.exec(t);
103
+ if (e) {
104
+ let r = e[0], s = tt(r, e[3] || "", this.rules);
105
+ return { type: "code", raw: r, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: s };
106
+ }
107
+ }
108
+ heading(t) {
109
+ let e = this.rules.block.heading.exec(t);
110
+ if (e) {
111
+ let r = e[2].trim();
112
+ if (this.rules.other.endingHash.test(r)) {
113
+ let s = P(r, "#");
114
+ (this.options.pedantic || !s || this.rules.other.endingSpaceChar.test(s)) && (r = s.trim());
115
+ }
116
+ return { type: "heading", raw: e[0], depth: e[1].length, text: r, tokens: this.lexer.inline(r) };
117
+ }
118
+ }
119
+ hr(t) {
120
+ let e = this.rules.block.hr.exec(t);
121
+ if (e) return { type: "hr", raw: P(e[0], `
122
+ `) };
123
+ }
124
+ blockquote(t) {
125
+ let e = this.rules.block.blockquote.exec(t);
126
+ if (e) {
127
+ let r = P(e[0], `
128
+ `).split(`
129
+ `), s = "", n = "", i = [];
130
+ for (; r.length > 0; ) {
131
+ let c = !1, l = [], o;
132
+ for (o = 0; o < r.length; o++) if (this.rules.other.blockquoteStart.test(r[o])) l.push(r[o]), c = !0;
133
+ else if (!c) l.push(r[o]);
134
+ else break;
135
+ r = r.slice(o);
136
+ let a = l.join(`
137
+ `), p = a.replace(this.rules.other.blockquoteSetextReplace, `
138
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
139
+ s = s ? `${s}
140
+ ${a}` : a, n = n ? `${n}
141
+ ${p}` : p;
142
+ let k = this.lexer.state.top;
143
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(p, i, !0), this.lexer.state.top = k, r.length === 0) break;
144
+ let h = i.at(-1);
145
+ if ((h == null ? void 0 : h.type) === "code") break;
146
+ if ((h == null ? void 0 : h.type) === "blockquote") {
147
+ let x = h, u = x.raw + `
148
+ ` + r.join(`
149
+ `), w = this.blockquote(u);
150
+ i[i.length - 1] = w, s = s.substring(0, s.length - x.raw.length) + w.raw, n = n.substring(0, n.length - x.text.length) + w.text;
151
+ break;
152
+ } else if ((h == null ? void 0 : h.type) === "list") {
153
+ let x = h, u = x.raw + `
154
+ ` + r.join(`
155
+ `), w = this.list(u);
156
+ i[i.length - 1] = w, s = s.substring(0, s.length - h.raw.length) + w.raw, n = n.substring(0, n.length - x.raw.length) + w.raw, r = u.substring(i.at(-1).raw.length).split(`
157
+ `);
158
+ continue;
159
+ }
160
+ }
161
+ return { type: "blockquote", raw: s, tokens: i, text: n };
162
+ }
163
+ }
164
+ list(t) {
165
+ let e = this.rules.block.list.exec(t);
166
+ if (e) {
167
+ let r = e[1].trim(), s = r.length > 1, n = { type: "list", raw: "", ordered: s, start: s ? +r.slice(0, -1) : "", loose: !1, items: [] };
168
+ r = s ? `\\d{1,9}\\${r.slice(-1)}` : `\\${r}`, this.options.pedantic && (r = s ? r : "[*+-]");
169
+ let i = this.rules.other.listItemRegex(r), c = !1;
170
+ for (; t; ) {
171
+ let o = !1, a = "", p = "";
172
+ if (!(e = i.exec(t)) || this.rules.block.hr.test(t)) break;
173
+ a = e[0], t = t.substring(a.length);
174
+ let k = e[2].split(`
175
+ `, 1)[0].replace(this.rules.other.listReplaceTabs, (z) => " ".repeat(3 * z.length)), h = t.split(`
176
+ `, 1)[0], x = !k.trim(), u = 0;
177
+ if (this.options.pedantic ? (u = 2, p = k.trimStart()) : x ? u = e[1].length + 1 : (u = e[2].search(this.rules.other.nonSpaceChar), u = u > 4 ? 1 : u, p = k.slice(u), u += e[1].length), x && this.rules.other.blankLine.test(h) && (a += h + `
178
+ `, t = t.substring(h.length + 1), o = !0), !o) {
179
+ let z = this.rules.other.nextBulletRegex(u), Y = this.rules.other.hrRegex(u), ee = this.rules.other.fencesBeginRegex(u), te = this.rules.other.headingBeginRegex(u), be = this.rules.other.htmlBeginRegex(u);
180
+ for (; t; ) {
181
+ let Q = t.split(`
182
+ `, 1)[0], A;
183
+ if (h = Q, this.options.pedantic ? (h = h.replace(this.rules.other.listReplaceNesting, " "), A = h) : A = h.replace(this.rules.other.tabCharGlobal, " "), ee.test(h) || te.test(h) || be.test(h) || z.test(h) || Y.test(h)) break;
184
+ if (A.search(this.rules.other.nonSpaceChar) >= u || !h.trim()) p += `
185
+ ` + A.slice(u);
186
+ else {
187
+ if (x || k.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || ee.test(k) || te.test(k) || Y.test(k)) break;
188
+ p += `
189
+ ` + h;
190
+ }
191
+ !x && !h.trim() && (x = !0), a += Q + `
192
+ `, t = t.substring(Q.length + 1), k = A.slice(u);
193
+ }
194
+ }
195
+ n.loose || (c ? n.loose = !0 : this.rules.other.doubleBlankLine.test(a) && (c = !0));
196
+ let w = null, S;
197
+ this.options.gfm && (w = this.rules.other.listIsTask.exec(p), w && (S = w[0] !== "[ ] ", p = p.replace(this.rules.other.listReplaceTask, ""))), n.items.push({ type: "list_item", raw: a, task: !!w, checked: S, loose: !1, text: p, tokens: [] }), n.raw += a;
198
+ }
199
+ let l = n.items.at(-1);
200
+ if (l) l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
201
+ else return;
202
+ n.raw = n.raw.trimEnd();
203
+ for (let o = 0; o < n.items.length; o++) if (this.lexer.state.top = !1, n.items[o].tokens = this.lexer.blockTokens(n.items[o].text, []), !n.loose) {
204
+ let a = n.items[o].tokens.filter((k) => k.type === "space"), p = a.length > 0 && a.some((k) => this.rules.other.anyLine.test(k.raw));
205
+ n.loose = p;
206
+ }
207
+ if (n.loose) for (let o = 0; o < n.items.length; o++) n.items[o].loose = !0;
208
+ return n;
209
+ }
210
+ }
211
+ html(t) {
212
+ let e = this.rules.block.html.exec(t);
213
+ if (e) return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
214
+ }
215
+ def(t) {
216
+ let e = this.rules.block.def.exec(t);
217
+ if (e) {
218
+ let r = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), s = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", n = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
219
+ return { type: "def", tag: r, raw: e[0], href: s, title: n };
220
+ }
221
+ }
222
+ table(t) {
223
+ var c;
224
+ let e = this.rules.block.table.exec(t);
225
+ if (!e || !this.rules.other.tableDelimiter.test(e[2])) return;
226
+ let r = le(e[1]), s = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), n = (c = e[3]) != null && c.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
227
+ `) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] };
228
+ if (r.length === s.length) {
229
+ for (let l of s) this.rules.other.tableAlignRight.test(l) ? i.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? i.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? i.align.push("left") : i.align.push(null);
230
+ 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] });
231
+ for (let l of n) i.rows.push(le(l, i.header.length).map((o, a) => ({ text: o, tokens: this.lexer.inline(o), header: !1, align: i.align[a] })));
232
+ return i;
233
+ }
234
+ }
235
+ lheading(t) {
236
+ let e = this.rules.block.lheading.exec(t);
237
+ if (e) return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: e[1], tokens: this.lexer.inline(e[1]) };
238
+ }
239
+ paragraph(t) {
240
+ let e = this.rules.block.paragraph.exec(t);
241
+ if (e) {
242
+ let r = e[1].charAt(e[1].length - 1) === `
243
+ ` ? e[1].slice(0, -1) : e[1];
244
+ return { type: "paragraph", raw: e[0], text: r, tokens: this.lexer.inline(r) };
245
+ }
246
+ }
247
+ text(t) {
248
+ let e = this.rules.block.text.exec(t);
249
+ if (e) return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
250
+ }
251
+ escape(t) {
252
+ let e = this.rules.inline.escape.exec(t);
253
+ if (e) return { type: "escape", raw: e[0], text: e[1] };
254
+ }
255
+ tag(t) {
256
+ let e = this.rules.inline.tag.exec(t);
257
+ 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] };
258
+ }
259
+ link(t) {
260
+ let e = this.rules.inline.link.exec(t);
261
+ if (e) {
262
+ let r = e[2].trim();
263
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(r)) {
264
+ if (!this.rules.other.endAngleBracket.test(r)) return;
265
+ let i = P(r.slice(0, -1), "\\");
266
+ if ((r.length - i.length) % 2 === 0) return;
267
+ } else {
268
+ let i = et(e[2], "()");
269
+ if (i === -2) return;
270
+ if (i > -1) {
271
+ let c = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
272
+ e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, c).trim(), e[3] = "";
273
+ }
274
+ }
275
+ let s = e[2], n = "";
276
+ if (this.options.pedantic) {
277
+ let i = this.rules.other.pedanticHrefTitle.exec(s);
278
+ i && (s = i[1], n = i[3]);
279
+ } else n = e[3] ? e[3].slice(1, -1) : "";
280
+ return s = s.trim(), this.rules.other.startAngleBracket.test(s) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(r) ? s = s.slice(1) : s = s.slice(1, -1)), ie(e, { href: s && s.replace(this.rules.inline.anyPunctuation, "$1"), title: n && n.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
281
+ }
282
+ }
283
+ reflink(t, e) {
284
+ let r;
285
+ if ((r = this.rules.inline.reflink.exec(t)) || (r = this.rules.inline.nolink.exec(t))) {
286
+ let s = (r[2] || r[1]).replace(this.rules.other.multipleSpaceGlobal, " "), n = e[s.toLowerCase()];
287
+ if (!n) {
288
+ let i = r[0].charAt(0);
289
+ return { type: "text", raw: i, text: i };
290
+ }
291
+ return ie(r, n, r[0], this.lexer, this.rules);
292
+ }
293
+ }
294
+ emStrong(t, e, r = "") {
295
+ let s = this.rules.inline.emStrongLDelim.exec(t);
296
+ if (!(!s || s[3] && r.match(this.rules.other.unicodeAlphaNumeric)) && (!(s[1] || s[2]) || !r || this.rules.inline.punctuation.exec(r))) {
297
+ let n = [...s[0]].length - 1, i, c, l = n, o = 0, a = s[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
298
+ for (a.lastIndex = 0, e = e.slice(-1 * t.length + n); (s = a.exec(e)) != null; ) {
299
+ if (i = s[1] || s[2] || s[3] || s[4] || s[5] || s[6], !i) continue;
300
+ if (c = [...i].length, s[3] || s[4]) {
301
+ l += c;
302
+ continue;
303
+ } else if ((s[5] || s[6]) && n % 3 && !((n + c) % 3)) {
304
+ o += c;
305
+ continue;
306
+ }
307
+ if (l -= c, l > 0) continue;
308
+ c = Math.min(c, c + l + o);
309
+ let p = [...s[0]][0].length, k = t.slice(0, n + s.index + p + c);
310
+ if (Math.min(n, c) % 2) {
311
+ let x = k.slice(1, -1);
312
+ return { type: "em", raw: k, text: x, tokens: this.lexer.inlineTokens(x) };
313
+ }
314
+ let h = k.slice(2, -2);
315
+ return { type: "strong", raw: k, text: h, tokens: this.lexer.inlineTokens(h) };
316
+ }
317
+ }
318
+ }
319
+ codespan(t) {
320
+ let e = this.rules.inline.code.exec(t);
321
+ if (e) {
322
+ let r = e[2].replace(this.rules.other.newLineCharGlobal, " "), s = this.rules.other.nonSpaceChar.test(r), n = this.rules.other.startingSpaceChar.test(r) && this.rules.other.endingSpaceChar.test(r);
323
+ return s && n && (r = r.substring(1, r.length - 1)), { type: "codespan", raw: e[0], text: r };
324
+ }
325
+ }
326
+ br(t) {
327
+ let e = this.rules.inline.br.exec(t);
328
+ if (e) return { type: "br", raw: e[0] };
329
+ }
330
+ del(t) {
331
+ let e = this.rules.inline.del.exec(t);
332
+ if (e) return { type: "del", raw: e[0], text: e[2], tokens: this.lexer.inlineTokens(e[2]) };
333
+ }
334
+ autolink(t) {
335
+ let e = this.rules.inline.autolink.exec(t);
336
+ if (e) {
337
+ let r, s;
338
+ return e[2] === "@" ? (r = e[1], s = "mailto:" + r) : (r = e[1], s = r), { type: "link", raw: e[0], text: r, href: s, tokens: [{ type: "text", raw: r, text: r }] };
339
+ }
340
+ }
341
+ url(t) {
342
+ var r;
343
+ let e;
344
+ if (e = this.rules.inline.url.exec(t)) {
345
+ let s, n;
346
+ if (e[2] === "@") s = e[0], n = "mailto:" + s;
347
+ else {
348
+ let i;
349
+ do
350
+ i = e[0], e[0] = ((r = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : r[0]) ?? "";
351
+ while (i !== e[0]);
352
+ s = e[0], e[1] === "www." ? n = "http://" + e[0] : n = e[0];
353
+ }
354
+ return { type: "link", raw: e[0], text: s, href: n, tokens: [{ type: "text", raw: s, text: s }] };
355
+ }
356
+ }
357
+ inlineText(t) {
358
+ let e = this.rules.inline.text.exec(t);
359
+ if (e) {
360
+ let r = this.lexer.state.inRawBlock;
361
+ return { type: "text", raw: e[0], text: e[0], escaped: r };
362
+ }
363
+ }
364
+ }, y = class N {
365
+ constructor(e) {
366
+ d(this, "tokens");
367
+ d(this, "options");
368
+ d(this, "state");
369
+ d(this, "tokenizer");
370
+ d(this, "inlineQueue");
371
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || T, this.options.tokenizer = this.options.tokenizer || new E(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
372
+ let r = { other: b, block: B.normal, inline: _.normal };
373
+ this.options.pedantic ? (r.block = B.pedantic, r.inline = _.pedantic) : this.options.gfm && (r.block = B.gfm, this.options.breaks ? r.inline = _.breaks : r.inline = _.gfm), this.tokenizer.rules = r;
374
+ }
375
+ static get rules() {
376
+ return { block: B, inline: _ };
377
+ }
378
+ static lex(e, r) {
379
+ return new N(r).lex(e);
380
+ }
381
+ static lexInline(e, r) {
382
+ return new N(r).inlineTokens(e);
383
+ }
384
+ lex(e) {
385
+ e = e.replace(b.carriageReturn, `
386
+ `), this.blockTokens(e, this.tokens);
387
+ for (let r = 0; r < this.inlineQueue.length; r++) {
388
+ let s = this.inlineQueue[r];
389
+ this.inlineTokens(s.src, s.tokens);
390
+ }
391
+ return this.inlineQueue = [], this.tokens;
392
+ }
393
+ blockTokens(e, r = [], s = !1) {
394
+ var n, i, c;
395
+ for (this.options.pedantic && (e = e.replace(b.tabCharGlobal, " ").replace(b.spaceLine, "")); e; ) {
396
+ let l;
397
+ if ((i = (n = this.options.extensions) == null ? void 0 : n.block) != null && i.some((a) => (l = a.call({ lexer: this }, e, r)) ? (e = e.substring(l.raw.length), r.push(l), !0) : !1)) continue;
398
+ if (l = this.tokenizer.space(e)) {
399
+ e = e.substring(l.raw.length);
400
+ let a = r.at(-1);
401
+ l.raw.length === 1 && a !== void 0 ? a.raw += `
402
+ ` : r.push(l);
403
+ continue;
404
+ }
405
+ if (l = this.tokenizer.code(e)) {
406
+ e = e.substring(l.raw.length);
407
+ let a = r.at(-1);
408
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += (a.raw.endsWith(`
409
+ `) ? "" : `
410
+ `) + l.raw, a.text += `
411
+ ` + l.text, this.inlineQueue.at(-1).src = a.text) : r.push(l);
412
+ continue;
413
+ }
414
+ if (l = this.tokenizer.fences(e)) {
415
+ e = e.substring(l.raw.length), r.push(l);
416
+ continue;
417
+ }
418
+ if (l = this.tokenizer.heading(e)) {
419
+ e = e.substring(l.raw.length), r.push(l);
420
+ continue;
421
+ }
422
+ if (l = this.tokenizer.hr(e)) {
423
+ e = e.substring(l.raw.length), r.push(l);
424
+ continue;
425
+ }
426
+ if (l = this.tokenizer.blockquote(e)) {
427
+ e = e.substring(l.raw.length), r.push(l);
428
+ continue;
429
+ }
430
+ if (l = this.tokenizer.list(e)) {
431
+ e = e.substring(l.raw.length), r.push(l);
432
+ continue;
433
+ }
434
+ if (l = this.tokenizer.html(e)) {
435
+ e = e.substring(l.raw.length), r.push(l);
436
+ continue;
437
+ }
438
+ if (l = this.tokenizer.def(e)) {
439
+ e = e.substring(l.raw.length);
440
+ let a = r.at(-1);
441
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += (a.raw.endsWith(`
442
+ `) ? "" : `
443
+ `) + l.raw, a.text += `
444
+ ` + l.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[l.tag] || (this.tokens.links[l.tag] = { href: l.href, title: l.title }, r.push(l));
445
+ continue;
446
+ }
447
+ if (l = this.tokenizer.table(e)) {
448
+ e = e.substring(l.raw.length), r.push(l);
449
+ continue;
450
+ }
451
+ if (l = this.tokenizer.lheading(e)) {
452
+ e = e.substring(l.raw.length), r.push(l);
453
+ continue;
454
+ }
455
+ let o = e;
456
+ if ((c = this.options.extensions) != null && c.startBlock) {
457
+ let a = 1 / 0, p = e.slice(1), k;
458
+ this.options.extensions.startBlock.forEach((h) => {
459
+ k = h.call({ lexer: this }, p), typeof k == "number" && k >= 0 && (a = Math.min(a, k));
460
+ }), a < 1 / 0 && a >= 0 && (o = e.substring(0, a + 1));
461
+ }
462
+ if (this.state.top && (l = this.tokenizer.paragraph(o))) {
463
+ let a = r.at(-1);
464
+ s && (a == null ? void 0 : a.type) === "paragraph" ? (a.raw += (a.raw.endsWith(`
465
+ `) ? "" : `
466
+ `) + l.raw, a.text += `
467
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : r.push(l), s = o.length !== e.length, e = e.substring(l.raw.length);
468
+ continue;
469
+ }
470
+ if (l = this.tokenizer.text(e)) {
471
+ e = e.substring(l.raw.length);
472
+ let a = r.at(-1);
473
+ (a == null ? void 0 : a.type) === "text" ? (a.raw += (a.raw.endsWith(`
474
+ `) ? "" : `
475
+ `) + l.raw, a.text += `
476
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : r.push(l);
477
+ continue;
478
+ }
479
+ if (e) {
480
+ let a = "Infinite loop on byte: " + e.charCodeAt(0);
481
+ if (this.options.silent) {
482
+ console.error(a);
483
+ break;
484
+ } else throw new Error(a);
485
+ }
486
+ }
487
+ return this.state.top = !0, r;
488
+ }
489
+ inline(e, r = []) {
490
+ return this.inlineQueue.push({ src: e, tokens: r }), r;
491
+ }
492
+ inlineTokens(e, r = []) {
493
+ var l, o, a, p, k;
494
+ let s = e, n = null;
495
+ if (this.tokens.links) {
496
+ let h = Object.keys(this.tokens.links);
497
+ if (h.length > 0) for (; (n = this.tokenizer.rules.inline.reflinkSearch.exec(s)) != null; ) h.includes(n[0].slice(n[0].lastIndexOf("[") + 1, -1)) && (s = s.slice(0, n.index) + "[" + "a".repeat(n[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
498
+ }
499
+ for (; (n = this.tokenizer.rules.inline.anyPunctuation.exec(s)) != null; ) s = s.slice(0, n.index) + "++" + s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
500
+ for (; (n = this.tokenizer.rules.inline.blockSkip.exec(s)) != null; ) s = s.slice(0, n.index) + "[" + "a".repeat(n[0].length - 2) + "]" + s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
501
+ s = ((o = (l = this.options.hooks) == null ? void 0 : l.emStrongMask) == null ? void 0 : o.call({ lexer: this }, s)) ?? s;
502
+ let i = !1, c = "";
503
+ for (; e; ) {
504
+ i || (c = ""), i = !1;
505
+ let h;
506
+ if ((p = (a = this.options.extensions) == null ? void 0 : a.inline) != null && p.some((u) => (h = u.call({ lexer: this }, e, r)) ? (e = e.substring(h.raw.length), r.push(h), !0) : !1)) continue;
507
+ if (h = this.tokenizer.escape(e)) {
508
+ e = e.substring(h.raw.length), r.push(h);
509
+ continue;
510
+ }
511
+ if (h = this.tokenizer.tag(e)) {
512
+ e = e.substring(h.raw.length), r.push(h);
513
+ continue;
514
+ }
515
+ if (h = this.tokenizer.link(e)) {
516
+ e = e.substring(h.raw.length), r.push(h);
517
+ continue;
518
+ }
519
+ if (h = this.tokenizer.reflink(e, this.tokens.links)) {
520
+ e = e.substring(h.raw.length);
521
+ let u = r.at(-1);
522
+ h.type === "text" && (u == null ? void 0 : u.type) === "text" ? (u.raw += h.raw, u.text += h.text) : r.push(h);
523
+ continue;
524
+ }
525
+ if (h = this.tokenizer.emStrong(e, s, c)) {
526
+ e = e.substring(h.raw.length), r.push(h);
527
+ continue;
528
+ }
529
+ if (h = this.tokenizer.codespan(e)) {
530
+ e = e.substring(h.raw.length), r.push(h);
531
+ continue;
532
+ }
533
+ if (h = this.tokenizer.br(e)) {
534
+ e = e.substring(h.raw.length), r.push(h);
535
+ continue;
536
+ }
537
+ if (h = this.tokenizer.del(e)) {
538
+ e = e.substring(h.raw.length), r.push(h);
539
+ continue;
540
+ }
541
+ if (h = this.tokenizer.autolink(e)) {
542
+ e = e.substring(h.raw.length), r.push(h);
543
+ continue;
544
+ }
545
+ if (!this.state.inLink && (h = this.tokenizer.url(e))) {
546
+ e = e.substring(h.raw.length), r.push(h);
547
+ continue;
548
+ }
549
+ let x = e;
550
+ if ((k = this.options.extensions) != null && k.startInline) {
551
+ let u = 1 / 0, w = e.slice(1), S;
552
+ this.options.extensions.startInline.forEach((z) => {
553
+ S = z.call({ lexer: this }, w), typeof S == "number" && S >= 0 && (u = Math.min(u, S));
554
+ }), u < 1 / 0 && u >= 0 && (x = e.substring(0, u + 1));
555
+ }
556
+ if (h = this.tokenizer.inlineText(x)) {
557
+ e = e.substring(h.raw.length), h.raw.slice(-1) !== "_" && (c = h.raw.slice(-1)), i = !0;
558
+ let u = r.at(-1);
559
+ (u == null ? void 0 : u.type) === "text" ? (u.raw += h.raw, u.text += h.text) : r.push(h);
560
+ continue;
561
+ }
562
+ if (e) {
563
+ let u = "Infinite loop on byte: " + e.charCodeAt(0);
564
+ if (this.options.silent) {
565
+ console.error(u);
566
+ break;
567
+ } else throw new Error(u);
568
+ }
569
+ }
570
+ return r;
571
+ }
572
+ }, Z = class {
573
+ constructor(t) {
574
+ d(this, "options");
575
+ d(this, "parser");
576
+ this.options = t || T;
577
+ }
578
+ space(t) {
579
+ return "";
580
+ }
581
+ code({ text: t, lang: e, escaped: r }) {
582
+ var i;
583
+ let s = (i = (e || "").match(b.notSpaceStart)) == null ? void 0 : i[0], n = t.replace(b.endingNewline, "") + `
584
+ `;
585
+ return s ? '<pre><code class="language-' + m(s) + '">' + (r ? n : m(n, !0)) + `</code></pre>
586
+ ` : "<pre><code>" + (r ? n : m(n, !0)) + `</code></pre>
587
+ `;
588
+ }
589
+ blockquote({ tokens: t }) {
590
+ return `<blockquote>
591
+ ${this.parser.parse(t)}</blockquote>
592
+ `;
593
+ }
594
+ html({ text: t }) {
595
+ return t;
596
+ }
597
+ def(t) {
598
+ return "";
599
+ }
600
+ heading({ tokens: t, depth: e }) {
601
+ return `<h${e}>${this.parser.parseInline(t)}</h${e}>
602
+ `;
603
+ }
604
+ hr(t) {
605
+ return `<hr>
606
+ `;
607
+ }
608
+ list(t) {
609
+ let e = t.ordered, r = t.start, s = "";
610
+ for (let c = 0; c < t.items.length; c++) {
611
+ let l = t.items[c];
612
+ s += this.listitem(l);
613
+ }
614
+ let n = e ? "ol" : "ul", i = e && r !== 1 ? ' start="' + r + '"' : "";
615
+ return "<" + n + i + `>
616
+ ` + s + "</" + n + `>
617
+ `;
618
+ }
619
+ listitem(t) {
620
+ var r;
621
+ let e = "";
622
+ if (t.task) {
623
+ let s = this.checkbox({ checked: !!t.checked });
624
+ t.loose ? ((r = t.tokens[0]) == null ? void 0 : r.type) === "paragraph" ? (t.tokens[0].text = s + " " + t.tokens[0].text, t.tokens[0].tokens && t.tokens[0].tokens.length > 0 && t.tokens[0].tokens[0].type === "text" && (t.tokens[0].tokens[0].text = s + " " + m(t.tokens[0].tokens[0].text), t.tokens[0].tokens[0].escaped = !0)) : t.tokens.unshift({ type: "text", raw: s + " ", text: s + " ", escaped: !0 }) : e += s + " ";
625
+ }
626
+ return e += this.parser.parse(t.tokens, !!t.loose), `<li>${e}</li>
627
+ `;
628
+ }
629
+ checkbox({ checked: t }) {
630
+ return "<input " + (t ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
631
+ }
632
+ paragraph({ tokens: t }) {
633
+ return `<p>${this.parser.parseInline(t)}</p>
634
+ `;
635
+ }
636
+ table(t) {
637
+ let e = "", r = "";
638
+ for (let n = 0; n < t.header.length; n++) r += this.tablecell(t.header[n]);
639
+ e += this.tablerow({ text: r });
640
+ let s = "";
641
+ for (let n = 0; n < t.rows.length; n++) {
642
+ let i = t.rows[n];
643
+ r = "";
644
+ for (let c = 0; c < i.length; c++) r += this.tablecell(i[c]);
645
+ s += this.tablerow({ text: r });
646
+ }
647
+ return s && (s = `<tbody>${s}</tbody>`), `<table>
648
+ <thead>
649
+ ` + e + `</thead>
650
+ ` + s + `</table>
651
+ `;
652
+ }
653
+ tablerow({ text: t }) {
654
+ return `<tr>
655
+ ${t}</tr>
656
+ `;
657
+ }
658
+ tablecell(t) {
659
+ let e = this.parser.parseInline(t.tokens), r = t.header ? "th" : "td";
660
+ return (t.align ? `<${r} align="${t.align}">` : `<${r}>`) + e + `</${r}>
661
+ `;
662
+ }
663
+ strong({ tokens: t }) {
664
+ return `<strong>${this.parser.parseInline(t)}</strong>`;
665
+ }
666
+ em({ tokens: t }) {
667
+ return `<em>${this.parser.parseInline(t)}</em>`;
668
+ }
669
+ codespan({ text: t }) {
670
+ return `<code>${m(t, !0)}</code>`;
671
+ }
672
+ br(t) {
673
+ return "<br>";
674
+ }
675
+ del({ tokens: t }) {
676
+ return `<del>${this.parser.parseInline(t)}</del>`;
677
+ }
678
+ link({ href: t, title: e, tokens: r }) {
679
+ let s = this.parser.parseInline(r), n = se(t);
680
+ if (n === null) return s;
681
+ t = n;
682
+ let i = '<a href="' + t + '"';
683
+ return e && (i += ' title="' + m(e) + '"'), i += ">" + s + "</a>", i;
684
+ }
685
+ image({ href: t, title: e, text: r, tokens: s }) {
686
+ s && (r = this.parser.parseInline(s, this.parser.textRenderer));
687
+ let n = se(t);
688
+ if (n === null) return m(r);
689
+ t = n;
690
+ let i = `<img src="${t}" alt="${r}"`;
691
+ return e && (i += ` title="${m(e)}"`), i += ">", i;
692
+ }
693
+ text(t) {
694
+ return "tokens" in t && t.tokens ? this.parser.parseInline(t.tokens) : "escaped" in t && t.escaped ? t.text : m(t.text);
695
+ }
696
+ }, V = class {
697
+ strong({ text: t }) {
698
+ return t;
699
+ }
700
+ em({ text: t }) {
701
+ return t;
702
+ }
703
+ codespan({ text: t }) {
704
+ return t;
705
+ }
706
+ del({ text: t }) {
707
+ return t;
708
+ }
709
+ html({ text: t }) {
710
+ return t;
711
+ }
712
+ text({ text: t }) {
713
+ return t;
714
+ }
715
+ link({ text: t }) {
716
+ return "" + t;
717
+ }
718
+ image({ text: t }) {
719
+ return "" + t;
720
+ }
721
+ br() {
722
+ return "";
723
+ }
724
+ }, $ = class O {
725
+ constructor(e) {
726
+ d(this, "options");
727
+ d(this, "renderer");
728
+ d(this, "textRenderer");
729
+ this.options = e || T, this.options.renderer = this.options.renderer || new Z(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new V();
730
+ }
731
+ static parse(e, r) {
732
+ return new O(r).parse(e);
733
+ }
734
+ static parseInline(e, r) {
735
+ return new O(r).parseInline(e);
736
+ }
737
+ parse(e, r = !0) {
738
+ var n, i;
739
+ let s = "";
740
+ for (let c = 0; c < e.length; c++) {
741
+ let l = e[c];
742
+ if ((i = (n = this.options.extensions) == null ? void 0 : n.renderers) != null && i[l.type]) {
743
+ let a = l, p = this.options.extensions.renderers[a.type].call({ parser: this }, a);
744
+ if (p !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(a.type)) {
745
+ s += p || "";
746
+ continue;
747
+ }
748
+ }
749
+ let o = l;
750
+ switch (o.type) {
751
+ case "space": {
752
+ s += this.renderer.space(o);
753
+ continue;
754
+ }
755
+ case "hr": {
756
+ s += this.renderer.hr(o);
757
+ continue;
758
+ }
759
+ case "heading": {
760
+ s += this.renderer.heading(o);
761
+ continue;
762
+ }
763
+ case "code": {
764
+ s += this.renderer.code(o);
765
+ continue;
766
+ }
767
+ case "table": {
768
+ s += this.renderer.table(o);
769
+ continue;
770
+ }
771
+ case "blockquote": {
772
+ s += this.renderer.blockquote(o);
773
+ continue;
774
+ }
775
+ case "list": {
776
+ s += this.renderer.list(o);
777
+ continue;
778
+ }
779
+ case "html": {
780
+ s += this.renderer.html(o);
781
+ continue;
782
+ }
783
+ case "def": {
784
+ s += this.renderer.def(o);
785
+ continue;
786
+ }
787
+ case "paragraph": {
788
+ s += this.renderer.paragraph(o);
789
+ continue;
790
+ }
791
+ case "text": {
792
+ let a = o, p = this.renderer.text(a);
793
+ for (; c + 1 < e.length && e[c + 1].type === "text"; ) a = e[++c], p += `
794
+ ` + this.renderer.text(a);
795
+ r ? s += this.renderer.paragraph({ type: "paragraph", raw: p, text: p, tokens: [{ type: "text", raw: p, text: p, escaped: !0 }] }) : s += p;
796
+ continue;
797
+ }
798
+ default: {
799
+ let a = 'Token with "' + o.type + '" type was not found.';
800
+ if (this.options.silent) return console.error(a), "";
801
+ throw new Error(a);
802
+ }
803
+ }
804
+ }
805
+ return s;
806
+ }
807
+ parseInline(e, r = this.renderer) {
808
+ var n, i;
809
+ let s = "";
810
+ for (let c = 0; c < e.length; c++) {
811
+ let l = e[c];
812
+ if ((i = (n = this.options.extensions) == null ? void 0 : n.renderers) != null && i[l.type]) {
813
+ let a = this.options.extensions.renderers[l.type].call({ parser: this }, l);
814
+ if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
815
+ s += a || "";
816
+ continue;
817
+ }
818
+ }
819
+ let o = l;
820
+ switch (o.type) {
821
+ case "escape": {
822
+ s += r.text(o);
823
+ break;
824
+ }
825
+ case "html": {
826
+ s += r.html(o);
827
+ break;
828
+ }
829
+ case "link": {
830
+ s += r.link(o);
831
+ break;
832
+ }
833
+ case "image": {
834
+ s += r.image(o);
835
+ break;
836
+ }
837
+ case "strong": {
838
+ s += r.strong(o);
839
+ break;
840
+ }
841
+ case "em": {
842
+ s += r.em(o);
843
+ break;
844
+ }
845
+ case "codespan": {
846
+ s += r.codespan(o);
847
+ break;
848
+ }
849
+ case "br": {
850
+ s += r.br(o);
851
+ break;
852
+ }
853
+ case "del": {
854
+ s += r.del(o);
855
+ break;
856
+ }
857
+ case "text": {
858
+ s += r.text(o);
859
+ break;
860
+ }
861
+ default: {
862
+ let a = 'Token with "' + o.type + '" type was not found.';
863
+ if (this.options.silent) return console.error(a), "";
864
+ throw new Error(a);
865
+ }
866
+ }
867
+ }
868
+ return s;
869
+ }
870
+ }, C, I = (C = class {
871
+ constructor(t) {
872
+ d(this, "options");
873
+ d(this, "block");
874
+ this.options = t || T;
875
+ }
876
+ preprocess(t) {
877
+ return t;
878
+ }
879
+ postprocess(t) {
880
+ return t;
881
+ }
882
+ processAllTokens(t) {
883
+ return t;
884
+ }
885
+ emStrongMask(t) {
886
+ return t;
887
+ }
888
+ provideLexer() {
889
+ return this.block ? y.lex : y.lexInline;
890
+ }
891
+ provideParser() {
892
+ return this.block ? $.parse : $.parseInline;
893
+ }
894
+ }, d(C, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), d(C, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), C), rt = class {
895
+ constructor(...t) {
896
+ d(this, "defaults", j());
897
+ d(this, "options", this.setOptions);
898
+ d(this, "parse", this.parseMarkdown(!0));
899
+ d(this, "parseInline", this.parseMarkdown(!1));
900
+ d(this, "Parser", $);
901
+ d(this, "Renderer", Z);
902
+ d(this, "TextRenderer", V);
903
+ d(this, "Lexer", y);
904
+ d(this, "Tokenizer", E);
905
+ d(this, "Hooks", I);
906
+ this.use(...t);
907
+ }
908
+ walkTokens(t, e) {
909
+ var s, n;
910
+ let r = [];
911
+ for (let i of t) switch (r = r.concat(e.call(this, i)), i.type) {
912
+ case "table": {
913
+ let c = i;
914
+ for (let l of c.header) r = r.concat(this.walkTokens(l.tokens, e));
915
+ for (let l of c.rows) for (let o of l) r = r.concat(this.walkTokens(o.tokens, e));
916
+ break;
917
+ }
918
+ case "list": {
919
+ let c = i;
920
+ r = r.concat(this.walkTokens(c.items, e));
921
+ break;
922
+ }
923
+ default: {
924
+ let c = i;
925
+ (n = (s = this.defaults.extensions) == null ? void 0 : s.childTokens) != null && n[c.type] ? this.defaults.extensions.childTokens[c.type].forEach((l) => {
926
+ let o = c[l].flat(1 / 0);
927
+ r = r.concat(this.walkTokens(o, e));
928
+ }) : c.tokens && (r = r.concat(this.walkTokens(c.tokens, e)));
929
+ }
930
+ }
931
+ return r;
932
+ }
933
+ use(...t) {
934
+ let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
935
+ return t.forEach((r) => {
936
+ let s = { ...r };
937
+ if (s.async = this.defaults.async || s.async || !1, r.extensions && (r.extensions.forEach((n) => {
938
+ if (!n.name) throw new Error("extension name required");
939
+ if ("renderer" in n) {
940
+ let i = e.renderers[n.name];
941
+ i ? e.renderers[n.name] = function(...c) {
942
+ let l = n.renderer.apply(this, c);
943
+ return l === !1 && (l = i.apply(this, c)), l;
944
+ } : e.renderers[n.name] = n.renderer;
945
+ }
946
+ if ("tokenizer" in n) {
947
+ if (!n.level || n.level !== "block" && n.level !== "inline") throw new Error("extension level must be 'block' or 'inline'");
948
+ let i = e[n.level];
949
+ i ? i.unshift(n.tokenizer) : e[n.level] = [n.tokenizer], n.start && (n.level === "block" ? e.startBlock ? e.startBlock.push(n.start) : e.startBlock = [n.start] : n.level === "inline" && (e.startInline ? e.startInline.push(n.start) : e.startInline = [n.start]));
950
+ }
951
+ "childTokens" in n && n.childTokens && (e.childTokens[n.name] = n.childTokens);
952
+ }), s.extensions = e), r.renderer) {
953
+ let n = this.defaults.renderer || new Z(this.defaults);
954
+ for (let i in r.renderer) {
955
+ if (!(i in n)) throw new Error(`renderer '${i}' does not exist`);
956
+ if (["options", "parser"].includes(i)) continue;
957
+ let c = i, l = r.renderer[c], o = n[c];
958
+ n[c] = (...a) => {
959
+ let p = l.apply(n, a);
960
+ return p === !1 && (p = o.apply(n, a)), p || "";
961
+ };
962
+ }
963
+ s.renderer = n;
964
+ }
965
+ if (r.tokenizer) {
966
+ let n = this.defaults.tokenizer || new E(this.defaults);
967
+ for (let i in r.tokenizer) {
968
+ if (!(i in n)) throw new Error(`tokenizer '${i}' does not exist`);
969
+ if (["options", "rules", "lexer"].includes(i)) continue;
970
+ let c = i, l = r.tokenizer[c], o = n[c];
971
+ n[c] = (...a) => {
972
+ let p = l.apply(n, a);
973
+ return p === !1 && (p = o.apply(n, a)), p;
974
+ };
975
+ }
976
+ s.tokenizer = n;
977
+ }
978
+ if (r.hooks) {
979
+ let n = this.defaults.hooks || new I();
980
+ for (let i in r.hooks) {
981
+ if (!(i in n)) throw new Error(`hook '${i}' does not exist`);
982
+ if (["options", "block"].includes(i)) continue;
983
+ let c = i, l = r.hooks[c], o = n[c];
984
+ I.passThroughHooks.has(i) ? n[c] = (a) => {
985
+ if (this.defaults.async && I.passThroughHooksRespectAsync.has(i)) return Promise.resolve(l.call(n, a)).then((k) => o.call(n, k));
986
+ let p = l.call(n, a);
987
+ return o.call(n, p);
988
+ } : n[c] = (...a) => {
989
+ let p = l.apply(n, a);
990
+ return p === !1 && (p = o.apply(n, a)), p;
991
+ };
992
+ }
993
+ s.hooks = n;
994
+ }
995
+ if (r.walkTokens) {
996
+ let n = this.defaults.walkTokens, i = r.walkTokens;
997
+ s.walkTokens = function(c) {
998
+ let l = [];
999
+ return l.push(i.call(this, c)), n && (l = l.concat(n.call(this, c))), l;
1000
+ };
1001
+ }
1002
+ this.defaults = { ...this.defaults, ...s };
1003
+ }), this;
1004
+ }
1005
+ setOptions(t) {
1006
+ return this.defaults = { ...this.defaults, ...t }, this;
1007
+ }
1008
+ lexer(t, e) {
1009
+ return y.lex(t, e ?? this.defaults);
1010
+ }
1011
+ parser(t, e) {
1012
+ return $.parse(t, e ?? this.defaults);
1013
+ }
1014
+ parseMarkdown(t) {
1015
+ return (e, r) => {
1016
+ let s = { ...r }, n = { ...this.defaults, ...s }, i = this.onError(!!n.silent, !!n.async);
1017
+ if (this.defaults.async === !0 && s.async === !1) return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
1018
+ if (typeof e > "u" || e === null) return i(new Error("marked(): input parameter is undefined or null"));
1019
+ if (typeof e != "string") return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
1020
+ n.hooks && (n.hooks.options = n, n.hooks.block = t);
1021
+ let c = n.hooks ? n.hooks.provideLexer() : t ? y.lex : y.lexInline, l = n.hooks ? n.hooks.provideParser() : t ? $.parse : $.parseInline;
1022
+ if (n.async) return Promise.resolve(n.hooks ? n.hooks.preprocess(e) : e).then((o) => c(o, n)).then((o) => n.hooks ? n.hooks.processAllTokens(o) : o).then((o) => n.walkTokens ? Promise.all(this.walkTokens(o, n.walkTokens)).then(() => o) : o).then((o) => l(o, n)).then((o) => n.hooks ? n.hooks.postprocess(o) : o).catch(i);
1023
+ try {
1024
+ n.hooks && (e = n.hooks.preprocess(e));
1025
+ let o = c(e, n);
1026
+ n.hooks && (o = n.hooks.processAllTokens(o)), n.walkTokens && this.walkTokens(o, n.walkTokens);
1027
+ let a = l(o, n);
1028
+ return n.hooks && (a = n.hooks.postprocess(a)), a;
1029
+ } catch (o) {
1030
+ return i(o);
1031
+ }
1032
+ };
1033
+ }
1034
+ onError(t, e) {
1035
+ return (r) => {
1036
+ if (r.message += `
1037
+ Please report this to https://github.com/markedjs/marked.`, t) {
1038
+ let s = "<p>An error occurred:</p><pre>" + m(r.message + "", !0) + "</pre>";
1039
+ return e ? Promise.resolve(s) : s;
1040
+ }
1041
+ if (e) return Promise.reject(r);
1042
+ throw r;
1043
+ };
1044
+ }
1045
+ }, R = new rt();
1046
+ function f(t, e) {
1047
+ return R.parse(t, e);
1048
+ }
1049
+ f.options = f.setOptions = function(t) {
1050
+ return R.setOptions(t), f.defaults = R.defaults, ae(f.defaults), f;
1051
+ };
1052
+ f.getDefaults = j;
1053
+ f.defaults = T;
1054
+ f.use = function(...t) {
1055
+ return R.use(...t), f.defaults = R.defaults, ae(f.defaults), f;
1056
+ };
1057
+ f.walkTokens = function(t, e) {
1058
+ return R.walkTokens(t, e);
1059
+ };
1060
+ f.parseInline = R.parseInline;
1061
+ f.Parser = $;
1062
+ f.parser = $.parse;
1063
+ f.Renderer = Z;
1064
+ f.TextRenderer = V;
1065
+ f.Lexer = y;
1066
+ f.lexer = y.lex;
1067
+ f.Tokenizer = E;
1068
+ f.Hooks = I;
1069
+ f.parse = f;
1070
+ var st = f.options, lt = f.setOptions, it = f.use, at = f.walkTokens, ot = f.parseInline, ct = f, ht = $.parse, pt = y.lex;
1071
+ export {
1072
+ I as Hooks,
1073
+ y as Lexer,
1074
+ rt as Marked,
1075
+ $ as Parser,
1076
+ Z as Renderer,
1077
+ V as TextRenderer,
1078
+ E as Tokenizer,
1079
+ T as defaults,
1080
+ j as getDefaults,
1081
+ pt as lexer,
1082
+ f as marked,
1083
+ st as options,
1084
+ ct as parse,
1085
+ ot as parseInline,
1086
+ ht as parser,
1087
+ lt as setOptions,
1088
+ it as use,
1089
+ at as walkTokens
1090
+ };