ai-chat-vue3 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.
@@ -0,0 +1,1401 @@
1
+ var De = Object.defineProperty;
2
+ var Oe = (r, e, t) => e in r ? De(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var b = (r, e, t) => (Oe(r, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { ref as O, watch as Ne, openBlock as I, createElementBlock as C, createElementVNode as y, Fragment as te, renderList as Qe, normalizeClass as re, toDisplayString as fe, createCommentVNode as je, withDirectives as He, withKeys as Ge, withModifiers as Ke, vModelText as Ue, nextTick as Fe, createVNode as Xe } from "vue";
5
+ function ie() {
6
+ return { async: !1, breaks: !1, extensions: null, gfm: !0, hooks: null, pedantic: !1, renderer: null, silent: !1, tokenizer: null, walkTokens: null };
7
+ }
8
+ var B = ie();
9
+ function Se(r) {
10
+ B = r;
11
+ }
12
+ var H = { exec: () => null };
13
+ function d(r, e = "") {
14
+ let t = typeof r == "string" ? r : r.source, n = { replace: (s, i) => {
15
+ let a = typeof i == "string" ? i : i.source;
16
+ return a = a.replace(w.caret, "$1"), t = t.replace(s, a), n;
17
+ }, getRegex: () => new RegExp(t, e) };
18
+ return n;
19
+ }
20
+ var Ve = (() => {
21
+ try {
22
+ return !!new RegExp("(?<=1)(?<!1)");
23
+ } catch {
24
+ return !1;
25
+ }
26
+ })(), w = { 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: (r) => new RegExp(`^( {0,3}${r})((?:[ ][^\\n]*)?(?:\\n|$))`), nextBulletRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`), hrRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`), fencesBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}(?:\`\`\`|~~~)`), headingBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}#`), htmlBeginRegex: (r) => new RegExp(`^ {0,${Math.min(3, r - 1)}}<(?:[a-z].*>|!--)`, "i") }, We = /^(?:[ \t]*(?:\n|$))+/, Je = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, Ye = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, G = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, et = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, ae = /(?:[*+-]|\d{1,9}[.)])/, Re = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, ve = d(Re).replace(/bull/g, ae).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(), tt = d(Re).replace(/bull/g, ae).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(), oe = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, rt = /^[^\n]+/, ce = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/, st = d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", ce).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), nt = d(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, ae).getRegex(), J = "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", he = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, lt = 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", he).replace("tag", J).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), _e = d(oe).replace("hr", G).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", J).getRegex(), it = d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", _e).getRegex(), pe = { blockquote: it, code: Je, def: st, fences: Ye, heading: et, hr: G, html: lt, lheading: ve, list: nt, newline: We, paragraph: _e, table: H, text: rt }, xe = d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", G).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", J).getRegex(), at = { ...pe, lheading: tt, table: xe, paragraph: d(oe).replace("hr", G).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", xe).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", J).getRegex() }, ot = { ...pe, html: d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", he).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: H, lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/, paragraph: d(oe).replace("hr", G).replace("heading", ` *#{1,6} *[^
27
+ ]`).replace("lheading", ve).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex() }, ct = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, ht = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, Te = /^( {2,}|\\)\n(?!\s*$)/, pt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, Y = /[\p{P}\p{S}]/u, ue = /[\s\p{P}\p{S}]/u, ze = /[^\s\p{P}\p{S}]/u, ut = d(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, ue).getRegex(), Ae = /(?!~)[\p{P}\p{S}]/u, gt = /(?!~)[\s\p{P}\p{S}]/u, kt = /(?:[^\s\p{P}\p{S}]|~)/u, dt = d(/link|precode-code|html/, "g").replace("link", /\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-", Ve ? "(?<!`)()" : "(^^|[^`])").replace("code", /(?<b>`+)[^`]+\k<b>(?!`)/).replace("html", /<(?! )[^<>]*?>/).getRegex(), Le = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, ft = d(Le, "u").replace(/punct/g, Y).getRegex(), xt = d(Le, "u").replace(/punct/g, Ae).getRegex(), Pe = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", bt = d(Pe, "gu").replace(/notPunctSpace/g, ze).replace(/punctSpace/g, ue).replace(/punct/g, Y).getRegex(), mt = d(Pe, "gu").replace(/notPunctSpace/g, kt).replace(/punctSpace/g, gt).replace(/punct/g, Ae).getRegex(), wt = d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, ze).replace(/punctSpace/g, ue).replace(/punct/g, Y).getRegex(), yt = d(/\\(punct)/, "gu").replace(/punct/g, Y).getRegex(), $t = 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(), St = d(he).replace("(?:-->|$)", "-->").getRegex(), Rt = 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", St).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), X = /(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/, vt = d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", X).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), Ie = d(/^!?\[(label)\]\[(ref)\]/).replace("label", X).replace("ref", ce).getRegex(), Ce = d(/^!?\[(ref)\](?:\[\])?/).replace("ref", ce).getRegex(), _t = d("reflink|nolink(?!\\()", "g").replace("reflink", Ie).replace("nolink", Ce).getRegex(), be = /[hH][tT][tT][pP][sS]?|[fF][tT][pP]/, ge = { _backpedal: H, anyPunctuation: yt, autolink: $t, blockSkip: dt, br: Te, code: ht, del: H, emStrongLDelim: ft, emStrongRDelimAst: bt, emStrongRDelimUnd: wt, escape: ct, link: vt, nolink: Ce, punctuation: ut, reflink: Ie, reflinkSearch: _t, tag: Rt, text: pt, url: H }, Tt = { ...ge, link: d(/^!?\[(label)\]\((.*?)\)/).replace("label", X).getRegex(), reflink: d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", X).getRegex() }, se = { ...ge, emStrongRDelimAst: mt, emStrongLDelim: xt, url: d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol", be).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", be).getRegex() }, zt = { ...se, br: d(Te).replace("{2,}", "*").getRegex(), text: d(se.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex() }, U = { normal: pe, gfm: at, pedantic: ot }, N = { normal: ge, gfm: se, breaks: zt, pedantic: Tt }, At = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, me = (r) => At[r];
28
+ function T(r, e) {
29
+ if (e) {
30
+ if (w.escapeTest.test(r))
31
+ return r.replace(w.escapeReplace, me);
32
+ } else if (w.escapeTestNoEncode.test(r))
33
+ return r.replace(w.escapeReplaceNoEncode, me);
34
+ return r;
35
+ }
36
+ function we(r) {
37
+ try {
38
+ r = encodeURI(r).replace(w.percentDecode, "%");
39
+ } catch {
40
+ return null;
41
+ }
42
+ return r;
43
+ }
44
+ function ye(r, e) {
45
+ var i;
46
+ let t = r.replace(w.findPipe, (a, l, h) => {
47
+ let o = !1, p = l;
48
+ for (; --p >= 0 && h[p] === "\\"; )
49
+ o = !o;
50
+ return o ? "|" : " |";
51
+ }), n = t.split(w.splitPipe), s = 0;
52
+ if (n[0].trim() || n.shift(), n.length > 0 && !((i = n.at(-1)) != null && i.trim()) && n.pop(), e)
53
+ if (n.length > e)
54
+ n.splice(e);
55
+ else
56
+ for (; n.length < e; )
57
+ n.push("");
58
+ for (; s < n.length; s++)
59
+ n[s] = n[s].trim().replace(w.slashPipe, "|");
60
+ return n;
61
+ }
62
+ function Q(r, e, t) {
63
+ let n = r.length;
64
+ if (n === 0)
65
+ return "";
66
+ let s = 0;
67
+ for (; s < n; ) {
68
+ let i = r.charAt(n - s - 1);
69
+ if (i === e && !t)
70
+ s++;
71
+ else if (i !== e && t)
72
+ s++;
73
+ else
74
+ break;
75
+ }
76
+ return r.slice(0, n - s);
77
+ }
78
+ function Lt(r, e) {
79
+ if (r.indexOf(e[1]) === -1)
80
+ return -1;
81
+ let t = 0;
82
+ for (let n = 0; n < r.length; n++)
83
+ if (r[n] === "\\")
84
+ n++;
85
+ else if (r[n] === e[0])
86
+ t++;
87
+ else if (r[n] === e[1] && (t--, t < 0))
88
+ return n;
89
+ return t > 0 ? -2 : -1;
90
+ }
91
+ function $e(r, e, t, n, s) {
92
+ let i = e.href, a = e.title || null, l = r[1].replace(s.other.outputLinkReplace, "$1");
93
+ n.state.inLink = !0;
94
+ let h = { type: r[0].charAt(0) === "!" ? "image" : "link", raw: t, href: i, title: a, text: l, tokens: n.inlineTokens(l) };
95
+ return n.state.inLink = !1, h;
96
+ }
97
+ function Pt(r, e, t) {
98
+ let n = r.match(t.other.indentCodeCompensation);
99
+ if (n === null)
100
+ return e;
101
+ let s = n[1];
102
+ return e.split(`
103
+ `).map((i) => {
104
+ let a = i.match(t.other.beginningSpace);
105
+ if (a === null)
106
+ return i;
107
+ let [l] = a;
108
+ return l.length >= s.length ? i.slice(s.length) : i;
109
+ }).join(`
110
+ `);
111
+ }
112
+ var V = class {
113
+ constructor(r) {
114
+ b(this, "options");
115
+ b(this, "rules");
116
+ b(this, "lexer");
117
+ this.options = r || B;
118
+ }
119
+ space(r) {
120
+ let e = this.rules.block.newline.exec(r);
121
+ if (e && e[0].length > 0)
122
+ return { type: "space", raw: e[0] };
123
+ }
124
+ code(r) {
125
+ let e = this.rules.block.code.exec(r);
126
+ if (e) {
127
+ let t = e[0].replace(this.rules.other.codeRemoveIndent, "");
128
+ return { type: "code", raw: e[0], codeBlockStyle: "indented", text: this.options.pedantic ? t : Q(t, `
129
+ `) };
130
+ }
131
+ }
132
+ fences(r) {
133
+ let e = this.rules.block.fences.exec(r);
134
+ if (e) {
135
+ let t = e[0], n = Pt(t, e[3] || "", this.rules);
136
+ return { type: "code", raw: t, lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2], text: n };
137
+ }
138
+ }
139
+ heading(r) {
140
+ let e = this.rules.block.heading.exec(r);
141
+ if (e) {
142
+ let t = e[2].trim();
143
+ if (this.rules.other.endingHash.test(t)) {
144
+ let n = Q(t, "#");
145
+ (this.options.pedantic || !n || this.rules.other.endingSpaceChar.test(n)) && (t = n.trim());
146
+ }
147
+ return { type: "heading", raw: e[0], depth: e[1].length, text: t, tokens: this.lexer.inline(t) };
148
+ }
149
+ }
150
+ hr(r) {
151
+ let e = this.rules.block.hr.exec(r);
152
+ if (e)
153
+ return { type: "hr", raw: Q(e[0], `
154
+ `) };
155
+ }
156
+ blockquote(r) {
157
+ let e = this.rules.block.blockquote.exec(r);
158
+ if (e) {
159
+ let t = Q(e[0], `
160
+ `).split(`
161
+ `), n = "", s = "", i = [];
162
+ for (; t.length > 0; ) {
163
+ let a = !1, l = [], h;
164
+ for (h = 0; h < t.length; h++)
165
+ if (this.rules.other.blockquoteStart.test(t[h]))
166
+ l.push(t[h]), a = !0;
167
+ else if (!a)
168
+ l.push(t[h]);
169
+ else
170
+ break;
171
+ t = t.slice(h);
172
+ let o = l.join(`
173
+ `), p = o.replace(this.rules.other.blockquoteSetextReplace, `
174
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
175
+ n = n ? `${n}
176
+ ${o}` : o, s = s ? `${s}
177
+ ${p}` : p;
178
+ let g = this.lexer.state.top;
179
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(p, i, !0), this.lexer.state.top = g, t.length === 0)
180
+ break;
181
+ let u = i.at(-1);
182
+ if ((u == null ? void 0 : u.type) === "code")
183
+ break;
184
+ if ((u == null ? void 0 : u.type) === "blockquote") {
185
+ let c = u, f = c.raw + `
186
+ ` + t.join(`
187
+ `), k = this.blockquote(f);
188
+ i[i.length - 1] = k, n = n.substring(0, n.length - c.raw.length) + k.raw, s = s.substring(0, s.length - c.text.length) + k.text;
189
+ break;
190
+ } else if ((u == null ? void 0 : u.type) === "list") {
191
+ let c = u, f = c.raw + `
192
+ ` + t.join(`
193
+ `), k = this.list(f);
194
+ i[i.length - 1] = k, n = n.substring(0, n.length - u.raw.length) + k.raw, s = s.substring(0, s.length - c.raw.length) + k.raw, t = f.substring(i.at(-1).raw.length).split(`
195
+ `);
196
+ continue;
197
+ }
198
+ }
199
+ return { type: "blockquote", raw: n, tokens: i, text: s };
200
+ }
201
+ }
202
+ list(r) {
203
+ var t, n;
204
+ let e = this.rules.block.list.exec(r);
205
+ if (e) {
206
+ let s = e[1].trim(), i = s.length > 1, a = { type: "list", raw: "", ordered: i, start: i ? +s.slice(0, -1) : "", loose: !1, items: [] };
207
+ s = i ? `\\d{1,9}\\${s.slice(-1)}` : `\\${s}`, this.options.pedantic && (s = i ? s : "[*+-]");
208
+ let l = this.rules.other.listItemRegex(s), h = !1;
209
+ for (; r; ) {
210
+ let p = !1, g = "", u = "";
211
+ if (!(e = l.exec(r)) || this.rules.block.hr.test(r))
212
+ break;
213
+ g = e[0], r = r.substring(g.length);
214
+ let c = e[2].split(`
215
+ `, 1)[0].replace(this.rules.other.listReplaceTabs, (R) => " ".repeat(3 * R.length)), f = r.split(`
216
+ `, 1)[0], k = !c.trim(), m = 0;
217
+ if (this.options.pedantic ? (m = 2, u = c.trimStart()) : k ? m = e[1].length + 1 : (m = e[2].search(this.rules.other.nonSpaceChar), m = m > 4 ? 1 : m, u = c.slice(m), m += e[1].length), k && this.rules.other.blankLine.test(f) && (g += f + `
218
+ `, r = r.substring(f.length + 1), p = !0), !p) {
219
+ let R = this.rules.other.nextBulletRegex(m), P = this.rules.other.hrRegex(m), M = this.rules.other.fencesBeginRegex(m), Z = this.rules.other.headingBeginRegex(m), z = this.rules.other.htmlBeginRegex(m);
220
+ for (; r; ) {
221
+ let q = r.split(`
222
+ `, 1)[0], S;
223
+ if (f = q, this.options.pedantic ? (f = f.replace(this.rules.other.listReplaceNesting, " "), S = f) : S = f.replace(this.rules.other.tabCharGlobal, " "), M.test(f) || Z.test(f) || z.test(f) || R.test(f) || P.test(f))
224
+ break;
225
+ if (S.search(this.rules.other.nonSpaceChar) >= m || !f.trim())
226
+ u += `
227
+ ` + S.slice(m);
228
+ else {
229
+ if (k || c.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || M.test(c) || Z.test(c) || P.test(c))
230
+ break;
231
+ u += `
232
+ ` + f;
233
+ }
234
+ !k && !f.trim() && (k = !0), g += q + `
235
+ `, r = r.substring(q.length + 1), c = S.slice(m);
236
+ }
237
+ }
238
+ a.loose || (h ? a.loose = !0 : this.rules.other.doubleBlankLine.test(g) && (h = !0)), a.items.push({ type: "list_item", raw: g, task: !!this.options.gfm && this.rules.other.listIsTask.test(u), loose: !1, text: u, tokens: [] }), a.raw += g;
239
+ }
240
+ let o = a.items.at(-1);
241
+ if (o)
242
+ o.raw = o.raw.trimEnd(), o.text = o.text.trimEnd();
243
+ else
244
+ return;
245
+ a.raw = a.raw.trimEnd();
246
+ for (let p of a.items) {
247
+ if (this.lexer.state.top = !1, p.tokens = this.lexer.blockTokens(p.text, []), p.task) {
248
+ if (p.text = p.text.replace(this.rules.other.listReplaceTask, ""), ((t = p.tokens[0]) == null ? void 0 : t.type) === "text" || ((n = p.tokens[0]) == null ? void 0 : n.type) === "paragraph") {
249
+ p.tokens[0].raw = p.tokens[0].raw.replace(this.rules.other.listReplaceTask, ""), p.tokens[0].text = p.tokens[0].text.replace(this.rules.other.listReplaceTask, "");
250
+ for (let u = this.lexer.inlineQueue.length - 1; u >= 0; u--)
251
+ if (this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)) {
252
+ this.lexer.inlineQueue[u].src = this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask, "");
253
+ break;
254
+ }
255
+ }
256
+ let g = this.rules.other.listTaskCheckbox.exec(p.raw);
257
+ if (g) {
258
+ let u = { type: "checkbox", raw: g[0] + " ", checked: g[0] !== "[ ]" };
259
+ p.checked = u.checked, a.loose ? p.tokens[0] && ["paragraph", "text"].includes(p.tokens[0].type) && "tokens" in p.tokens[0] && p.tokens[0].tokens ? (p.tokens[0].raw = u.raw + p.tokens[0].raw, p.tokens[0].text = u.raw + p.tokens[0].text, p.tokens[0].tokens.unshift(u)) : p.tokens.unshift({ type: "paragraph", raw: u.raw, text: u.raw, tokens: [u] }) : p.tokens.unshift(u);
260
+ }
261
+ }
262
+ if (!a.loose) {
263
+ let g = p.tokens.filter((c) => c.type === "space"), u = g.length > 0 && g.some((c) => this.rules.other.anyLine.test(c.raw));
264
+ a.loose = u;
265
+ }
266
+ }
267
+ if (a.loose)
268
+ for (let p of a.items) {
269
+ p.loose = !0;
270
+ for (let g of p.tokens)
271
+ g.type === "text" && (g.type = "paragraph");
272
+ }
273
+ return a;
274
+ }
275
+ }
276
+ html(r) {
277
+ let e = this.rules.block.html.exec(r);
278
+ if (e)
279
+ return { type: "html", block: !0, raw: e[0], pre: e[1] === "pre" || e[1] === "script" || e[1] === "style", text: e[0] };
280
+ }
281
+ def(r) {
282
+ let e = this.rules.block.def.exec(r);
283
+ if (e) {
284
+ let t = 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") : "", s = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
285
+ return { type: "def", tag: t, raw: e[0], href: n, title: s };
286
+ }
287
+ }
288
+ table(r) {
289
+ var a;
290
+ let e = this.rules.block.table.exec(r);
291
+ if (!e || !this.rules.other.tableDelimiter.test(e[2]))
292
+ return;
293
+ let t = ye(e[1]), n = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), s = (a = e[3]) != null && a.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
294
+ `) : [], i = { type: "table", raw: e[0], header: [], align: [], rows: [] };
295
+ if (t.length === n.length) {
296
+ for (let l of n)
297
+ 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);
298
+ for (let l = 0; l < t.length; l++)
299
+ i.header.push({ text: t[l], tokens: this.lexer.inline(t[l]), header: !0, align: i.align[l] });
300
+ for (let l of s)
301
+ i.rows.push(ye(l, i.header.length).map((h, o) => ({ text: h, tokens: this.lexer.inline(h), header: !1, align: i.align[o] })));
302
+ return i;
303
+ }
304
+ }
305
+ lheading(r) {
306
+ let e = this.rules.block.lheading.exec(r);
307
+ if (e)
308
+ return { type: "heading", raw: e[0], depth: e[2].charAt(0) === "=" ? 1 : 2, text: e[1], tokens: this.lexer.inline(e[1]) };
309
+ }
310
+ paragraph(r) {
311
+ let e = this.rules.block.paragraph.exec(r);
312
+ if (e) {
313
+ let t = e[1].charAt(e[1].length - 1) === `
314
+ ` ? e[1].slice(0, -1) : e[1];
315
+ return { type: "paragraph", raw: e[0], text: t, tokens: this.lexer.inline(t) };
316
+ }
317
+ }
318
+ text(r) {
319
+ let e = this.rules.block.text.exec(r);
320
+ if (e)
321
+ return { type: "text", raw: e[0], text: e[0], tokens: this.lexer.inline(e[0]) };
322
+ }
323
+ escape(r) {
324
+ let e = this.rules.inline.escape.exec(r);
325
+ if (e)
326
+ return { type: "escape", raw: e[0], text: e[1] };
327
+ }
328
+ tag(r) {
329
+ let e = this.rules.inline.tag.exec(r);
330
+ if (e)
331
+ 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] };
332
+ }
333
+ link(r) {
334
+ let e = this.rules.inline.link.exec(r);
335
+ if (e) {
336
+ let t = e[2].trim();
337
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
338
+ if (!this.rules.other.endAngleBracket.test(t))
339
+ return;
340
+ let i = Q(t.slice(0, -1), "\\");
341
+ if ((t.length - i.length) % 2 === 0)
342
+ return;
343
+ } else {
344
+ let i = Lt(e[2], "()");
345
+ if (i === -2)
346
+ return;
347
+ if (i > -1) {
348
+ let a = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + i;
349
+ e[2] = e[2].substring(0, i), e[0] = e[0].substring(0, a).trim(), e[3] = "";
350
+ }
351
+ }
352
+ let n = e[2], s = "";
353
+ if (this.options.pedantic) {
354
+ let i = this.rules.other.pedanticHrefTitle.exec(n);
355
+ i && (n = i[1], s = i[3]);
356
+ } else
357
+ s = e[3] ? e[3].slice(1, -1) : "";
358
+ return n = n.trim(), this.rules.other.startAngleBracket.test(n) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? n = n.slice(1) : n = n.slice(1, -1)), $e(e, { href: n && n.replace(this.rules.inline.anyPunctuation, "$1"), title: s && s.replace(this.rules.inline.anyPunctuation, "$1") }, e[0], this.lexer, this.rules);
359
+ }
360
+ }
361
+ reflink(r, e) {
362
+ let t;
363
+ if ((t = this.rules.inline.reflink.exec(r)) || (t = this.rules.inline.nolink.exec(r))) {
364
+ let n = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), s = e[n.toLowerCase()];
365
+ if (!s) {
366
+ let i = t[0].charAt(0);
367
+ return { type: "text", raw: i, text: i };
368
+ }
369
+ return $e(t, s, t[0], this.lexer, this.rules);
370
+ }
371
+ }
372
+ emStrong(r, e, t = "") {
373
+ let n = this.rules.inline.emStrongLDelim.exec(r);
374
+ if (!(!n || n[3] && t.match(this.rules.other.unicodeAlphaNumeric)) && (!(n[1] || n[2]) || !t || this.rules.inline.punctuation.exec(t))) {
375
+ let s = [...n[0]].length - 1, i, a, l = s, h = 0, o = n[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
376
+ for (o.lastIndex = 0, e = e.slice(-1 * r.length + s); (n = o.exec(e)) != null; ) {
377
+ if (i = n[1] || n[2] || n[3] || n[4] || n[5] || n[6], !i)
378
+ continue;
379
+ if (a = [...i].length, n[3] || n[4]) {
380
+ l += a;
381
+ continue;
382
+ } else if ((n[5] || n[6]) && s % 3 && !((s + a) % 3)) {
383
+ h += a;
384
+ continue;
385
+ }
386
+ if (l -= a, l > 0)
387
+ continue;
388
+ a = Math.min(a, a + l + h);
389
+ let p = [...n[0]][0].length, g = r.slice(0, s + n.index + p + a);
390
+ if (Math.min(s, a) % 2) {
391
+ let c = g.slice(1, -1);
392
+ return { type: "em", raw: g, text: c, tokens: this.lexer.inlineTokens(c) };
393
+ }
394
+ let u = g.slice(2, -2);
395
+ return { type: "strong", raw: g, text: u, tokens: this.lexer.inlineTokens(u) };
396
+ }
397
+ }
398
+ }
399
+ codespan(r) {
400
+ let e = this.rules.inline.code.exec(r);
401
+ if (e) {
402
+ let t = e[2].replace(this.rules.other.newLineCharGlobal, " "), n = this.rules.other.nonSpaceChar.test(t), s = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
403
+ return n && s && (t = t.substring(1, t.length - 1)), { type: "codespan", raw: e[0], text: t };
404
+ }
405
+ }
406
+ br(r) {
407
+ let e = this.rules.inline.br.exec(r);
408
+ if (e)
409
+ return { type: "br", raw: e[0] };
410
+ }
411
+ del(r) {
412
+ let e = this.rules.inline.del.exec(r);
413
+ if (e)
414
+ return { type: "del", raw: e[0], text: e[2], tokens: this.lexer.inlineTokens(e[2]) };
415
+ }
416
+ autolink(r) {
417
+ let e = this.rules.inline.autolink.exec(r);
418
+ if (e) {
419
+ let t, n;
420
+ return e[2] === "@" ? (t = e[1], n = "mailto:" + t) : (t = e[1], n = t), { type: "link", raw: e[0], text: t, href: n, tokens: [{ type: "text", raw: t, text: t }] };
421
+ }
422
+ }
423
+ url(r) {
424
+ var t;
425
+ let e;
426
+ if (e = this.rules.inline.url.exec(r)) {
427
+ let n, s;
428
+ if (e[2] === "@")
429
+ n = e[0], s = "mailto:" + n;
430
+ else {
431
+ let i;
432
+ do
433
+ i = e[0], e[0] = ((t = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : t[0]) ?? "";
434
+ while (i !== e[0]);
435
+ n = e[0], e[1] === "www." ? s = "http://" + e[0] : s = e[0];
436
+ }
437
+ return { type: "link", raw: e[0], text: n, href: s, tokens: [{ type: "text", raw: n, text: n }] };
438
+ }
439
+ }
440
+ inlineText(r) {
441
+ let e = this.rules.inline.text.exec(r);
442
+ if (e) {
443
+ let t = this.lexer.state.inRawBlock;
444
+ return { type: "text", raw: e[0], text: e[0], escaped: t };
445
+ }
446
+ }
447
+ }, v = class ne {
448
+ constructor(e) {
449
+ b(this, "tokens");
450
+ b(this, "options");
451
+ b(this, "state");
452
+ b(this, "inlineQueue");
453
+ b(this, "tokenizer");
454
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || B, this.options.tokenizer = this.options.tokenizer || new V(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = { inLink: !1, inRawBlock: !1, top: !0 };
455
+ let t = { other: w, block: U.normal, inline: N.normal };
456
+ this.options.pedantic ? (t.block = U.pedantic, t.inline = N.pedantic) : this.options.gfm && (t.block = U.gfm, this.options.breaks ? t.inline = N.breaks : t.inline = N.gfm), this.tokenizer.rules = t;
457
+ }
458
+ static get rules() {
459
+ return { block: U, inline: N };
460
+ }
461
+ static lex(e, t) {
462
+ return new ne(t).lex(e);
463
+ }
464
+ static lexInline(e, t) {
465
+ return new ne(t).inlineTokens(e);
466
+ }
467
+ lex(e) {
468
+ e = e.replace(w.carriageReturn, `
469
+ `), this.blockTokens(e, this.tokens);
470
+ for (let t = 0; t < this.inlineQueue.length; t++) {
471
+ let n = this.inlineQueue[t];
472
+ this.inlineTokens(n.src, n.tokens);
473
+ }
474
+ return this.inlineQueue = [], this.tokens;
475
+ }
476
+ blockTokens(e, t = [], n = !1) {
477
+ var s, i, a;
478
+ for (this.options.pedantic && (e = e.replace(w.tabCharGlobal, " ").replace(w.spaceLine, "")); e; ) {
479
+ let l;
480
+ if ((i = (s = this.options.extensions) == null ? void 0 : s.block) != null && i.some((o) => (l = o.call({ lexer: this }, e, t)) ? (e = e.substring(l.raw.length), t.push(l), !0) : !1))
481
+ continue;
482
+ if (l = this.tokenizer.space(e)) {
483
+ e = e.substring(l.raw.length);
484
+ let o = t.at(-1);
485
+ l.raw.length === 1 && o !== void 0 ? o.raw += `
486
+ ` : t.push(l);
487
+ continue;
488
+ }
489
+ if (l = this.tokenizer.code(e)) {
490
+ e = e.substring(l.raw.length);
491
+ let o = t.at(-1);
492
+ (o == null ? void 0 : o.type) === "paragraph" || (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
493
+ `) ? "" : `
494
+ `) + l.raw, o.text += `
495
+ ` + l.text, this.inlineQueue.at(-1).src = o.text) : t.push(l);
496
+ continue;
497
+ }
498
+ if (l = this.tokenizer.fences(e)) {
499
+ e = e.substring(l.raw.length), t.push(l);
500
+ continue;
501
+ }
502
+ if (l = this.tokenizer.heading(e)) {
503
+ e = e.substring(l.raw.length), t.push(l);
504
+ continue;
505
+ }
506
+ if (l = this.tokenizer.hr(e)) {
507
+ e = e.substring(l.raw.length), t.push(l);
508
+ continue;
509
+ }
510
+ if (l = this.tokenizer.blockquote(e)) {
511
+ e = e.substring(l.raw.length), t.push(l);
512
+ continue;
513
+ }
514
+ if (l = this.tokenizer.list(e)) {
515
+ e = e.substring(l.raw.length), t.push(l);
516
+ continue;
517
+ }
518
+ if (l = this.tokenizer.html(e)) {
519
+ e = e.substring(l.raw.length), t.push(l);
520
+ continue;
521
+ }
522
+ if (l = this.tokenizer.def(e)) {
523
+ e = e.substring(l.raw.length);
524
+ let o = t.at(-1);
525
+ (o == null ? void 0 : o.type) === "paragraph" || (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
526
+ `) ? "" : `
527
+ `) + l.raw, o.text += `
528
+ ` + l.raw, this.inlineQueue.at(-1).src = o.text) : this.tokens.links[l.tag] || (this.tokens.links[l.tag] = { href: l.href, title: l.title }, t.push(l));
529
+ continue;
530
+ }
531
+ if (l = this.tokenizer.table(e)) {
532
+ e = e.substring(l.raw.length), t.push(l);
533
+ continue;
534
+ }
535
+ if (l = this.tokenizer.lheading(e)) {
536
+ e = e.substring(l.raw.length), t.push(l);
537
+ continue;
538
+ }
539
+ let h = e;
540
+ if ((a = this.options.extensions) != null && a.startBlock) {
541
+ let o = 1 / 0, p = e.slice(1), g;
542
+ this.options.extensions.startBlock.forEach((u) => {
543
+ g = u.call({ lexer: this }, p), typeof g == "number" && g >= 0 && (o = Math.min(o, g));
544
+ }), o < 1 / 0 && o >= 0 && (h = e.substring(0, o + 1));
545
+ }
546
+ if (this.state.top && (l = this.tokenizer.paragraph(h))) {
547
+ let o = t.at(-1);
548
+ n && (o == null ? void 0 : o.type) === "paragraph" ? (o.raw += (o.raw.endsWith(`
549
+ `) ? "" : `
550
+ `) + l.raw, o.text += `
551
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(l), n = h.length !== e.length, e = e.substring(l.raw.length);
552
+ continue;
553
+ }
554
+ if (l = this.tokenizer.text(e)) {
555
+ e = e.substring(l.raw.length);
556
+ let o = t.at(-1);
557
+ (o == null ? void 0 : o.type) === "text" ? (o.raw += (o.raw.endsWith(`
558
+ `) ? "" : `
559
+ `) + l.raw, o.text += `
560
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = o.text) : t.push(l);
561
+ continue;
562
+ }
563
+ if (e) {
564
+ let o = "Infinite loop on byte: " + e.charCodeAt(0);
565
+ if (this.options.silent) {
566
+ console.error(o);
567
+ break;
568
+ } else
569
+ throw new Error(o);
570
+ }
571
+ }
572
+ return this.state.top = !0, t;
573
+ }
574
+ inline(e, t = []) {
575
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
576
+ }
577
+ inlineTokens(e, t = []) {
578
+ var h, o, p, g, u;
579
+ let n = e, s = null;
580
+ if (this.tokens.links) {
581
+ let c = Object.keys(this.tokens.links);
582
+ if (c.length > 0)
583
+ for (; (s = this.tokenizer.rules.inline.reflinkSearch.exec(n)) != null; )
584
+ c.includes(s[0].slice(s[0].lastIndexOf("[") + 1, -1)) && (n = n.slice(0, s.index) + "[" + "a".repeat(s[0].length - 2) + "]" + n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
585
+ }
586
+ for (; (s = this.tokenizer.rules.inline.anyPunctuation.exec(n)) != null; )
587
+ n = n.slice(0, s.index) + "++" + n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
588
+ let i;
589
+ for (; (s = this.tokenizer.rules.inline.blockSkip.exec(n)) != null; )
590
+ i = s[2] ? s[2].length : 0, n = n.slice(0, s.index + i) + "[" + "a".repeat(s[0].length - i - 2) + "]" + n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
591
+ n = ((o = (h = this.options.hooks) == null ? void 0 : h.emStrongMask) == null ? void 0 : o.call({ lexer: this }, n)) ?? n;
592
+ let a = !1, l = "";
593
+ for (; e; ) {
594
+ a || (l = ""), a = !1;
595
+ let c;
596
+ if ((g = (p = this.options.extensions) == null ? void 0 : p.inline) != null && g.some((k) => (c = k.call({ lexer: this }, e, t)) ? (e = e.substring(c.raw.length), t.push(c), !0) : !1))
597
+ continue;
598
+ if (c = this.tokenizer.escape(e)) {
599
+ e = e.substring(c.raw.length), t.push(c);
600
+ continue;
601
+ }
602
+ if (c = this.tokenizer.tag(e)) {
603
+ e = e.substring(c.raw.length), t.push(c);
604
+ continue;
605
+ }
606
+ if (c = this.tokenizer.link(e)) {
607
+ e = e.substring(c.raw.length), t.push(c);
608
+ continue;
609
+ }
610
+ if (c = this.tokenizer.reflink(e, this.tokens.links)) {
611
+ e = e.substring(c.raw.length);
612
+ let k = t.at(-1);
613
+ c.type === "text" && (k == null ? void 0 : k.type) === "text" ? (k.raw += c.raw, k.text += c.text) : t.push(c);
614
+ continue;
615
+ }
616
+ if (c = this.tokenizer.emStrong(e, n, l)) {
617
+ e = e.substring(c.raw.length), t.push(c);
618
+ continue;
619
+ }
620
+ if (c = this.tokenizer.codespan(e)) {
621
+ e = e.substring(c.raw.length), t.push(c);
622
+ continue;
623
+ }
624
+ if (c = this.tokenizer.br(e)) {
625
+ e = e.substring(c.raw.length), t.push(c);
626
+ continue;
627
+ }
628
+ if (c = this.tokenizer.del(e)) {
629
+ e = e.substring(c.raw.length), t.push(c);
630
+ continue;
631
+ }
632
+ if (c = this.tokenizer.autolink(e)) {
633
+ e = e.substring(c.raw.length), t.push(c);
634
+ continue;
635
+ }
636
+ if (!this.state.inLink && (c = this.tokenizer.url(e))) {
637
+ e = e.substring(c.raw.length), t.push(c);
638
+ continue;
639
+ }
640
+ let f = e;
641
+ if ((u = this.options.extensions) != null && u.startInline) {
642
+ let k = 1 / 0, m = e.slice(1), R;
643
+ this.options.extensions.startInline.forEach((P) => {
644
+ R = P.call({ lexer: this }, m), typeof R == "number" && R >= 0 && (k = Math.min(k, R));
645
+ }), k < 1 / 0 && k >= 0 && (f = e.substring(0, k + 1));
646
+ }
647
+ if (c = this.tokenizer.inlineText(f)) {
648
+ e = e.substring(c.raw.length), c.raw.slice(-1) !== "_" && (l = c.raw.slice(-1)), a = !0;
649
+ let k = t.at(-1);
650
+ (k == null ? void 0 : k.type) === "text" ? (k.raw += c.raw, k.text += c.text) : t.push(c);
651
+ continue;
652
+ }
653
+ if (e) {
654
+ let k = "Infinite loop on byte: " + e.charCodeAt(0);
655
+ if (this.options.silent) {
656
+ console.error(k);
657
+ break;
658
+ } else
659
+ throw new Error(k);
660
+ }
661
+ }
662
+ return t;
663
+ }
664
+ }, W = class {
665
+ constructor(r) {
666
+ b(this, "options");
667
+ b(this, "parser");
668
+ this.options = r || B;
669
+ }
670
+ space(r) {
671
+ return "";
672
+ }
673
+ code({ text: r, lang: e, escaped: t }) {
674
+ var i;
675
+ let n = (i = (e || "").match(w.notSpaceStart)) == null ? void 0 : i[0], s = r.replace(w.endingNewline, "") + `
676
+ `;
677
+ return n ? '<pre><code class="language-' + T(n) + '">' + (t ? s : T(s, !0)) + `</code></pre>
678
+ ` : "<pre><code>" + (t ? s : T(s, !0)) + `</code></pre>
679
+ `;
680
+ }
681
+ blockquote({ tokens: r }) {
682
+ return `<blockquote>
683
+ ${this.parser.parse(r)}</blockquote>
684
+ `;
685
+ }
686
+ html({ text: r }) {
687
+ return r;
688
+ }
689
+ def(r) {
690
+ return "";
691
+ }
692
+ heading({ tokens: r, depth: e }) {
693
+ return `<h${e}>${this.parser.parseInline(r)}</h${e}>
694
+ `;
695
+ }
696
+ hr(r) {
697
+ return `<hr>
698
+ `;
699
+ }
700
+ list(r) {
701
+ let e = r.ordered, t = r.start, n = "";
702
+ for (let a = 0; a < r.items.length; a++) {
703
+ let l = r.items[a];
704
+ n += this.listitem(l);
705
+ }
706
+ let s = e ? "ol" : "ul", i = e && t !== 1 ? ' start="' + t + '"' : "";
707
+ return "<" + s + i + `>
708
+ ` + n + "</" + s + `>
709
+ `;
710
+ }
711
+ listitem(r) {
712
+ return `<li>${this.parser.parse(r.tokens)}</li>
713
+ `;
714
+ }
715
+ checkbox({ checked: r }) {
716
+ return "<input " + (r ? 'checked="" ' : "") + 'disabled="" type="checkbox"> ';
717
+ }
718
+ paragraph({ tokens: r }) {
719
+ return `<p>${this.parser.parseInline(r)}</p>
720
+ `;
721
+ }
722
+ table(r) {
723
+ let e = "", t = "";
724
+ for (let s = 0; s < r.header.length; s++)
725
+ t += this.tablecell(r.header[s]);
726
+ e += this.tablerow({ text: t });
727
+ let n = "";
728
+ for (let s = 0; s < r.rows.length; s++) {
729
+ let i = r.rows[s];
730
+ t = "";
731
+ for (let a = 0; a < i.length; a++)
732
+ t += this.tablecell(i[a]);
733
+ n += this.tablerow({ text: t });
734
+ }
735
+ return n && (n = `<tbody>${n}</tbody>`), `<table>
736
+ <thead>
737
+ ` + e + `</thead>
738
+ ` + n + `</table>
739
+ `;
740
+ }
741
+ tablerow({ text: r }) {
742
+ return `<tr>
743
+ ${r}</tr>
744
+ `;
745
+ }
746
+ tablecell(r) {
747
+ let e = this.parser.parseInline(r.tokens), t = r.header ? "th" : "td";
748
+ return (r.align ? `<${t} align="${r.align}">` : `<${t}>`) + e + `</${t}>
749
+ `;
750
+ }
751
+ strong({ tokens: r }) {
752
+ return `<strong>${this.parser.parseInline(r)}</strong>`;
753
+ }
754
+ em({ tokens: r }) {
755
+ return `<em>${this.parser.parseInline(r)}</em>`;
756
+ }
757
+ codespan({ text: r }) {
758
+ return `<code>${T(r, !0)}</code>`;
759
+ }
760
+ br(r) {
761
+ return "<br>";
762
+ }
763
+ del({ tokens: r }) {
764
+ return `<del>${this.parser.parseInline(r)}</del>`;
765
+ }
766
+ link({ href: r, title: e, tokens: t }) {
767
+ let n = this.parser.parseInline(t), s = we(r);
768
+ if (s === null)
769
+ return n;
770
+ r = s;
771
+ let i = '<a href="' + r + '"';
772
+ return e && (i += ' title="' + T(e) + '"'), i += ">" + n + "</a>", i;
773
+ }
774
+ image({ href: r, title: e, text: t, tokens: n }) {
775
+ n && (t = this.parser.parseInline(n, this.parser.textRenderer));
776
+ let s = we(r);
777
+ if (s === null)
778
+ return T(t);
779
+ r = s;
780
+ let i = `<img src="${r}" alt="${t}"`;
781
+ return e && (i += ` title="${T(e)}"`), i += ">", i;
782
+ }
783
+ text(r) {
784
+ return "tokens" in r && r.tokens ? this.parser.parseInline(r.tokens) : "escaped" in r && r.escaped ? r.text : T(r.text);
785
+ }
786
+ }, ke = class {
787
+ strong({ text: r }) {
788
+ return r;
789
+ }
790
+ em({ text: r }) {
791
+ return r;
792
+ }
793
+ codespan({ text: r }) {
794
+ return r;
795
+ }
796
+ del({ text: r }) {
797
+ return r;
798
+ }
799
+ html({ text: r }) {
800
+ return r;
801
+ }
802
+ text({ text: r }) {
803
+ return r;
804
+ }
805
+ link({ text: r }) {
806
+ return "" + r;
807
+ }
808
+ image({ text: r }) {
809
+ return "" + r;
810
+ }
811
+ br() {
812
+ return "";
813
+ }
814
+ checkbox({ raw: r }) {
815
+ return r;
816
+ }
817
+ }, _ = class le {
818
+ constructor(e) {
819
+ b(this, "options");
820
+ b(this, "renderer");
821
+ b(this, "textRenderer");
822
+ this.options = e || B, this.options.renderer = this.options.renderer || new W(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new ke();
823
+ }
824
+ static parse(e, t) {
825
+ return new le(t).parse(e);
826
+ }
827
+ static parseInline(e, t) {
828
+ return new le(t).parseInline(e);
829
+ }
830
+ parse(e) {
831
+ var n, s;
832
+ let t = "";
833
+ for (let i = 0; i < e.length; i++) {
834
+ let a = e[i];
835
+ if ((s = (n = this.options.extensions) == null ? void 0 : n.renderers) != null && s[a.type]) {
836
+ let h = a, o = this.options.extensions.renderers[h.type].call({ parser: this }, h);
837
+ if (o !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "def", "paragraph", "text"].includes(h.type)) {
838
+ t += o || "";
839
+ continue;
840
+ }
841
+ }
842
+ let l = a;
843
+ switch (l.type) {
844
+ case "space": {
845
+ t += this.renderer.space(l);
846
+ break;
847
+ }
848
+ case "hr": {
849
+ t += this.renderer.hr(l);
850
+ break;
851
+ }
852
+ case "heading": {
853
+ t += this.renderer.heading(l);
854
+ break;
855
+ }
856
+ case "code": {
857
+ t += this.renderer.code(l);
858
+ break;
859
+ }
860
+ case "table": {
861
+ t += this.renderer.table(l);
862
+ break;
863
+ }
864
+ case "blockquote": {
865
+ t += this.renderer.blockquote(l);
866
+ break;
867
+ }
868
+ case "list": {
869
+ t += this.renderer.list(l);
870
+ break;
871
+ }
872
+ case "checkbox": {
873
+ t += this.renderer.checkbox(l);
874
+ break;
875
+ }
876
+ case "html": {
877
+ t += this.renderer.html(l);
878
+ break;
879
+ }
880
+ case "def": {
881
+ t += this.renderer.def(l);
882
+ break;
883
+ }
884
+ case "paragraph": {
885
+ t += this.renderer.paragraph(l);
886
+ break;
887
+ }
888
+ case "text": {
889
+ t += this.renderer.text(l);
890
+ break;
891
+ }
892
+ default: {
893
+ let h = 'Token with "' + l.type + '" type was not found.';
894
+ if (this.options.silent)
895
+ return console.error(h), "";
896
+ throw new Error(h);
897
+ }
898
+ }
899
+ }
900
+ return t;
901
+ }
902
+ parseInline(e, t = this.renderer) {
903
+ var s, i;
904
+ let n = "";
905
+ for (let a = 0; a < e.length; a++) {
906
+ let l = e[a];
907
+ if ((i = (s = this.options.extensions) == null ? void 0 : s.renderers) != null && i[l.type]) {
908
+ let o = this.options.extensions.renderers[l.type].call({ parser: this }, l);
909
+ if (o !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
910
+ n += o || "";
911
+ continue;
912
+ }
913
+ }
914
+ let h = l;
915
+ switch (h.type) {
916
+ case "escape": {
917
+ n += t.text(h);
918
+ break;
919
+ }
920
+ case "html": {
921
+ n += t.html(h);
922
+ break;
923
+ }
924
+ case "link": {
925
+ n += t.link(h);
926
+ break;
927
+ }
928
+ case "image": {
929
+ n += t.image(h);
930
+ break;
931
+ }
932
+ case "checkbox": {
933
+ n += t.checkbox(h);
934
+ break;
935
+ }
936
+ case "strong": {
937
+ n += t.strong(h);
938
+ break;
939
+ }
940
+ case "em": {
941
+ n += t.em(h);
942
+ break;
943
+ }
944
+ case "codespan": {
945
+ n += t.codespan(h);
946
+ break;
947
+ }
948
+ case "br": {
949
+ n += t.br(h);
950
+ break;
951
+ }
952
+ case "del": {
953
+ n += t.del(h);
954
+ break;
955
+ }
956
+ case "text": {
957
+ n += t.text(h);
958
+ break;
959
+ }
960
+ default: {
961
+ let o = 'Token with "' + h.type + '" type was not found.';
962
+ if (this.options.silent)
963
+ return console.error(o), "";
964
+ throw new Error(o);
965
+ }
966
+ }
967
+ }
968
+ return n;
969
+ }
970
+ }, F, j = (F = class {
971
+ constructor(r) {
972
+ b(this, "options");
973
+ b(this, "block");
974
+ this.options = r || B;
975
+ }
976
+ preprocess(r) {
977
+ return r;
978
+ }
979
+ postprocess(r) {
980
+ return r;
981
+ }
982
+ processAllTokens(r) {
983
+ return r;
984
+ }
985
+ emStrongMask(r) {
986
+ return r;
987
+ }
988
+ provideLexer() {
989
+ return this.block ? v.lex : v.lexInline;
990
+ }
991
+ provideParser() {
992
+ return this.block ? _.parse : _.parseInline;
993
+ }
994
+ }, b(F, "passThroughHooks", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens", "emStrongMask"])), b(F, "passThroughHooksRespectAsync", /* @__PURE__ */ new Set(["preprocess", "postprocess", "processAllTokens"])), F), It = class {
995
+ constructor(...r) {
996
+ b(this, "defaults", ie());
997
+ b(this, "options", this.setOptions);
998
+ b(this, "parse", this.parseMarkdown(!0));
999
+ b(this, "parseInline", this.parseMarkdown(!1));
1000
+ b(this, "Parser", _);
1001
+ b(this, "Renderer", W);
1002
+ b(this, "TextRenderer", ke);
1003
+ b(this, "Lexer", v);
1004
+ b(this, "Tokenizer", V);
1005
+ b(this, "Hooks", j);
1006
+ this.use(...r);
1007
+ }
1008
+ walkTokens(r, e) {
1009
+ var n, s;
1010
+ let t = [];
1011
+ for (let i of r)
1012
+ switch (t = t.concat(e.call(this, i)), i.type) {
1013
+ case "table": {
1014
+ let a = i;
1015
+ for (let l of a.header)
1016
+ t = t.concat(this.walkTokens(l.tokens, e));
1017
+ for (let l of a.rows)
1018
+ for (let h of l)
1019
+ t = t.concat(this.walkTokens(h.tokens, e));
1020
+ break;
1021
+ }
1022
+ case "list": {
1023
+ let a = i;
1024
+ t = t.concat(this.walkTokens(a.items, e));
1025
+ break;
1026
+ }
1027
+ default: {
1028
+ let a = i;
1029
+ (s = (n = this.defaults.extensions) == null ? void 0 : n.childTokens) != null && s[a.type] ? this.defaults.extensions.childTokens[a.type].forEach((l) => {
1030
+ let h = a[l].flat(1 / 0);
1031
+ t = t.concat(this.walkTokens(h, e));
1032
+ }) : a.tokens && (t = t.concat(this.walkTokens(a.tokens, e)));
1033
+ }
1034
+ }
1035
+ return t;
1036
+ }
1037
+ use(...r) {
1038
+ let e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1039
+ return r.forEach((t) => {
1040
+ let n = { ...t };
1041
+ if (n.async = this.defaults.async || n.async || !1, t.extensions && (t.extensions.forEach((s) => {
1042
+ if (!s.name)
1043
+ throw new Error("extension name required");
1044
+ if ("renderer" in s) {
1045
+ let i = e.renderers[s.name];
1046
+ i ? e.renderers[s.name] = function(...a) {
1047
+ let l = s.renderer.apply(this, a);
1048
+ return l === !1 && (l = i.apply(this, a)), l;
1049
+ } : e.renderers[s.name] = s.renderer;
1050
+ }
1051
+ if ("tokenizer" in s) {
1052
+ if (!s.level || s.level !== "block" && s.level !== "inline")
1053
+ throw new Error("extension level must be 'block' or 'inline'");
1054
+ let i = e[s.level];
1055
+ i ? i.unshift(s.tokenizer) : e[s.level] = [s.tokenizer], s.start && (s.level === "block" ? e.startBlock ? e.startBlock.push(s.start) : e.startBlock = [s.start] : s.level === "inline" && (e.startInline ? e.startInline.push(s.start) : e.startInline = [s.start]));
1056
+ }
1057
+ "childTokens" in s && s.childTokens && (e.childTokens[s.name] = s.childTokens);
1058
+ }), n.extensions = e), t.renderer) {
1059
+ let s = this.defaults.renderer || new W(this.defaults);
1060
+ for (let i in t.renderer) {
1061
+ if (!(i in s))
1062
+ throw new Error(`renderer '${i}' does not exist`);
1063
+ if (["options", "parser"].includes(i))
1064
+ continue;
1065
+ let a = i, l = t.renderer[a], h = s[a];
1066
+ s[a] = (...o) => {
1067
+ let p = l.apply(s, o);
1068
+ return p === !1 && (p = h.apply(s, o)), p || "";
1069
+ };
1070
+ }
1071
+ n.renderer = s;
1072
+ }
1073
+ if (t.tokenizer) {
1074
+ let s = this.defaults.tokenizer || new V(this.defaults);
1075
+ for (let i in t.tokenizer) {
1076
+ if (!(i in s))
1077
+ throw new Error(`tokenizer '${i}' does not exist`);
1078
+ if (["options", "rules", "lexer"].includes(i))
1079
+ continue;
1080
+ let a = i, l = t.tokenizer[a], h = s[a];
1081
+ s[a] = (...o) => {
1082
+ let p = l.apply(s, o);
1083
+ return p === !1 && (p = h.apply(s, o)), p;
1084
+ };
1085
+ }
1086
+ n.tokenizer = s;
1087
+ }
1088
+ if (t.hooks) {
1089
+ let s = this.defaults.hooks || new j();
1090
+ for (let i in t.hooks) {
1091
+ if (!(i in s))
1092
+ throw new Error(`hook '${i}' does not exist`);
1093
+ if (["options", "block"].includes(i))
1094
+ continue;
1095
+ let a = i, l = t.hooks[a], h = s[a];
1096
+ j.passThroughHooks.has(i) ? s[a] = (o) => {
1097
+ if (this.defaults.async && j.passThroughHooksRespectAsync.has(i))
1098
+ return (async () => {
1099
+ let g = await l.call(s, o);
1100
+ return h.call(s, g);
1101
+ })();
1102
+ let p = l.call(s, o);
1103
+ return h.call(s, p);
1104
+ } : s[a] = (...o) => {
1105
+ if (this.defaults.async)
1106
+ return (async () => {
1107
+ let g = await l.apply(s, o);
1108
+ return g === !1 && (g = await h.apply(s, o)), g;
1109
+ })();
1110
+ let p = l.apply(s, o);
1111
+ return p === !1 && (p = h.apply(s, o)), p;
1112
+ };
1113
+ }
1114
+ n.hooks = s;
1115
+ }
1116
+ if (t.walkTokens) {
1117
+ let s = this.defaults.walkTokens, i = t.walkTokens;
1118
+ n.walkTokens = function(a) {
1119
+ let l = [];
1120
+ return l.push(i.call(this, a)), s && (l = l.concat(s.call(this, a))), l;
1121
+ };
1122
+ }
1123
+ this.defaults = { ...this.defaults, ...n };
1124
+ }), this;
1125
+ }
1126
+ setOptions(r) {
1127
+ return this.defaults = { ...this.defaults, ...r }, this;
1128
+ }
1129
+ lexer(r, e) {
1130
+ return v.lex(r, e ?? this.defaults);
1131
+ }
1132
+ parser(r, e) {
1133
+ return _.parse(r, e ?? this.defaults);
1134
+ }
1135
+ parseMarkdown(r) {
1136
+ return (e, t) => {
1137
+ let n = { ...t }, s = { ...this.defaults, ...n }, i = this.onError(!!s.silent, !!s.async);
1138
+ if (this.defaults.async === !0 && n.async === !1)
1139
+ 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."));
1140
+ if (typeof e > "u" || e === null)
1141
+ return i(new Error("marked(): input parameter is undefined or null"));
1142
+ if (typeof e != "string")
1143
+ return i(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"));
1144
+ if (s.hooks && (s.hooks.options = s, s.hooks.block = r), s.async)
1145
+ return (async () => {
1146
+ let a = s.hooks ? await s.hooks.preprocess(e) : e, l = await (s.hooks ? await s.hooks.provideLexer() : r ? v.lex : v.lexInline)(a, s), h = s.hooks ? await s.hooks.processAllTokens(l) : l;
1147
+ s.walkTokens && await Promise.all(this.walkTokens(h, s.walkTokens));
1148
+ let o = await (s.hooks ? await s.hooks.provideParser() : r ? _.parse : _.parseInline)(h, s);
1149
+ return s.hooks ? await s.hooks.postprocess(o) : o;
1150
+ })().catch(i);
1151
+ try {
1152
+ s.hooks && (e = s.hooks.preprocess(e));
1153
+ let a = (s.hooks ? s.hooks.provideLexer() : r ? v.lex : v.lexInline)(e, s);
1154
+ s.hooks && (a = s.hooks.processAllTokens(a)), s.walkTokens && this.walkTokens(a, s.walkTokens);
1155
+ let l = (s.hooks ? s.hooks.provideParser() : r ? _.parse : _.parseInline)(a, s);
1156
+ return s.hooks && (l = s.hooks.postprocess(l)), l;
1157
+ } catch (a) {
1158
+ return i(a);
1159
+ }
1160
+ };
1161
+ }
1162
+ onError(r, e) {
1163
+ return (t) => {
1164
+ if (t.message += `
1165
+ Please report this to https://github.com/markedjs/marked.`, r) {
1166
+ let n = "<p>An error occurred:</p><pre>" + T(t.message + "", !0) + "</pre>";
1167
+ return e ? Promise.resolve(n) : n;
1168
+ }
1169
+ if (e)
1170
+ return Promise.reject(t);
1171
+ throw t;
1172
+ };
1173
+ }
1174
+ }, E = new It();
1175
+ function x(r, e) {
1176
+ return E.parse(r, e);
1177
+ }
1178
+ x.options = x.setOptions = function(r) {
1179
+ return E.setOptions(r), x.defaults = E.defaults, Se(x.defaults), x;
1180
+ };
1181
+ x.getDefaults = ie;
1182
+ x.defaults = B;
1183
+ x.use = function(...r) {
1184
+ return E.use(...r), x.defaults = E.defaults, Se(x.defaults), x;
1185
+ };
1186
+ x.walkTokens = function(r, e) {
1187
+ return E.walkTokens(r, e);
1188
+ };
1189
+ x.parseInline = E.parseInline;
1190
+ x.Parser = _;
1191
+ x.parser = _.parse;
1192
+ x.Renderer = W;
1193
+ x.TextRenderer = ke;
1194
+ x.Lexer = v;
1195
+ x.lexer = v.lex;
1196
+ x.Tokenizer = V;
1197
+ x.Hooks = j;
1198
+ x.parse = x;
1199
+ x.options;
1200
+ x.setOptions;
1201
+ x.use;
1202
+ x.walkTokens;
1203
+ x.parseInline;
1204
+ _.parse;
1205
+ v.lex;
1206
+ const Ct = (r, e) => {
1207
+ const t = r.__vccOpts || r;
1208
+ for (const [n, s] of e)
1209
+ t[n] = s;
1210
+ return t;
1211
+ }, Et = { class: "chat-container" }, Bt = { class: "bubble" }, qt = ["innerHTML"], Mt = { class: "bubble" }, Zt = {
1212
+ key: 0,
1213
+ class: "loading"
1214
+ }, Dt = { class: "toolbar" }, Ot = { class: "input" }, Nt = ["disabled", "onKeydown"], Qt = ["disabled"], jt = "向大模型提问,例:帮我起一个智能助手的名字。", Ht = {
1215
+ __name: "ChatPanel",
1216
+ setup(r) {
1217
+ const e = O(""), t = O([]), n = O(!1), s = O(null), i = O("glm-4.6v-flash"), a = {
1218
+ "mimo-v2-flash": {
1219
+ model: "mimo-v2-flash",
1220
+ name: "Mimo V2 Flash",
1221
+ apiKey: "sk-cna17w0o4spxrtgp1ieaaq77u38vifffe3dpjbw1z9alrnif",
1222
+ apiUrl: "https://api.xiaomimimo.com/v1/chat/completions"
1223
+ },
1224
+ "doubao-seed-1-8-251215": {
1225
+ model: "doubao-seed-1-8-251215",
1226
+ name: "Doubao Seed 1.8 251215",
1227
+ apiKey: "e54eb32a-75ba-4190-8a4f-fc05d5d857cb",
1228
+ apiUrl: "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
1229
+ },
1230
+ "glm-4.6v-flash": {
1231
+ model: "glm-4.6v-flash",
1232
+ name: "GLM 4.6v Flash",
1233
+ apiKey: "9f29ea7cbab7437bb3161d9c2adf490f.mPv5XskGyi0SqaMl",
1234
+ apiUrl: "https://open.bigmodel.cn/api/paas/v4/chat/completions"
1235
+ }
1236
+ }, l = (g) => {
1237
+ try {
1238
+ return x(g || "");
1239
+ } catch (u) {
1240
+ return console.error("Markdown解析失败:", u), g || "";
1241
+ }
1242
+ }, h = () => {
1243
+ Fe(() => {
1244
+ const g = s.value;
1245
+ if (g) {
1246
+ const u = document.createElement("div");
1247
+ g.appendChild(u), u.scrollIntoView({ behavior: "smooth", block: "center" }), g.removeChild(u);
1248
+ }
1249
+ });
1250
+ };
1251
+ Ne(t, h, { deep: !0, immediate: !0 });
1252
+ const o = async (g) => {
1253
+ var u, c, f, k, m, R, P, M, Z;
1254
+ n.value = !0;
1255
+ try {
1256
+ let z = {
1257
+ "Content-Type": "application/json"
1258
+ };
1259
+ const q = a[i.value].apiKey;
1260
+ i.value === "glm-4.6v-flash" || i.value === "doubao-seed-1-8-251215" ? z.Authorization = `Bearer ${q}` : z["api-key"] = q;
1261
+ const S = await fetch(a[i.value].apiUrl, {
1262
+ method: "POST",
1263
+ headers: z,
1264
+ body: JSON.stringify({
1265
+ model: a[i.value].model,
1266
+ messages: g,
1267
+ stream: !0
1268
+ // 启用流式响应
1269
+ })
1270
+ });
1271
+ if (!S.ok)
1272
+ throw new Error(`LLM 接口响应异常: ${S.status}`);
1273
+ if (S.body && typeof S.body.getReader == "function") {
1274
+ const $ = t.value.length;
1275
+ t.value.push({
1276
+ role: "system",
1277
+ content: ""
1278
+ });
1279
+ const ee = new TextDecoder(), Ee = S.body.getReader();
1280
+ let D = "";
1281
+ for (; ; ) {
1282
+ const { done: Be, value: qe } = await Ee.read();
1283
+ if (Be)
1284
+ break;
1285
+ const Me = ee.decode(qe, { stream: !0 }).split(`
1286
+ `);
1287
+ for (const Ze of Me) {
1288
+ const K = Ze.trim();
1289
+ if (K.startsWith("data:")) {
1290
+ const A = K.substring(5).trim();
1291
+ if (A === "[DONE]")
1292
+ break;
1293
+ try {
1294
+ const L = JSON.parse(A), de = ((f = (c = (u = L == null ? void 0 : L.choices) == null ? void 0 : u[0]) == null ? void 0 : c.delta) == null ? void 0 : f.content) || "";
1295
+ de && (D += de, t.value[$].content = D, h());
1296
+ } catch (L) {
1297
+ console.error("解析流式数据失败:", L);
1298
+ }
1299
+ } else if (K)
1300
+ try {
1301
+ const A = JSON.parse(K), L = ((R = (m = (k = A == null ? void 0 : A.choices) == null ? void 0 : k[0]) == null ? void 0 : m.delta) == null ? void 0 : R.content) || "";
1302
+ L && (D += L, t.value[$].content = D, h());
1303
+ } catch (A) {
1304
+ console.error("解析非SSE流式数据失败:", A);
1305
+ }
1306
+ }
1307
+ }
1308
+ D || (t.value[$].content = "(流式响应未返回有效内容)");
1309
+ } else {
1310
+ const $ = await S.json(), ee = ((Z = (M = (P = $ == null ? void 0 : $.choices) == null ? void 0 : P[0]) == null ? void 0 : M.message) == null ? void 0 : Z.content) || ($ == null ? void 0 : $.reply) || ($ == null ? void 0 : $.message) || "(接口未返回有效内容)";
1311
+ t.value.push({
1312
+ role: "system",
1313
+ content: ee
1314
+ });
1315
+ }
1316
+ } catch (z) {
1317
+ t.value.push({
1318
+ role: "system",
1319
+ content: `调用模型失败:${z.message || z}`
1320
+ });
1321
+ } finally {
1322
+ n.value = !1;
1323
+ }
1324
+ }, p = async () => {
1325
+ if (!e.value.trim() || n.value)
1326
+ return;
1327
+ const g = e.value.trim();
1328
+ t.value.push({ role: "user", content: g }), e.value = "", await o(t.value);
1329
+ };
1330
+ return (g, u) => (I(), C("section", Et, [
1331
+ y("div", {
1332
+ class: "messages",
1333
+ ref_key: "messageList",
1334
+ ref: s
1335
+ }, [
1336
+ (I(!0), C(te, null, Qe(t.value, (c, f) => (I(), C("div", {
1337
+ key: f,
1338
+ class: re(["message", c.role === "user" ? "user-message" : "system-message"])
1339
+ }, [
1340
+ c.role === "system" ? (I(), C(te, { key: 0 }, [
1341
+ y("div", {
1342
+ class: re(["avatar", "system"])
1343
+ }, "AI"),
1344
+ y("div", Bt, [
1345
+ y("div", {
1346
+ innerHTML: l(c.content)
1347
+ }, null, 8, qt)
1348
+ ])
1349
+ ], 64)) : (I(), C(te, { key: 1 }, [
1350
+ y("div", Mt, fe(c.content), 1),
1351
+ y("div", {
1352
+ class: re(["avatar", "user"])
1353
+ }, "我")
1354
+ ], 64))
1355
+ ], 2))), 128)),
1356
+ n.value ? (I(), C("div", Zt, "AI 正在思考...")) : je("", !0)
1357
+ ], 512),
1358
+ y("div", Dt, [
1359
+ y("div", Ot, [
1360
+ He(y("textarea", {
1361
+ "onUpdate:modelValue": u[0] || (u[0] = (c) => e.value = c),
1362
+ class: "prompt-input",
1363
+ placeholder: jt,
1364
+ disabled: n.value,
1365
+ onKeydown: Ge(Ke(p, ["exact", "prevent"]), ["enter"])
1366
+ }, null, 40, Nt), [
1367
+ [Ue, e.value]
1368
+ ]),
1369
+ y("button", {
1370
+ class: "send-btn",
1371
+ disabled: n.value || !e.value.trim(),
1372
+ onClick: p
1373
+ }, fe(n.value ? "等待中…" : "发送"), 9, Qt)
1374
+ ])
1375
+ ])
1376
+ ]));
1377
+ }
1378
+ }, Gt = /* @__PURE__ */ Ct(Ht, [["__scopeId", "data-v-ecd3c21e"]]), Kt = { class: "page" }, Ut = {
1379
+ __name: "App",
1380
+ setup(r) {
1381
+ return (e, t) => (I(), C("div", Kt, [
1382
+ t[0] || (t[0] = y("div", { class: "card" }, [
1383
+ y("header", { style: { padding: "22px 20px 8px" } }, [
1384
+ y("h1", { class: "title" }, "大模型对话 Demo"),
1385
+ y("p", { class: "subtitle" }, " 早上好,用户806979 ")
1386
+ ])
1387
+ ], -1)),
1388
+ Xe(Gt)
1389
+ ]));
1390
+ }
1391
+ }, Ft = [Ut], Jt = {
1392
+ install(r) {
1393
+ Ft.forEach((e) => {
1394
+ r.component(e.name, e);
1395
+ });
1396
+ }
1397
+ };
1398
+ export {
1399
+ Ut as appMain,
1400
+ Jt as default
1401
+ };