@inkandswitch/patchwork-pkg-base 0.0.86 → 0.0.88

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,3408 @@
1
+ var wt = Object.defineProperty;
2
+ var vt = (n, e, t) => e in n ? wt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var w = (n, e, t) => vt(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { showPanel as Ke, EditorView as le, Decoration as N, hoverTooltip as Ue, WidgetType as yt, keymap as We, ViewPlugin as ke, showDialog as xe, getDialog as St, showTooltip as Ct } from "@codemirror/view";
5
+ import { StateEffect as I, StateField as be, Facet as Qe, combineConfig as Rt, RangeSetBuilder as Tt, ChangeSet as ue, MapMode as ze, EditorState as Pt, Prec as $t } from "@codemirror/state";
6
+ import { indentUnit as At, getIndentUnit as _t, language as we, highlightingFor as Je } from "@codemirror/language";
7
+ import { c as D, a as Ee, s as Dt, i as zt, h as Xe } from "./tool-B3O4i8l2.js";
8
+ function ve() {
9
+ return {
10
+ async: !1,
11
+ breaks: !1,
12
+ extensions: null,
13
+ gfm: !0,
14
+ hooks: null,
15
+ pedantic: !1,
16
+ renderer: null,
17
+ silent: !1,
18
+ tokenizer: null,
19
+ walkTokens: null
20
+ };
21
+ }
22
+ var O = ve();
23
+ function Ye(n) {
24
+ O = n;
25
+ }
26
+ var G = { exec: () => null };
27
+ function x(n, e = "") {
28
+ let t = typeof n == "string" ? n : n.source;
29
+ const i = {
30
+ replace: (r, s) => {
31
+ let o = typeof s == "string" ? s : s.source;
32
+ return o = o.replace(R.caret, "$1"), t = t.replace(r, o), i;
33
+ },
34
+ getRegex: () => new RegExp(t, e)
35
+ };
36
+ return i;
37
+ }
38
+ var R = {
39
+ codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
40
+ outputLinkReplace: /\\([\[\]])/g,
41
+ indentCodeCompensation: /^(\s+)(?:```)/,
42
+ beginningSpace: /^\s+/,
43
+ endingHash: /#$/,
44
+ startingSpaceChar: /^ /,
45
+ endingSpaceChar: / $/,
46
+ nonSpaceChar: /[^ ]/,
47
+ newLineCharGlobal: /\n/g,
48
+ tabCharGlobal: /\t/g,
49
+ multipleSpaceGlobal: /\s+/g,
50
+ blankLine: /^[ \t]*$/,
51
+ doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
52
+ blockquoteStart: /^ {0,3}>/,
53
+ blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
54
+ blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
55
+ listReplaceTabs: /^\t+/,
56
+ listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
57
+ listIsTask: /^\[[ xX]\] /,
58
+ listReplaceTask: /^\[[ xX]\] +/,
59
+ anyLine: /\n.*\n/,
60
+ hrefBrackets: /^<(.*)>$/,
61
+ tableDelimiter: /[:|]/,
62
+ tableAlignChars: /^\||\| *$/g,
63
+ tableRowBlankLine: /\n[ \t]*$/,
64
+ tableAlignRight: /^ *-+: *$/,
65
+ tableAlignCenter: /^ *:-+: *$/,
66
+ tableAlignLeft: /^ *:-+ *$/,
67
+ startATag: /^<a /i,
68
+ endATag: /^<\/a>/i,
69
+ startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
70
+ endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
71
+ startAngleBracket: /^</,
72
+ endAngleBracket: />$/,
73
+ pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
74
+ unicodeAlphaNumeric: /[\p{L}\p{N}]/u,
75
+ escapeTest: /[&<>"']/,
76
+ escapeReplace: /[&<>"']/g,
77
+ escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
78
+ escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
79
+ unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
80
+ caret: /(^|[^\[])\^/g,
81
+ percentDecode: /%25/g,
82
+ findPipe: /\|/g,
83
+ splitPipe: / \|/,
84
+ slashPipe: /\\\|/g,
85
+ carriageReturn: /\r\n|\r/g,
86
+ spaceLine: /^ +$/gm,
87
+ notSpaceStart: /^\S*/,
88
+ endingNewline: /\n$/,
89
+ listItemRegex: (n) => new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),
90
+ nextBulletRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),
91
+ hrRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),
92
+ fencesBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}(?:\`\`\`|~~~)`),
93
+ headingBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}#`),
94
+ htmlBeginRegex: (n) => new RegExp(`^ {0,${Math.min(3, n - 1)}}<(?:[a-z].*>|!--)`, "i")
95
+ }, Et = /^(?:[ \t]*(?:\n|$))+/, Lt = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/, qt = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/, W = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/, It = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, ye = /(?:[*+-]|\d{1,9}[.)])/, et = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, tt = x(et).replace(/bull/g, ye).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(), Mt = x(et).replace(/bull/g, ye).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(), Se = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, Ft = /^[^\n]+/, Ce = /(?!\s*\])(?:\\.|[^\[\]\\])+/, Bt = x(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", Ce).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(), Ot = x(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, ye).getRegex(), oe = "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", Re = /<!--(?:-?>|[\s\S]*?(?:-->|$))/, Ht = x(
96
+ "^ {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|$))",
97
+ "i"
98
+ ).replace("comment", Re).replace("tag", oe).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), nt = x(Se).replace("hr", W).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", oe).getRegex(), Nt = x(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", nt).getRegex(), Te = {
99
+ blockquote: Nt,
100
+ code: Lt,
101
+ def: Bt,
102
+ fences: qt,
103
+ heading: It,
104
+ hr: W,
105
+ html: Ht,
106
+ lheading: tt,
107
+ list: Ot,
108
+ newline: Et,
109
+ paragraph: nt,
110
+ table: G,
111
+ text: Ft
112
+ }, Le = x(
113
+ "^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"
114
+ ).replace("hr", W).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", oe).getRegex(), jt = {
115
+ ...Te,
116
+ lheading: Mt,
117
+ table: Le,
118
+ paragraph: x(Se).replace("hr", W).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", Le).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", oe).getRegex()
119
+ }, Zt = {
120
+ ...Te,
121
+ html: x(
122
+ `^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`
123
+ ).replace("comment", Re).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(),
124
+ def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
125
+ heading: /^(#{1,6})(.*)(?:\n+|$)/,
126
+ fences: G,
127
+ // fences not supported
128
+ lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
129
+ paragraph: x(Se).replace("hr", W).replace("heading", ` *#{1,6} *[^
130
+ ]`).replace("lheading", tt).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
131
+ }, Vt = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, Gt = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, it = /^( {2,}|\\)\n(?!\s*$)/, Kt = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/, ae = /[\p{P}\p{S}]/u, Pe = /[\s\p{P}\p{S}]/u, rt = /[^\s\p{P}\p{S}]/u, Ut = x(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, Pe).getRegex(), st = /(?!~)[\p{P}\p{S}]/u, Wt = /(?!~)[\s\p{P}\p{S}]/u, Qt = /(?:[^\s\p{P}\p{S}]|~)/u, Jt = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g, lt = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/, Xt = x(lt, "u").replace(/punct/g, ae).getRegex(), Yt = x(lt, "u").replace(/punct/g, st).getRegex(), ot = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)", en = x(ot, "gu").replace(/notPunctSpace/g, rt).replace(/punctSpace/g, Pe).replace(/punct/g, ae).getRegex(), tn = x(ot, "gu").replace(/notPunctSpace/g, Qt).replace(/punctSpace/g, Wt).replace(/punct/g, st).getRegex(), nn = x(
132
+ "^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)",
133
+ "gu"
134
+ ).replace(/notPunctSpace/g, rt).replace(/punctSpace/g, Pe).replace(/punct/g, ae).getRegex(), rn = x(/\\(punct)/, "gu").replace(/punct/g, ae).getRegex(), sn = x(/^<(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(), ln = x(Re).replace("(?:-->|$)", "-->").getRegex(), on = x(
135
+ "^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
136
+ ).replace("comment", ln).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(), te = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, an = x(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label", te).replace("href", /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(), at = x(/^!?\[(label)\]\[(ref)\]/).replace("label", te).replace("ref", Ce).getRegex(), ct = x(/^!?\[(ref)\](?:\[\])?/).replace("ref", Ce).getRegex(), cn = x("reflink|nolink(?!\\()", "g").replace("reflink", at).replace("nolink", ct).getRegex(), $e = {
137
+ _backpedal: G,
138
+ // only used for GFM url
139
+ anyPunctuation: rn,
140
+ autolink: sn,
141
+ blockSkip: Jt,
142
+ br: it,
143
+ code: Gt,
144
+ del: G,
145
+ emStrongLDelim: Xt,
146
+ emStrongRDelimAst: en,
147
+ emStrongRDelimUnd: nn,
148
+ escape: Vt,
149
+ link: an,
150
+ nolink: ct,
151
+ punctuation: Ut,
152
+ reflink: at,
153
+ reflinkSearch: cn,
154
+ tag: on,
155
+ text: Kt,
156
+ url: G
157
+ }, un = {
158
+ ...$e,
159
+ link: x(/^!?\[(label)\]\((.*?)\)/).replace("label", te).getRegex(),
160
+ reflink: x(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", te).getRegex()
161
+ }, pe = {
162
+ ...$e,
163
+ emStrongRDelimAst: tn,
164
+ emStrongLDelim: Yt,
165
+ url: x(/^((?: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(),
166
+ _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
167
+ del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
168
+ text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
169
+ }, pn = {
170
+ ...pe,
171
+ br: x(it).replace("{2,}", "*").getRegex(),
172
+ text: x(pe.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
173
+ }, Q = {
174
+ normal: Te,
175
+ gfm: jt,
176
+ pedantic: Zt
177
+ }, Z = {
178
+ normal: $e,
179
+ gfm: pe,
180
+ breaks: pn,
181
+ pedantic: un
182
+ }, hn = {
183
+ "&": "&amp;",
184
+ "<": "&lt;",
185
+ ">": "&gt;",
186
+ '"': "&quot;",
187
+ "'": "&#39;"
188
+ }, qe = (n) => hn[n];
189
+ function _(n, e) {
190
+ if (e) {
191
+ if (R.escapeTest.test(n))
192
+ return n.replace(R.escapeReplace, qe);
193
+ } else if (R.escapeTestNoEncode.test(n))
194
+ return n.replace(R.escapeReplaceNoEncode, qe);
195
+ return n;
196
+ }
197
+ function Ie(n) {
198
+ try {
199
+ n = encodeURI(n).replace(R.percentDecode, "%");
200
+ } catch {
201
+ return null;
202
+ }
203
+ return n;
204
+ }
205
+ function Me(n, e) {
206
+ var s;
207
+ const t = n.replace(R.findPipe, (o, l, u) => {
208
+ let a = !1, c = l;
209
+ for (; --c >= 0 && u[c] === "\\"; ) a = !a;
210
+ return a ? "|" : " |";
211
+ }), i = t.split(R.splitPipe);
212
+ let r = 0;
213
+ if (i[0].trim() || i.shift(), i.length > 0 && !((s = i.at(-1)) != null && s.trim()) && i.pop(), e)
214
+ if (i.length > e)
215
+ i.splice(e);
216
+ else
217
+ for (; i.length < e; ) i.push("");
218
+ for (; r < i.length; r++)
219
+ i[r] = i[r].trim().replace(R.slashPipe, "|");
220
+ return i;
221
+ }
222
+ function V(n, e, t) {
223
+ const i = n.length;
224
+ if (i === 0)
225
+ return "";
226
+ let r = 0;
227
+ for (; r < i && n.charAt(i - r - 1) === e; )
228
+ r++;
229
+ return n.slice(0, i - r);
230
+ }
231
+ function fn(n, e) {
232
+ if (n.indexOf(e[1]) === -1)
233
+ return -1;
234
+ let t = 0;
235
+ for (let i = 0; i < n.length; i++)
236
+ if (n[i] === "\\")
237
+ i++;
238
+ else if (n[i] === e[0])
239
+ t++;
240
+ else if (n[i] === e[1] && (t--, t < 0))
241
+ return i;
242
+ return t > 0 ? -2 : -1;
243
+ }
244
+ function Fe(n, e, t, i, r) {
245
+ const s = e.href, o = e.title || null, l = n[1].replace(r.other.outputLinkReplace, "$1");
246
+ i.state.inLink = !0;
247
+ const u = {
248
+ type: n[0].charAt(0) === "!" ? "image" : "link",
249
+ raw: t,
250
+ href: s,
251
+ title: o,
252
+ text: l,
253
+ tokens: i.inlineTokens(l)
254
+ };
255
+ return i.state.inLink = !1, u;
256
+ }
257
+ function dn(n, e, t) {
258
+ const i = n.match(t.other.indentCodeCompensation);
259
+ if (i === null)
260
+ return e;
261
+ const r = i[1];
262
+ return e.split(`
263
+ `).map((s) => {
264
+ const o = s.match(t.other.beginningSpace);
265
+ if (o === null)
266
+ return s;
267
+ const [l] = o;
268
+ return l.length >= r.length ? s.slice(r.length) : s;
269
+ }).join(`
270
+ `);
271
+ }
272
+ var ne = class {
273
+ // set by the lexer
274
+ constructor(n) {
275
+ w(this, "options");
276
+ w(this, "rules");
277
+ // set by the lexer
278
+ w(this, "lexer");
279
+ this.options = n || O;
280
+ }
281
+ space(n) {
282
+ const e = this.rules.block.newline.exec(n);
283
+ if (e && e[0].length > 0)
284
+ return {
285
+ type: "space",
286
+ raw: e[0]
287
+ };
288
+ }
289
+ code(n) {
290
+ const e = this.rules.block.code.exec(n);
291
+ if (e) {
292
+ const t = e[0].replace(this.rules.other.codeRemoveIndent, "");
293
+ return {
294
+ type: "code",
295
+ raw: e[0],
296
+ codeBlockStyle: "indented",
297
+ text: this.options.pedantic ? t : V(t, `
298
+ `)
299
+ };
300
+ }
301
+ }
302
+ fences(n) {
303
+ const e = this.rules.block.fences.exec(n);
304
+ if (e) {
305
+ const t = e[0], i = dn(t, e[3] || "", this.rules);
306
+ return {
307
+ type: "code",
308
+ raw: t,
309
+ lang: e[2] ? e[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : e[2],
310
+ text: i
311
+ };
312
+ }
313
+ }
314
+ heading(n) {
315
+ const e = this.rules.block.heading.exec(n);
316
+ if (e) {
317
+ let t = e[2].trim();
318
+ if (this.rules.other.endingHash.test(t)) {
319
+ const i = V(t, "#");
320
+ (this.options.pedantic || !i || this.rules.other.endingSpaceChar.test(i)) && (t = i.trim());
321
+ }
322
+ return {
323
+ type: "heading",
324
+ raw: e[0],
325
+ depth: e[1].length,
326
+ text: t,
327
+ tokens: this.lexer.inline(t)
328
+ };
329
+ }
330
+ }
331
+ hr(n) {
332
+ const e = this.rules.block.hr.exec(n);
333
+ if (e)
334
+ return {
335
+ type: "hr",
336
+ raw: V(e[0], `
337
+ `)
338
+ };
339
+ }
340
+ blockquote(n) {
341
+ const e = this.rules.block.blockquote.exec(n);
342
+ if (e) {
343
+ let t = V(e[0], `
344
+ `).split(`
345
+ `), i = "", r = "";
346
+ const s = [];
347
+ for (; t.length > 0; ) {
348
+ let o = !1;
349
+ const l = [];
350
+ let u;
351
+ for (u = 0; u < t.length; u++)
352
+ if (this.rules.other.blockquoteStart.test(t[u]))
353
+ l.push(t[u]), o = !0;
354
+ else if (!o)
355
+ l.push(t[u]);
356
+ else
357
+ break;
358
+ t = t.slice(u);
359
+ const a = l.join(`
360
+ `), c = a.replace(this.rules.other.blockquoteSetextReplace, `
361
+ $1`).replace(this.rules.other.blockquoteSetextReplace2, "");
362
+ i = i ? `${i}
363
+ ${a}` : a, r = r ? `${r}
364
+ ${c}` : c;
365
+ const d = this.lexer.state.top;
366
+ if (this.lexer.state.top = !0, this.lexer.blockTokens(c, s, !0), this.lexer.state.top = d, t.length === 0)
367
+ break;
368
+ const p = s.at(-1);
369
+ if ((p == null ? void 0 : p.type) === "code")
370
+ break;
371
+ if ((p == null ? void 0 : p.type) === "blockquote") {
372
+ const h = p, f = h.raw + `
373
+ ` + t.join(`
374
+ `), g = this.blockquote(f);
375
+ s[s.length - 1] = g, i = i.substring(0, i.length - h.raw.length) + g.raw, r = r.substring(0, r.length - h.text.length) + g.text;
376
+ break;
377
+ } else if ((p == null ? void 0 : p.type) === "list") {
378
+ const h = p, f = h.raw + `
379
+ ` + t.join(`
380
+ `), g = this.list(f);
381
+ s[s.length - 1] = g, i = i.substring(0, i.length - p.raw.length) + g.raw, r = r.substring(0, r.length - h.raw.length) + g.raw, t = f.substring(s.at(-1).raw.length).split(`
382
+ `);
383
+ continue;
384
+ }
385
+ }
386
+ return {
387
+ type: "blockquote",
388
+ raw: i,
389
+ tokens: s,
390
+ text: r
391
+ };
392
+ }
393
+ }
394
+ list(n) {
395
+ let e = this.rules.block.list.exec(n);
396
+ if (e) {
397
+ let t = e[1].trim();
398
+ const i = t.length > 1, r = {
399
+ type: "list",
400
+ raw: "",
401
+ ordered: i,
402
+ start: i ? +t.slice(0, -1) : "",
403
+ loose: !1,
404
+ items: []
405
+ };
406
+ t = i ? `\\d{1,9}\\${t.slice(-1)}` : `\\${t}`, this.options.pedantic && (t = i ? t : "[*+-]");
407
+ const s = this.rules.other.listItemRegex(t);
408
+ let o = !1;
409
+ for (; n; ) {
410
+ let u = !1, a = "", c = "";
411
+ if (!(e = s.exec(n)) || this.rules.block.hr.test(n))
412
+ break;
413
+ a = e[0], n = n.substring(a.length);
414
+ let d = e[2].split(`
415
+ `, 1)[0].replace(this.rules.other.listReplaceTabs, (y) => " ".repeat(3 * y.length)), p = n.split(`
416
+ `, 1)[0], h = !d.trim(), f = 0;
417
+ if (this.options.pedantic ? (f = 2, c = d.trimStart()) : h ? f = e[1].length + 1 : (f = e[2].search(this.rules.other.nonSpaceChar), f = f > 4 ? 1 : f, c = d.slice(f), f += e[1].length), h && this.rules.other.blankLine.test(p) && (a += p + `
418
+ `, n = n.substring(p.length + 1), u = !0), !u) {
419
+ const y = this.rules.other.nextBulletRegex(f), S = this.rules.other.hrRegex(f), m = this.rules.other.fencesBeginRegex(f), v = this.rules.other.headingBeginRegex(f), T = this.rules.other.htmlBeginRegex(f);
420
+ for (; n; ) {
421
+ const P = n.split(`
422
+ `, 1)[0];
423
+ let $;
424
+ if (p = P, this.options.pedantic ? (p = p.replace(this.rules.other.listReplaceNesting, " "), $ = p) : $ = p.replace(this.rules.other.tabCharGlobal, " "), m.test(p) || v.test(p) || T.test(p) || y.test(p) || S.test(p))
425
+ break;
426
+ if ($.search(this.rules.other.nonSpaceChar) >= f || !p.trim())
427
+ c += `
428
+ ` + $.slice(f);
429
+ else {
430
+ if (h || d.replace(this.rules.other.tabCharGlobal, " ").search(this.rules.other.nonSpaceChar) >= 4 || m.test(d) || v.test(d) || S.test(d))
431
+ break;
432
+ c += `
433
+ ` + p;
434
+ }
435
+ !h && !p.trim() && (h = !0), a += P + `
436
+ `, n = n.substring(P.length + 1), d = $.slice(f);
437
+ }
438
+ }
439
+ r.loose || (o ? r.loose = !0 : this.rules.other.doubleBlankLine.test(a) && (o = !0));
440
+ let g = null, k;
441
+ this.options.gfm && (g = this.rules.other.listIsTask.exec(c), g && (k = g[0] !== "[ ] ", c = c.replace(this.rules.other.listReplaceTask, ""))), r.items.push({
442
+ type: "list_item",
443
+ raw: a,
444
+ task: !!g,
445
+ checked: k,
446
+ loose: !1,
447
+ text: c,
448
+ tokens: []
449
+ }), r.raw += a;
450
+ }
451
+ const l = r.items.at(-1);
452
+ if (l)
453
+ l.raw = l.raw.trimEnd(), l.text = l.text.trimEnd();
454
+ else
455
+ return;
456
+ r.raw = r.raw.trimEnd();
457
+ for (let u = 0; u < r.items.length; u++)
458
+ if (this.lexer.state.top = !1, r.items[u].tokens = this.lexer.blockTokens(r.items[u].text, []), !r.loose) {
459
+ const a = r.items[u].tokens.filter((d) => d.type === "space"), c = a.length > 0 && a.some((d) => this.rules.other.anyLine.test(d.raw));
460
+ r.loose = c;
461
+ }
462
+ if (r.loose)
463
+ for (let u = 0; u < r.items.length; u++)
464
+ r.items[u].loose = !0;
465
+ return r;
466
+ }
467
+ }
468
+ html(n) {
469
+ const e = this.rules.block.html.exec(n);
470
+ if (e)
471
+ return {
472
+ type: "html",
473
+ block: !0,
474
+ raw: e[0],
475
+ pre: e[1] === "pre" || e[1] === "script" || e[1] === "style",
476
+ text: e[0]
477
+ };
478
+ }
479
+ def(n) {
480
+ const e = this.rules.block.def.exec(n);
481
+ if (e) {
482
+ const t = e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " "), i = e[2] ? e[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "", r = e[3] ? e[3].substring(1, e[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : e[3];
483
+ return {
484
+ type: "def",
485
+ tag: t,
486
+ raw: e[0],
487
+ href: i,
488
+ title: r
489
+ };
490
+ }
491
+ }
492
+ table(n) {
493
+ var o;
494
+ const e = this.rules.block.table.exec(n);
495
+ if (!e || !this.rules.other.tableDelimiter.test(e[2]))
496
+ return;
497
+ const t = Me(e[1]), i = e[2].replace(this.rules.other.tableAlignChars, "").split("|"), r = (o = e[3]) != null && o.trim() ? e[3].replace(this.rules.other.tableRowBlankLine, "").split(`
498
+ `) : [], s = {
499
+ type: "table",
500
+ raw: e[0],
501
+ header: [],
502
+ align: [],
503
+ rows: []
504
+ };
505
+ if (t.length === i.length) {
506
+ for (const l of i)
507
+ this.rules.other.tableAlignRight.test(l) ? s.align.push("right") : this.rules.other.tableAlignCenter.test(l) ? s.align.push("center") : this.rules.other.tableAlignLeft.test(l) ? s.align.push("left") : s.align.push(null);
508
+ for (let l = 0; l < t.length; l++)
509
+ s.header.push({
510
+ text: t[l],
511
+ tokens: this.lexer.inline(t[l]),
512
+ header: !0,
513
+ align: s.align[l]
514
+ });
515
+ for (const l of r)
516
+ s.rows.push(Me(l, s.header.length).map((u, a) => ({
517
+ text: u,
518
+ tokens: this.lexer.inline(u),
519
+ header: !1,
520
+ align: s.align[a]
521
+ })));
522
+ return s;
523
+ }
524
+ }
525
+ lheading(n) {
526
+ const e = this.rules.block.lheading.exec(n);
527
+ if (e)
528
+ return {
529
+ type: "heading",
530
+ raw: e[0],
531
+ depth: e[2].charAt(0) === "=" ? 1 : 2,
532
+ text: e[1],
533
+ tokens: this.lexer.inline(e[1])
534
+ };
535
+ }
536
+ paragraph(n) {
537
+ const e = this.rules.block.paragraph.exec(n);
538
+ if (e) {
539
+ const t = e[1].charAt(e[1].length - 1) === `
540
+ ` ? e[1].slice(0, -1) : e[1];
541
+ return {
542
+ type: "paragraph",
543
+ raw: e[0],
544
+ text: t,
545
+ tokens: this.lexer.inline(t)
546
+ };
547
+ }
548
+ }
549
+ text(n) {
550
+ const e = this.rules.block.text.exec(n);
551
+ if (e)
552
+ return {
553
+ type: "text",
554
+ raw: e[0],
555
+ text: e[0],
556
+ tokens: this.lexer.inline(e[0])
557
+ };
558
+ }
559
+ escape(n) {
560
+ const e = this.rules.inline.escape.exec(n);
561
+ if (e)
562
+ return {
563
+ type: "escape",
564
+ raw: e[0],
565
+ text: e[1]
566
+ };
567
+ }
568
+ tag(n) {
569
+ const e = this.rules.inline.tag.exec(n);
570
+ if (e)
571
+ 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), {
572
+ type: "html",
573
+ raw: e[0],
574
+ inLink: this.lexer.state.inLink,
575
+ inRawBlock: this.lexer.state.inRawBlock,
576
+ block: !1,
577
+ text: e[0]
578
+ };
579
+ }
580
+ link(n) {
581
+ const e = this.rules.inline.link.exec(n);
582
+ if (e) {
583
+ const t = e[2].trim();
584
+ if (!this.options.pedantic && this.rules.other.startAngleBracket.test(t)) {
585
+ if (!this.rules.other.endAngleBracket.test(t))
586
+ return;
587
+ const s = V(t.slice(0, -1), "\\");
588
+ if ((t.length - s.length) % 2 === 0)
589
+ return;
590
+ } else {
591
+ const s = fn(e[2], "()");
592
+ if (s === -2)
593
+ return;
594
+ if (s > -1) {
595
+ const l = (e[0].indexOf("!") === 0 ? 5 : 4) + e[1].length + s;
596
+ e[2] = e[2].substring(0, s), e[0] = e[0].substring(0, l).trim(), e[3] = "";
597
+ }
598
+ }
599
+ let i = e[2], r = "";
600
+ if (this.options.pedantic) {
601
+ const s = this.rules.other.pedanticHrefTitle.exec(i);
602
+ s && (i = s[1], r = s[3]);
603
+ } else
604
+ r = e[3] ? e[3].slice(1, -1) : "";
605
+ return i = i.trim(), this.rules.other.startAngleBracket.test(i) && (this.options.pedantic && !this.rules.other.endAngleBracket.test(t) ? i = i.slice(1) : i = i.slice(1, -1)), Fe(e, {
606
+ href: i && i.replace(this.rules.inline.anyPunctuation, "$1"),
607
+ title: r && r.replace(this.rules.inline.anyPunctuation, "$1")
608
+ }, e[0], this.lexer, this.rules);
609
+ }
610
+ }
611
+ reflink(n, e) {
612
+ let t;
613
+ if ((t = this.rules.inline.reflink.exec(n)) || (t = this.rules.inline.nolink.exec(n))) {
614
+ const i = (t[2] || t[1]).replace(this.rules.other.multipleSpaceGlobal, " "), r = e[i.toLowerCase()];
615
+ if (!r) {
616
+ const s = t[0].charAt(0);
617
+ return {
618
+ type: "text",
619
+ raw: s,
620
+ text: s
621
+ };
622
+ }
623
+ return Fe(t, r, t[0], this.lexer, this.rules);
624
+ }
625
+ }
626
+ emStrong(n, e, t = "") {
627
+ let i = this.rules.inline.emStrongLDelim.exec(n);
628
+ if (!i || i[3] && t.match(this.rules.other.unicodeAlphaNumeric)) return;
629
+ if (!(i[1] || i[2] || "") || !t || this.rules.inline.punctuation.exec(t)) {
630
+ const s = [...i[0]].length - 1;
631
+ let o, l, u = s, a = 0;
632
+ const c = i[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
633
+ for (c.lastIndex = 0, e = e.slice(-1 * n.length + s); (i = c.exec(e)) != null; ) {
634
+ if (o = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !o) continue;
635
+ if (l = [...o].length, i[3] || i[4]) {
636
+ u += l;
637
+ continue;
638
+ } else if ((i[5] || i[6]) && s % 3 && !((s + l) % 3)) {
639
+ a += l;
640
+ continue;
641
+ }
642
+ if (u -= l, u > 0) continue;
643
+ l = Math.min(l, l + u + a);
644
+ const d = [...i[0]][0].length, p = n.slice(0, s + i.index + d + l);
645
+ if (Math.min(s, l) % 2) {
646
+ const f = p.slice(1, -1);
647
+ return {
648
+ type: "em",
649
+ raw: p,
650
+ text: f,
651
+ tokens: this.lexer.inlineTokens(f)
652
+ };
653
+ }
654
+ const h = p.slice(2, -2);
655
+ return {
656
+ type: "strong",
657
+ raw: p,
658
+ text: h,
659
+ tokens: this.lexer.inlineTokens(h)
660
+ };
661
+ }
662
+ }
663
+ }
664
+ codespan(n) {
665
+ const e = this.rules.inline.code.exec(n);
666
+ if (e) {
667
+ let t = e[2].replace(this.rules.other.newLineCharGlobal, " ");
668
+ const i = this.rules.other.nonSpaceChar.test(t), r = this.rules.other.startingSpaceChar.test(t) && this.rules.other.endingSpaceChar.test(t);
669
+ return i && r && (t = t.substring(1, t.length - 1)), {
670
+ type: "codespan",
671
+ raw: e[0],
672
+ text: t
673
+ };
674
+ }
675
+ }
676
+ br(n) {
677
+ const e = this.rules.inline.br.exec(n);
678
+ if (e)
679
+ return {
680
+ type: "br",
681
+ raw: e[0]
682
+ };
683
+ }
684
+ del(n) {
685
+ const e = this.rules.inline.del.exec(n);
686
+ if (e)
687
+ return {
688
+ type: "del",
689
+ raw: e[0],
690
+ text: e[2],
691
+ tokens: this.lexer.inlineTokens(e[2])
692
+ };
693
+ }
694
+ autolink(n) {
695
+ const e = this.rules.inline.autolink.exec(n);
696
+ if (e) {
697
+ let t, i;
698
+ return e[2] === "@" ? (t = e[1], i = "mailto:" + t) : (t = e[1], i = t), {
699
+ type: "link",
700
+ raw: e[0],
701
+ text: t,
702
+ href: i,
703
+ tokens: [
704
+ {
705
+ type: "text",
706
+ raw: t,
707
+ text: t
708
+ }
709
+ ]
710
+ };
711
+ }
712
+ }
713
+ url(n) {
714
+ var t;
715
+ let e;
716
+ if (e = this.rules.inline.url.exec(n)) {
717
+ let i, r;
718
+ if (e[2] === "@")
719
+ i = e[0], r = "mailto:" + i;
720
+ else {
721
+ let s;
722
+ do
723
+ s = e[0], e[0] = ((t = this.rules.inline._backpedal.exec(e[0])) == null ? void 0 : t[0]) ?? "";
724
+ while (s !== e[0]);
725
+ i = e[0], e[1] === "www." ? r = "http://" + e[0] : r = e[0];
726
+ }
727
+ return {
728
+ type: "link",
729
+ raw: e[0],
730
+ text: i,
731
+ href: r,
732
+ tokens: [
733
+ {
734
+ type: "text",
735
+ raw: i,
736
+ text: i
737
+ }
738
+ ]
739
+ };
740
+ }
741
+ }
742
+ inlineText(n) {
743
+ const e = this.rules.inline.text.exec(n);
744
+ if (e) {
745
+ const t = this.lexer.state.inRawBlock;
746
+ return {
747
+ type: "text",
748
+ raw: e[0],
749
+ text: e[0],
750
+ escaped: t
751
+ };
752
+ }
753
+ }
754
+ }, z = class he {
755
+ constructor(e) {
756
+ w(this, "tokens");
757
+ w(this, "options");
758
+ w(this, "state");
759
+ w(this, "tokenizer");
760
+ w(this, "inlineQueue");
761
+ this.tokens = [], this.tokens.links = /* @__PURE__ */ Object.create(null), this.options = e || O, this.options.tokenizer = this.options.tokenizer || new ne(), this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options, this.tokenizer.lexer = this, this.inlineQueue = [], this.state = {
762
+ inLink: !1,
763
+ inRawBlock: !1,
764
+ top: !0
765
+ };
766
+ const t = {
767
+ other: R,
768
+ block: Q.normal,
769
+ inline: Z.normal
770
+ };
771
+ this.options.pedantic ? (t.block = Q.pedantic, t.inline = Z.pedantic) : this.options.gfm && (t.block = Q.gfm, this.options.breaks ? t.inline = Z.breaks : t.inline = Z.gfm), this.tokenizer.rules = t;
772
+ }
773
+ /**
774
+ * Expose Rules
775
+ */
776
+ static get rules() {
777
+ return {
778
+ block: Q,
779
+ inline: Z
780
+ };
781
+ }
782
+ /**
783
+ * Static Lex Method
784
+ */
785
+ static lex(e, t) {
786
+ return new he(t).lex(e);
787
+ }
788
+ /**
789
+ * Static Lex Inline Method
790
+ */
791
+ static lexInline(e, t) {
792
+ return new he(t).inlineTokens(e);
793
+ }
794
+ /**
795
+ * Preprocessing
796
+ */
797
+ lex(e) {
798
+ e = e.replace(R.carriageReturn, `
799
+ `), this.blockTokens(e, this.tokens);
800
+ for (let t = 0; t < this.inlineQueue.length; t++) {
801
+ const i = this.inlineQueue[t];
802
+ this.inlineTokens(i.src, i.tokens);
803
+ }
804
+ return this.inlineQueue = [], this.tokens;
805
+ }
806
+ blockTokens(e, t = [], i = !1) {
807
+ var r, s, o;
808
+ for (this.options.pedantic && (e = e.replace(R.tabCharGlobal, " ").replace(R.spaceLine, "")); e; ) {
809
+ let l;
810
+ if ((s = (r = this.options.extensions) == null ? void 0 : r.block) != null && s.some((a) => (l = a.call({ lexer: this }, e, t)) ? (e = e.substring(l.raw.length), t.push(l), !0) : !1))
811
+ continue;
812
+ if (l = this.tokenizer.space(e)) {
813
+ e = e.substring(l.raw.length);
814
+ const a = t.at(-1);
815
+ l.raw.length === 1 && a !== void 0 ? a.raw += `
816
+ ` : t.push(l);
817
+ continue;
818
+ }
819
+ if (l = this.tokenizer.code(e)) {
820
+ e = e.substring(l.raw.length);
821
+ const a = t.at(-1);
822
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += `
823
+ ` + l.raw, a.text += `
824
+ ` + l.text, this.inlineQueue.at(-1).src = a.text) : t.push(l);
825
+ continue;
826
+ }
827
+ if (l = this.tokenizer.fences(e)) {
828
+ e = e.substring(l.raw.length), t.push(l);
829
+ continue;
830
+ }
831
+ if (l = this.tokenizer.heading(e)) {
832
+ e = e.substring(l.raw.length), t.push(l);
833
+ continue;
834
+ }
835
+ if (l = this.tokenizer.hr(e)) {
836
+ e = e.substring(l.raw.length), t.push(l);
837
+ continue;
838
+ }
839
+ if (l = this.tokenizer.blockquote(e)) {
840
+ e = e.substring(l.raw.length), t.push(l);
841
+ continue;
842
+ }
843
+ if (l = this.tokenizer.list(e)) {
844
+ e = e.substring(l.raw.length), t.push(l);
845
+ continue;
846
+ }
847
+ if (l = this.tokenizer.html(e)) {
848
+ e = e.substring(l.raw.length), t.push(l);
849
+ continue;
850
+ }
851
+ if (l = this.tokenizer.def(e)) {
852
+ e = e.substring(l.raw.length);
853
+ const a = t.at(-1);
854
+ (a == null ? void 0 : a.type) === "paragraph" || (a == null ? void 0 : a.type) === "text" ? (a.raw += `
855
+ ` + l.raw, a.text += `
856
+ ` + l.raw, this.inlineQueue.at(-1).src = a.text) : this.tokens.links[l.tag] || (this.tokens.links[l.tag] = {
857
+ href: l.href,
858
+ title: l.title
859
+ });
860
+ continue;
861
+ }
862
+ if (l = this.tokenizer.table(e)) {
863
+ e = e.substring(l.raw.length), t.push(l);
864
+ continue;
865
+ }
866
+ if (l = this.tokenizer.lheading(e)) {
867
+ e = e.substring(l.raw.length), t.push(l);
868
+ continue;
869
+ }
870
+ let u = e;
871
+ if ((o = this.options.extensions) != null && o.startBlock) {
872
+ let a = 1 / 0;
873
+ const c = e.slice(1);
874
+ let d;
875
+ this.options.extensions.startBlock.forEach((p) => {
876
+ d = p.call({ lexer: this }, c), typeof d == "number" && d >= 0 && (a = Math.min(a, d));
877
+ }), a < 1 / 0 && a >= 0 && (u = e.substring(0, a + 1));
878
+ }
879
+ if (this.state.top && (l = this.tokenizer.paragraph(u))) {
880
+ const a = t.at(-1);
881
+ i && (a == null ? void 0 : a.type) === "paragraph" ? (a.raw += `
882
+ ` + l.raw, a.text += `
883
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(l), i = u.length !== e.length, e = e.substring(l.raw.length);
884
+ continue;
885
+ }
886
+ if (l = this.tokenizer.text(e)) {
887
+ e = e.substring(l.raw.length);
888
+ const a = t.at(-1);
889
+ (a == null ? void 0 : a.type) === "text" ? (a.raw += `
890
+ ` + l.raw, a.text += `
891
+ ` + l.text, this.inlineQueue.pop(), this.inlineQueue.at(-1).src = a.text) : t.push(l);
892
+ continue;
893
+ }
894
+ if (e) {
895
+ const a = "Infinite loop on byte: " + e.charCodeAt(0);
896
+ if (this.options.silent) {
897
+ console.error(a);
898
+ break;
899
+ } else
900
+ throw new Error(a);
901
+ }
902
+ }
903
+ return this.state.top = !0, t;
904
+ }
905
+ inline(e, t = []) {
906
+ return this.inlineQueue.push({ src: e, tokens: t }), t;
907
+ }
908
+ /**
909
+ * Lexing/Compiling
910
+ */
911
+ inlineTokens(e, t = []) {
912
+ var l, u, a;
913
+ let i = e, r = null;
914
+ if (this.tokens.links) {
915
+ const c = Object.keys(this.tokens.links);
916
+ if (c.length > 0)
917
+ for (; (r = this.tokenizer.rules.inline.reflinkSearch.exec(i)) != null; )
918
+ c.includes(r[0].slice(r[0].lastIndexOf("[") + 1, -1)) && (i = i.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));
919
+ }
920
+ for (; (r = this.tokenizer.rules.inline.anyPunctuation.exec(i)) != null; )
921
+ i = i.slice(0, r.index) + "++" + i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
922
+ for (; (r = this.tokenizer.rules.inline.blockSkip.exec(i)) != null; )
923
+ i = i.slice(0, r.index) + "[" + "a".repeat(r[0].length - 2) + "]" + i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
924
+ let s = !1, o = "";
925
+ for (; e; ) {
926
+ s || (o = ""), s = !1;
927
+ let c;
928
+ if ((u = (l = this.options.extensions) == null ? void 0 : l.inline) != null && u.some((p) => (c = p.call({ lexer: this }, e, t)) ? (e = e.substring(c.raw.length), t.push(c), !0) : !1))
929
+ continue;
930
+ if (c = this.tokenizer.escape(e)) {
931
+ e = e.substring(c.raw.length), t.push(c);
932
+ continue;
933
+ }
934
+ if (c = this.tokenizer.tag(e)) {
935
+ e = e.substring(c.raw.length), t.push(c);
936
+ continue;
937
+ }
938
+ if (c = this.tokenizer.link(e)) {
939
+ e = e.substring(c.raw.length), t.push(c);
940
+ continue;
941
+ }
942
+ if (c = this.tokenizer.reflink(e, this.tokens.links)) {
943
+ e = e.substring(c.raw.length);
944
+ const p = t.at(-1);
945
+ c.type === "text" && (p == null ? void 0 : p.type) === "text" ? (p.raw += c.raw, p.text += c.text) : t.push(c);
946
+ continue;
947
+ }
948
+ if (c = this.tokenizer.emStrong(e, i, o)) {
949
+ e = e.substring(c.raw.length), t.push(c);
950
+ continue;
951
+ }
952
+ if (c = this.tokenizer.codespan(e)) {
953
+ e = e.substring(c.raw.length), t.push(c);
954
+ continue;
955
+ }
956
+ if (c = this.tokenizer.br(e)) {
957
+ e = e.substring(c.raw.length), t.push(c);
958
+ continue;
959
+ }
960
+ if (c = this.tokenizer.del(e)) {
961
+ e = e.substring(c.raw.length), t.push(c);
962
+ continue;
963
+ }
964
+ if (c = this.tokenizer.autolink(e)) {
965
+ e = e.substring(c.raw.length), t.push(c);
966
+ continue;
967
+ }
968
+ if (!this.state.inLink && (c = this.tokenizer.url(e))) {
969
+ e = e.substring(c.raw.length), t.push(c);
970
+ continue;
971
+ }
972
+ let d = e;
973
+ if ((a = this.options.extensions) != null && a.startInline) {
974
+ let p = 1 / 0;
975
+ const h = e.slice(1);
976
+ let f;
977
+ this.options.extensions.startInline.forEach((g) => {
978
+ f = g.call({ lexer: this }, h), typeof f == "number" && f >= 0 && (p = Math.min(p, f));
979
+ }), p < 1 / 0 && p >= 0 && (d = e.substring(0, p + 1));
980
+ }
981
+ if (c = this.tokenizer.inlineText(d)) {
982
+ e = e.substring(c.raw.length), c.raw.slice(-1) !== "_" && (o = c.raw.slice(-1)), s = !0;
983
+ const p = t.at(-1);
984
+ (p == null ? void 0 : p.type) === "text" ? (p.raw += c.raw, p.text += c.text) : t.push(c);
985
+ continue;
986
+ }
987
+ if (e) {
988
+ const p = "Infinite loop on byte: " + e.charCodeAt(0);
989
+ if (this.options.silent) {
990
+ console.error(p);
991
+ break;
992
+ } else
993
+ throw new Error(p);
994
+ }
995
+ }
996
+ return t;
997
+ }
998
+ }, ie = class {
999
+ // set by the parser
1000
+ constructor(n) {
1001
+ w(this, "options");
1002
+ w(this, "parser");
1003
+ this.options = n || O;
1004
+ }
1005
+ space(n) {
1006
+ return "";
1007
+ }
1008
+ code({ text: n, lang: e, escaped: t }) {
1009
+ var s;
1010
+ const i = (s = (e || "").match(R.notSpaceStart)) == null ? void 0 : s[0], r = n.replace(R.endingNewline, "") + `
1011
+ `;
1012
+ return i ? '<pre><code class="language-' + _(i) + '">' + (t ? r : _(r, !0)) + `</code></pre>
1013
+ ` : "<pre><code>" + (t ? r : _(r, !0)) + `</code></pre>
1014
+ `;
1015
+ }
1016
+ blockquote({ tokens: n }) {
1017
+ return `<blockquote>
1018
+ ${this.parser.parse(n)}</blockquote>
1019
+ `;
1020
+ }
1021
+ html({ text: n }) {
1022
+ return n;
1023
+ }
1024
+ heading({ tokens: n, depth: e }) {
1025
+ return `<h${e}>${this.parser.parseInline(n)}</h${e}>
1026
+ `;
1027
+ }
1028
+ hr(n) {
1029
+ return `<hr>
1030
+ `;
1031
+ }
1032
+ list(n) {
1033
+ const e = n.ordered, t = n.start;
1034
+ let i = "";
1035
+ for (let o = 0; o < n.items.length; o++) {
1036
+ const l = n.items[o];
1037
+ i += this.listitem(l);
1038
+ }
1039
+ const r = e ? "ol" : "ul", s = e && t !== 1 ? ' start="' + t + '"' : "";
1040
+ return "<" + r + s + `>
1041
+ ` + i + "</" + r + `>
1042
+ `;
1043
+ }
1044
+ listitem(n) {
1045
+ var t;
1046
+ let e = "";
1047
+ if (n.task) {
1048
+ const i = this.checkbox({ checked: !!n.checked });
1049
+ n.loose ? ((t = n.tokens[0]) == null ? void 0 : t.type) === "paragraph" ? (n.tokens[0].text = i + " " + n.tokens[0].text, n.tokens[0].tokens && n.tokens[0].tokens.length > 0 && n.tokens[0].tokens[0].type === "text" && (n.tokens[0].tokens[0].text = i + " " + _(n.tokens[0].tokens[0].text), n.tokens[0].tokens[0].escaped = !0)) : n.tokens.unshift({
1050
+ type: "text",
1051
+ raw: i + " ",
1052
+ text: i + " ",
1053
+ escaped: !0
1054
+ }) : e += i + " ";
1055
+ }
1056
+ return e += this.parser.parse(n.tokens, !!n.loose), `<li>${e}</li>
1057
+ `;
1058
+ }
1059
+ checkbox({ checked: n }) {
1060
+ return "<input " + (n ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
1061
+ }
1062
+ paragraph({ tokens: n }) {
1063
+ return `<p>${this.parser.parseInline(n)}</p>
1064
+ `;
1065
+ }
1066
+ table(n) {
1067
+ let e = "", t = "";
1068
+ for (let r = 0; r < n.header.length; r++)
1069
+ t += this.tablecell(n.header[r]);
1070
+ e += this.tablerow({ text: t });
1071
+ let i = "";
1072
+ for (let r = 0; r < n.rows.length; r++) {
1073
+ const s = n.rows[r];
1074
+ t = "";
1075
+ for (let o = 0; o < s.length; o++)
1076
+ t += this.tablecell(s[o]);
1077
+ i += this.tablerow({ text: t });
1078
+ }
1079
+ return i && (i = `<tbody>${i}</tbody>`), `<table>
1080
+ <thead>
1081
+ ` + e + `</thead>
1082
+ ` + i + `</table>
1083
+ `;
1084
+ }
1085
+ tablerow({ text: n }) {
1086
+ return `<tr>
1087
+ ${n}</tr>
1088
+ `;
1089
+ }
1090
+ tablecell(n) {
1091
+ const e = this.parser.parseInline(n.tokens), t = n.header ? "th" : "td";
1092
+ return (n.align ? `<${t} align="${n.align}">` : `<${t}>`) + e + `</${t}>
1093
+ `;
1094
+ }
1095
+ /**
1096
+ * span level renderer
1097
+ */
1098
+ strong({ tokens: n }) {
1099
+ return `<strong>${this.parser.parseInline(n)}</strong>`;
1100
+ }
1101
+ em({ tokens: n }) {
1102
+ return `<em>${this.parser.parseInline(n)}</em>`;
1103
+ }
1104
+ codespan({ text: n }) {
1105
+ return `<code>${_(n, !0)}</code>`;
1106
+ }
1107
+ br(n) {
1108
+ return "<br>";
1109
+ }
1110
+ del({ tokens: n }) {
1111
+ return `<del>${this.parser.parseInline(n)}</del>`;
1112
+ }
1113
+ link({ href: n, title: e, tokens: t }) {
1114
+ const i = this.parser.parseInline(t), r = Ie(n);
1115
+ if (r === null)
1116
+ return i;
1117
+ n = r;
1118
+ let s = '<a href="' + n + '"';
1119
+ return e && (s += ' title="' + _(e) + '"'), s += ">" + i + "</a>", s;
1120
+ }
1121
+ image({ href: n, title: e, text: t, tokens: i }) {
1122
+ i && (t = this.parser.parseInline(i, this.parser.textRenderer));
1123
+ const r = Ie(n);
1124
+ if (r === null)
1125
+ return _(t);
1126
+ n = r;
1127
+ let s = `<img src="${n}" alt="${t}"`;
1128
+ return e && (s += ` title="${_(e)}"`), s += ">", s;
1129
+ }
1130
+ text(n) {
1131
+ return "tokens" in n && n.tokens ? this.parser.parseInline(n.tokens) : "escaped" in n && n.escaped ? n.text : _(n.text);
1132
+ }
1133
+ }, Ae = class {
1134
+ // no need for block level renderers
1135
+ strong({ text: n }) {
1136
+ return n;
1137
+ }
1138
+ em({ text: n }) {
1139
+ return n;
1140
+ }
1141
+ codespan({ text: n }) {
1142
+ return n;
1143
+ }
1144
+ del({ text: n }) {
1145
+ return n;
1146
+ }
1147
+ html({ text: n }) {
1148
+ return n;
1149
+ }
1150
+ text({ text: n }) {
1151
+ return n;
1152
+ }
1153
+ link({ text: n }) {
1154
+ return "" + n;
1155
+ }
1156
+ image({ text: n }) {
1157
+ return "" + n;
1158
+ }
1159
+ br() {
1160
+ return "";
1161
+ }
1162
+ }, E = class fe {
1163
+ constructor(e) {
1164
+ w(this, "options");
1165
+ w(this, "renderer");
1166
+ w(this, "textRenderer");
1167
+ this.options = e || O, this.options.renderer = this.options.renderer || new ie(), this.renderer = this.options.renderer, this.renderer.options = this.options, this.renderer.parser = this, this.textRenderer = new Ae();
1168
+ }
1169
+ /**
1170
+ * Static Parse Method
1171
+ */
1172
+ static parse(e, t) {
1173
+ return new fe(t).parse(e);
1174
+ }
1175
+ /**
1176
+ * Static Parse Inline Method
1177
+ */
1178
+ static parseInline(e, t) {
1179
+ return new fe(t).parseInline(e);
1180
+ }
1181
+ /**
1182
+ * Parse Loop
1183
+ */
1184
+ parse(e, t = !0) {
1185
+ var r, s;
1186
+ let i = "";
1187
+ for (let o = 0; o < e.length; o++) {
1188
+ const l = e[o];
1189
+ if ((s = (r = this.options.extensions) == null ? void 0 : r.renderers) != null && s[l.type]) {
1190
+ const a = l, c = this.options.extensions.renderers[a.type].call({ parser: this }, a);
1191
+ if (c !== !1 || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(a.type)) {
1192
+ i += c || "";
1193
+ continue;
1194
+ }
1195
+ }
1196
+ const u = l;
1197
+ switch (u.type) {
1198
+ case "space": {
1199
+ i += this.renderer.space(u);
1200
+ continue;
1201
+ }
1202
+ case "hr": {
1203
+ i += this.renderer.hr(u);
1204
+ continue;
1205
+ }
1206
+ case "heading": {
1207
+ i += this.renderer.heading(u);
1208
+ continue;
1209
+ }
1210
+ case "code": {
1211
+ i += this.renderer.code(u);
1212
+ continue;
1213
+ }
1214
+ case "table": {
1215
+ i += this.renderer.table(u);
1216
+ continue;
1217
+ }
1218
+ case "blockquote": {
1219
+ i += this.renderer.blockquote(u);
1220
+ continue;
1221
+ }
1222
+ case "list": {
1223
+ i += this.renderer.list(u);
1224
+ continue;
1225
+ }
1226
+ case "html": {
1227
+ i += this.renderer.html(u);
1228
+ continue;
1229
+ }
1230
+ case "paragraph": {
1231
+ i += this.renderer.paragraph(u);
1232
+ continue;
1233
+ }
1234
+ case "text": {
1235
+ let a = u, c = this.renderer.text(a);
1236
+ for (; o + 1 < e.length && e[o + 1].type === "text"; )
1237
+ a = e[++o], c += `
1238
+ ` + this.renderer.text(a);
1239
+ t ? i += this.renderer.paragraph({
1240
+ type: "paragraph",
1241
+ raw: c,
1242
+ text: c,
1243
+ tokens: [{ type: "text", raw: c, text: c, escaped: !0 }]
1244
+ }) : i += c;
1245
+ continue;
1246
+ }
1247
+ default: {
1248
+ const a = 'Token with "' + u.type + '" type was not found.';
1249
+ if (this.options.silent)
1250
+ return console.error(a), "";
1251
+ throw new Error(a);
1252
+ }
1253
+ }
1254
+ }
1255
+ return i;
1256
+ }
1257
+ /**
1258
+ * Parse Inline Tokens
1259
+ */
1260
+ parseInline(e, t = this.renderer) {
1261
+ var r, s;
1262
+ let i = "";
1263
+ for (let o = 0; o < e.length; o++) {
1264
+ const l = e[o];
1265
+ if ((s = (r = this.options.extensions) == null ? void 0 : r.renderers) != null && s[l.type]) {
1266
+ const a = this.options.extensions.renderers[l.type].call({ parser: this }, l);
1267
+ if (a !== !1 || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(l.type)) {
1268
+ i += a || "";
1269
+ continue;
1270
+ }
1271
+ }
1272
+ const u = l;
1273
+ switch (u.type) {
1274
+ case "escape": {
1275
+ i += t.text(u);
1276
+ break;
1277
+ }
1278
+ case "html": {
1279
+ i += t.html(u);
1280
+ break;
1281
+ }
1282
+ case "link": {
1283
+ i += t.link(u);
1284
+ break;
1285
+ }
1286
+ case "image": {
1287
+ i += t.image(u);
1288
+ break;
1289
+ }
1290
+ case "strong": {
1291
+ i += t.strong(u);
1292
+ break;
1293
+ }
1294
+ case "em": {
1295
+ i += t.em(u);
1296
+ break;
1297
+ }
1298
+ case "codespan": {
1299
+ i += t.codespan(u);
1300
+ break;
1301
+ }
1302
+ case "br": {
1303
+ i += t.br(u);
1304
+ break;
1305
+ }
1306
+ case "del": {
1307
+ i += t.del(u);
1308
+ break;
1309
+ }
1310
+ case "text": {
1311
+ i += t.text(u);
1312
+ break;
1313
+ }
1314
+ default: {
1315
+ const a = 'Token with "' + u.type + '" type was not found.';
1316
+ if (this.options.silent)
1317
+ return console.error(a), "";
1318
+ throw new Error(a);
1319
+ }
1320
+ }
1321
+ }
1322
+ return i;
1323
+ }
1324
+ }, ce, Y = (ce = class {
1325
+ constructor(n) {
1326
+ w(this, "options");
1327
+ w(this, "block");
1328
+ this.options = n || O;
1329
+ }
1330
+ /**
1331
+ * Process markdown before marked
1332
+ */
1333
+ preprocess(n) {
1334
+ return n;
1335
+ }
1336
+ /**
1337
+ * Process HTML after marked is finished
1338
+ */
1339
+ postprocess(n) {
1340
+ return n;
1341
+ }
1342
+ /**
1343
+ * Process all tokens before walk tokens
1344
+ */
1345
+ processAllTokens(n) {
1346
+ return n;
1347
+ }
1348
+ /**
1349
+ * Provide function to tokenize markdown
1350
+ */
1351
+ provideLexer() {
1352
+ return this.block ? z.lex : z.lexInline;
1353
+ }
1354
+ /**
1355
+ * Provide function to parse tokens
1356
+ */
1357
+ provideParser() {
1358
+ return this.block ? E.parse : E.parseInline;
1359
+ }
1360
+ }, w(ce, "passThroughHooks", /* @__PURE__ */ new Set([
1361
+ "preprocess",
1362
+ "postprocess",
1363
+ "processAllTokens"
1364
+ ])), ce), ut = class {
1365
+ constructor(...n) {
1366
+ w(this, "defaults", ve());
1367
+ w(this, "options", this.setOptions);
1368
+ w(this, "parse", this.parseMarkdown(!0));
1369
+ w(this, "parseInline", this.parseMarkdown(!1));
1370
+ w(this, "Parser", E);
1371
+ w(this, "Renderer", ie);
1372
+ w(this, "TextRenderer", Ae);
1373
+ w(this, "Lexer", z);
1374
+ w(this, "Tokenizer", ne);
1375
+ w(this, "Hooks", Y);
1376
+ this.use(...n);
1377
+ }
1378
+ /**
1379
+ * Run callback for every token
1380
+ */
1381
+ walkTokens(n, e) {
1382
+ var i, r;
1383
+ let t = [];
1384
+ for (const s of n)
1385
+ switch (t = t.concat(e.call(this, s)), s.type) {
1386
+ case "table": {
1387
+ const o = s;
1388
+ for (const l of o.header)
1389
+ t = t.concat(this.walkTokens(l.tokens, e));
1390
+ for (const l of o.rows)
1391
+ for (const u of l)
1392
+ t = t.concat(this.walkTokens(u.tokens, e));
1393
+ break;
1394
+ }
1395
+ case "list": {
1396
+ const o = s;
1397
+ t = t.concat(this.walkTokens(o.items, e));
1398
+ break;
1399
+ }
1400
+ default: {
1401
+ const o = s;
1402
+ (r = (i = this.defaults.extensions) == null ? void 0 : i.childTokens) != null && r[o.type] ? this.defaults.extensions.childTokens[o.type].forEach((l) => {
1403
+ const u = o[l].flat(1 / 0);
1404
+ t = t.concat(this.walkTokens(u, e));
1405
+ }) : o.tokens && (t = t.concat(this.walkTokens(o.tokens, e)));
1406
+ }
1407
+ }
1408
+ return t;
1409
+ }
1410
+ use(...n) {
1411
+ const e = this.defaults.extensions || { renderers: {}, childTokens: {} };
1412
+ return n.forEach((t) => {
1413
+ const i = { ...t };
1414
+ if (i.async = this.defaults.async || i.async || !1, t.extensions && (t.extensions.forEach((r) => {
1415
+ if (!r.name)
1416
+ throw new Error("extension name required");
1417
+ if ("renderer" in r) {
1418
+ const s = e.renderers[r.name];
1419
+ s ? e.renderers[r.name] = function(...o) {
1420
+ let l = r.renderer.apply(this, o);
1421
+ return l === !1 && (l = s.apply(this, o)), l;
1422
+ } : e.renderers[r.name] = r.renderer;
1423
+ }
1424
+ if ("tokenizer" in r) {
1425
+ if (!r.level || r.level !== "block" && r.level !== "inline")
1426
+ throw new Error("extension level must be 'block' or 'inline'");
1427
+ const s = e[r.level];
1428
+ s ? s.unshift(r.tokenizer) : e[r.level] = [r.tokenizer], r.start && (r.level === "block" ? e.startBlock ? e.startBlock.push(r.start) : e.startBlock = [r.start] : r.level === "inline" && (e.startInline ? e.startInline.push(r.start) : e.startInline = [r.start]));
1429
+ }
1430
+ "childTokens" in r && r.childTokens && (e.childTokens[r.name] = r.childTokens);
1431
+ }), i.extensions = e), t.renderer) {
1432
+ const r = this.defaults.renderer || new ie(this.defaults);
1433
+ for (const s in t.renderer) {
1434
+ if (!(s in r))
1435
+ throw new Error(`renderer '${s}' does not exist`);
1436
+ if (["options", "parser"].includes(s))
1437
+ continue;
1438
+ const o = s, l = t.renderer[o], u = r[o];
1439
+ r[o] = (...a) => {
1440
+ let c = l.apply(r, a);
1441
+ return c === !1 && (c = u.apply(r, a)), c || "";
1442
+ };
1443
+ }
1444
+ i.renderer = r;
1445
+ }
1446
+ if (t.tokenizer) {
1447
+ const r = this.defaults.tokenizer || new ne(this.defaults);
1448
+ for (const s in t.tokenizer) {
1449
+ if (!(s in r))
1450
+ throw new Error(`tokenizer '${s}' does not exist`);
1451
+ if (["options", "rules", "lexer"].includes(s))
1452
+ continue;
1453
+ const o = s, l = t.tokenizer[o], u = r[o];
1454
+ r[o] = (...a) => {
1455
+ let c = l.apply(r, a);
1456
+ return c === !1 && (c = u.apply(r, a)), c;
1457
+ };
1458
+ }
1459
+ i.tokenizer = r;
1460
+ }
1461
+ if (t.hooks) {
1462
+ const r = this.defaults.hooks || new Y();
1463
+ for (const s in t.hooks) {
1464
+ if (!(s in r))
1465
+ throw new Error(`hook '${s}' does not exist`);
1466
+ if (["options", "block"].includes(s))
1467
+ continue;
1468
+ const o = s, l = t.hooks[o], u = r[o];
1469
+ Y.passThroughHooks.has(s) ? r[o] = (a) => {
1470
+ if (this.defaults.async)
1471
+ return Promise.resolve(l.call(r, a)).then((d) => u.call(r, d));
1472
+ const c = l.call(r, a);
1473
+ return u.call(r, c);
1474
+ } : r[o] = (...a) => {
1475
+ let c = l.apply(r, a);
1476
+ return c === !1 && (c = u.apply(r, a)), c;
1477
+ };
1478
+ }
1479
+ i.hooks = r;
1480
+ }
1481
+ if (t.walkTokens) {
1482
+ const r = this.defaults.walkTokens, s = t.walkTokens;
1483
+ i.walkTokens = function(o) {
1484
+ let l = [];
1485
+ return l.push(s.call(this, o)), r && (l = l.concat(r.call(this, o))), l;
1486
+ };
1487
+ }
1488
+ this.defaults = { ...this.defaults, ...i };
1489
+ }), this;
1490
+ }
1491
+ setOptions(n) {
1492
+ return this.defaults = { ...this.defaults, ...n }, this;
1493
+ }
1494
+ lexer(n, e) {
1495
+ return z.lex(n, e ?? this.defaults);
1496
+ }
1497
+ parser(n, e) {
1498
+ return E.parse(n, e ?? this.defaults);
1499
+ }
1500
+ parseMarkdown(n) {
1501
+ return (t, i) => {
1502
+ const r = { ...i }, s = { ...this.defaults, ...r }, o = this.onError(!!s.silent, !!s.async);
1503
+ if (this.defaults.async === !0 && r.async === !1)
1504
+ return o(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."));
1505
+ if (typeof t > "u" || t === null)
1506
+ return o(new Error("marked(): input parameter is undefined or null"));
1507
+ if (typeof t != "string")
1508
+ return o(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(t) + ", string expected"));
1509
+ s.hooks && (s.hooks.options = s, s.hooks.block = n);
1510
+ const l = s.hooks ? s.hooks.provideLexer() : n ? z.lex : z.lexInline, u = s.hooks ? s.hooks.provideParser() : n ? E.parse : E.parseInline;
1511
+ if (s.async)
1512
+ return Promise.resolve(s.hooks ? s.hooks.preprocess(t) : t).then((a) => l(a, s)).then((a) => s.hooks ? s.hooks.processAllTokens(a) : a).then((a) => s.walkTokens ? Promise.all(this.walkTokens(a, s.walkTokens)).then(() => a) : a).then((a) => u(a, s)).then((a) => s.hooks ? s.hooks.postprocess(a) : a).catch(o);
1513
+ try {
1514
+ s.hooks && (t = s.hooks.preprocess(t));
1515
+ let a = l(t, s);
1516
+ s.hooks && (a = s.hooks.processAllTokens(a)), s.walkTokens && this.walkTokens(a, s.walkTokens);
1517
+ let c = u(a, s);
1518
+ return s.hooks && (c = s.hooks.postprocess(c)), c;
1519
+ } catch (a) {
1520
+ return o(a);
1521
+ }
1522
+ };
1523
+ }
1524
+ onError(n, e) {
1525
+ return (t) => {
1526
+ if (t.message += `
1527
+ Please report this to https://github.com/markedjs/marked.`, n) {
1528
+ const i = "<p>An error occurred:</p><pre>" + _(t.message + "", !0) + "</pre>";
1529
+ return e ? Promise.resolve(i) : i;
1530
+ }
1531
+ if (e)
1532
+ return Promise.reject(t);
1533
+ throw t;
1534
+ };
1535
+ }
1536
+ }, B = new ut();
1537
+ function b(n, e) {
1538
+ return B.parse(n, e);
1539
+ }
1540
+ b.options = b.setOptions = function(n) {
1541
+ return B.setOptions(n), b.defaults = B.defaults, Ye(b.defaults), b;
1542
+ };
1543
+ b.getDefaults = ve;
1544
+ b.defaults = O;
1545
+ b.use = function(...n) {
1546
+ return B.use(...n), b.defaults = B.defaults, Ye(b.defaults), b;
1547
+ };
1548
+ b.walkTokens = function(n, e) {
1549
+ return B.walkTokens(n, e);
1550
+ };
1551
+ b.parseInline = B.parseInline;
1552
+ b.Parser = E;
1553
+ b.parser = E.parse;
1554
+ b.Renderer = ie;
1555
+ b.TextRenderer = Ae;
1556
+ b.Lexer = z;
1557
+ b.lexer = z.lex;
1558
+ b.Tokenizer = ne;
1559
+ b.Hooks = Y;
1560
+ b.parse = b;
1561
+ b.options;
1562
+ b.setOptions;
1563
+ b.use;
1564
+ b.walkTokens;
1565
+ b.parseInline;
1566
+ E.parse;
1567
+ z.lex;
1568
+ class Be {
1569
+ constructor(e, t, i) {
1570
+ this.from = e, this.to = t, this.diagnostic = i;
1571
+ }
1572
+ }
1573
+ class F {
1574
+ constructor(e, t, i) {
1575
+ this.diagnostics = e, this.panel = t, this.selected = i;
1576
+ }
1577
+ static init(e, t, i) {
1578
+ let r = i.facet(K).markerFilter;
1579
+ r && (e = r(e, i));
1580
+ let s = e.slice().sort((h, f) => h.from - f.from || h.to - f.to), o = new Tt(), l = [], u = 0, a = i.doc.iter(), c = 0, d = i.doc.length;
1581
+ for (let h = 0; ; ) {
1582
+ let f = h == s.length ? null : s[h];
1583
+ if (!f && !l.length)
1584
+ break;
1585
+ let g, k;
1586
+ if (l.length)
1587
+ g = u, k = l.reduce((m, v) => Math.min(m, v.to), f && f.from > g ? f.from : 1e8);
1588
+ else {
1589
+ if (g = f.from, g > d)
1590
+ break;
1591
+ k = f.to, l.push(f), h++;
1592
+ }
1593
+ for (; h < s.length; ) {
1594
+ let m = s[h];
1595
+ if (m.from == g && (m.to > m.from || m.to == g))
1596
+ l.push(m), h++, k = Math.min(m.to, k);
1597
+ else {
1598
+ k = Math.min(m.from, k);
1599
+ break;
1600
+ }
1601
+ }
1602
+ k = Math.min(k, d);
1603
+ let y = !1;
1604
+ if (l.some((m) => m.from == g && (m.to == k || k == d)) && (y = g == k, !y && k - g < 10)) {
1605
+ let m = g - (c + a.value.length);
1606
+ m > 0 && (a.next(m), c = g);
1607
+ for (let v = g; ; ) {
1608
+ if (v >= k) {
1609
+ y = !0;
1610
+ break;
1611
+ }
1612
+ if (!a.lineBreak && c + a.value.length > v)
1613
+ break;
1614
+ v = c + a.value.length, c += a.value.length, a.next();
1615
+ }
1616
+ }
1617
+ let S = Rn(l);
1618
+ if (y)
1619
+ o.add(g, g, N.widget({
1620
+ widget: new vn(S),
1621
+ diagnostics: l.slice()
1622
+ }));
1623
+ else {
1624
+ let m = l.reduce((v, T) => T.markClass ? v + " " + T.markClass : v, "");
1625
+ o.add(g, k, N.mark({
1626
+ class: "cm-lintRange cm-lintRange-" + S + m,
1627
+ diagnostics: l.slice(),
1628
+ inclusiveEnd: l.some((v) => v.to > k)
1629
+ }));
1630
+ }
1631
+ if (u = k, u == d)
1632
+ break;
1633
+ for (let m = 0; m < l.length; m++)
1634
+ l[m].to <= u && l.splice(m--, 1);
1635
+ }
1636
+ let p = o.finish();
1637
+ return new F(p, t, j(p));
1638
+ }
1639
+ }
1640
+ function j(n, e = null, t = 0) {
1641
+ let i = null;
1642
+ return n.between(t, 1e9, (r, s, { spec: o }) => {
1643
+ if (!(e && o.diagnostics.indexOf(e) < 0))
1644
+ if (!i)
1645
+ i = new Be(r, s, e || o.diagnostics[0]);
1646
+ else {
1647
+ if (o.diagnostics.indexOf(i.diagnostic) < 0)
1648
+ return !1;
1649
+ i = new Be(i.from, s, i.diagnostic);
1650
+ }
1651
+ }), i;
1652
+ }
1653
+ function gn(n, e) {
1654
+ let t = e.pos, i = e.end || t, r = n.state.facet(K).hideOn(n, t, i);
1655
+ if (r != null)
1656
+ return r;
1657
+ let s = n.startState.doc.lineAt(e.pos);
1658
+ return !!(n.effects.some((o) => o.is(_e)) || n.changes.touchesRange(s.from, Math.max(s.to, i)));
1659
+ }
1660
+ function mn(n, e) {
1661
+ return n.field(A, !1) ? e : e.concat(I.appendConfig.of(Pn));
1662
+ }
1663
+ function kn(n, e) {
1664
+ return {
1665
+ effects: mn(n, [_e.of(e)])
1666
+ };
1667
+ }
1668
+ const _e = /* @__PURE__ */ I.define(), pt = /* @__PURE__ */ I.define(), ht = /* @__PURE__ */ I.define(), A = /* @__PURE__ */ be.define({
1669
+ create() {
1670
+ return new F(N.none, null, null);
1671
+ },
1672
+ update(n, e) {
1673
+ if (e.docChanged && n.diagnostics.size) {
1674
+ let t = n.diagnostics.map(e.changes), i = null, r = n.panel;
1675
+ if (n.selected) {
1676
+ let s = e.changes.mapPos(n.selected.from, 1);
1677
+ i = j(t, n.selected.diagnostic, s) || j(t, null, s);
1678
+ }
1679
+ !t.size && r && e.state.facet(K).autoPanel && (r = null), n = new F(t, r, i);
1680
+ }
1681
+ for (let t of e.effects)
1682
+ if (t.is(_e)) {
1683
+ let i = e.state.facet(K).autoPanel ? t.value.length ? re.open : null : n.panel;
1684
+ n = F.init(t.value, i, e.state);
1685
+ } else t.is(pt) ? n = new F(n.diagnostics, t.value ? re.open : null, n.selected) : t.is(ht) && (n = new F(n.diagnostics, n.panel, t.value));
1686
+ return n;
1687
+ },
1688
+ provide: (n) => [
1689
+ Ke.from(n, (e) => e.panel),
1690
+ le.decorations.from(n, (e) => e.diagnostics)
1691
+ ]
1692
+ }), xn = /* @__PURE__ */ N.mark({ class: "cm-lintRange cm-lintRange-active" });
1693
+ function bn(n, e, t) {
1694
+ let { diagnostics: i } = n.state.field(A), r, s = -1, o = -1;
1695
+ i.between(e - (t < 0 ? 1 : 0), e + (t > 0 ? 1 : 0), (u, a, { spec: c }) => {
1696
+ if (e >= u && e <= a && (u == a || (e > u || t > 0) && (e < a || t < 0)))
1697
+ return r = c.diagnostics, s = u, o = a, !1;
1698
+ });
1699
+ let l = n.state.facet(K).tooltipFilter;
1700
+ return r && l && (r = l(r, n.state)), r ? {
1701
+ pos: s,
1702
+ end: o,
1703
+ above: !0,
1704
+ create() {
1705
+ return { dom: wn(n, r) };
1706
+ }
1707
+ } : null;
1708
+ }
1709
+ function wn(n, e) {
1710
+ return D("ul", { class: "cm-tooltip-lint" }, e.map((t) => dt(n, t, !1)));
1711
+ }
1712
+ const Oe = (n) => {
1713
+ let e = n.state.field(A, !1);
1714
+ return !e || !e.panel ? !1 : (n.dispatch({ effects: pt.of(!1) }), !0);
1715
+ }, K = /* @__PURE__ */ Qe.define({
1716
+ combine(n) {
1717
+ return {
1718
+ sources: n.map((e) => e.source).filter((e) => e != null),
1719
+ ...Rt(n.map((e) => e.config), {
1720
+ delay: 750,
1721
+ markerFilter: null,
1722
+ tooltipFilter: null,
1723
+ needsRefresh: null,
1724
+ hideOn: () => null
1725
+ }, {
1726
+ delay: Math.max,
1727
+ markerFilter: He,
1728
+ tooltipFilter: He,
1729
+ needsRefresh: (e, t) => e ? t ? (i) => e(i) || t(i) : e : t,
1730
+ hideOn: (e, t) => e ? t ? (i, r, s) => e(i, r, s) || t(i, r, s) : e : t,
1731
+ autoPanel: (e, t) => e || t
1732
+ })
1733
+ };
1734
+ }
1735
+ });
1736
+ function He(n, e) {
1737
+ return n ? e ? (t, i) => e(n(t, i), i) : n : e;
1738
+ }
1739
+ function ft(n) {
1740
+ let e = [];
1741
+ if (n)
1742
+ e: for (let { name: t } of n) {
1743
+ for (let i = 0; i < t.length; i++) {
1744
+ let r = t[i];
1745
+ if (/[a-zA-Z]/.test(r) && !e.some((s) => s.toLowerCase() == r.toLowerCase())) {
1746
+ e.push(r);
1747
+ continue e;
1748
+ }
1749
+ }
1750
+ e.push("");
1751
+ }
1752
+ return e;
1753
+ }
1754
+ function dt(n, e, t) {
1755
+ var i;
1756
+ let r = t ? ft(e.actions) : [];
1757
+ return D("li", { class: "cm-diagnostic cm-diagnostic-" + e.severity }, D("span", { class: "cm-diagnosticText" }, e.renderMessage ? e.renderMessage(n) : e.message), (i = e.actions) === null || i === void 0 ? void 0 : i.map((s, o) => {
1758
+ let l = !1, u = (h) => {
1759
+ if (h.preventDefault(), l)
1760
+ return;
1761
+ l = !0;
1762
+ let f = j(n.state.field(A).diagnostics, e);
1763
+ f && s.apply(n, f.from, f.to);
1764
+ }, { name: a } = s, c = r[o] ? a.indexOf(r[o]) : -1, d = c < 0 ? a : [
1765
+ a.slice(0, c),
1766
+ D("u", a.slice(c, c + 1)),
1767
+ a.slice(c + 1)
1768
+ ], p = s.markClass ? " " + s.markClass : "";
1769
+ return D("button", {
1770
+ type: "button",
1771
+ class: "cm-diagnosticAction" + p,
1772
+ onclick: u,
1773
+ onmousedown: u,
1774
+ "aria-label": ` Action: ${a}${c < 0 ? "" : ` (access key "${r[o]})"`}.`
1775
+ }, d);
1776
+ }), e.source && D("div", { class: "cm-diagnosticSource" }, e.source));
1777
+ }
1778
+ class vn extends yt {
1779
+ constructor(e) {
1780
+ super(), this.sev = e;
1781
+ }
1782
+ eq(e) {
1783
+ return e.sev == this.sev;
1784
+ }
1785
+ toDOM() {
1786
+ return D("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
1787
+ }
1788
+ }
1789
+ class Ne {
1790
+ constructor(e, t) {
1791
+ this.diagnostic = t, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = dt(e, t, !0), this.dom.id = this.id, this.dom.setAttribute("role", "option");
1792
+ }
1793
+ }
1794
+ class re {
1795
+ constructor(e) {
1796
+ this.view = e, this.items = [];
1797
+ let t = (r) => {
1798
+ if (!(r.ctrlKey || r.altKey || r.metaKey)) {
1799
+ if (r.keyCode == 27)
1800
+ Oe(this.view), this.view.focus();
1801
+ else if (r.keyCode == 38 || r.keyCode == 33)
1802
+ this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
1803
+ else if (r.keyCode == 40 || r.keyCode == 34)
1804
+ this.moveSelection((this.selectedIndex + 1) % this.items.length);
1805
+ else if (r.keyCode == 36)
1806
+ this.moveSelection(0);
1807
+ else if (r.keyCode == 35)
1808
+ this.moveSelection(this.items.length - 1);
1809
+ else if (r.keyCode == 13)
1810
+ this.view.focus();
1811
+ else if (r.keyCode >= 65 && r.keyCode <= 90 && this.selectedIndex >= 0) {
1812
+ let { diagnostic: s } = this.items[this.selectedIndex], o = ft(s.actions);
1813
+ for (let l = 0; l < o.length; l++)
1814
+ if (o[l].toUpperCase().charCodeAt(0) == r.keyCode) {
1815
+ let u = j(this.view.state.field(A).diagnostics, s);
1816
+ u && s.actions[l].apply(e, u.from, u.to);
1817
+ }
1818
+ } else
1819
+ return;
1820
+ r.preventDefault();
1821
+ }
1822
+ }, i = (r) => {
1823
+ for (let s = 0; s < this.items.length; s++)
1824
+ this.items[s].dom.contains(r.target) && this.moveSelection(s);
1825
+ };
1826
+ this.list = D("ul", {
1827
+ tabIndex: 0,
1828
+ role: "listbox",
1829
+ "aria-label": this.view.state.phrase("Diagnostics"),
1830
+ onkeydown: t,
1831
+ onclick: i
1832
+ }), this.dom = D("div", { class: "cm-panel-lint" }, this.list, D("button", {
1833
+ type: "button",
1834
+ name: "close",
1835
+ "aria-label": this.view.state.phrase("close"),
1836
+ onclick: () => Oe(this.view)
1837
+ }, "×")), this.update();
1838
+ }
1839
+ get selectedIndex() {
1840
+ let e = this.view.state.field(A).selected;
1841
+ if (!e)
1842
+ return -1;
1843
+ for (let t = 0; t < this.items.length; t++)
1844
+ if (this.items[t].diagnostic == e.diagnostic)
1845
+ return t;
1846
+ return -1;
1847
+ }
1848
+ update() {
1849
+ let { diagnostics: e, selected: t } = this.view.state.field(A), i = 0, r = !1, s = null, o = /* @__PURE__ */ new Set();
1850
+ for (e.between(0, this.view.state.doc.length, (l, u, { spec: a }) => {
1851
+ for (let c of a.diagnostics) {
1852
+ if (o.has(c))
1853
+ continue;
1854
+ o.add(c);
1855
+ let d = -1, p;
1856
+ for (let h = i; h < this.items.length; h++)
1857
+ if (this.items[h].diagnostic == c) {
1858
+ d = h;
1859
+ break;
1860
+ }
1861
+ d < 0 ? (p = new Ne(this.view, c), this.items.splice(i, 0, p), r = !0) : (p = this.items[d], d > i && (this.items.splice(i, d - i), r = !0)), t && p.diagnostic == t.diagnostic ? p.dom.hasAttribute("aria-selected") || (p.dom.setAttribute("aria-selected", "true"), s = p) : p.dom.hasAttribute("aria-selected") && p.dom.removeAttribute("aria-selected"), i++;
1862
+ }
1863
+ }); i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
1864
+ r = !0, this.items.pop();
1865
+ this.items.length == 0 && (this.items.push(new Ne(this.view, {
1866
+ from: -1,
1867
+ to: -1,
1868
+ severity: "info",
1869
+ message: this.view.state.phrase("No diagnostics")
1870
+ })), r = !0), s ? (this.list.setAttribute("aria-activedescendant", s.id), this.view.requestMeasure({
1871
+ key: this,
1872
+ read: () => ({ sel: s.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
1873
+ write: ({ sel: l, panel: u }) => {
1874
+ let a = u.height / this.list.offsetHeight;
1875
+ l.top < u.top ? this.list.scrollTop -= (u.top - l.top) / a : l.bottom > u.bottom && (this.list.scrollTop += (l.bottom - u.bottom) / a);
1876
+ }
1877
+ })) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), r && this.sync();
1878
+ }
1879
+ sync() {
1880
+ let e = this.list.firstChild;
1881
+ function t() {
1882
+ let i = e;
1883
+ e = i.nextSibling, i.remove();
1884
+ }
1885
+ for (let i of this.items)
1886
+ if (i.dom.parentNode == this.list) {
1887
+ for (; e != i.dom; )
1888
+ t();
1889
+ e = i.dom.nextSibling;
1890
+ } else
1891
+ this.list.insertBefore(i.dom, e);
1892
+ for (; e; )
1893
+ t();
1894
+ }
1895
+ moveSelection(e) {
1896
+ if (this.selectedIndex < 0)
1897
+ return;
1898
+ let t = this.view.state.field(A), i = j(t.diagnostics, this.items[e].diagnostic);
1899
+ i && this.view.dispatch({
1900
+ selection: { anchor: i.from, head: i.to },
1901
+ scrollIntoView: !0,
1902
+ effects: ht.of(i)
1903
+ });
1904
+ }
1905
+ static open(e) {
1906
+ return new re(e);
1907
+ }
1908
+ }
1909
+ function yn(n, e = 'viewBox="0 0 40 40"') {
1910
+ return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`;
1911
+ }
1912
+ function J(n) {
1913
+ return yn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
1914
+ }
1915
+ const Sn = /* @__PURE__ */ le.baseTheme({
1916
+ ".cm-diagnostic": {
1917
+ padding: "3px 6px 3px 8px",
1918
+ marginLeft: "-1px",
1919
+ display: "block",
1920
+ whiteSpace: "pre-wrap"
1921
+ },
1922
+ ".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
1923
+ ".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
1924
+ ".cm-diagnostic-info": { borderLeft: "5px solid #999" },
1925
+ ".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
1926
+ ".cm-diagnosticAction": {
1927
+ font: "inherit",
1928
+ border: "none",
1929
+ padding: "2px 4px",
1930
+ backgroundColor: "#444",
1931
+ color: "white",
1932
+ borderRadius: "3px",
1933
+ marginLeft: "8px",
1934
+ cursor: "pointer"
1935
+ },
1936
+ ".cm-diagnosticSource": {
1937
+ fontSize: "70%",
1938
+ opacity: 0.7
1939
+ },
1940
+ ".cm-lintRange": {
1941
+ backgroundPosition: "left bottom",
1942
+ backgroundRepeat: "repeat-x",
1943
+ paddingBottom: "0.7px"
1944
+ },
1945
+ ".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ J("#f11") },
1946
+ ".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ J("orange") },
1947
+ ".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ J("#999") },
1948
+ ".cm-lintRange-hint": { backgroundImage: /* @__PURE__ */ J("#66d") },
1949
+ ".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
1950
+ ".cm-tooltip-lint": {
1951
+ padding: 0,
1952
+ margin: 0
1953
+ },
1954
+ ".cm-lintPoint": {
1955
+ position: "relative",
1956
+ "&:after": {
1957
+ content: '""',
1958
+ position: "absolute",
1959
+ bottom: 0,
1960
+ left: "-2px",
1961
+ borderLeft: "3px solid transparent",
1962
+ borderRight: "3px solid transparent",
1963
+ borderBottom: "4px solid #d11"
1964
+ }
1965
+ },
1966
+ ".cm-lintPoint-warning": {
1967
+ "&:after": { borderBottomColor: "orange" }
1968
+ },
1969
+ ".cm-lintPoint-info": {
1970
+ "&:after": { borderBottomColor: "#999" }
1971
+ },
1972
+ ".cm-lintPoint-hint": {
1973
+ "&:after": { borderBottomColor: "#66d" }
1974
+ },
1975
+ ".cm-panel.cm-panel-lint": {
1976
+ position: "relative",
1977
+ "& ul": {
1978
+ maxHeight: "100px",
1979
+ overflowY: "auto",
1980
+ "& [aria-selected]": {
1981
+ backgroundColor: "#ddd",
1982
+ "& u": { textDecoration: "underline" }
1983
+ },
1984
+ "&:focus [aria-selected]": {
1985
+ background_fallback: "#bdf",
1986
+ backgroundColor: "Highlight",
1987
+ color_fallback: "white",
1988
+ color: "HighlightText"
1989
+ },
1990
+ "& u": { textDecoration: "none" },
1991
+ padding: 0,
1992
+ margin: 0
1993
+ },
1994
+ "& [name=close]": {
1995
+ position: "absolute",
1996
+ top: "0",
1997
+ right: "2px",
1998
+ background: "inherit",
1999
+ border: "none",
2000
+ font: "inherit",
2001
+ padding: 0,
2002
+ margin: 0
2003
+ }
2004
+ },
2005
+ "&dark .cm-lintRange-active": { backgroundColor: "#86714a80" },
2006
+ "&dark .cm-panel.cm-panel-lint ul": {
2007
+ "& [aria-selected]": {
2008
+ backgroundColor: "#2e343e"
2009
+ }
2010
+ }
2011
+ });
2012
+ function Cn(n) {
2013
+ return n == "error" ? 4 : n == "warning" ? 3 : n == "info" ? 2 : 1;
2014
+ }
2015
+ function Rn(n) {
2016
+ let e = "hint", t = 1;
2017
+ for (let i of n) {
2018
+ let r = Cn(i.severity);
2019
+ r > t && (t = r, e = i.severity);
2020
+ }
2021
+ return e;
2022
+ }
2023
+ const Tn = /* @__PURE__ */ Ue(bn, { hideOn: gn }), Pn = [
2024
+ A,
2025
+ /* @__PURE__ */ le.decorations.compute([A], (n) => {
2026
+ let { selected: e, panel: t } = n.field(A);
2027
+ return !e || !t || e.from == e.to ? N.none : N.set([
2028
+ xn.range(e.from, e.to)
2029
+ ]);
2030
+ }),
2031
+ Tn,
2032
+ Sn
2033
+ ];
2034
+ let L = null;
2035
+ function $n(n, e, t) {
2036
+ let i = L;
2037
+ try {
2038
+ return L = { view: n, language: e }, t();
2039
+ } finally {
2040
+ L = i;
2041
+ }
2042
+ }
2043
+ const An = /* @__PURE__ */ new ut({
2044
+ walkTokens(n) {
2045
+ if (!L || n.type != "code")
2046
+ return;
2047
+ let e = L.language && L.language(n.lang);
2048
+ if (!e) {
2049
+ let r = L.view.state.facet(we);
2050
+ r && r.name == n.lang && (e = r);
2051
+ }
2052
+ if (!e)
2053
+ return;
2054
+ let t = { style: (r) => Je(L.view.state, r) }, i = "";
2055
+ Xe(n.text, e.parser.parse(n.text), t, (r, s) => {
2056
+ i += s ? `<span class="${s}">${H(r)}</span>` : H(r);
2057
+ }, () => {
2058
+ i += "<br>";
2059
+ }), n.escaped = !0, n.text = i;
2060
+ }
2061
+ });
2062
+ function H(n) {
2063
+ return n.replace(/[\n<&]/g, (e) => e == `
2064
+ ` ? "<br>" : e == "<" ? "&lt;" : "&amp;");
2065
+ }
2066
+ function _n(n, e) {
2067
+ let t = e, i = n;
2068
+ return typeof i != "string" && (t = i.kind, i = i.value), t == "plaintext" ? H(i) : An.parse(i, { async: !1 });
2069
+ }
2070
+ function de(n, e) {
2071
+ let t = n.lineAt(e);
2072
+ return { line: t.number - 1, character: e - t.from };
2073
+ }
2074
+ function se(n, e) {
2075
+ return n.line(e.line + 1).from + e.character;
2076
+ }
2077
+ function je(n, e) {
2078
+ if (e.line < 0 || e.line >= n.lines)
2079
+ return null;
2080
+ let t = n.line(e.line + 1);
2081
+ return e.character < 0 || e.character > t.length ? null : t.from + e.character;
2082
+ }
2083
+ class C {
2084
+ /**
2085
+ @internal
2086
+ */
2087
+ constructor(e, { client: t, uri: i, languageID: r }) {
2088
+ if (this.view = e, this.client = t, this.uri = i, !r) {
2089
+ let s = e.state.facet(we);
2090
+ r = s ? s.name : "";
2091
+ }
2092
+ t.workspace.openFile(i, r, e), this.syncedDoc = e.state.doc, this.unsyncedChanges = ue.empty(e.state.doc.length);
2093
+ }
2094
+ /**
2095
+ Render a doc string from the server to HTML.
2096
+ */
2097
+ docToHTML(e, t = "plaintext") {
2098
+ let i = $n(this.view, this.client.config.highlightLanguage, () => _n(e, t));
2099
+ return this.client.config.sanitizeHTML ? this.client.config.sanitizeHTML(i) : i;
2100
+ }
2101
+ /**
2102
+ Convert a CodeMirror document offset into an LSP `{line,
2103
+ character}` object. Defaults to using the view's current
2104
+ document, but can be given another one.
2105
+ */
2106
+ toPosition(e, t = this.view.state.doc) {
2107
+ return de(t, e);
2108
+ }
2109
+ /**
2110
+ Convert an LSP `{line, character}` object to a CodeMirror
2111
+ document offset.
2112
+ */
2113
+ fromPosition(e, t = this.view.state.doc) {
2114
+ return se(t, e);
2115
+ }
2116
+ /**
2117
+ Display an error in this plugin's editor.
2118
+ */
2119
+ reportError(e, t) {
2120
+ xe(this.view, {
2121
+ label: this.view.state.phrase(e) + ": " + (t.message || t),
2122
+ class: "cm-lsp-message cm-lsp-message-error",
2123
+ top: !0
2124
+ });
2125
+ }
2126
+ /**
2127
+ Reset the [unsynced
2128
+ changes](https://codemirror.net/6/docs/ref/#lsp-client.LSPPlugin.unsyncedChanges). Should probably
2129
+ only be called by a [workspace](https://codemirror.net/6/docs/ref/#lsp-client.Workspace).
2130
+ */
2131
+ clear() {
2132
+ this.syncedDoc = this.view.state.doc, this.unsyncedChanges = ue.empty(this.view.state.doc.length);
2133
+ }
2134
+ /**
2135
+ @internal
2136
+ */
2137
+ update(e) {
2138
+ e.docChanged && (this.unsyncedChanges = this.unsyncedChanges.compose(e.changes));
2139
+ }
2140
+ /**
2141
+ @internal
2142
+ */
2143
+ destroy() {
2144
+ this.client.workspace.closeFile(this.uri, this.view);
2145
+ }
2146
+ /**
2147
+ Get the LSP plugin associated with an editor, if any.
2148
+ */
2149
+ static get(e) {
2150
+ return e.plugin(gt);
2151
+ }
2152
+ /**
2153
+ Deprecated. Use
2154
+ [`LSPClient.plugin`](https://codemirror.net/6/docs/ref/#lsp-client.LSPClient.plugin) instead.
2155
+ */
2156
+ static create(e, t, i) {
2157
+ return e.plugin(t, i);
2158
+ }
2159
+ }
2160
+ const gt = /* @__PURE__ */ ke.fromClass(C);
2161
+ class Dn {
2162
+ /**
2163
+ The constructor, as called by the client when creating a
2164
+ workspace.
2165
+ */
2166
+ constructor(e) {
2167
+ this.client = e;
2168
+ }
2169
+ /**
2170
+ Find the open file with the given URI, if it exists. The default
2171
+ implementation just looks it up in `this.files`.
2172
+ */
2173
+ getFile(e) {
2174
+ return this.files.find((t) => t.uri == e) || null;
2175
+ }
2176
+ /**
2177
+ Called to request that the workspace open a file. The default
2178
+ implementation simply returns the file if it is open, null
2179
+ otherwise.
2180
+ */
2181
+ requestFile(e) {
2182
+ return Promise.resolve(this.getFile(e));
2183
+ }
2184
+ /**
2185
+ Called when the client for this workspace is connected. The
2186
+ default implementation calls
2187
+ [`LSPClient.didOpen`](https://codemirror.net/6/docs/ref/#lsp-client.LSPClient.didOpen) on all open
2188
+ files.
2189
+ */
2190
+ connected() {
2191
+ for (let e of this.files)
2192
+ this.client.didOpen(e);
2193
+ }
2194
+ /**
2195
+ Called when the client for this workspace is disconnected. The
2196
+ default implementation does nothing.
2197
+ */
2198
+ disconnected() {
2199
+ }
2200
+ /**
2201
+ Called when a server-initiated change to a file is applied. The
2202
+ default implementation simply dispatches the update to the
2203
+ file's view, if the file is open and has a view.
2204
+ */
2205
+ updateFile(e, t) {
2206
+ var i;
2207
+ let r = this.getFile(e);
2208
+ r && ((i = r.getView()) === null || i === void 0 || i.dispatch(t));
2209
+ }
2210
+ /**
2211
+ When the client needs to put a file other than the one loaded in
2212
+ the current editor in front of the user, for example in
2213
+ [`jumpToDefinition`](https://codemirror.net/6/docs/ref/#lsp-client.jumpToDefinition), it will call
2214
+ this function. It should make sure to create or find an editor
2215
+ with the file and make it visible to the user, or return null if
2216
+ this isn't possible.
2217
+ */
2218
+ displayFile(e) {
2219
+ let t = this.getFile(e);
2220
+ return Promise.resolve(t ? t.getView() : null);
2221
+ }
2222
+ }
2223
+ class zn {
2224
+ constructor(e, t, i, r, s) {
2225
+ this.uri = e, this.languageId = t, this.version = i, this.doc = r, this.view = s;
2226
+ }
2227
+ getView() {
2228
+ return this.view;
2229
+ }
2230
+ }
2231
+ class En extends Dn {
2232
+ constructor() {
2233
+ super(...arguments), this.files = [], this.fileVersions = /* @__PURE__ */ Object.create(null);
2234
+ }
2235
+ nextFileVersion(e) {
2236
+ var t;
2237
+ return this.fileVersions[e] = ((t = this.fileVersions[e]) !== null && t !== void 0 ? t : -1) + 1;
2238
+ }
2239
+ syncFiles() {
2240
+ let e = [];
2241
+ for (let t of this.files) {
2242
+ let i = C.get(t.view);
2243
+ if (!i)
2244
+ continue;
2245
+ let r = i.unsyncedChanges;
2246
+ r.empty || (e.push({ changes: r, file: t, prevDoc: t.doc }), t.doc = t.view.state.doc, t.version = this.nextFileVersion(t.uri), i.clear());
2247
+ }
2248
+ return e;
2249
+ }
2250
+ openFile(e, t, i) {
2251
+ if (this.getFile(e))
2252
+ throw new Error("Default workspace implementation doesn't support multiple views on the same file");
2253
+ let r = new zn(e, t, this.nextFileVersion(e), i.state.doc, i);
2254
+ this.files.push(r), this.client.didOpen(r);
2255
+ }
2256
+ closeFile(e) {
2257
+ let t = this.getFile(e);
2258
+ t && (this.files = this.files.filter((i) => i != t), this.client.didClose(e));
2259
+ }
2260
+ }
2261
+ const Ln = /* @__PURE__ */ le.baseTheme({
2262
+ ".cm-lsp-documentation": {
2263
+ padding: "0 7px",
2264
+ "& p, & pre": {
2265
+ margin: "2px 0"
2266
+ }
2267
+ },
2268
+ ".cm-lsp-signature-tooltip": {
2269
+ padding: "2px 6px",
2270
+ borderRadius: "2.5px",
2271
+ position: "relative",
2272
+ maxWidth: "30em",
2273
+ maxHeight: "10em",
2274
+ overflowY: "scroll",
2275
+ "& .cm-lsp-documentation": {
2276
+ padding: "0",
2277
+ fontSize: "80%"
2278
+ },
2279
+ "& .cm-lsp-signature-num": {
2280
+ fontFamily: "monospace",
2281
+ position: "absolute",
2282
+ left: "2px",
2283
+ top: "4px",
2284
+ fontSize: "70%",
2285
+ lineHeight: "1.3"
2286
+ },
2287
+ "& .cm-lsp-signature": {
2288
+ fontFamily: "monospace",
2289
+ textIndent: "1em hanging"
2290
+ },
2291
+ "& .cm-lsp-active-parameter": {
2292
+ fontWeight: "bold"
2293
+ }
2294
+ },
2295
+ ".cm-lsp-signature-multiple": {
2296
+ paddingLeft: "1.5em"
2297
+ },
2298
+ ".cm-panel.cm-lsp-rename-panel": {
2299
+ padding: "2px 6px 4px",
2300
+ position: "relative",
2301
+ "& label": { fontSize: "80%" },
2302
+ "& [name=close]": {
2303
+ position: "absolute",
2304
+ top: "0",
2305
+ bottom: "0",
2306
+ right: "4px",
2307
+ backgroundColor: "inherit",
2308
+ border: "none",
2309
+ font: "inherit",
2310
+ padding: "0"
2311
+ }
2312
+ },
2313
+ ".cm-lsp-message button[type=submit]": {
2314
+ display: "block"
2315
+ },
2316
+ ".cm-lsp-reference-panel": {
2317
+ fontFamily: "monospace",
2318
+ whiteSpace: "pre",
2319
+ padding: "3px 6px",
2320
+ maxHeight: "120px",
2321
+ overflow: "auto",
2322
+ "& .cm-lsp-reference-file": {
2323
+ fontWeight: "bold"
2324
+ },
2325
+ "& .cm-lsp-reference": {
2326
+ cursor: "pointer",
2327
+ "&[aria-selected]": {
2328
+ backgroundColor: "#0077ee44"
2329
+ }
2330
+ },
2331
+ "& .cm-lsp-reference-line": {
2332
+ opacity: "0.7"
2333
+ }
2334
+ }
2335
+ });
2336
+ class qn {
2337
+ constructor(e, t, i) {
2338
+ this.id = e, this.params = t, this.timeout = i, this.promise = new Promise((r, s) => {
2339
+ this.resolve = r, this.reject = s;
2340
+ });
2341
+ }
2342
+ }
2343
+ const In = {
2344
+ general: {
2345
+ markdown: {
2346
+ parser: "marked"
2347
+ }
2348
+ },
2349
+ textDocument: {
2350
+ completion: {
2351
+ completionItem: {
2352
+ snippetSupport: !0,
2353
+ documentationFormat: ["markdown", "plaintext"],
2354
+ insertReplaceSupport: !1
2355
+ },
2356
+ completionList: {
2357
+ itemDefaults: ["commitCharacters", "editRange", "insertTextFormat"]
2358
+ },
2359
+ completionItemKind: { valueSet: [] },
2360
+ contextSupport: !0
2361
+ },
2362
+ hover: {
2363
+ contentFormat: ["markdown", "plaintext"]
2364
+ },
2365
+ formatting: {},
2366
+ rename: {},
2367
+ signatureHelp: {
2368
+ contextSupport: !0,
2369
+ signatureInformation: {
2370
+ documentationFormat: ["markdown", "plaintext"],
2371
+ parameterInformation: { labelOffsetSupport: !0 },
2372
+ activeParameterSupport: !0
2373
+ }
2374
+ },
2375
+ definition: {},
2376
+ declaration: {},
2377
+ implementation: {},
2378
+ typeDefinition: {},
2379
+ references: {},
2380
+ diagnostic: {}
2381
+ },
2382
+ window: {
2383
+ showMessage: {}
2384
+ }
2385
+ };
2386
+ class Mn {
2387
+ /**
2388
+ @internal
2389
+ */
2390
+ constructor(e) {
2391
+ this.client = e, this.mappings = /* @__PURE__ */ new Map(), this.startDocs = /* @__PURE__ */ new Map();
2392
+ for (let t of e.workspace.files)
2393
+ this.mappings.set(t.uri, ue.empty(t.doc.length)), this.startDocs.set(t.uri, t.doc);
2394
+ }
2395
+ /**
2396
+ @internal
2397
+ */
2398
+ addChanges(e, t) {
2399
+ let i = this.mappings.get(e);
2400
+ i && this.mappings.set(e, i.composeDesc(t));
2401
+ }
2402
+ /**
2403
+ Get the changes made to the document with the given URI since
2404
+ the mapping was created. Returns null for documents that aren't
2405
+ open.
2406
+ */
2407
+ getMapping(e) {
2408
+ let t = this.mappings.get(e);
2409
+ if (!t)
2410
+ return null;
2411
+ let i = this.client.workspace.getFile(e), r = i == null ? void 0 : i.getView(), s = r && C.get(r);
2412
+ return s ? t.composeDesc(s.unsyncedChanges) : t;
2413
+ }
2414
+ mapPos(e, t, i = -1, r = ze.Simple) {
2415
+ let s = this.getMapping(e);
2416
+ return s ? s.mapPos(t, i, r) : t;
2417
+ }
2418
+ mapPosition(e, t, i = -1, r = ze.Simple) {
2419
+ let s = this.startDocs.get(e);
2420
+ if (!s)
2421
+ throw new Error("Cannot map from a file that's not in the workspace");
2422
+ let o = se(s, t), l = this.getMapping(e);
2423
+ return l ? l.mapPos(o, i, r) : o;
2424
+ }
2425
+ /**
2426
+ Disconnect this mapping from the client so that it will no
2427
+ longer be notified of new changes. You must make sure to call
2428
+ this on every mapping you create, except when you use
2429
+ [`withMapping`](https://codemirror.net/6/docs/ref/#lsp-client.LSPClient.withMapping), which will
2430
+ automatically schedule a disconnect when the given promise
2431
+ resolves or aborts.
2432
+ */
2433
+ destroy() {
2434
+ this.client.activeMappings = this.client.activeMappings.filter((e) => e != this);
2435
+ }
2436
+ }
2437
+ const Fn = {
2438
+ "window/logMessage": (n, e) => {
2439
+ e.type == 1 ? console.error("[lsp] " + e.message) : e.type == 2 && console.warn("[lsp] " + e.message);
2440
+ },
2441
+ "window/showMessage": (n, e) => {
2442
+ if (e.type > 3)
2443
+ return;
2444
+ let t;
2445
+ for (let i of n.workspace.files)
2446
+ if (t = i.getView())
2447
+ break;
2448
+ t && xe(t, {
2449
+ label: e.message,
2450
+ class: "cm-lsp-message cm-lsp-message-" + (e.type == 1 ? "error" : e.type == 2 ? "warning" : "info"),
2451
+ top: !0
2452
+ });
2453
+ }
2454
+ };
2455
+ class Bn {
2456
+ /**
2457
+ Create a client object.
2458
+ */
2459
+ constructor(e = {}) {
2460
+ var t;
2461
+ if (this.config = e, this.transport = null, this.nextReqID = 0, this.requests = [], this.activeMappings = [], this.serverCapabilities = null, this.supportSync = -1, this.extensions = [], this.receiveMessage = this.receiveMessage.bind(this), this.initializing = new Promise((i, r) => this.init = { resolve: i, reject: r }), this.timeout = (t = e.timeout) !== null && t !== void 0 ? t : 3e3, this.workspace = e.workspace ? e.workspace(this) : new En(this), e.extensions)
2462
+ for (let i of e.extensions)
2463
+ Array.isArray(i) || i.extension ? this.extensions.push(i) : i.editorExtension && this.extensions.push(i.editorExtension);
2464
+ }
2465
+ /**
2466
+ Whether this client is connected (has a transport).
2467
+ */
2468
+ get connected() {
2469
+ return !!this.transport;
2470
+ }
2471
+ /**
2472
+ Connect this client to a server over the given transport. Will
2473
+ immediately start the initialization exchange with the server,
2474
+ and resolve `this.initializing` (which it also returns) when
2475
+ successful.
2476
+ */
2477
+ connect(e) {
2478
+ this.transport && this.transport.unsubscribe(this.receiveMessage), this.transport = e, e.subscribe(this.receiveMessage);
2479
+ let t = In;
2480
+ if (this.config.extensions)
2481
+ for (let i of this.config.extensions) {
2482
+ let { clientCapabilities: r } = i;
2483
+ r && (t = mt(t, r));
2484
+ }
2485
+ return this.requestInner("initialize", {
2486
+ processId: null,
2487
+ clientInfo: { name: "@codemirror/lsp-client" },
2488
+ rootUri: this.config.rootUri || null,
2489
+ initializationOptions: this.config.initializationOptions,
2490
+ capabilities: t
2491
+ }).promise.then((i) => {
2492
+ var r;
2493
+ this.serverCapabilities = i.capabilities;
2494
+ let s = i.capabilities.textDocumentSync;
2495
+ this.supportSync = s == null ? 0 : typeof s == "number" ? s : (r = s.change) !== null && r !== void 0 ? r : 0, e.send(JSON.stringify({ jsonrpc: "2.0", method: "initialized", params: {} })), this.init.resolve(null);
2496
+ }, this.init.reject), this.workspace.connected(), this;
2497
+ }
2498
+ /**
2499
+ Disconnect the client from the server.
2500
+ */
2501
+ disconnect() {
2502
+ this.transport && this.transport.unsubscribe(this.receiveMessage), this.serverCapabilities = null, this.initializing = new Promise((e, t) => this.init = { resolve: e, reject: t }), this.workspace.disconnected();
2503
+ }
2504
+ /**
2505
+ Create a plugin for this client, to add to an editor
2506
+ configuration. This extension is necessary to use LSP-related
2507
+ functionality exported by this package. The returned extension
2508
+ will include the editor
2509
+ extensions included in this client's
2510
+ [configuration](https://codemirror.net/6/docs/ref/#lsp-client.LSPClientConfig.extensions).
2511
+
2512
+ Creating an editor with this plugin will cause
2513
+ [`openFile`](https://codemirror.net/6/docs/ref/#lsp-client.Workspace.openFile) to be called on the
2514
+ workspace.
2515
+
2516
+ By default, the language ID given to the server for this file is
2517
+ derived from the editor's language configuration via
2518
+ [`Language.name`](https://codemirror.net/6/docs/ref/#language.Language.name). You can pass in
2519
+ a specific ID as a third parameter.
2520
+ */
2521
+ plugin(e, t) {
2522
+ return [
2523
+ gt.of({ client: this, uri: e, languageID: t }),
2524
+ Ln,
2525
+ this.extensions
2526
+ ];
2527
+ }
2528
+ /**
2529
+ Send a `textDocument/didOpen` notification to the server.
2530
+ */
2531
+ didOpen(e) {
2532
+ this.notification("textDocument/didOpen", {
2533
+ textDocument: {
2534
+ uri: e.uri,
2535
+ languageId: e.languageId,
2536
+ text: e.doc.toString(),
2537
+ version: e.version
2538
+ }
2539
+ });
2540
+ }
2541
+ /**
2542
+ Send a `textDocument/didClose` notification to the server.
2543
+ */
2544
+ didClose(e) {
2545
+ this.notification("textDocument/didClose", { textDocument: { uri: e } });
2546
+ }
2547
+ receiveMessage(e) {
2548
+ var t;
2549
+ const i = JSON.parse(e);
2550
+ if ("id" in i && !("method" in i)) {
2551
+ let r = this.requests.findIndex((s) => s.id == i.id);
2552
+ if (r < 0)
2553
+ console.warn(`[lsp] Received a response for non-existent request ${i.id}`);
2554
+ else {
2555
+ let s = this.requests[r];
2556
+ clearTimeout(s.timeout), this.requests.splice(r, 1), i.error ? s.reject(i.error) : s.resolve(i.result);
2557
+ }
2558
+ } else if ("id" in i) {
2559
+ let r = {
2560
+ jsonrpc: "2.0",
2561
+ id: i.id,
2562
+ error: { code: -32601, message: "Method not implemented" }
2563
+ };
2564
+ this.transport.send(JSON.stringify(r));
2565
+ } else {
2566
+ let r = (t = this.config.notificationHandlers) === null || t === void 0 ? void 0 : t[i.method];
2567
+ if (r && r(this, i.params))
2568
+ return;
2569
+ if (this.config.extensions)
2570
+ for (let o of this.config.extensions) {
2571
+ let { notificationHandlers: l } = o, u = l == null ? void 0 : l[i.method];
2572
+ if (u && u(this, i.params))
2573
+ return;
2574
+ }
2575
+ let s = Fn[i.method];
2576
+ s ? s(this, i.params) : this.config.unhandledNotification && this.config.unhandledNotification(this, i.method, i.params);
2577
+ }
2578
+ }
2579
+ /**
2580
+ Make a request to the server. Returns a promise that resolves to
2581
+ the response or rejects with a failure message. You'll probably
2582
+ want to use types from the `vscode-languageserver-protocol`
2583
+ package for the type parameters.
2584
+
2585
+ The caller is responsible for
2586
+ [synchronizing](https://codemirror.net/6/docs/ref/#lsp-client.LSPClient.sync) state before the
2587
+ request and correctly handling state drift caused by local
2588
+ changes that happend during the request.
2589
+ */
2590
+ request(e, t) {
2591
+ return this.transport ? this.initializing.then(() => this.requestInner(e, t).promise) : Promise.reject(new Error("Client not connected"));
2592
+ }
2593
+ requestInner(e, t, i = !1) {
2594
+ let r = ++this.nextReqID, s = {
2595
+ jsonrpc: "2.0",
2596
+ id: r,
2597
+ method: e,
2598
+ params: t
2599
+ }, o = new qn(r, t, setTimeout(() => this.timeoutRequest(o), this.timeout));
2600
+ this.requests.push(o);
2601
+ try {
2602
+ this.transport.send(JSON.stringify(s));
2603
+ } catch (l) {
2604
+ o.reject(l);
2605
+ }
2606
+ return o;
2607
+ }
2608
+ /**
2609
+ Send a notification to the server.
2610
+ */
2611
+ notification(e, t) {
2612
+ this.transport && this.initializing.then(() => {
2613
+ let i = {
2614
+ jsonrpc: "2.0",
2615
+ method: e,
2616
+ params: t
2617
+ };
2618
+ this.transport.send(JSON.stringify(i));
2619
+ });
2620
+ }
2621
+ /**
2622
+ Cancel the in-progress request with the given parameter value
2623
+ (which is compared by identity).
2624
+ */
2625
+ cancelRequest(e) {
2626
+ let t = this.requests.find((i) => i.params === e);
2627
+ t && this.notification("$/cancelRequest", { id: t.id });
2628
+ }
2629
+ /**
2630
+ @internal
2631
+ */
2632
+ hasCapability(e) {
2633
+ return this.serverCapabilities ? !!this.serverCapabilities[e] : null;
2634
+ }
2635
+ /**
2636
+ Create a [workspace mapping](https://codemirror.net/6/docs/ref/#lsp-client.WorkspaceMapping) that
2637
+ tracks changes to files in this client's workspace, relative to
2638
+ the moment where it was created. Make sure you call
2639
+ [`destroy`](https://codemirror.net/6/docs/ref/#lsp-client.WorkspaceMapping.destroy) on the mapping
2640
+ when you're done with it.
2641
+ */
2642
+ workspaceMapping() {
2643
+ let e = new Mn(this);
2644
+ return this.activeMappings.push(e), e;
2645
+ }
2646
+ /**
2647
+ Run the given promise with a [workspace
2648
+ mapping](https://codemirror.net/6/docs/ref/#lsp-client.WorkspaceMapping) active. Automatically
2649
+ release the mapping when the promise resolves or rejects.
2650
+ */
2651
+ withMapping(e) {
2652
+ let t = this.workspaceMapping();
2653
+ return e(t).finally(() => t.destroy());
2654
+ }
2655
+ /**
2656
+ Push any [pending changes](https://codemirror.net/6/docs/ref/#lsp-client.Workspace.syncFiles) in
2657
+ the open files to the server. You'll want to call this before
2658
+ most types of requests, to make sure the server isn't working
2659
+ with outdated information.
2660
+ */
2661
+ sync() {
2662
+ for (let { file: e, changes: t, prevDoc: i } of this.workspace.syncFiles()) {
2663
+ for (let r of this.activeMappings)
2664
+ r.addChanges(e.uri, t);
2665
+ this.supportSync && this.notification("textDocument/didChange", {
2666
+ textDocument: { uri: e.uri, version: e.version },
2667
+ contentChanges: On(
2668
+ e,
2669
+ i,
2670
+ t,
2671
+ this.supportSync == 2
2672
+ /* Incremental */
2673
+ )
2674
+ });
2675
+ }
2676
+ }
2677
+ timeoutRequest(e) {
2678
+ let t = this.requests.indexOf(e);
2679
+ t > -1 && (e.reject(new Error("Request timed out")), this.requests.splice(t, 1));
2680
+ }
2681
+ }
2682
+ function On(n, e, t, i) {
2683
+ if (!i || n.doc.length < 1024)
2684
+ return [{ text: n.doc.toString() }];
2685
+ let r = [];
2686
+ return t.iterChanges((s, o, l, u, a) => {
2687
+ r.push({
2688
+ range: { start: de(e, s), end: de(e, o) },
2689
+ text: a.toString()
2690
+ });
2691
+ }), r.reverse();
2692
+ }
2693
+ function mt(n, e) {
2694
+ if (e == null)
2695
+ return n;
2696
+ if (typeof n != "object" || typeof e != "object")
2697
+ return e;
2698
+ let t = {}, i = Object.keys(n), r = Object.keys(e);
2699
+ for (let s of i)
2700
+ t[s] = r.indexOf(s) > -1 ? mt(n[s], e[s]) : n[s];
2701
+ for (let s of r)
2702
+ i.indexOf(s) < 0 && (t[s] = e[s]);
2703
+ return t;
2704
+ }
2705
+ function Hn(n) {
2706
+ return n.replace(/\\([$}\\])|\$(\d+)/g, (e, t, i) => t || `\${${i}}`);
2707
+ }
2708
+ function Nn(n = {}) {
2709
+ let e;
2710
+ if (n.override)
2711
+ e = [Ee({ override: [Ze] })];
2712
+ else {
2713
+ let t = [{ autocomplete: Ze }];
2714
+ e = [Ee(), Pt.languageData.of(() => t)];
2715
+ }
2716
+ return n.validFor && e.push(kt.of({ validFor: n.validFor })), e;
2717
+ }
2718
+ const kt = /* @__PURE__ */ Qe.define({
2719
+ combine: (n) => n.length ? n[0] : { validFor: null }
2720
+ });
2721
+ function jn(n, e, t, i) {
2722
+ if (n.client.hasCapability("completionProvider") === !1)
2723
+ return Promise.resolve(null);
2724
+ n.client.sync();
2725
+ let r = {
2726
+ position: n.toPosition(e),
2727
+ textDocument: { uri: n.uri },
2728
+ context: t
2729
+ };
2730
+ return i && i.addEventListener("abort", () => n.client.cancelRequest(r)), n.client.request("textDocument/completion", r);
2731
+ }
2732
+ function Zn(n) {
2733
+ var e;
2734
+ let t = Math.ceil(n.length / 50), i = [];
2735
+ for (let r = 0; r < n.length; r += t) {
2736
+ let s = n[r], o = ((e = s.textEdit) === null || e === void 0 ? void 0 : e.newText) || s.textEditText || s.insertText || s.label;
2737
+ if (!/^\w/.test(o)) {
2738
+ let l = /^[^\w]*/.exec(o)[0];
2739
+ i.indexOf(l) < 0 && i.push(l);
2740
+ }
2741
+ }
2742
+ return i.length ? new RegExp("^(?:" + i.map(RegExp.escape || ((r) => r.replace(/[^\w\s]/g, "\\$&"))).join("|") + ")?\\w*$") : /^\w*$/;
2743
+ }
2744
+ function Vn(n, e) {
2745
+ var t, i;
2746
+ let r = (i = (t = n.client.serverCapabilities) === null || t === void 0 ? void 0 : t.completionProvider) === null || i === void 0 ? void 0 : i.triggerCharacters;
2747
+ return r && r.indexOf(e) > -1 ? "triggerCharacter" : /[a-zA-Z_]/.test(e) ? "identifier" : null;
2748
+ }
2749
+ function xt(n, e) {
2750
+ return (t, i) => {
2751
+ n = n ? n.composeDesc(i) : i;
2752
+ let r = t.options.slice();
2753
+ for (let { index: s, edits: o, text: l } of e)
2754
+ r[s] = { ...r[s], apply: bt(o, l, n) };
2755
+ return {
2756
+ ...t,
2757
+ options: r,
2758
+ map: xt(n, e)
2759
+ };
2760
+ };
2761
+ }
2762
+ function bt(n, e, t) {
2763
+ return (i, r, s, o) => {
2764
+ let l = zt(i.state, e, s, o), u = [];
2765
+ for (let { from: a, to: c, text: d } of n) {
2766
+ if (t) {
2767
+ if (t.touchesRange(a, c))
2768
+ continue;
2769
+ let p = c - a;
2770
+ a = t.mapPos(a, 1), c = a + p;
2771
+ }
2772
+ u.push({ from: a, to: c, insert: d });
2773
+ }
2774
+ i.dispatch(l, { changes: u });
2775
+ };
2776
+ }
2777
+ const Ze = (n) => {
2778
+ const e = n.view && C.get(n.view);
2779
+ if (!e)
2780
+ return null;
2781
+ let t = n.state.sliceDoc(n.pos - 1, n.pos), i = n.explicit ? "invoked" : Vn(e, t);
2782
+ if (!i)
2783
+ return null;
2784
+ let r = i == "triggerCharacter" ? { triggerKind: 2, triggerCharacter: t } : {
2785
+ triggerKind: 1
2786
+ /* Invoked */
2787
+ };
2788
+ return jn(e, n.pos, r, n).then((s) => {
2789
+ var o, l;
2790
+ if (!s)
2791
+ return null;
2792
+ Array.isArray(s) && (s = { items: s });
2793
+ let { from: u, to: a } = Gn(n, s), c = (o = s.itemDefaults) === null || o === void 0 ? void 0 : o.commitCharacters, d = n.state.facet(kt), p = [];
2794
+ return {
2795
+ from: u,
2796
+ to: a,
2797
+ options: s.items.map((h, f) => {
2798
+ var g, k, y;
2799
+ let S = ((g = h.textEdit) === null || g === void 0 ? void 0 : g.newText) || h.textEditText || h.insertText || h.label, m = {
2800
+ label: h.filterText || h.label,
2801
+ displayLabel: h.label,
2802
+ type: h.kind && Un[h.kind]
2803
+ }, v = (k = h.insertTextFormat) !== null && k !== void 0 ? k : (y = s.itemDefaults) === null || y === void 0 ? void 0 : y.insertTextFormat;
2804
+ if (h.commitCharacters && h.commitCharacters != c && (m.commitCharacters = h.commitCharacters), h.detail && (m.detail = h.detail), h.sortText && (m.sortText = h.sortText), v == 2)
2805
+ m.apply = (T, P, $, M) => Dt(Hn(S))(T, P, $, M);
2806
+ else if (h.additionalTextEdits) {
2807
+ let T = [];
2808
+ for (let P of h.additionalTextEdits) {
2809
+ let $ = je(n.state.doc, P.range.start), M = je(n.state.doc, P.range.end);
2810
+ $ != null && M != null && T.push({ from: $, to: M, text: P.newText });
2811
+ }
2812
+ p.push({ index: f, text: S, edits: T }), m.apply = bt(T, S, null);
2813
+ } else m.label != S && (m.apply = S);
2814
+ return h.documentation && (m.info = () => Kn(e, h.documentation)), m;
2815
+ }),
2816
+ commitCharacters: c,
2817
+ validFor: s.isIncomplete ? void 0 : (l = d.validFor) !== null && l !== void 0 ? l : Zn(s.items),
2818
+ map: p.length ? xt(null, p) : void 0
2819
+ };
2820
+ }, (s) => {
2821
+ if ("code" in s && s.code == -32800)
2822
+ return null;
2823
+ throw s;
2824
+ });
2825
+ };
2826
+ function Gn(n, e) {
2827
+ var t;
2828
+ if (!e.items.length)
2829
+ return { from: n.pos, to: n.pos };
2830
+ let i = (t = e.itemDefaults) === null || t === void 0 ? void 0 : t.editRange, r = e.items[0], s = i ? "insert" in i ? i.insert : i : r.textEdit ? "range" in r.textEdit ? r.textEdit.range : r.textEdit.insert : null;
2831
+ if (!s)
2832
+ return n.state.wordAt(n.pos) || { from: n.pos, to: n.pos };
2833
+ let o = n.state.doc.lineAt(n.pos);
2834
+ return { from: o.from + s.start.character, to: o.from + s.end.character };
2835
+ }
2836
+ function Kn(n, e) {
2837
+ let t = document.createElement("div");
2838
+ return t.className = "cm-lsp-documentation cm-lsp-completion-documentation", t.innerHTML = n.docToHTML(e), t;
2839
+ }
2840
+ const Un = {
2841
+ 1: "text",
2842
+ // Text
2843
+ 2: "method",
2844
+ // Method
2845
+ 3: "function",
2846
+ // Function
2847
+ 4: "class",
2848
+ // Constructor
2849
+ 5: "property",
2850
+ // Field
2851
+ 6: "variable",
2852
+ // Variable
2853
+ 7: "class",
2854
+ // Class
2855
+ 8: "interface",
2856
+ // Interface
2857
+ 9: "namespace",
2858
+ // Module
2859
+ 10: "property",
2860
+ // Property
2861
+ 11: "keyword",
2862
+ // Unit
2863
+ 12: "constant",
2864
+ // Value
2865
+ 13: "constant",
2866
+ // Enum
2867
+ 14: "keyword",
2868
+ // Keyword
2869
+ 16: "constant",
2870
+ // Color
2871
+ 20: "constant",
2872
+ // EnumMember
2873
+ 21: "constant",
2874
+ // Constant
2875
+ 22: "class",
2876
+ // Struct
2877
+ 25: "type"
2878
+ // TypeParameter
2879
+ };
2880
+ function Wn(n = {}) {
2881
+ return Ue(Jn, {
2882
+ hideOn: (e) => e.docChanged,
2883
+ hoverTime: n.hoverTime
2884
+ });
2885
+ }
2886
+ function Qn(n, e) {
2887
+ return n.client.hasCapability("hoverProvider") === !1 ? Promise.resolve(null) : (n.client.sync(), n.client.request("textDocument/hover", {
2888
+ position: n.toPosition(e),
2889
+ textDocument: { uri: n.uri }
2890
+ }));
2891
+ }
2892
+ function Jn(n, e) {
2893
+ const t = C.get(n);
2894
+ return t ? Qn(t, e).then((i) => i ? {
2895
+ pos: i.range ? se(n.state.doc, i.range.start) : e,
2896
+ end: i.range ? se(n.state.doc, i.range.end) : e,
2897
+ create() {
2898
+ let r = document.createElement("div");
2899
+ return r.className = "cm-lsp-hover-tooltip cm-lsp-documentation", r.innerHTML = Xn(t, i.contents), { dom: r };
2900
+ },
2901
+ above: !0
2902
+ } : null) : Promise.resolve(null);
2903
+ }
2904
+ function Xn(n, e) {
2905
+ return Array.isArray(e) ? e.map((t) => Ve(n, t)).join("<br>") : typeof e == "string" || typeof e == "object" && "language" in e ? Ve(n, e) : n.docToHTML(e);
2906
+ }
2907
+ function Ve(n, e) {
2908
+ if (typeof e == "string")
2909
+ return n.docToHTML(e, "markdown");
2910
+ let { language: t, value: i } = e, r = n.client.config.highlightLanguage && n.client.config.highlightLanguage(t || "");
2911
+ if (!r) {
2912
+ let o = n.view.state.facet(we);
2913
+ o && (!t || o.name == t) && (r = o);
2914
+ }
2915
+ if (!r)
2916
+ return H(i);
2917
+ let s = "";
2918
+ return Xe(i, r.parser.parse(i), { style: (o) => Je(n.view.state, o) }, (o, l) => {
2919
+ s += l ? `<span class="${l}">${H(o)}</span>` : H(o);
2920
+ }, () => {
2921
+ s += "<br>";
2922
+ }), s;
2923
+ }
2924
+ function Yn(n, e) {
2925
+ return n.client.request("textDocument/formatting", {
2926
+ options: e,
2927
+ textDocument: { uri: n.uri }
2928
+ });
2929
+ }
2930
+ const ei = (n) => {
2931
+ const e = C.get(n);
2932
+ return e ? (e.client.sync(), e.client.withMapping((t) => Yn(e, {
2933
+ tabSize: _t(n.state),
2934
+ insertSpaces: n.state.facet(At).indexOf(" ") < 0
2935
+ }).then((i) => {
2936
+ if (!i)
2937
+ return;
2938
+ let r = t.getMapping(e.uri), s = [];
2939
+ for (let o of i) {
2940
+ let l = t.mapPosition(e.uri, o.range.start), u = t.mapPosition(e.uri, o.range.end);
2941
+ if (r) {
2942
+ if (r.touchesRange(l, u))
2943
+ return;
2944
+ l = r.mapPos(l, 1), u = r.mapPos(u, -1);
2945
+ }
2946
+ s.push({ from: l, to: u, insert: o.newText });
2947
+ }
2948
+ n.dispatch({
2949
+ changes: s,
2950
+ userEvent: "format"
2951
+ });
2952
+ }, (i) => {
2953
+ e.reportError("Formatting request failed", i);
2954
+ })), !0) : !1;
2955
+ }, ti = [
2956
+ { key: "Shift-Alt-f", run: ei, preventDefault: !0 }
2957
+ ];
2958
+ function ni(n, e, t) {
2959
+ return n.client.request("textDocument/rename", {
2960
+ newName: t,
2961
+ position: n.toPosition(e),
2962
+ textDocument: { uri: n.uri }
2963
+ });
2964
+ }
2965
+ const ii = (n) => {
2966
+ let e = n.state.wordAt(n.state.selection.main.head), t = C.get(n);
2967
+ if (!e || !t || t.client.hasCapability("renameProvider") === !1)
2968
+ return !1;
2969
+ const i = n.state.sliceDoc(e.from, e.to);
2970
+ let r = St(n, "cm-lsp-rename-panel");
2971
+ if (r) {
2972
+ let s = r.dom.querySelector("[name=name]");
2973
+ s.value = i, s.select();
2974
+ } else {
2975
+ let { close: s, result: o } = xe(n, {
2976
+ label: n.state.phrase("New name"),
2977
+ input: { name: "name", value: i },
2978
+ focus: !0,
2979
+ submitLabel: n.state.phrase("rename"),
2980
+ class: "cm-lsp-rename-panel"
2981
+ });
2982
+ o.then((l) => {
2983
+ n.dispatch({ effects: s }), l && ri(n, l.elements.namedItem("name").value);
2984
+ });
2985
+ }
2986
+ return !0;
2987
+ };
2988
+ function ri(n, e) {
2989
+ const t = C.get(n), i = n.state.wordAt(n.state.selection.main.head);
2990
+ if (!t || !i)
2991
+ return !1;
2992
+ t.client.sync(), t.client.withMapping((r) => ni(t, i.from, e).then((s) => {
2993
+ if (s)
2994
+ for (let o in s.changes) {
2995
+ let l = s.changes[o], u = t.client.workspace.getFile(o);
2996
+ !l.length || !u || t.client.workspace.updateFile(o, {
2997
+ changes: l.map((a) => ({
2998
+ from: r.mapPosition(o, a.range.start),
2999
+ to: r.mapPosition(o, a.range.end),
3000
+ insert: a.newText
3001
+ })),
3002
+ userEvent: "rename"
3003
+ });
3004
+ }
3005
+ }, (s) => {
3006
+ t.reportError("Rename request failed", s);
3007
+ }));
3008
+ }
3009
+ const si = [
3010
+ { key: "F2", run: ii, preventDefault: !0 }
3011
+ ];
3012
+ function li(n, e, t) {
3013
+ return n.client.hasCapability("signatureHelpProvider") === !1 ? Promise.resolve(null) : (n.client.sync(), n.client.request("textDocument/signatureHelp", {
3014
+ context: t,
3015
+ position: n.toPosition(e),
3016
+ textDocument: { uri: n.uri }
3017
+ }));
3018
+ }
3019
+ const ee = /* @__PURE__ */ ke.fromClass(class {
3020
+ constructor() {
3021
+ this.activeRequest = null, this.delayedRequest = 0;
3022
+ }
3023
+ update(n) {
3024
+ var e;
3025
+ this.activeRequest && (n.selectionSet ? (this.activeRequest.drop = !0, this.activeRequest = null) : n.docChanged && (this.activeRequest.pos = n.changes.mapPos(this.activeRequest.pos)));
3026
+ const t = C.get(n.view);
3027
+ if (!t)
3028
+ return;
3029
+ const i = n.view.state.field(q);
3030
+ let r = "";
3031
+ if (n.docChanged && n.transactions.some((s) => s.isUserEvent("input.type"))) {
3032
+ const s = (e = t.client.serverCapabilities) === null || e === void 0 ? void 0 : e.signatureHelpProvider, o = ((s == null ? void 0 : s.triggerCharacters) || []).concat(i && (s == null ? void 0 : s.retriggerCharacters) || []);
3033
+ o && n.changes.iterChanges((l, u, a, c, d) => {
3034
+ let p = d.toString();
3035
+ if (p)
3036
+ for (let h of o)
3037
+ p.indexOf(h) > -1 && (r = h);
3038
+ });
3039
+ }
3040
+ r ? this.startRequest(t, {
3041
+ triggerKind: 2,
3042
+ isRetrigger: !!i,
3043
+ triggerCharacter: r,
3044
+ activeSignatureHelp: i ? i.data : void 0
3045
+ }) : i && n.selectionSet && (this.delayedRequest && clearTimeout(this.delayedRequest), this.delayedRequest = setTimeout(() => {
3046
+ this.startRequest(t, {
3047
+ triggerKind: 3,
3048
+ isRetrigger: !0,
3049
+ activeSignatureHelp: i.data
3050
+ });
3051
+ }, 250));
3052
+ }
3053
+ startRequest(n, e) {
3054
+ this.delayedRequest && clearTimeout(this.delayedRequest);
3055
+ let { view: t } = n, i = t.state.selection.main.head;
3056
+ this.activeRequest && (this.activeRequest.drop = !0);
3057
+ let r = this.activeRequest = { pos: i, drop: !1 };
3058
+ li(n, i, e).then((s) => {
3059
+ var o;
3060
+ if (!r.drop)
3061
+ if (s && s.signatures.length) {
3062
+ let l = t.state.field(q), u = l && oi(l.data, s), a = u && e.triggerKind == 3 ? l.active : (o = s.activeSignature) !== null && o !== void 0 ? o : 0;
3063
+ if (u && ai(l.data, s, a))
3064
+ return;
3065
+ t.dispatch({ effects: U.of({
3066
+ data: s,
3067
+ active: a,
3068
+ pos: u ? l.tooltip.pos : r.pos
3069
+ }) });
3070
+ } else t.state.field(q) && t.dispatch({ effects: U.of(null) });
3071
+ }, e.triggerKind == 1 ? (s) => n.reportError("Signature request failed", s) : void 0);
3072
+ }
3073
+ destroy() {
3074
+ this.delayedRequest && clearTimeout(this.delayedRequest), this.activeRequest && (this.activeRequest.drop = !0);
3075
+ }
3076
+ });
3077
+ function oi(n, e) {
3078
+ return n.signatures.length != e.signatures.length ? !1 : n.signatures.every((t, i) => t.label == e.signatures[i].label);
3079
+ }
3080
+ function ai(n, e, t) {
3081
+ var i, r;
3082
+ return ((i = n.signatures[t].activeParameter) !== null && i !== void 0 ? i : n.activeParameter) == ((r = e.signatures[t].activeParameter) !== null && r !== void 0 ? r : e.activeParameter);
3083
+ }
3084
+ class Ge {
3085
+ constructor(e, t, i) {
3086
+ this.data = e, this.active = t, this.tooltip = i;
3087
+ }
3088
+ }
3089
+ const q = /* @__PURE__ */ be.define({
3090
+ create() {
3091
+ return null;
3092
+ },
3093
+ update(n, e) {
3094
+ for (let t of e.effects)
3095
+ if (t.is(U))
3096
+ return t.value ? new Ge(t.value.data, t.value.active, ci(t.value.data, t.value.active, t.value.pos)) : null;
3097
+ return n && e.docChanged ? new Ge(n.data, n.active, { ...n.tooltip, pos: e.changes.mapPos(n.tooltip.pos) }) : n;
3098
+ },
3099
+ provide: (n) => Ct.from(n, (e) => e && e.tooltip)
3100
+ }), U = /* @__PURE__ */ I.define();
3101
+ function ci(n, e, t) {
3102
+ return {
3103
+ pos: t,
3104
+ above: !0,
3105
+ create: (i) => ui(i, n, e)
3106
+ };
3107
+ }
3108
+ function ui(n, e, t) {
3109
+ var i;
3110
+ let r = document.createElement("div");
3111
+ if (r.className = "cm-lsp-signature-tooltip", e.signatures.length > 1) {
3112
+ r.classList.add("cm-lsp-signature-multiple");
3113
+ let d = r.appendChild(document.createElement("div"));
3114
+ d.className = "cm-lsp-signature-num", d.textContent = `${t + 1}/${e.signatures.length}`;
3115
+ }
3116
+ let s = e.signatures[t], o = r.appendChild(document.createElement("div"));
3117
+ o.className = "cm-lsp-signature";
3118
+ let l = 0, u = 0, a = (i = s.activeParameter) !== null && i !== void 0 ? i : e.activeParameter, c = a != null && s.parameters ? s.parameters[a] : null;
3119
+ if (c && Array.isArray(c.label))
3120
+ [l, u] = c.label;
3121
+ else if (c) {
3122
+ let d = s.label.indexOf(c.label);
3123
+ d > -1 && (l = d, u = d + c.label.length);
3124
+ }
3125
+ if (u) {
3126
+ o.appendChild(document.createTextNode(s.label.slice(0, l)));
3127
+ let d = o.appendChild(document.createElement("span"));
3128
+ d.className = "cm-lsp-active-parameter", d.textContent = s.label.slice(l, u), o.appendChild(document.createTextNode(s.label.slice(u)));
3129
+ } else
3130
+ o.textContent = s.label;
3131
+ if (s.documentation) {
3132
+ let d = C.get(n);
3133
+ if (d) {
3134
+ let p = r.appendChild(document.createElement("div"));
3135
+ p.className = "cm-lsp-signature-documentation cm-lsp-documentation", p.innerHTML = d.docToHTML(s.documentation);
3136
+ }
3137
+ }
3138
+ return { dom: r };
3139
+ }
3140
+ const pi = (n) => {
3141
+ let e = n.plugin(ee);
3142
+ e || (n.dispatch({ effects: I.appendConfig.of([q, ee]) }), e = n.plugin(ee));
3143
+ let t = n.state.field(q);
3144
+ if (!e || t === void 0)
3145
+ return !1;
3146
+ let i = C.get(n);
3147
+ return i ? (e.startRequest(i, {
3148
+ triggerKind: 1,
3149
+ activeSignatureHelp: t ? t.data : void 0,
3150
+ isRetrigger: !!t
3151
+ }), !0) : !1;
3152
+ }, hi = (n) => {
3153
+ let e = n.state.field(q);
3154
+ return e ? (e.active < e.data.signatures.length - 1 && n.dispatch({ effects: U.of({ data: e.data, active: e.active + 1, pos: e.tooltip.pos }) }), !0) : !1;
3155
+ }, fi = (n) => {
3156
+ let e = n.state.field(q);
3157
+ return e ? (e.active > 0 && n.dispatch({ effects: U.of({ data: e.data, active: e.active - 1, pos: e.tooltip.pos }) }), !0) : !1;
3158
+ }, di = [
3159
+ { key: "Mod-Shift-Space", run: pi },
3160
+ { key: "Mod-Shift-ArrowUp", run: fi },
3161
+ { key: "Mod-Shift-ArrowDown", run: hi }
3162
+ ];
3163
+ function gi(n = {}) {
3164
+ return [
3165
+ q,
3166
+ ee,
3167
+ n.keymap === !1 ? [] : $t.high(We.of(di))
3168
+ ];
3169
+ }
3170
+ function mi(n, e) {
3171
+ return n.client.request("textDocument/definition", {
3172
+ textDocument: { uri: n.uri },
3173
+ position: n.toPosition(e)
3174
+ });
3175
+ }
3176
+ function ki(n, e) {
3177
+ const t = C.get(n);
3178
+ return !t || t.client.hasCapability(e.capability) === !1 ? !1 : (t.client.sync(), t.client.withMapping((i) => e.get(t, n.state.selection.main.head).then((r) => {
3179
+ let s = Array.isArray(r) ? r[0] : r;
3180
+ if (s)
3181
+ return (s.uri == t.uri ? Promise.resolve(n) : t.client.workspace.displayFile(s.uri)).then((o) => {
3182
+ if (!o)
3183
+ return;
3184
+ let l = i.getMapping(s.uri) ? i.mapPosition(s.uri, s.range.start) : t.fromPosition(s.range.start, o.state.doc);
3185
+ o.dispatch({ selection: { anchor: l }, scrollIntoView: !0, userEvent: "select.definition" });
3186
+ });
3187
+ }, (r) => t.reportError("Find definition failed", r))), !0);
3188
+ }
3189
+ const xi = (n) => ki(n, {
3190
+ get: mi,
3191
+ capability: "definitionProvider"
3192
+ }), bi = [
3193
+ { key: "F12", run: xi, preventDefault: !0 }
3194
+ ];
3195
+ function wi(n, e) {
3196
+ return n.client.request("textDocument/references", {
3197
+ textDocument: { uri: n.uri },
3198
+ position: n.toPosition(e),
3199
+ context: { includeDeclaration: !0 }
3200
+ });
3201
+ }
3202
+ const vi = (n) => {
3203
+ const e = C.get(n);
3204
+ if (!e || e.client.hasCapability("referencesProvider") === !1)
3205
+ return !1;
3206
+ e.client.sync();
3207
+ let t = e.client.workspaceMapping(), i = !1;
3208
+ return wi(e, n.state.selection.main.head).then((r) => {
3209
+ if (r)
3210
+ return Promise.all(r.map((s) => e.client.workspace.requestFile(s.uri).then((o) => o ? { file: o, range: s.range } : null))).then((s) => {
3211
+ let o = s.filter((l) => l);
3212
+ o.length && (yi(e.view, o, t), i = !0);
3213
+ });
3214
+ }, (r) => e.reportError("Finding references failed", r)).finally(() => {
3215
+ i || t.destroy();
3216
+ }), !0;
3217
+ }, ge = (n) => n.state.field(me, !1) ? (n.dispatch({ effects: De.of(null) }), !0) : !1, me = /* @__PURE__ */ be.define({
3218
+ create() {
3219
+ return null;
3220
+ },
3221
+ update(n, e) {
3222
+ for (let t of e.effects)
3223
+ if (t.is(De))
3224
+ return t.value;
3225
+ return n;
3226
+ },
3227
+ provide: (n) => Ke.from(n)
3228
+ }), De = /* @__PURE__ */ I.define();
3229
+ function yi(n, e, t) {
3230
+ let i = Si(e, t), r = n.state.field(me, !1) === void 0 ? I.appendConfig.of(me.init(() => i)) : De.of(i);
3231
+ n.dispatch({ effects: r });
3232
+ }
3233
+ function Si(n, e) {
3234
+ let t = !1;
3235
+ return setTimeout(() => {
3236
+ t || e.destroy();
3237
+ }, 500), (i) => {
3238
+ t = !0;
3239
+ let r = Ci(n.map((h) => h.file.uri)), s = document.createElement("div"), o = null;
3240
+ s.className = "cm-lsp-reference-panel", s.tabIndex = 0, s.role = "listbox", s.setAttribute("aria-label", i.state.phrase("Reference list"));
3241
+ let l = [];
3242
+ for (let { file: h, range: f } of n) {
3243
+ let g = h.uri.slice(r);
3244
+ if (g != o) {
3245
+ o = g;
3246
+ let M = s.appendChild(document.createElement("div"));
3247
+ M.className = "cm-lsp-reference-file", M.textContent = g;
3248
+ }
3249
+ let k = s.appendChild(document.createElement("div"));
3250
+ k.className = "cm-lsp-reference", k.role = "option";
3251
+ let y = e.mapPosition(h.uri, f.start, 1), S = e.mapPosition(h.uri, f.end, -1), m = h.getView(), v = (m ? m.state.doc : h.doc).lineAt(y), T = k.appendChild(document.createElement("span"));
3252
+ T.className = "cm-lsp-reference-line", T.textContent = (v.number + ": ").padStart(5, " ");
3253
+ let P = v.text.slice(Math.max(0, y - v.from - 50), y - v.from);
3254
+ P && k.appendChild(document.createTextNode(P)), k.appendChild(document.createElement("strong")).textContent = v.text.slice(y - v.from, S - v.from);
3255
+ let $ = v.text.slice(S - v.from, Math.min(v.length, 100 - P.length));
3256
+ $ && k.appendChild(document.createTextNode($)), l.length || k.setAttribute("aria-selected", "true"), l.push(k);
3257
+ }
3258
+ function u() {
3259
+ for (let h = 0; h < l.length; h++)
3260
+ if (l[h].hasAttribute("aria-selected"))
3261
+ return h;
3262
+ return 0;
3263
+ }
3264
+ function a(h) {
3265
+ for (let f = 0; f < l.length; f++)
3266
+ f == h ? l[f].setAttribute("aria-selected", "true") : l[f].removeAttribute("aria-selected");
3267
+ }
3268
+ function c(h) {
3269
+ let { file: f, range: g } = n[h], k = C.get(i);
3270
+ k && Promise.resolve(f.uri == k.uri ? i : k.client.workspace.displayFile(f.uri)).then((y) => {
3271
+ if (!y)
3272
+ return;
3273
+ let S = e.mapPosition(f.uri, g.start, 1);
3274
+ y.focus(), y.dispatch({
3275
+ selection: { anchor: S },
3276
+ scrollIntoView: !0
3277
+ });
3278
+ });
3279
+ }
3280
+ s.addEventListener("keydown", (h) => {
3281
+ if (h.keyCode == 27)
3282
+ ge(i), i.focus();
3283
+ else if (h.keyCode == 38 || h.keyCode == 33)
3284
+ a((u() - 1 + n.length) % n.length);
3285
+ else if (h.keyCode == 40 || h.keyCode == 34)
3286
+ a((u() + 1) % n.length);
3287
+ else if (h.keyCode == 36)
3288
+ a(0);
3289
+ else if (h.keyCode == 35)
3290
+ a(l.length - 1);
3291
+ else if (h.keyCode == 13 || h.keyCode == 10)
3292
+ c(u());
3293
+ else
3294
+ return;
3295
+ h.preventDefault();
3296
+ }), s.addEventListener("click", (h) => {
3297
+ for (let f = 0; f < l.length; f++)
3298
+ l[f].contains(h.target) && (a(f), c(f), h.preventDefault());
3299
+ });
3300
+ let d = document.createElement("div");
3301
+ d.appendChild(s);
3302
+ let p = d.appendChild(document.createElement("button"));
3303
+ return p.className = "cm-dialog-close", p.textContent = "×", p.addEventListener("click", () => ge(i)), p.setAttribute("aria-label", i.state.phrase("close")), {
3304
+ dom: d,
3305
+ destroy: () => e.destroy(),
3306
+ mount: () => s.focus()
3307
+ };
3308
+ };
3309
+ }
3310
+ function Ci(n) {
3311
+ let e = n[0], t = e.length;
3312
+ for (let i = 1; i < n.length; i++) {
3313
+ let r = n[i], s = 0;
3314
+ for (let o = Math.min(t, r.length); s < o && e[s] == r[s]; s++)
3315
+ ;
3316
+ t = s;
3317
+ }
3318
+ for (; t && e[t - 1] != "/"; )
3319
+ t--;
3320
+ return t;
3321
+ }
3322
+ const Ri = [
3323
+ { key: "Shift-F12", run: vi, preventDefault: !0 },
3324
+ { key: "Escape", run: ge }
3325
+ ];
3326
+ function Ti(n) {
3327
+ return n == 1 ? "error" : n == 2 ? "warning" : n == 3 ? "info" : "hint";
3328
+ }
3329
+ const Pi = /* @__PURE__ */ ke.fromClass(class {
3330
+ constructor() {
3331
+ this.pending = -1;
3332
+ }
3333
+ update(n) {
3334
+ n.docChanged && (this.pending > -1 && clearTimeout(this.pending), this.pending = setTimeout(() => {
3335
+ this.pending = -1;
3336
+ let e = C.get(n.view);
3337
+ e && e.client.sync();
3338
+ }, 500));
3339
+ }
3340
+ destroy() {
3341
+ this.pending > -1 && clearTimeout(this.pending);
3342
+ }
3343
+ });
3344
+ function $i() {
3345
+ return {
3346
+ clientCapabilities: { textDocument: { publishDiagnostics: { versionSupport: !0 } } },
3347
+ notificationHandlers: {
3348
+ "textDocument/publishDiagnostics": (n, e) => {
3349
+ let t = n.workspace.getFile(e.uri);
3350
+ if (!t || e.version != null && e.version != t.version)
3351
+ return !1;
3352
+ const i = t.getView(), r = i && C.get(i);
3353
+ return !i || !r ? !1 : (i.dispatch(kn(i.state, e.diagnostics.map((s) => {
3354
+ var o;
3355
+ return {
3356
+ from: r.unsyncedChanges.mapPos(r.fromPosition(s.range.start, r.syncedDoc)),
3357
+ to: r.unsyncedChanges.mapPos(r.fromPosition(s.range.end, r.syncedDoc)),
3358
+ severity: Ti((o = s.severity) !== null && o !== void 0 ? o : 1),
3359
+ message: s.message
3360
+ };
3361
+ }))), !0);
3362
+ }
3363
+ },
3364
+ editorExtension: Pi
3365
+ };
3366
+ }
3367
+ function Ai() {
3368
+ return [
3369
+ Nn(),
3370
+ Wn(),
3371
+ We.of([...ti, ...si, ...bi, ...Ri]),
3372
+ gi(),
3373
+ $i()
3374
+ ];
3375
+ }
3376
+ let X;
3377
+ function qi() {
3378
+ if (X) return X;
3379
+ const n = new Worker(new URL(
3380
+ /* @vite-ignore */
3381
+ "/assets/tsgo-worker-BDQ8_wHH.js",
3382
+ import.meta.url
3383
+ ), {
3384
+ type: "module"
3385
+ }), e = /* @__PURE__ */ new Set();
3386
+ n.onmessage = (i) => {
3387
+ var r, s;
3388
+ if (typeof ((r = i.data) == null ? void 0 : r.lsp) == "string")
3389
+ for (const o of e) o(i.data.lsp);
3390
+ else (s = i.data) != null && s.failed && console.error("TypeScript language server didn't start:", i.data.failed);
3391
+ }, n.onerror = (i) => {
3392
+ console.error("TypeScript language server worker:", i.message);
3393
+ };
3394
+ const t = {
3395
+ send: (i) => n.postMessage({ lsp: i }),
3396
+ subscribe: (i) => e.add(i),
3397
+ unsubscribe: (i) => e.delete(i)
3398
+ };
3399
+ return X = new Bn({
3400
+ rootUri: "file:///",
3401
+ timeout: 3e4,
3402
+ extensions: Ai()
3403
+ }).connect(t), X;
3404
+ }
3405
+ export {
3406
+ qi as typescriptLanguageServer
3407
+ };
3408
+ //# sourceMappingURL=typescript-language-server-oTU8pKzb.js.map