UNPKG

vue-renderer-markdown-monaco

Version:

A Vue 3 component that renders Markdown string content as HTML, supporting custom components and advanced markdown features.

1,672 lines 4.72 MB
var Zee = Object.defineProperty, Yee = Object.defineProperties; var Xee = Object.getOwnPropertyDescriptors; var J0 = Object.getOwnPropertySymbols, Qee = Object.getPrototypeOf, r8 = Object.prototype.hasOwnProperty, a8 = Object.prototype.propertyIsEnumerable, Jee = Reflect.get; var XC = (s, e) => (e = Symbol[s]) ? e : Symbol.for("Symbol." + s), ete = (s) => { throw TypeError(s); }, El = Math.pow, YT = (s, e, t) => e in s ? Zee(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, H = (s, e) => { for (var t in e || (e = {})) r8.call(e, t) && YT(s, t, e[t]); if (J0) for (var t of J0(e)) a8.call(e, t) && YT(s, t, e[t]); return s; }, ie = (s, e) => Yee(s, Xee(e)); var XT = (s, e) => { var t = {}; for (var i in s) r8.call(s, i) && e.indexOf(i) < 0 && (t[i] = s[i]); if (s != null && J0) for (var i of J0(s)) e.indexOf(i) < 0 && a8.call(s, i) && (t[i] = s[i]); return t; }; var ce = (s, e, t) => YT(s, typeof e != "symbol" ? e + "" : e, t); var l8 = (s, e, t) => Jee(Qee(s), t, e); var I = (s, e, t) => new Promise((i, n) => { var o = (l) => { try { a(t.next(l)); } catch (c) { n(c); } }, r = (l) => { try { a(t.throw(l)); } catch (c) { n(c); } }, a = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(o, r); a((t = t.apply(s, e)).next()); }), tte = function(s, e) { this[0] = s, this[1] = e; }; var QC = (s) => { var e = s[XC("asyncIterator")], t = !1, i, n = {}; return e == null ? (e = s[XC("iterator")](), i = (o) => n[o] = (r) => e[o](r)) : (e = e.call(s), i = (o) => n[o] = (r) => { if (t) { if (t = !1, o === "throw") throw r; return r; } return t = !0, { done: !1, value: new tte(new Promise((a) => { var l = e[o](r); l instanceof Object || ete("Object expected"), a(l); }), 1) }; }), n[XC("iterator")] = () => n, i("next"), "throw" in e ? i("throw") : n.throw = (o) => { throw o; }, "return" in e && i("return"), n; }, Wc = (s, e, t) => (e = s[XC("asyncIterator")]) ? e.call(s) : (s = s[XC("iterator")](), e = {}, t = (i, n) => (n = s[i]) && (e[i] = (o) => new Promise((r, a, l) => (o = n.call(s, o), l = o.done, Promise.resolve(o.value).then((c) => r({ value: c, done: l }), a)))), t("next"), t("return"), e); import { defineComponent as Ci, createElementBlock as lt, openBlock as ze, toDisplayString as eo, Fragment as io, renderList as Ro, createBlock as Bo, resolveDynamicComponent as ya, unref as Ni, createVNode as hs, ref as ls, createElementVNode as At, createCommentVNode as aj, onMounted as iE, watch as Vh, normalizeClass as Id, withCtx as b1, computed as sf, onUnmounted as ite, renderSlot as nte, nextTick as ste, normalizeStyle as ote } from "vue"; import { v4 as lj } from "uuid"; import cj from "katex"; import { useI18n as Y3 } from "vue-i18n"; import { useDark as rte, useThrottleFn as ate } from "@vueuse/core"; import { Icon as Lg } from "@iconify/vue"; import lte from "mermaid"; import { cva as cte } from "class-variance-authority"; import { Primitive as dte } from "radix-vue"; import { clsx as hte } from "clsx"; import { twMerge as ute } from "tailwind-merge"; import dj from "markdown-it"; import gte from "markdown-it-mathjax3"; import fte from "markdown-it-sub"; import pte from "markdown-it-sup"; import mte from "markdown-it-mark"; import { full as _te } from "markdown-it-emoji"; import bte from "markdown-it-ins"; import Cte from "markdown-it-task-checkbox"; import vte from "markdown-it-footnote"; import wte from "markdown-it-container"; const Ste = { class: "whitespace-pre-wrap break-normal", style: { "font-weight": "inherit" } }, Nd = Ci({ __name: "TextNode", props: { node: {} }, emits: ["copy"], setup(s) { const e = s; return (t, i) => (ze(), lt("span", Ste, eo(e.node.content), 1)); } }); Nd.install = (s) => { s.component(Nd.__name, Nd); }; let hj = null; function o0() { return hj; } function yte(s) { hj = s; } const Jv = Ci({ __name: "ParagraphNode", props: { node: {} }, setup(s) { const e = o0(); return (t, i) => (ze(), lt("p", null, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(Ni(e)[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }); Jv.install = (s) => { s.component(Jv.__name, Jv); }; const Lte = { class: "inline-block px-1 py-0.5 rounded text-xs font-mono bg-secondary before:content-[''] after:content-['']" }, Ed = Ci({ __name: "InlineCodeNode", props: { node: {} }, setup(s) { return (e, t) => (ze(), lt("code", Lte, eo(e.node.code), 1)); } }); Ed.install = (s) => { s.component(Ed.__name, Ed); }; const Qn = (s, e) => { const t = s.__vccOpts || s; for (const [i, n] of e) t[i] = n; return t; }, xte = ["href", "title"], kte = Ci({ __name: "LinkNode", props: { node: {} }, emits: ["copy"], setup(s) { return (e, t) => (ze(), lt("a", { class: "link-node", href: e.node.href, title: e.node.title || "", target: "_blank", rel: "noopener noreferrer" }, [ hs(Ni(Sa), { nodes: e.node.children, onCopy: t[0] || (t[0] = (i) => e.$emit("copy", i)) }, null, 8, ["nodes"]) ], 8, xte)); } }), Td = /* @__PURE__ */ Qn(kte, [["__scopeId", "data-v-8b20099e"]]); Td.install = (s) => { s.component(Td.__name, Td); }; const Dte = { class: "text-center my-4" }, Ite = ["src", "alt", "title"], Nte = { key: 0, class: "mt-2 text-sm text-gray-500 italic" }, z_ = Ci({ __name: "ImageNode", props: { node: {} }, setup(s) { const e = ls(!1), t = ls(!1); function i() { t.value = !0; } function n() { e.value = !0; } return (o, r) => (ze(), lt("figure", Dte, [ At("img", { class: "max-w-96 h-auto rounded-lg", src: o.node.src, alt: o.node.alt, title: o.node.title || o.node.alt, onError: i, onLoad: n }, null, 40, Ite), o.node.alt ? (ze(), lt("figcaption", Nte, eo(o.node.alt), 1)) : aj("", !0) ])); } }); z_.install = (s) => { s.component(z_.__name, z_); }; const Ete = { class: "strong-node" }, Tte = Ci({ __name: "StrongNode", props: { node: {} }, setup(s) { const e = o0(); return (t, i) => (ze(), lt("strong", Ete, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(Ni(e)[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), Rd = /* @__PURE__ */ Qn(Tte, [["__scopeId", "data-v-80635e1c"]]); Rd.install = (s) => { s.component(Rd.__name, Rd); }; const Rte = { class: "strikethrough-node" }, Mte = Ci({ __name: "StrikethroughNode", props: { node: {} }, setup(s) { const e = o0(); return (t, i) => (ze(), lt("del", Rte, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(Ni(e)[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), Md = /* @__PURE__ */ Qn(Mte, [["__scopeId", "data-v-0acbeccf"]]); Md.install = (s) => { s.component(Md.__name, Md); }; const Ate = { class: "subscript-node" }, Pte = Ci({ __name: "SubscriptNode", props: { node: {} }, setup(s) { const e = o0(); return (t, i) => (ze(), lt("sub", Ate, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(Ni(e)[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), Ad = /* @__PURE__ */ Qn(Pte, [["__scopeId", "data-v-49d625ea"]]); Ad.install = (s) => { s.component(Ad.__name, Ad); }; const Ote = { class: "superscript-node" }, Fte = Ci({ __name: "SuperscriptNode", props: { node: {} }, setup(s) { const e = o0(); return (t, i) => (ze(), lt("sup", Ote, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(Ni(e)[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), Pd = /* @__PURE__ */ Qn(Fte, [["__scopeId", "data-v-490b7261"]]); Pd.install = (s) => { s.component(Pd.__name, Pd); }; const Wte = { class: "emoji-node" }, Bte = Ci({ __name: "EmojiNode", props: { node: {} }, setup(s) { return (e, t) => (ze(), lt("span", Wte, eo(e.node.emoji), 1)); } }), Od = /* @__PURE__ */ Qn(Bte, [["__scopeId", "data-v-574a91fb"]]); Od.install = (s) => { s.component(Od.__name, Od); }; const Hte = ["title"], Vte = Ci({ __name: "FootnoteReferenceNode", props: { node: {} }, setup(s) { const t = `#footnote-${s.node.id}`; function i() { const n = document.querySelector(t); n ? n.scrollIntoView({ behavior: "smooth" }) : console.warn(`Element with href: ${t} not found`); } return (n, o) => (ze(), lt("sup", { class: "footnote-reference", onClick: i }, [ At("span", { href: t, title: `查看脚注 ${n.node.id}`, class: "footnote-link cursor-pointer" }, "[" + eo(n.node.id) + "]", 9, Hte) ])); } }), Fd = /* @__PURE__ */ Qn(Vte, [["__scopeId", "data-v-340dc096"]]); Fd.install = (s) => { s.component(Fd.__name, Fd); }; const Wd = Ci({ __name: "MathInlineNode", props: { node: {} }, setup(s) { const e = s, t = ls(null); function i() { if (!(!t.value || !e.node.content)) try { cj.render(e.node.content, t.value, { throwOnError: !1, displayMode: !1, output: "html" }); } catch (n) { console.error("KaTeX rendering error:", n), t.value.textContent = e.node.raw; } } return iE(() => { i(); }), Vh( () => e.node.content, () => { i(); } ), (n, o) => (ze(), lt("span", { ref_key: "mathElement", ref: t, class: "math-inline" }, null, 512)); } }); Wd.install = (s) => { s.component(Wd.__name, Wd); }; const zte = { class: "insert-node" }, Ute = Ci({ __name: "InsertNode", props: { node: {} }, setup(s) { const e = { text: Nd, inline_code: Ed, link: Td, strong: Rd, emphasis: ff, strikethrough: Md, highlight: nu, subscript: Ad, superscript: Pd, emoji: Od, footnote_reference: Fd, math_inline: Wd // reference: ReferenceNode }; return (t, i) => (ze(), lt("ins", zte, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(e[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), iu = /* @__PURE__ */ Qn(Ute, [["__scopeId", "data-v-0df8a784"]]); iu.install = (s) => { s.component(iu.__name, iu); }; const $te = { class: "highlight-node" }, jte = Ci({ __name: "HighlightNode", props: { node: {} }, setup(s) { const e = { text: Nd, inline_code: Ed, link: Td, strong: Rd, emphasis: ff, strikethrough: Md, insert: iu, subscript: Ad, superscript: Pd, emoji: Od, footnote_reference: Fd, math_inline: Wd // reference: ReferenceNode }; return (t, i) => (ze(), lt("mark", $te, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(e[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), nu = /* @__PURE__ */ Qn(jte, [["__scopeId", "data-v-f00ab1c4"]]); nu.install = (s) => { s.component(nu.__name, nu); }; const qte = { class: "emphasis-node" }, Kte = Ci({ __name: "EmphasisNode", props: { node: {} }, setup(s) { const e = { text: Nd, inline_code: Ed, link: Td, strong: Rd, strikethrough: Md, highlight: nu, insert: iu, subscript: Ad, superscript: Pd, emoji: Od, footnote_reference: Fd, math_inline: Wd // reference: ReferenceNode }; return (t, i) => (ze(), lt("em", qte, [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(e[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ])); } }), ff = /* @__PURE__ */ Qn(Kte, [["__scopeId", "data-v-f789330e"]]); ff.install = (s) => { s.component(ff.__name, ff); }; const Gte = { class: "checkbox-node" }, Zte = ["checked"], Yte = Ci({ __name: "CheckboxNode", props: { node: {} }, setup(s) { return (e, t) => (ze(), lt("span", Gte, [ At("input", { type: "checkbox", checked: e.node.checked, disabled: "", class: "checkbox-input" }, null, 8, Zte) ])); } }), U_ = /* @__PURE__ */ Qn(Yte, [["__scopeId", "data-v-52198b9c"]]); U_.install = (s) => { s.component(U_.__name, U_); }; const Xte = { class: "hard-break" }, Qte = Ci({ __name: "HardBreakNode", props: { node: {} }, setup(s) { return (e, t) => (ze(), lt("br", Xte)); } }), $_ = /* @__PURE__ */ Qn(Qte, [["__scopeId", "data-v-7be625c1"]]); $_.install = (s) => { s.component($_.__name, $_); }; const Jte = Ci({ __name: "HeadingNode", props: { node: {} }, setup(s) { const e = { text: Nd, inline_code: Ed, link: Td, image: z_, strong: Rd, emphasis: ff, strikethrough: Md, highlight: nu, insert: iu, subscript: Ad, superscript: Pd, emoji: Od, checkbox: U_, footnote_reference: Fd, hardbreak: $_, math_inline: Wd // reference: ReferenceNode // 添加其他内联元素组件 }; return (t, i) => (ze(), Bo(ya(`h${t.node.level}`), { class: Id(["heading-node", [`heading-${t.node.level}`]]) }, { default: b1(() => [ (ze(!0), lt(io, null, Ro(t.node.children, (n, o) => (ze(), Bo(ya(e[n.type]), { key: o, node: n }, null, 8, ["node"]))), 128)) ]), _: 1 }, 8, ["class"])); } }), ew = /* @__PURE__ */ Qn(Jte, [["__scopeId", "data-v-f011d008"]]); ew.install = (s) => { s.component(ew.__name, ew); }; const eie = [ ["bash", [/#!(\/usr)?\/bin\/bash/g, 500], [/\b(if|elif|then|fi|echo)\b|\$/g, 10]], ["html", [/<\/?[a-z-][^\n>]*>/g, 10], [/^\s+<!DOCTYPE\s+html/g, 500]], ["http", [/^(GET|HEAD|POST|PUT|DELETE|PATCH|HTTP)\b/g, 500]], [ "js", [ /\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require)\b/g, 10 ] ], [ "ts", [ /\b(console|await|async|function|export|import|this|class|for|let|const|map|join|require|implements|interface|namespace)\b/g, 10 ] ], ["py", [/\b(def|print|class|and|or|lambda)\b/g, 10]], ["sql", [/\b(SELECT|INSERT|FROM)\b/g, 50]], ["pl", [/#!(\/usr)?\/bin\/perl/g, 500], [/\b(use|print)\b|\$/g, 10]], ["lua", [/#!(\/usr)?\/bin\/lua/g, 500]], ["make", [/\b(ifneq|endif|if|elif|then|fi|echo|.PHONY|^[a-z]+ ?:$)\b|\$/gm, 10]], ["uri", [/https?:|mailto:|tel:|ftp:/g, 30]], ["css", [/^(@import|@page|@media|(\.|#)[a-z]+)/gm, 20]], ["diff", [/^[+><-]/gm, 10], [/^@@[-+,0-9 ]+@@/gm, 25]], ["md", [/^(>|\t\*|\t\d+.|#{1,6} |-\s+|\*\s+)/gm, 25], [/\[.*\](.*)/g, 10]], ["docker", [/^(FROM|ENTRYPOINT|RUN)/gm, 500]], ["xml", [/<\/?[a-z-][^\n>]*>/g, 10], [/^<\?xml/g, 500]], ["c", [/#include\b|\bprintf\s+\(/g, 100]], ["rs", [/^\s+(use|fn|mut|match)\b/gm, 100]], ["go", [/\b(func|fmt|package)\b/g, 100]], ["java", [/^import\s+java/gm, 500]], ["asm", [/^(section|global main|extern|\t(call|mov|ret))/gm, 100]], ["css", [/^(@import|@page|@media|(\.|#)[a-z]+)/gm, 20]], ["json", [/\b(true|false|null|\{\})\b|"[^"]+":/g, 10]], ["yaml", [/^(\s+)?[a-z][a-z0-9]*:/gim, 10]], ["toml", [/^\s*\[.*\]\s*$/gm, 100], [/^\s*[\w-]+ *= */gm, 20]], [ "mermaid", [ /^(graph|flowchart|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|mindmap)/gm, 500 ], [/\b(-->|--o|--x|=>|\[\]|[{}])\b/g, 10] ] ]; function tie(s) { var e; return ((e = eie.map( ([t, ...i]) => [ t, i.reduce( (n, [o, r]) => n + [...s.matchAll(o)].length * r, 0 ) ] ).filter(([, t]) => t > 20).sort((t, i) => i[1] - t[1])[0]) == null ? void 0 : e[0]) || "plain"; } function iie(s) { switch (s) { case "javascript": case "js": return "vscode-icons:file-type-js-official"; case "typescript": case "ts": return "vscode-icons:file-type-typescript"; case "jsx": return "vscode-icons:file-type-reactjs"; case "tsx": return "vscode-icons:file-type-reactts"; case "html": return "vscode-icons:file-type-html"; case "css": return "vscode-icons:file-type-css"; case "scss": return "vscode-icons:file-type-scss"; case "json": return "vscode-icons:file-type-json"; case "python": case "py": return "vscode-icons:file-type-python"; case "ruby": case "rb": return "vscode-icons:file-type-ruby"; case "go": case "golang": return "vscode-icons:file-type-go"; case "r": return "vscode-icons:file-type-r"; case "java": return "vscode-icons:file-type-java"; case "kotlin": case "kt": return "vscode-icons:file-type-kotlin"; case "c": return "vscode-icons:file-type-c"; case "cpp": case "c++": return "vscode-icons:file-type-cpp"; case "cs": case "csharp": return "vscode-icons:file-type-csharp"; case "php": return "vscode-icons:file-type-php"; case "scala": return "vscode-icons:file-type-scala"; case "shell": case "sh": case "bash": case "zsh": case "powershell": case "ps1": case "bat": case "batch": return "vscode-icons:file-type-powershell"; case "sql": return "vscode-icons:file-type-sql"; case "yaml": case "yml": return "vscode-icons:file-type-yaml"; case "markdown": case "md": return "vscode-icons:file-type-markdown"; case "xml": return "vscode-icons:file-type-xml"; case "rust": case "rs": return "vscode-icons:file-type-rust"; case "swift": return "vscode-icons:file-type-swift"; case "perl": return "vscode-icons:file-type-perl"; case "lua": return "vscode-icons:file-type-lua"; case "haskell": return "vscode-icons:file-type-haskell"; case "erlang": return "vscode-icons:file-type-erlang"; case "clojure": return "vscode-icons:file-type-clojure"; case "vue": return "vscode-icons:file-type-vue"; case "svg": return "vscode-icons:file-type-svg"; case "mermaid": return "vscode-icons:file-type-mermaid"; // Or 'mdi:graph' if mermaid icon missing case "dart": return "vscode-icons:file-type-dartlang"; case "assembly": return "vscode-icons:file-type-assembly"; case "dockerfile": return "vscode-icons:file-type-docker"; case "fortran": return "vscode-icons:file-type-fortran"; case "lisp": return "vscode-icons:file-type-lisp"; case "ocaml": return "vscode-icons:file-type-ocaml"; case "prolog": return "vscode-icons:file-type-prolog"; case "groovy": return "vscode-icons:file-type-groovy"; case "matlab": return "vscode-icons:file-type-matlab"; case "cobol": return "vscode-icons:file-type-cobol"; case "ada": return "vscode-icons:file-type-ada"; case "julia": return "vscode-icons:file-type-julia"; case "elixir": return "vscode-icons:file-type-elixir"; case "vb.net": return "vscode-icons:file-type-vb"; case "nim": return "vscode-icons:file-type-nim"; case "crystal": return "vscode-icons:file-type-crystal"; case "d": return "vscode-icons:file-type-dlang"; case "applescript": return "vscode-icons:file-type-applescript"; case "solidity": return "vscode-icons:file-type-solidity"; case "objectivec": return "vscode-icons:file-type-objectivec"; case "objectivecpp": return "vscode-icons:file-type-objectivecpp"; case "terraform": return "vscode-icons:file-type-terraform"; case "plain": case "text": return "vscode-icons:file-type-text"; // Icon for plain text default: return "lucide:square-code"; } } function nie(s) { return X3(s); } function X3(s) { return Array.isArray(s) ? sie(s) : s instanceof RegExp ? s : typeof s == "object" ? oie(s) : s; } function sie(s) { let e = []; for (let t = 0, i = s.length; t < i; t++) e[t] = X3(s[t]); return e; } function oie(s) { let e = {}; for (let t in s) e[t] = X3(s[t]); return e; } function uj(s, ...e) { return e.forEach((t) => { for (let i in t) s[i] = t[i]; }), s; } function gj(s) { const e = ~s.lastIndexOf("/") || ~s.lastIndexOf("\\"); return e === 0 ? s : ~e === s.length - 1 ? gj(s.substring(0, s.length - 1)) : s.substr(~e + 1); } var QT = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g, ey = class { static hasCaptures(s) { return s === null ? !1 : (QT.lastIndex = 0, QT.test(s)); } static replaceCaptures(s, e, t) { return s.replace(QT, (i, n, o, r) => { let a = t[parseInt(n || o, 10)]; if (a) { let l = e.substring(a.start, a.end); for (; l[0] === "."; ) l = l.substring(1); switch (r) { case "downcase": return l.toLowerCase(); case "upcase": return l.toUpperCase(); default: return l; } } else return i; }); } }; function fj(s, e) { return s < e ? -1 : s > e ? 1 : 0; } function pj(s, e) { if (s === null && e === null) return 0; if (!s) return -1; if (!e) return 1; let t = s.length, i = e.length; if (t === i) { for (let n = 0; n < t; n++) { let o = fj(s[n], e[n]); if (o !== 0) return o; } return 0; } return t - i; } function c8(s) { return !!(/^#[0-9a-f]{6}$/i.test(s) || /^#[0-9a-f]{8}$/i.test(s) || /^#[0-9a-f]{3}$/i.test(s) || /^#[0-9a-f]{4}$/i.test(s)); } function mj(s) { return s.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, "\\$&"); } var _j = class { constructor(s) { ce(this, "cache", /* @__PURE__ */ new Map()); this.fn = s; } get(s) { if (this.cache.has(s)) return this.cache.get(s); const e = this.fn(s); return this.cache.set(s, e), e; } }, ax = class { constructor(s, e, t) { ce(this, "_cachedMatchRoot", new _j( (s) => this._root.match(s) )); this._colorMap = s, this._defaults = e, this._root = t; } static createFromRawTheme(s, e) { return this.createFromParsedTheme(lie(s), e); } static createFromParsedTheme(s, e) { return die(s, e); } getColorMap() { return this._colorMap.getColorMap(); } getDefaults() { return this._defaults; } match(s) { if (s === null) return this._defaults; const e = s.scopeName, i = this._cachedMatchRoot.get(e).find( (n) => rie(s.parent, n.parentScopes) ); return i ? new bj( i.fontStyle, i.foreground, i.background ) : null; } }, JT = class _L { constructor(e, t) { this.parent = e, this.scopeName = t; } static push(e, t) { for (const i of t) e = new _L(e, i); return e; } static from(...e) { let t = null; for (let i = 0; i < e.length; i++) t = new _L(t, e[i]); return t; } push(e) { return new _L(this, e); } getSegments() { let e = this; const t = []; for (; e; ) t.push(e.scopeName), e = e.parent; return t.reverse(), t; } toString() { return this.getSegments().join(" "); } extends(e) { return this === e ? !0 : this.parent === null ? !1 : this.parent.extends(e); } getExtensionIfDefined(e) { const t = []; let i = this; for (; i && i !== e; ) t.push(i.scopeName), i = i.parent; return i === e ? t.reverse() : void 0; } }; function rie(s, e) { if (e.length === 0) return !0; for (let t = 0; t < e.length; t++) { let i = e[t], n = !1; if (i === ">") { if (t === e.length - 1) return !1; i = e[++t], n = !0; } for (; s && !aie(s.scopeName, i); ) { if (n) return !1; s = s.parent; } if (!s) return !1; s = s.parent; } return !0; } function aie(s, e) { return e === s || s.startsWith(e) && s[e.length] === "."; } var bj = class { constructor(s, e, t) { this.fontStyle = s, this.foregroundId = e, this.backgroundId = t; } }; function lie(s) { if (!s) return []; if (!s.settings || !Array.isArray(s.settings)) return []; let e = s.settings, t = [], i = 0; for (let n = 0, o = e.length; n < o; n++) { let r = e[n]; if (!r.settings) continue; let a; if (typeof r.scope == "string") { let h = r.scope; h = h.replace(/^[,]+/, ""), h = h.replace(/[,]+$/, ""), a = h.split(","); } else Array.isArray(r.scope) ? a = r.scope : a = [""]; let l = -1; if (typeof r.settings.fontStyle == "string") { l = 0; let h = r.settings.fontStyle.split(" "); for (let u = 0, g = h.length; u < g; u++) switch (h[u]) { case "italic": l = l | 1; break; case "bold": l = l | 2; break; case "underline": l = l | 4; break; case "strikethrough": l = l | 8; break; } } let c = null; typeof r.settings.foreground == "string" && c8(r.settings.foreground) && (c = r.settings.foreground); let d = null; typeof r.settings.background == "string" && c8(r.settings.background) && (d = r.settings.background); for (let h = 0, u = a.length; h < u; h++) { let f = a[h].trim().split(" "), m = f[f.length - 1], _ = null; f.length > 1 && (_ = f.slice(0, f.length - 1), _.reverse()), t[i++] = new cie( m, _, n, l, c, d ); } } return t; } var cie = class { constructor(s, e, t, i, n, o) { this.scope = s, this.parentScopes = e, this.index = t, this.fontStyle = i, this.foreground = n, this.background = o; } }, Js = /* @__PURE__ */ ((s) => (s[s.NotSet = -1] = "NotSet", s[s.None = 0] = "None", s[s.Italic = 1] = "Italic", s[s.Bold = 2] = "Bold", s[s.Underline = 4] = "Underline", s[s.Strikethrough = 8] = "Strikethrough", s))(Js || {}); function die(s, e) { s.sort((l, c) => { let d = fj(l.scope, c.scope); return d !== 0 || (d = pj(l.parentScopes, c.parentScopes), d !== 0) ? d : l.index - c.index; }); let t = 0, i = "#000000", n = "#ffffff"; for (; s.length >= 1 && s[0].scope === ""; ) { let l = s.shift(); l.fontStyle !== -1 && (t = l.fontStyle), l.foreground !== null && (i = l.foreground), l.background !== null && (n = l.background); } let o = new hie(e), r = new bj(t, o.getId(i), o.getId(n)), a = new gie(new p2(0, null, -1, 0, 0), []); for (let l = 0, c = s.length; l < c; l++) { let d = s[l]; a.insert(0, d.scope, d.parentScopes, d.fontStyle, o.getId(d.foreground), o.getId(d.background)); } return new ax(o, r, a); } var hie = class { constructor(e) { ce(this, "_isFrozen"); ce(this, "_lastColorId"); ce(this, "_id2color"); ce(this, "_color2id"); if (this._lastColorId = 0, this._id2color = [], this._color2id = /* @__PURE__ */ Object.create(null), Array.isArray(e)) { this._isFrozen = !0; for (let t = 0, i = e.length; t < i; t++) this._color2id[e[t]] = t, this._id2color[t] = e[t]; } else this._isFrozen = !1; } getId(e) { if (e === null) return 0; e = e.toUpperCase(); let t = this._color2id[e]; if (t) return t; if (this._isFrozen) throw new Error(`Missing color in color map - ${e}`); return t = ++this._lastColorId, this._color2id[e] = t, this._id2color[t] = e, t; } getColorMap() { return this._id2color.slice(0); } }, uie = Object.freeze([]), p2 = class Cj { constructor(e, t, i, n, o) { ce(this, "scopeDepth"); ce(this, "parentScopes"); ce(this, "fontStyle"); ce(this, "foreground"); ce(this, "background"); this.scopeDepth = e, this.parentScopes = t || uie, this.fontStyle = i, this.foreground = n, this.background = o; } clone() { return new Cj(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background); } static cloneArr(e) { let t = []; for (let i = 0, n = e.length; i < n; i++) t[i] = e[i].clone(); return t; } acceptOverwrite(e, t, i, n) { this.scopeDepth > e ? console.log("how did this happen?") : this.scopeDepth = e, t !== -1 && (this.fontStyle = t), i !== 0 && (this.foreground = i), n !== 0 && (this.background = n); } }, gie = class m2 { constructor(e, t = [], i = {}) { ce(this, "_rulesWithParentScopes"); this._mainRule = e, this._children = i, this._rulesWithParentScopes = t; } static _cmpBySpecificity(e, t) { if (e.scopeDepth !== t.scopeDepth) return t.scopeDepth - e.scopeDepth; let i = 0, n = 0; for (; e.parentScopes[i] === ">" && i++, t.parentScopes[n] === ">" && n++, !(i >= e.parentScopes.length || n >= t.parentScopes.length); ) { const o = t.parentScopes[n].length - e.parentScopes[i].length; if (o !== 0) return o; i++, n++; } return t.parentScopes.length - e.parentScopes.length; } match(e) { if (e !== "") { let i = e.indexOf("."), n, o; if (i === -1 ? (n = e, o = "") : (n = e.substring(0, i), o = e.substring(i + 1)), this._children.hasOwnProperty(n)) return this._children[n].match(o); } const t = this._rulesWithParentScopes.concat(this._mainRule); return t.sort(m2._cmpBySpecificity), t; } insert(e, t, i, n, o, r) { if (t === "") { this._doInsertHere(e, i, n, o, r); return; } let a = t.indexOf("."), l, c; a === -1 ? (l = t, c = "") : (l = t.substring(0, a), c = t.substring(a + 1)); let d; this._children.hasOwnProperty(l) ? d = this._children[l] : (d = new m2(this._mainRule.clone(), p2.cloneArr(this._rulesWithParentScopes)), this._children[l] = d), d.insert(e + 1, c, i, n, o, r); } _doInsertHere(e, t, i, n, o) { if (t === null) { this._mainRule.acceptOverwrite(e, i, n, o); return; } for (let r = 0, a = this._rulesWithParentScopes.length; r < a; r++) { let l = this._rulesWithParentScopes[r]; if (pj(l.parentScopes, t) === 0) { l.acceptOverwrite(e, i, n, o); return; } } i === -1 && (i = this._mainRule.fontStyle), n === 0 && (n = this._mainRule.foreground), o === 0 && (o = this._mainRule.background), this._rulesWithParentScopes.push(new p2(e, t, i, n, o)); } }, xp = class sa { static toBinaryStr(e) { return e.toString(2).padStart(32, "0"); } static print(e) { const t = sa.getLanguageId(e), i = sa.getTokenType(e), n = sa.getFontStyle(e), o = sa.getForeground(e), r = sa.getBackground(e); console.log({ languageId: t, tokenType: i, fontStyle: n, foreground: o, background: r }); } static getLanguageId(e) { return (e & 255) >>> 0; } static getTokenType(e) { return (e & 768) >>> 8; } static containsBalancedBrackets(e) { return (e & 1024) !== 0; } static getFontStyle(e) { return (e & 30720) >>> 11; } static getForeground(e) { return (e & 16744448) >>> 15; } static getBackground(e) { return (e & 4278190080) >>> 24; } /** * Updates the fields in `metadata`. * A value of `0`, `NotSet` or `null` indicates that the corresponding field should be left as is. */ static set(e, t, i, n, o, r, a) { let l = sa.getLanguageId(e), c = sa.getTokenType(e), d = sa.containsBalancedBrackets(e) ? 1 : 0, h = sa.getFontStyle(e), u = sa.getForeground(e), g = sa.getBackground(e); return t !== 0 && (l = t), i !== 8 && (c = i), n !== null && (d = n ? 1 : 0), o !== -1 && (h = o), r !== 0 && (u = r), a !== 0 && (g = a), (l << 0 | c << 8 | d << 10 | h << 11 | u << 15 | g << 24) >>> 0; } }; function lx(s, e) { const t = [], i = fie(s); let n = i.next(); for (; n !== null; ) { let l = 0; if (n.length === 2 && n.charAt(1) === ":") { switch (n.charAt(0)) { case "R": l = 1; break; case "L": l = -1; break; default: console.log(`Unknown priority ${n} in scope selector`); } n = i.next(); } let c = r(); if (t.push({ matcher: c, priority: l }), n !== ",") break; n = i.next(); } return t; function o() { if (n === "-") { n = i.next(); const l = o(); return (c) => !!l && !l(c); } if (n === "(") { n = i.next(); const l = a(); return n === ")" && (n = i.next()), l; } if (d8(n)) { const l = []; do l.push(n), n = i.next(); while (d8(n)); return (c) => e(l, c); } return null; } function r() { const l = []; let c = o(); for (; c; ) l.push(c), c = o(); return (d) => l.every((h) => h(d)); } function a() { const l = []; let c = r(); for (; c && (l.push(c), n === "|" || n === ","); ) { do n = i.next(); while (n === "|" || n === ","); c = r(); } return (d) => l.some((h) => h(d)); } } function d8(s) { return !!s && !!s.match(/[\w\.:]+/); } function fie(s) { let e = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g, t = e.exec(s); return { next: () => { if (!t) return null; const i = t[0]; return t = e.exec(s), i; } }; } function vj(s) { typeof s.dispose == "function" && s.dispose(); } var C1 = class { constructor(s) { this.scopeName = s; } toKey() { return this.scopeName; } }, pie = class { constructor(s, e) { this.scopeName = s, this.ruleName = e; } toKey() { return `${this.scopeName}#${this.ruleName}`; } }, mie = class { constructor() { ce(this, "_references", []); ce(this, "_seenReferenceKeys", /* @__PURE__ */ new Set()); ce(this, "visitedRule", /* @__PURE__ */ new Set()); } get references() { return this._references; } add(s) { const e = s.toKey(); this._seenReferenceKeys.has(e) || (this._seenReferenceKeys.add(e), this._references.push(s)); } }, _ie = class { constructor(s, e) { ce(this, "seenFullScopeRequests", /* @__PURE__ */ new Set()); ce(this, "seenPartialScopeRequests", /* @__PURE__ */ new Set()); ce(this, "Q"); this.repo = s, this.initialScopeName = e, this.seenFullScopeRequests.add(this.initialScopeName), this.Q = [new C1(this.initialScopeName)]; } processQueue() { const s = this.Q; this.Q = []; const e = new mie(); for (const t of s) bie(t, this.initialScopeName, this.repo, e); for (const t of e.references) if (t instanceof C1) { if (this.seenFullScopeRequests.has(t.scopeName)) continue; this.seenFullScopeRequests.add(t.scopeName), this.Q.push(t); } else { if (this.seenFullScopeRequests.has(t.scopeName) || this.seenPartialScopeRequests.has(t.toKey())) continue; this.seenPartialScopeRequests.add(t.toKey()), this.Q.push(t); } } }; function bie(s, e, t, i) { const n = t.lookup(s.scopeName); if (!n) { if (s.scopeName === e) throw new Error(`No grammar provided for <${e}>`); return; } const o = t.lookup(e); s instanceof C1 ? bL({ baseGrammar: o, selfGrammar: n }, i) : _2( s.ruleName, { baseGrammar: o, selfGrammar: n, repository: n.repository }, i ); const r = t.injections(s.scopeName); if (r) for (const a of r) i.add(new C1(a)); } function _2(s, e, t) { if (e.repository && e.repository[s]) { const i = e.repository[s]; cx([i], e, t); } } function bL(s, e) { s.selfGrammar.patterns && Array.isArray(s.selfGrammar.patterns) && cx( s.selfGrammar.patterns, ie(H({}, s), { repository: s.selfGrammar.repository }), e ), s.selfGrammar.injections && cx( Object.values(s.selfGrammar.injections), ie(H({}, s), { repository: s.selfGrammar.repository }), e ); } function cx(s, e, t) { for (const i of s) { if (t.visitedRule.has(i)) continue; t.visitedRule.add(i); const n = i.repository ? uj({}, e.repository, i.repository) : e.repository; Array.isArray(i.patterns) && cx(i.patterns, ie(H({}, e), { repository: n }), t); const o = i.include; if (!o) continue; const r = wj(o); switch (r.kind) { case 0: bL(ie(H({}, e), { selfGrammar: e.baseGrammar }), t); break; case 1: bL(e, t); break; case 2: _2(r.ruleName, ie(H({}, e), { repository: n }), t); break; case 3: case 4: const a = r.scopeName === e.selfGrammar.scopeName ? e.selfGrammar : r.scopeName === e.baseGrammar.scopeName ? e.baseGrammar : void 0; if (a) { const l = { baseGrammar: e.baseGrammar, selfGrammar: a, repository: n }; r.kind === 4 ? _2(r.ruleName, l, t) : bL(l, t); } else r.kind === 4 ? t.add(new pie(r.scopeName, r.ruleName)) : t.add(new C1(r.scopeName)); break; } } } var Cie = class { constructor() { ce(this, "kind", 0); } }, vie = class { constructor() { ce(this, "kind", 1); } }, wie = class { constructor(s) { ce(this, "kind", 2); this.ruleName = s; } }, Sie = class { constructor(s) { ce(this, "kind", 3); this.scopeName = s; } }, yie = class { constructor(s, e) { ce(this, "kind", 4); this.scopeName = s, this.ruleName = e; } }; function wj(s) { if (s === "$base") return new Cie(); if (s === "$self") return new vie(); const e = s.indexOf("#"); if (e === -1) return new Sie(s); if (e === 0) return new wie(s.substring(1)); { const t = s.substring(0, e), i = s.substring(e + 1); return new yie(t, i); } } var Lie = /\\(\d+)/, h8 = /\\(\d+)/g, xie = -1, Sj = -2; var r0 = class { constructor(e, t, i, n) { ce(this, "$location"); ce(this, "id"); ce(this, "_nameIsCapturing"); ce(this, "_name"); ce(this, "_contentNameIsCapturing"); ce(this, "_contentName"); this.$location = e, this.id = t, this._name = i || null, this._nameIsCapturing = ey.hasCaptures(this._name), this._contentName = n || null, this._contentNameIsCapturing = ey.hasCaptures(this._contentName); } get debugName() { const e = this.$location ? `${gj(this.$location.filename)}:${this.$location.line}` : "unknown"; return `${this.constructor.name}#${this.id} @ ${e}`; } getName(e, t) { return !this._nameIsCapturing || this._name === null || e === null || t === null ? this._name : ey.replaceCaptures(this._name, e, t); } getContentName(e, t) { return !this._contentNameIsCapturing || this._contentName === null ? this._contentName : ey.replaceCaptures(this._contentName, e, t); } }, kie = class extends r0 { constructor(e, t, i, n, o) { super(e, t, i, n); ce(this, "retokenizeCapturedWithRuleId"); this.retokenizeCapturedWithRuleId = o; } dispose() { } collectPatterns(e, t) { throw new Error("Not supported!"); } compile(e, t) { throw new Error("Not supported!"); } compileAG(e, t, i, n) { throw new Error("Not supported!"); } }, Die = class extends r0 { constructor(e, t, i, n, o) { super(e, t, i, null); ce(this, "_match"); ce(this, "captures"); ce(this, "_cachedCompiledPatterns"); this._match = new v1(n, this.id), this.captures = o, this._cachedCompiledPatterns = null; } dispose() { this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null); } get debugMatchRegExp() { return `${this._match.source}`; } collectPatterns(e, t) { t.push(this._match); } compile(e, t) { return this._getCachedCompiledPatterns(e).compile(e); } compileAG(e, t, i, n) { return this._getCachedCompiledPatterns(e).compileAG(e, i, n); } _getCachedCompiledPatterns(e) { return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new w1(), this.collectPatterns(e, this._cachedCompiledPatterns)), this._cachedCompiledPatterns; } }, u8 = class extends r0 { constructor(e, t, i, n, o) { super(e, t, i, n); ce(this, "hasMissingPatterns"); ce(this, "patterns"); ce(this, "_cachedCompiledPatterns"); this.patterns = o.patterns, this.hasMissingPatterns = o.hasMissingPatterns, this._cachedCompiledPatterns = null; } dispose() { this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null); } collectPatterns(e, t) { for (const i of this.patterns) e.getRule(i).collectPatterns(e, t); } compile(e, t) { return this._getCachedCompiledPatterns(e).compile(e); } compileAG(e, t, i, n) { return this._getCachedCompiledPatterns(e).compileAG(e, i, n); } _getCachedCompiledPatterns(e) { return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new w1(), this.collectPatterns(e, this._cachedCompiledPatterns)), this._cachedCompiledPatterns; } }, b2 = class extends r0 { constructor(e, t, i, n, o, r, a, l, c, d) { super(e, t, i, n); ce(this, "_begin"); ce(this, "beginCaptures"); ce(this, "_end"); ce(this, "endHasBackReferences"); ce(this, "endCaptures"); ce(this, "applyEndPatternLast"); ce(this, "hasMissingPatterns"); ce(this, "patterns"); ce(this, "_cachedCompiledPatterns"); this._begin = new v1(o, this.id), this.beginCaptures = r, this._end = new v1(a || "￿", -1), this.endHasBackReferences = this._end.hasBackReferences, this.endCaptures = l, this.applyEndPatternLast = c || !1, this.patterns = d.patterns, this.hasMissingPatterns = d.hasMissingPatterns, this._cachedCompiledPatterns = null; } dispose() { this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null); } get debugBeginRegExp() { return `${this._begin.source}`; } get debugEndRegExp() { return `${this._end.source}`; } getEndWithResolvedBackReferences(e, t) { return this._end.resolveBackReferences(e, t); } collectPatterns(e, t) { t.push(this._begin); } compile(e, t) { return this._getCachedCompiledPatterns(e, t).compile(e); } compileAG(e, t, i, n) { return this._getCachedCompiledPatterns(e, t).compileAG(e, i, n); } _getCachedCompiledPatterns(e, t) { if (!this._cachedCompiledPatterns) { this._cachedCompiledPatterns = new w1(); for (const i of this.patterns) e.getRule(i).collectPatterns(e, this._cachedCompiledPatterns); this.applyEndPatternLast ? this._cachedCompiledPatterns.push(this._end.hasBackReferences ? this._end.clone() : this._end) : this._cachedCompiledPatterns.unshift(this._end.hasBackReferences ? this._end.clone() : this._end); } return this._end.hasBackReferences && (this.applyEndPatternLast ? this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length() - 1, t) : this._cachedCompiledPatterns.setSource(0, t)), this._cachedCompiledPatterns; } }, dx = class extends r0 { constructor(e, t, i, n, o, r, a, l, c) { super(e, t, i, n); ce(this, "_begin"); ce(this, "beginCaptures"); ce(this, "whileCaptures"); ce(this, "_while"); ce(this, "whileHasBackReferences"); ce(this, "hasMissingPatterns"); ce(this, "patterns"); ce(this, "_cachedCompiledPatterns"); ce(this, "_cachedCompiledWhilePatterns"); this._begin = new v1(o, this.id), this.beginCaptures = r, this.whileCaptures = l, this._while = new v1(a, Sj), this.whileHasBackReferences = this._while.hasBackReferences, this.patterns = c.patterns, this.hasMissingPatterns = c.hasMissingPatterns, this._cachedCompiledPatterns = null, this._cachedCompiledWhilePatterns = null; } dispose() { this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null), this._cachedCompiledWhilePatterns && (this._cachedCompiledWhilePatterns.dispose(), this._cachedCompiledWhilePatterns = null); } get debugBeginRegExp() { return `${this._begin.source}`; } get debugWhileRegExp() { return `${this._while.source}`; } getWhileWithResolvedBackReferences(e, t) { return this._while.resolveBackReferences(e, t); } collectPatterns(e, t) { t.push(this._begin); } compile(e, t) { return this._getCachedCompiledPatterns(e).compile(e); } compileAG(e, t, i, n) { return this._getCachedCompiledPatterns(e).compileAG(e, i, n); } _getCachedCompiledPatterns(e) { if (!this._cachedCompiledPatterns) { this._cachedCompiledPatterns = new w1(); for (const t of this.patterns) e.getRule(t).collectPatterns(e, this._cachedCompiledPatterns); } return this._cachedCompiledPatterns; } compileWhile(e, t) { return this._getCachedCompiledWhilePatterns(e, t).compile(e); } compileWhileAG(e, t, i, n) { return this._getCachedCompiledWhilePatterns(e, t).compileAG(e, i, n); } _getCachedCompiledWhilePatterns(e, t) { return this._cachedCompiledWhilePatterns || (this._cachedCompiledWhilePatterns = new w1(), this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences ? this._while.clone() : this._while)), this._while.hasBackReferences && this._cachedCompiledWhilePatterns.setSource(0, t || "￿"), this._cachedCompiledWhilePatterns; } }, yj = class qs { static createCaptureRule(e, t, i, n, o) { return e.registerRule((r) => new kie(t, r, i, n, o)); } static getCompiledRuleId(e, t, i) { return e.id || t.registerRule((n) => { if (e.id = n, e.match) return new Die( e.$vscodeTextmateLocation, e.id, e.name, e.match, qs._compileCaptures(e.captures, t, i) ); if (typeof e.begin == "undefined") { e.repository && (i = uj({}, i, e.repository)); let o = e.patterns; return typeof o == "undefined" && e.include && (o = [{ include: e.include }]), new u8( e.$vscodeTextmateLocation, e.id, e.name, e.contentName, qs._compilePatterns(o, t, i) ); } return e.while ? new dx( e.$vscodeTextmateLocation, e.id, e.name, e.contentName, e.begin, qs._compileCaptures(e.beginCaptures || e.captures, t, i), e.while, qs._compileCaptures(e.whileCaptures || e.captures, t, i), qs._compilePatterns(e.patterns, t, i) ) : new b2( e.$vscodeTextmateLocation, e.id, e.name, e.contentName, e.begin, qs._compileCaptures(e.beginCaptures || e.captures, t, i), e.end, qs._compileCaptures(e.endCaptures || e.captures, t, i), e.applyEndPatternLast, qs._compilePatterns(e.patterns, t, i) ); }), e.id; } static _compileCaptures(e, t, i) { let n = []; if (e) { let o = 0; for (const r in e) { if (r === "$vscodeTextmateLocation") continue; const a = parseInt(r, 10); a > o && (o = a); } for (let r = 0; r <= o; r++) n[r] = null; for (const r in e) { if (r === "$vscodeTextmateLocation") continue; const a = parseInt(r, 10); let l = 0; e[r].patterns && (l = qs.getCompiledRuleId(e[r], t, i)), n[a] = qs.createCaptureRule(t, e[r].$vscodeTextmateLocation, e[r].name, e[r].contentName, l); } } return n; } static _compilePatterns(e, t, i) { let n = []; if (e) for (let o = 0, r = e.length; o < r; o++) { const a = e[o]; let l = -1; if (a.include) { const c = wj(a.include); switch (c.kind) { case 0: case 1: l = qs.getCompiledRuleId(i[a.include], t, i); break; case 2: let d = i[c.ruleName]; d && (l = qs.getCompiledRuleId(d, t, i)); break; case 3: case 4: const h = c.scopeName, u = c.kind === 4 ? c.ruleName : null, g = t.getExternalGrammar(h, i); if (g) if (u) { let f = g.repository[u]; f && (l = qs.getCompiledRuleId(f, t, g.repository)); } else l = qs.getCompiledRuleId(g.repository.$self, t, g.repository); break; } } else l = qs.getCompiledRuleId(a, t, i); if (l !== -1) { const c = t.getRule(l); let d = !1; if ((c instanceof u8 || c instanceof b2 || c instanceof dx) && c.hasMissingPatterns && c.patterns.length === 0 && (d = !0), d) continue; n.push(l); } } return { patterns: n, hasMissingPatterns: (e ? e.length : 0) !== n.length }; } }, v1 = class Lj { constructor(e, t) { ce(this, "source"); ce(this, "ruleId"); ce(this, "hasAnchor"); ce(this, "hasBackReferences"); ce(this, "_anchorCache"); if (e && typeof e == "string") { const i = e.length; let n = 0, o = [], r = !1; for (let a = 0; a < i; a++) if (e.charAt(a) === "\\" && a + 1 < i) { const c = e.charAt(a + 1); c === "z" ? (o.push(e.substring(n, a)), o.push("$(?!\\n)(?<!\\n)"), n = a + 2) : (c === "A" || c === "G") && (r = !0), a++; } this.hasAnchor = r, n === 0 ? this.source = e : (o.push(e.substring(n, i)), this.source = o.join("")); } else this.hasAnchor = !1, this.source = e; this.hasAnchor ? this._anchorCache = this._buildAnchorCache() : this._anchorCache = null, this.ruleId = t, typeof this.source == "string" ? this.hasBackReferences = Lie.test(this.source) : this.hasBackReferences = !1; } c