SLOPSHOPPER

restyled-chat

Color themes and full-width code blocks for the Claude Code terminal

newrowstoasttimer
★ 1v?GPL-3.0-or-laterupdated 2026-10-13macwilk/cc-extensions/restyled-chat
A shopper browsing a rack in a slop shop
README

restyled-chat

The restyled-chat mod changes how the Claude Code terminal looks:

  • It adds color themes.
  • It draws each fenced code block in a reply as one full-width shaded block. The first row of the block shows the language and a copy button.
  • It colors the code in a block as VS Code colors it under the same theme, and a diff block from the diff colors of the theme.

<img src="../media/restyled-chat-before.png" alt="A prompt, an edit and a reply with a code block, in the dark theme of Claude Code with no mod" width="49%"> <img src="../media/themes/dracula.png" alt="The same conversation in the Dracula theme, with the code block shaded" width="49%">

Themes

Each preview shows the same conversation.

<img src="../media/themes/catppuccin-mocha.png" alt="The Catppuccin Mocha theme" width="49%"> <img src="../media/themes/dark-modern.png" alt="The Dark Modern theme" width="49%"> <img src="../media/themes/dracula.png" alt="The Dracula theme" width="49%"> <img src="../media/themes/github-dark.png" alt="The GitHub Dark theme" width="49%"> <img src="../media/themes/gruvbox-dark.png" alt="The Gruvbox Dark theme" width="49%"> <img src="../media/themes/monokai.png" alt="The Monokai theme" width="49%"> <img src="../media/themes/noctis-uva.png" alt="The Noctis Uva theme" width="49%"> <img src="../media/themes/nord.png" alt="The Nord theme" width="49%"> <img src="../media/themes/one-dark-pro.png" alt="The One Dark Pro theme" width="49%"> <img src="../media/themes/solarized-dark.png" alt="The Solarized Dark theme" width="49%"> <img src="../media/themes/tokyo-night.png" alt="The Tokyo Night theme" width="49%">

Code colors

The mod colors code with Shiki, which uses the grammars and the theme files of VS Code. Code takes the colors and the font styles that VS Code gives it under the theme of the same name.

Code keeps the colors of Claude Code in the following cases:

  • Shiki has no grammar for the language. Shiki has grammars for more than 200 languages.
  • Shiki has no theme of the same name as the Claude Code theme, for example under a built-in theme of Claude Code.
  • The block is too long to draw line by line.

The mod reads a grammar or a theme from its shiki directory the first time that a reply needs it.

Install the mod

claude plugin marketplace add macwilk/cc-extensions
claude plugin install restyled-chat@cc-extensions

In a Claude Code session that is already open, run /reload-plugins.

To receive new versions, run /plugin, go to the Marketplaces tab, select cc-extensions, and then select Enable auto-update. Claude Code leaves auto-update off for this marketplace.

Turn on a theme

  1. In Claude Code, run /theme.
  2. Select the theme, for example Dracula.

What a theme colors

A theme sets the colors that Claude Code chooses: the accent, the borders, the status colors, the diff backgrounds, and the message backgrounds.

Your terminal's color scheme sets the remaining colors:

  • The body text of a reply uses the terminal's foreground color.
  • Links use the terminal's 16 ANSI colors.

Code blocks and inline code use the syntax colors of Claude Code itself.

Every theme here uses the dark base and assumes the background of its source theme. To match the remaining colors, set the same color scheme in your terminal.

Add a theme

  1. Create palettes/SLUG.json with the name of the theme, its base, and its 13 colors by role. To start, copy another palette.

Replace SLUG with a short name for the theme, for example dracula.

  1. Build the theme file:
   python3 scripts/build_theme.py palettes/SLUG.json --out themes
  1. Give the theme its code colors. The mod uses the VS Code theme named SLUG in shiki/themes. If Shiki doesn't ship a theme of that name, save the VS Code theme file as tools/shiki/themes/SLUG.json at the root of the repository, and then update Shiki.
  2. Add the theme and a preview of it to Themes.
  3. In a Claude Code session that is already open, run /reload-plugins.

The theme appears in /theme under its name. If you change the base of a theme that a session already uses, start a new session to see the change. The /reload-plugins command doesn't apply it.

Noctis Uva has no palette. Its theme file is written by hand.

Source 6 files
hooks/register.ts 161 lines
1import { atom, memberOf, read, update } from 'claude-code'
2import type { Register, RenderSurface } from 'claude-code'
3
4import { diffLinesOf, type DiffLine } from './diff'
5import { segmentsOf } from './segments'
6import { linesOf, themeFor, type Read, type Run } from './shiki'
7
8// Claude Code sets a reply two cells in, under its bullet.
9const INDENT = 2
10// In this mod's themes, darker than the terminal's own background, where the code's shade is lighter.
11const HEAD_SHADE = 'composerSidebarBackground'
12// How long a block's button says that its code was copied.
13const COPIED_MS = 1500
14// Which block of a reply has its button saying so: the button's key, or none.
15const copiedBlock = atom({ plugin: 'restyled-chat', key: 'copiedBlock' } as const, '')
16// Claude Code refuses a drawing of more than 20,000 nodes and draws the reply itself. This much of it
17// is for the lines of code and of diffs; the rest of a reply's drawing is small.
18const NODE_ROOM = 15_000
19// The row of a diff line, its text, and the string in it.
20const DIFF_ROW_NODES = 3
21const DIFF_LANGUAGES = ['diff', 'patch']
22const DIFF_SHADE = { added: 'diffAdded', removed: 'diffRemoved' } as const
23// A reply of no visible text. Asked to draw it, Claude Code draws the row's bullet, indent and top
24// margin and nothing else, and the mod sets its own drawing on that row.
25const EMPTY_REPLY = '​'
26
27const isPlain = ({ text: _, ...style }: Run) => Object.keys(style).length === 0
28
29/** The nodes a drawing of these lines holds: a row for each line, a styled run and its text, a plain run. */
30function nodesOf(lines: Run[][]): number {
31  return lines.reduce((sum, line) => sum + 1 + (line.length === 0 ? 1 : line.reduce((runs, run) => runs + (isPlain(run) ? 1 : 2), 0)), 0)
32}
33
34export const register: Register = on => {
35  on('ui.render', { component: 'AssistantMessage' }, async ($, e, next) => {
36    // A summary keeps Claude Code's own mark, which a drawing of the mod's would drop.
37    if (e.surface !== 'terminal' || e.props.isSummary) return next(e)
38    const segments = segmentsOf(e.props.text)
39    if (!segments.some(segment => segment.kind === 'code')) return next(e)
40
41    const { Box, Text, Button, Markdown, Code } = $.ui.resolve(e)
42    const mine = memberOf(copiedBlock, e)
43    const copied = await read($, mine)
44    const copy = async (text: string, key: string, surface: RenderSurface) => {
45      const { isCopied } = await $.ui.copy({ text, surface })
46      // Claude Code slides a toast in over several frames, so a copy that took is said on the button.
47      if (!isCopied) return $.ui.toast('Not copied')
48      await update($, mine, () => key)
49      // Another block of the reply may be copied before the wait ends; its mark stays.
50      $.clock.after(COPIED_MS, () => void update($, mine, marked => (marked === key ? '' : marked)))
51    }
52    // The first row of a block, a shade apart from its code: the language its fence names, and a button
53    // that copies the block.
54    const head = (language: string | undefined, source: string, key: string) =>
55      Box({
56        backgroundColor: HEAD_SHADE,
57        flexDirection: 'row',
58        justifyContent: 'space-between',
59        paddingX: 1,
60        children: [
61          // With no language named, a blank holds the left end, so the button stays at the right.
62          Text({ color: 'inactive', children: [language ?? ' '] }),
63          Button({
64            key,
65            plain: true,
66            onPress: press => void copy(source, key, press.surface),
67            children: [copied === key ? Text({ color: 'success', children: ['copied'] }) : Text({ color: 'suggestion', children: ['copy'] })],
68          }),
69        ],
70      })
71    // The lines the mod draws are counted against its share of the nodes a drawing may hold. A block
72    // that no longer fits is left whole to the Code element, which is one node.
73    let room = NODE_ROOM
74    const takes = (nodes: number) => {
75      if (nodes > room) return false
76      room -= nodes
77      return true
78    }
79    const readData: Read = path => $.fs.read(`${$.plugin.root}/shiki/${path}`)
80    // The Shiki theme that goes with the theme the person has on, looked up when a block first needs it.
81    let theme: Promise<string | undefined> | undefined
82    const themeNow = () =>
83      (theme ??= $.config.list().then(rows => {
84        const active = rows.find(row => row.key === 'theme')?.value
85        return typeof active === 'string' ? themeFor(readData, active) : undefined
86      }))
87    // Code takes the colors its language has in the person's theme, a line to a row. Under a theme or
88    // in a language Shiki's data has nothing for, it is left to the Code element, which colors it from
89    // a palette of Claude Code's own.
90    const code = async (source: string, language: string | undefined) => {
91      const shikiTheme = language === undefined ? undefined : await themeNow()
92      const lines = language === undefined || shikiTheme === undefined ? undefined : await linesOf(readData, source, language, shikiTheme)
93      if (lines === undefined || !takes(nodesOf(lines))) return [Code(language === undefined ? { source } : { source, language })]
94      return lines.map(line =>
95        Text({
96          // A row of no text would take no height.
97          children:
98            line.length === 0
99              ? [' ']
100              : line.map(run => {
101                  const { text, ...style } = run
102                  return isPlain(run) ? text : Text({ ...style, children: [text] })
103                }),
104        }),
105      )
106    }
107    // The Box, not the code, carries the shade, so it reaches the full width on every row.
108    const codeBlock = async (source: string, language: string | undefined, key: string) =>
109      Box({
110        backgroundColor: 'userMessageBackground',
111        flexDirection: 'column',
112        children: [head(language, source, key), Box({ paddingX: 1, flexDirection: 'column', children: await code(source, language) })],
113      })
114    // Each line of a diff is a row, an added or removed one on the theme's color for it, as Claude Code
115    // draws the diff of an edit.
116    const diffBlock = (lines: DiffLine[], source: string, language: string | undefined, key: string) =>
117      Box({
118        backgroundColor: 'userMessageBackground',
119        flexDirection: 'column',
120        children: [
121          head(language, source, key),
122          ...lines.map(line =>
123            Box({
124              paddingX: 1,
125              ...(line.kind === 'added' || line.kind === 'removed' ? { backgroundColor: DIFF_SHADE[line.kind] } : {}),
126              // A row of no text would take no height.
127              children: [Text({ ...(line.kind === 'about' ? { color: 'inactive' } : {}), children: [line.text === '' ? ' ' : line.text] })],
128            }),
129          ),
130        ],
131      })
132
133    const row = await next({ ...e, props: { ...e.props, text: EMPTY_REPLY } })
134    // In the order written, so the blocks of a reply take their share of the nodes in that order.
135    const parts = []
136    let blocks = 0
137    for (const segment of segments) {
138      if (segment.kind === 'prose') {
139        parts.push(Markdown({ text: segment.text }))
140        continue
141      }
142      // The button of a block is told from the others of the reply by the block's place among them.
143      const key = `copy-${blocks++}`
144      const diff = DIFF_LANGUAGES.includes(segment.language ?? '') ? diffLinesOf(segment.source) : undefined
145      parts.push(
146        diff !== undefined && takes(diff.length * DIFF_ROW_NODES)
147          ? diffBlock(diff, segment.source, segment.language, key)
148          : await codeBlock(segment.source, segment.language, key),
149      )
150    }
151    return Box({
152      flexDirection: 'column',
153      children: [
154        row,
155        // Up one row, onto the row Claude Code drew.
156        Box({ marginTop: -1, marginLeft: INDENT, flexDirection: 'column', gap: 1, children: parts }),
157      ],
158    })
159  })
160}
161
hooks/diff.ts 19 lines
1export type DiffLine = { kind: 'added' | 'removed' | 'about' | 'context'; text: string }
2
3// A hunk's range, and the lines git writes before the first hunk of a file.
4const ABOUT = /^(@@|diff |index )/
5
6/** The lines of a unified diff, each as what it is: added, removed, about the diff, or context. */
7export function diffLinesOf(source: string): DiffLine[] {
8  const lines = source.split('\n')
9  return lines.map((text, index) => {
10    // The pair that names the two files reads like a removed and an added line, so it is told by its partner.
11    const namesOldFile = text.startsWith('--- ') && lines[index + 1]?.startsWith('+++ ') === true
12    const namesNewFile = text.startsWith('+++ ') && lines[index - 1]?.startsWith('--- ') === true
13    if (ABOUT.test(text) || namesOldFile || namesNewFile) return { kind: 'about', text }
14    if (text.startsWith('+')) return { kind: 'added', text }
15    if (text.startsWith('-')) return { kind: 'removed', text }
16    return { kind: 'context', text }
17  })
18}
19
hooks/segments.ts 50 lines
1/** A stretch of a reply: prose for the markdown renderer, or the inside of a fenced block. */
2export type Segment = { kind: 'prose'; text: string } | { kind: 'code'; source: string; language?: string }
3
4// A fence that starts its line. One indented under a list item belongs to that item, and splitting
5// the list around it would break the list, so it stays with the prose.
6const FENCE = /^(`{3,})([^`]*)$/
7
8// Markdown and Code take tabs and line breaks and no other control character.
9function printable(text: string): string {
10  return text.replace(/[\u0000-\u0008\u000b-\u001f\u007f]/g, '')
11}
12
13/** Splits a reply at its fenced blocks. A fence still open at the end, as while a reply streams, runs to the end. */
14export function segmentsOf(markdown: string): Segment[] {
15  const segments: Segment[] = []
16  let prose: string[] = []
17  let code: string[] | undefined
18  let opening = ''
19  let language: string | undefined
20
21  const closeProse = () => {
22    const text = printable(prose.join('\n')).trim()
23    if (text !== '') segments.push({ kind: 'prose', text })
24    prose = []
25  }
26  const closeCode = (lines: string[]) => {
27    const source = printable(lines.join('\n'))
28    if (source.trim() !== '') segments.push(language === undefined ? { kind: 'code', source } : { kind: 'code', source, language })
29  }
30
31  for (const line of markdown.split('\n')) {
32    const fence = FENCE.exec(line)
33    if (code === undefined) {
34      if (fence === null) prose.push(line)
35      else {
36        closeProse()
37        code = []
38        opening = fence[1] ?? ''
39        language = (fence[2] ?? '').trim().split(/\s+/)[0] || undefined
40      }
41    } else if (fence !== null && (fence[1] ?? '').length >= opening.length && (fence[2] ?? '').trim() === '') {
42      closeCode(code)
43      code = undefined
44    } else code.push(line)
45  }
46  if (code === undefined) closeProse()
47  else closeCode(code)
48  return segments
49}
50
hooks/shiki.ts 107 lines
1import { createHighlighterCoreSync, createJavaScriptRegexEngine, type ShikiHighlighter, type ShikiToken } from './shiki-core.mjs'
2
3/** A run of code in one style. A run in the theme's plain text color has no color of its own. */
4export type Run = { text: string; color?: string; italic?: true; bold?: true; underline?: true }
5
6/** Reads one of the data files tools/shiki/build.mjs wrote, by its path under the mod's `shiki` folder. */
7export type Read = (path: string) => Promise<string>
8
9type Index = {
10  /** Every name and alias of a language, to the name of its grammar. */
11  langs: Record<string, string>
12  /** The grammars a grammar embeds, which load with it. */
13  embedded: Record<string, string[]>
14  themes: string[]
15}
16
17// The themes of this mod whose colors Shiki has under another name.
18const THEME_NAMES: Record<string, string> = { 'dark-modern': 'dark-plus', 'gruvbox-dark': 'gruvbox-dark-medium' }
19// Shiki's bits for a token's font style.
20const ITALIC = 1
21const BOLD = 2
22const UNDERLINE = 4
23
24// What a session has read so far. A grammar or a theme is read when a reply first needs it, since
25// Claude Code loads no module on demand and the data is too large to load with the mod.
26let index: Promise<Index> | undefined
27let highlighter: ShikiHighlighter | undefined
28const loaded = new Set<string>()
29
30function indexOf(read: Read): Promise<Index> {
31  index ??= read('index.json').then(text => JSON.parse(text) as Index)
32  return index
33}
34
35/** The Shiki theme that goes with a Claude Code theme, such as `custom:restyled-chat:dracula`, if there is one. */
36export async function themeFor(read: Read, activeTheme: string): Promise<string | undefined> {
37  const slug = activeTheme.slice(activeTheme.lastIndexOf(':') + 1)
38  const name = THEME_NAMES[slug] ?? slug
39  return (await indexOf(read)).themes.includes(name) ? name : undefined
40}
41
42async function load(read: Read, kind: 'langs' | 'themes', names: string[]): Promise<unknown[]> {
43  const missing = names.filter(name => !loaded.has(`${kind}/${name}`))
44  const files = await Promise.all(missing.map(name => read(`${kind}/${name}.json`)))
45  for (const name of missing) loaded.add(`${kind}/${name}`)
46  return files.map(text => JSON.parse(text) as unknown)
47}
48
49/** A grammar and every grammar it embeds, however deep. */
50function withEmbedded({ langs, embedded }: Index, grammar: string): string[] {
51  const all = new Set<string>()
52  const visit = (name: string) => {
53    if (all.has(name)) return
54    all.add(name)
55    for (const inner of embedded[name] ?? []) visit(langs[inner] ?? inner)
56  }
57  visit(grammar)
58  return [...all]
59}
60
61function runOf(token: ShikiToken, plainColor: string): Run {
62  const style = token.fontStyle ?? 0
63  const color = token.color?.toLowerCase()
64  return {
65    text: token.content,
66    ...(color !== undefined && color !== plainColor ? { color } : {}),
67    ...(style & ITALIC ? { italic: true as const } : {}),
68    ...(style & BOLD ? { bold: true as const } : {}),
69    ...(style & UNDERLINE ? { underline: true as const } : {}),
70  }
71}
72
73const isSameStyle = (a: Run, b: Run) => a.color === b.color && a.italic === b.italic && a.bold === b.bold && a.underline === b.underline
74
75/** The runs of a line with neighbours of one style joined, and white space joined to the run before it. */
76function joined(runs: Run[]): Run[] {
77  const line: Run[] = []
78  for (const run of runs) {
79    const last = line[line.length - 1]
80    // Space shows no color, so it can ride on any run that draws no line under it.
81    const rides = last !== undefined && run.text.trim() === '' && last.underline === undefined
82    if (last !== undefined && (rides || isSameStyle(last, run))) last.text += run.text
83    else if (run.text !== '') line.push(run.text.trim() === '' ? { text: run.text } : run)
84  }
85  return line
86}
87
88/**
89 * The code line by line, each line as runs in the colors and styles the theme gives them.
90 *
91 * @param theme a name `themeFor` returned
92 * @returns undefined for a language Shiki has no grammar for
93 */
94export async function linesOf(read: Read, source: string, language: string, theme: string): Promise<Run[][] | undefined> {
95  const known = await indexOf(read)
96  const grammar = known.langs[language.toLowerCase()]
97  if (grammar === undefined) return undefined
98
99  highlighter ??= createHighlighterCoreSync({ themes: [], langs: [], engine: createJavaScriptRegexEngine() })
100  const [themes, grammars] = await Promise.all([load(read, 'themes', [theme]), load(read, 'langs', withEmbedded(known, grammar))])
101  if (themes.length > 0) highlighter.loadThemeSync(...themes)
102  if (grammars.length > 0) highlighter.loadLanguageSync(...grammars)
103
104  const plainColor = highlighter.getTheme(theme).fg.toLowerCase()
105  return highlighter.codeToTokensBase(source.replaceAll('\t', '    '), { lang: grammar, theme }).map(line => joined(line.map(token => runOf(token, plainColor))))
106}
107
hooks/shiki-core.mjs 153 lines
1var zs=Object.defineProperty;var Hs=(e,t)=>{for(var n in t)zs(e,n,{get:t[n],enumerable:!0})};var E=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function qs(e){return Ft(e)}function Ft(e){return Array.isArray(e)?Vs(e):e instanceof RegExp?e:typeof e=="object"?Xs(e):e}function Vs(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=Ft(e[n]);return t}function Xs(e){let t={};for(let n in e)t[n]=Ft(e[n]);return t}function Mn(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function On(e){let t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?On(e.substring(0,e.length-1)):e.substr(~t+1)}var Nt=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Ve=class{static hasCaptures(e){return e===null?!1:(Nt.lastIndex=0,Nt.test(e))}static replaceCaptures(e,t,n){return e.replace(Nt,(r,s,o,a)=>{let i=n[parseInt(s||o,10)];if(i){let l=t.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(a){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Gn(e,t){return e<t?-1:e>t?1:0}function Bn(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let s=0;s<n;s++){let o=Gn(e[s],t[s]);if(o!==0)return o}return 0}return n-r}function An(e){return!!(/^#[0-9a-f]{6}$/i.test(e)||/^#[0-9a-f]{8}$/i.test(e)||/^#[0-9a-f]{3}$/i.test(e)||/^#[0-9a-f]{4}$/i.test(e))}function Fn(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var Dn=class{constructor(e){this.fn=e}cache=new Map;get(e){if(this.cache.has(e))return this.cache.get(e);let t=this.fn(e);return this.cache.set(e,t),t}},Ie=class{constructor(e,t,n){this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(Ys(e),t)}static createFromParsedTheme(e,t){return Zs(e,t)}_cachedMatchRoot=new Dn(e=>this._root.match(e));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;let t=e.scopeName,r=this._cachedMatchRoot.get(t).find(s=>Ks(e.parent,s.parentScopes));return r?new Un(r.fontStyle,r.foreground,r.background):null}},Tt=class Xe{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(let r of n)t=new Xe(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new Xe(n,t[r]);return n}push(t){return new Xe(this,t)}getSegments(){let t=this,n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){let n=[],r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function Ks(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],s=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],s=!0}for(;e&&!Qs(e.scopeName,r);){if(s)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function Qs(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Un=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function Ys(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=0;for(let s=0,o=t.length;s<o;s++){let a=t[s];if(!a.settings)continue;let i;if(typeof a.scope=="string"){let h=a.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(a.scope)?i=a.scope:i=[""];let l=-1;if(typeof a.settings.fontStyle=="string"){l=0;let h=a.settings.fontStyle.split(" ");for(let p=0,f=h.length;p<f;p++)switch(h[p]){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 a.settings.foreground=="string"&&An(a.settings.foreground)&&(c=a.settings.foreground);let u=null;typeof a.settings.background=="string"&&An(a.settings.background)&&(u=a.settings.background);for(let h=0,p=i.length;h<p;h++){let d=i[h].trim().split(" "),b=d[d.length-1],w=null;d.length>1&&(w=d.slice(0,d.length-1),w.reverse()),n[r++]=new Js(b,w,s,l,c,u)}}return n}var Js=class{constructor(e,t,n,r,s,o){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},$=(e=>(e[e.NotSet=-1]="NotSet",e[e.None=0]="None",e[e.Italic=1]="Italic",e[e.Bold=2]="Bold",e[e.Underline=4]="Underline",e[e.Strikethrough=8]="Strikethrough",e))($||{});function Zs(e,t){e.sort((l,c)=>{let u=Gn(l.scope,c.scope);return u!==0||(u=Bn(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",s="#ffffff";for(;e.length>=1&&e[0].scope==="";){let l=e.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(s=l.background)}let o=new eo(t),a=new Un(n,o.getId(r),o.getId(s)),i=new no(new Pt(0,null,-1,0,0),[]);for(let l=0,c=e.length;l<c;l++){let u=e[l];i.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new Ie(o,a,i)}var eo=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(e){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,n=e.length;t<n;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)}},to=Object.freeze([]),Pt=class jn{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(t,n,r,s,o){this.scopeDepth=t,this.parentScopes=n||to,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new jn(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,s=t.length;r<s;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,s){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},no=class $t{constructor(t,n=[],r={}){this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,s=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=t.parentScopes.length||s>=n.parentScopes.length);){let o=n.parentScopes[s].length-t.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),s,o;if(r===-1?(s=t,o=""):(s=t.substring(0,r),o=t.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}let n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort($t._cmpBySpecificity),n}insert(t,n,r,s,o,a){if(n===""){this._doInsertHere(t,r,s,o,a);return}let i=n.indexOf("."),l,c;i===-1?(l=n,c=""):(l=n.substring(0,i),c=n.substring(i+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new $t(this._mainRule.clone(),Pt.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(t+1,c,r,s,o,a)}_doInsertHere(t,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(t,r,s,o);return}for(let a=0,i=this._rulesWithParentScopes.length;a<i;a++){let l=this._rulesWithParentScopes[a];if(Bn(l.parentScopes,n)===0){l.acceptOverwrite(t,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Pt(t,n,r,s,o))}},re=class D{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){let n=D.getLanguageId(t),r=D.getTokenType(t),s=D.getFontStyle(t),o=D.getForeground(t),a=D.getBackground(t);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:a})}static getLanguageId(t){return(t&255)>>>0}static getTokenType(t){return(t&768)>>>8}static containsBalancedBrackets(t){return(t&1024)!==0}static getFontStyle(t){return(t&30720)>>>11}static getForeground(t){return(t&16744448)>>>15}static getBackground(t){return(t&4278190080)>>>24}static set(t,n,r,s,o,a,i){let l=D.getLanguageId(t),c=D.getTokenType(t),u=D.containsBalancedBrackets(t)?1:0,h=D.getFontStyle(t),p=D.getForeground(t),f=D.getBackground(t);return n!==0&&(l=n),r!==8&&(c=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),a!==0&&(p=a),i!==0&&(f=i),(l<<0|c<<8|u<<10|h<<11|p<<15|f<<24)>>>0}};function Qe(e,t){let n=[],r=ro(e),s=r.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let c=a();if(n.push({matcher:c,priority:l}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();let l=o();return c=>!!l&&!l(c)}if(s==="("){s=r.next();let l=i();return s===")"&&(s=r.next()),l}if(In(s)){let l=[];do l.push(s),s=r.next();while(In(s));return c=>t(l,c)}return null}function a(){let l=[],c=o();for(;c;)l.push(c),c=o();return u=>l.every(h=>h(u))}function i(){let l=[],c=a();for(;c&&(l.push(c),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");c=a()}return u=>l.some(h=>h(u))}}function In(e){return!!e&&!!e.match(/[\w\.:]+/)}function ro(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;let r=n[0];return n=t.exec(e),r}}}function Wn(e){typeof e.dispose=="function"&&e.dispose()}var Re=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},so=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},oo=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(e){let t=e.toKey();this._seenReferenceKeys.has(t)||(this._seenReferenceKeys.add(t),this._references.push(e))}},ao=class{constructor(e,t){this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Re(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){let e=this.Q;this.Q=[];let t=new oo;for(let n of e)io(n,this.initialScopeName,this.repo,t);for(let n of t.references)if(n instanceof Re){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function io(e,t,n,r){let s=n.lookup(e.scopeName);if(!s){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}let o=n.lookup(t);e instanceof Re?Ke({baseGrammar:o,selfGrammar:s},r):Mt(e.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);let a=n.injections(e.scopeName);if(a)for(let i of a)r.add(new Re(i))}function Mt(e,t,n){if(t.repository&&t.repository[e]){let r=t.repository[e];Ye([r],t,n)}}function Ke(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ye(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ye(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ye(e,t,n){for(let r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);let s=r.repository?Mn({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Ye(r.patterns,{...t,repository:s},n);let o=r.include;if(!o)continue;let a=zn(o);switch(a.kind){case 0:Ke({...t,selfGrammar:t.baseGrammar},n);break;case 1:Ke(t,n);break;case 2:Mt(a.ruleName,{...t,repository:s},n);break;case 3:case 4:let i=a.scopeName===t.selfGrammar.scopeName?t.selfGrammar:a.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(i){let l={baseGrammar:t.baseGrammar,selfGrammar:i,repository:s};a.kind===4?Mt(a.ruleName,l,n):Ke(l,n)}else a.kind===4?n.add(new so(a.scopeName,a.ruleName)):n.add(new Re(a.scopeName));break}}}var lo=class{kind=0},co=class{kind=1},uo=class{constructor(e){this.ruleName=e}kind=2},ho=class{constructor(e){this.scopeName=e}kind=3},po=class{constructor(e,t){this.scopeName=e,this.ruleName=t}kind=4};function zn(e){if(e==="$base")return new lo;if(e==="$self")return new co;let t=e.indexOf("#");if(t===-1)return new ho(e);if(t===0)return new uo(e.substring(1));{let n=e.substring(0,t),r=e.substring(t+1);return new po(n,r)}}var fo=/\\(\d+)/,Rn=/\\(\d+)/g;var go=-1,Hn=-2;var Le=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(e,t,n,r){this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Ve.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Ve.hasCaptures(this._contentName)}get debugName(){let e=this.$location?`${On(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:Ve.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Ve.replaceCaptures(this._contentName,e,t)}},mo=class extends Le{retokenizeCapturedWithRuleId;constructor(e,t,n,r,s){super(e,t,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,n,r){throw new Error("Not supported!")}},yo=class extends Le{_match;captures;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,null),this._match=new Ne(r,this.id),this.captures=s,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,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Te,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Nn=class extends Le{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s){super(e,t,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(let n of this.patterns)e.getRule(n).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new Te,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Ot=class extends Le{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(e,t,n,r,s,o,a,i,l,c){super(e,t,n,r),this._begin=new Ne(s,this.id),this.beginCaptures=o,this._end=new Ne(a||"\uFFFF",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.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,n,r){return this._getCachedCompiledPatterns(e,t).compileAG(e,n,r)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Te;for(let n of this.patterns)e.getRule(n).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}},Je=class extends Le{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(e,t,n,r,s,o,a,i,l){super(e,t,n,r),this._begin=new Ne(s,this.id),this.beginCaptures=o,this.whileCaptures=i,this._while=new Ne(a,Hn),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.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,n,r){return this._getCachedCompiledPatterns(e).compileAG(e,n,r)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new Te;for(let 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,n,r){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,n,r)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new Te,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"\uFFFF"),this._cachedCompiledWhilePatterns}},qn=class M{static createCaptureRule(t,n,r,s,o){return t.registerRule(a=>new mo(n,a,r,s,o))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(s=>{if(t.id=s,t.match)return new yo(t.$vscodeTextmateLocation,t.id,t.name,t.match,M._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=Mn({},r,t.repository));let o=t.patterns;return typeof o>"u"&&t.include&&(o=[{include:t.include}]),new Nn(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,M._compilePatterns(o,n,r))}return t.while?new Je(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,M._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,M._compileCaptures(t.whileCaptures||t.captures,n,r),M._compilePatterns(t.patterns,n,r)):new Ot(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,M._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,M._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,M._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){let s=[];if(t){let o=0;for(let a in t){if(a==="$vscodeTextmateLocation")continue;let i=parseInt(a,10);i>o&&(o=i)}for(let a=0;a<=o;a++)s[a]=null;for(let a in t){if(a==="$vscodeTextmateLocation")continue;let i=parseInt(a,10),l=0;t[a].patterns&&(l=M.getCompiledRuleId(t[a],n,r)),s[i]=M.createCaptureRule(n,t[a].$vscodeTextmateLocation,t[a].name,t[a].contentName,l)}}return s}static _compilePatterns(t,n,r){let s=[];if(t)for(let o=0,a=t.length;o<a;o++){let i=t[o],l=-1;if(i.include){let c=zn(i.include);switch(c.kind){case 0:case 1:l=M.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=M.getCompiledRuleId(u,n,r));break;case 3:case 4:let h=c.scopeName,p=c.kind===4?c.ruleName:null,f=n.getExternalGrammar(h,r);if(f)if(p){let d=f.repository[p];d&&(l=M.getCompiledRuleId(d,n,f.repository))}else l=M.getCompiledRuleId(f.repository.$self,n,f.repository);break}}else l=M.getCompiledRuleId(i,n,r);if(l!==-1){let c=n.getRule(l),u=!1;if((c instanceof Nn||c instanceof Ot||c instanceof Je)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(t?t.length:0)!==s.length}}},Ne=class Vn{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(t,n){if(t&&typeof t=="string"){let r=t.length,s=0,o=[],a=!1;for(let i=0;i<r;i++)if(t.charAt(i)==="\\"&&i+1<r){let c=t.charAt(i+1);c==="z"?(o.push(t.substring(s,i)),o.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(a=!0),i++}this.hasAnchor=a,s===0?this.source=t:(o.push(t.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=t;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=fo.test(this.source):this.hasBackReferences=!1}clone(){return new Vn(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>t.substring(s.start,s.end));return Rn.lastIndex=0,this.source.replace(Rn,(s,o)=>Fn(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let t=[],n=[],r=[],s=[],o,a,i,l;for(o=0,a=this.source.length;o<a;o++)i=this.source.charAt(o),t[o]=i,n[o]=i,r[o]=i,s[o]=i,i==="\\"&&o+1<a&&(l=this.source.charAt(o+1),l==="A"?(t[o+1]="\uFFFF",n[o+1]="\uFFFF",r[o+1]="A",s[o+1]="A"):l==="G"?(t[o+1]="\uFFFF",n[o+1]="G",r[o+1]="\uFFFF",s[o+1]="G"):(t[o+1]=l,n[o+1]=l,r[o+1]=l,s[o+1]=l),o++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},Te=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(e){this._items.push(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}unshift(e){this._items.unshift(e),this._hasAnchors=this._hasAnchors||e.hasAnchor}length(){return this._items.length}setSource(e,t){this._items[e].source!==t&&(this._disposeCaches(),this._items[e].setSource(t))}compile(e){if(!this._cached){let t=this._items.map(n=>n.source);this._cached=new Tn(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(s=>s.resolveAnchors(t,n));return new Tn(e,r,this._items.map(s=>s.ruleId))}},Tn=class{constructor(e,t,n){this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){let e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push("   - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
2`)}findNextMatchSync(e,t,n){let r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Lt=class{constructor(e,t){this.languageId=e,this.tokenType=t}},bo=class Gt{_defaultAttributes;_embeddedLanguagesMatcher;constructor(t,n){this._defaultAttributes=new Lt(t,8),this._embeddedLanguagesMatcher=new wo(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?Gt._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}static _NULL_SCOPE_METADATA=new Lt(0,0);_getBasicScopeAttributes=new Dn(t=>{let n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Lt(n,r)});_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){let n=t.match(Gt.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},wo=class{values;scopesRegExp;constructor(e){if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);let t=e.map(([n,r])=>Fn(n));t.sort(),t.reverse(),this.scopesRegExp=new RegExp(`^((${t.join(")|(")}))($|\\.)`,"")}}match(e){if(!this.scopesRegExp)return;let t=e.match(this.scopesRegExp);if(t)return this.values.get(t[1])}},Hl={InDebugMode:typeof process<"u"&&!!process.env.VSCODE_TEXTMATE_DEBUG},Xn=!1,Ln=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Kn(e,t,n,r,s,o,a,i){let l=t.content.length,c=!1,u=-1;if(a){let f=Co(e,t,n,r,s,o);s=f.stack,r=f.linePos,n=f.isFirstLine,u=f.anchorPosition}let h=Date.now();for(;!c;){if(i!==0&&Date.now()-h>i)return new Ln(s,!0);p()}return new Ln(s,!1);function p(){let f=_o(e,t,n,r,s,u);if(!f){o.produce(s,l),c=!0;return}let d=f.captureIndices,b=f.matchedRuleId,w=d&&d.length>0?d[0].end>r:!1;if(b===go){let m=s.getRule(e);o.produce(s,d[0].start),s=s.withContentNameScopesList(s.nameScopesList),Ee(e,t,n,s,o,m.endCaptures,d),o.produce(s,d[0].end);let y=s;if(s=s.parent,u=y.getAnchorPos(),!w&&y.getEnterPos()===r){s=y,o.produce(s,l),c=!0;return}}else{let m=e.getRule(b);o.produce(s,d[0].start);let y=s,C=m.getName(t.content,d),k=s.contentNameScopesList.pushAttributed(C,e);if(s=s.push(b,r,u,d[0].end===l,null,k,k),m instanceof Ot){let v=m;Ee(e,t,n,s,o,v.beginCaptures,d),o.produce(s,d[0].end),u=d[0].end;let P=v.getContentName(t.content,d),O=k.pushAttributed(P,e);if(s=s.withContentNameScopesList(O),v.endHasBackReferences&&(s=s.withEndRule(v.getEndWithResolvedBackReferences(t.content,d))),!w&&y.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(m instanceof Je){let v=m;Ee(e,t,n,s,o,v.beginCaptures,d),o.produce(s,d[0].end),u=d[0].end;let P=v.getContentName(t.content,d),O=k.pushAttributed(P,e);if(s=s.withContentNameScopesList(O),v.whileHasBackReferences&&(s=s.withEndRule(v.getWhileWithResolvedBackReferences(t.content,d))),!w&&y.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(Ee(e,t,n,s,o,m.captures,d),o.produce(s,d[0].end),s=s.pop(),!w){s=s.safePop(),o.produce(s,l),c=!0;return}}d[0].end>r&&(r=d[0].end,n=!1)}}function Co(e,t,n,r,s,o){let a=s.beginRuleCapturedEOL?0:-1,i=[];for(let l=s;l;l=l.pop()){let c=l.getRule(e);c instanceof Je&&i.push({rule:c,stack:l})}for(let l=i.pop();l;l=i.pop()){let{ruleScanner:c,findOptions:u}=xo(l.rule,e,l.stack.endRule,n,r===a),h=c.findNextMatchSync(t,r,u);if(h){if(h.ruleId!==Hn){s=l.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(l.stack,h.captureIndices[0].start),Ee(e,t,n,l.stack,o,l.rule.whileCaptures,h.captureIndices),o.produce(l.stack,h.captureIndices[0].end),a=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=l.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:a,isFirstLine:n}}function _o(e,t,n,r,s,o){let a=So(e,t,n,r,s,o),i=e.getInjections();if(i.length===0)return a;let l=ko(i,e,t,n,r,s,o);if(!l)return a;if(!a)return l;let c=a.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:a}function So(e,t,n,r,s,o){let a=s.getRule(e),{ruleScanner:i,findOptions:l}=Qn(a,e,s.endRule,n,r===o),c=i.findNextMatchSync(t,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function ko(e,t,n,r,s,o,a){let i=Number.MAX_VALUE,l=null,c,u=0,h=o.contentNameScopesList.getScopeNames();for(let p=0,f=e.length;p<f;p++){let d=e[p];if(!d.matcher(h))continue;let b=t.getRule(d.ruleId),{ruleScanner:w,findOptions:m}=Qn(b,t,null,r,s===a),y=w.findNextMatchSync(n,s,m);if(!y)continue;let C=y.captureIndices[0].start;if(!(C>=i)&&(i=C,l=y.captureIndices,c=y.ruleId,u=d.priority,i===s))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function Qn(e,t,n,r,s){if(Xn){let a=e.compile(t,n),i=Yn(r,s);return{ruleScanner:a,findOptions:i}}return{ruleScanner:e.compileAG(t,n,r,s),findOptions:0}}function xo(e,t,n,r,s){if(Xn){let a=e.compileWhile(t,n),i=Yn(r,s);return{ruleScanner:a,findOptions:i}}return{ruleScanner:e.compileWhileAG(t,n,r,s),findOptions:0}}function Yn(e,t){let n=0;return e||(n|=1),t||(n|=4),n}function Ee(e,t,n,r,s,o,a){if(o.length===0)return;let i=t.content,l=Math.min(o.length,a.length),c=[],u=a[0].end;for(let h=0;h<l;h++){let p=o[h];if(p===null)continue;let f=a[h];if(f.length===0)continue;if(f.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=f.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,f.start):s.produce(r,f.start),p.retokenizeCapturedWithRuleId){let b=p.getName(i,a),w=r.contentNameScopesList.pushAttributed(b,e),m=p.getContentName(i,a),y=w.pushAttributed(m,e),C=r.push(p.retokenizeCapturedWithRuleId,f.start,-1,!1,null,w,y),k=e.createOnigString(i.substring(0,f.end));Kn(e,k,n&&f.start===0,f.start,C,s,!1,0),Wn(k);continue}let d=p.getName(i,a);if(d!==null){let w=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(d,e);c.push(new vo(w,f.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var vo=class{scopes;endPos;constructor(e,t){this.scopes=e,this.endPos=t}};function Eo(e,t,n,r,s,o,a,i){return new Io(e,t,n,r,s,o,a,i)}function Pn(e,t,n,r,s){let o=Qe(t,Ze),a=qn.getCompiledRuleId(n,r,s.repository);for(let i of o)e.push({debugSelector:t,matcher:i.matcher,ruleId:a,grammar:s,priority:i.priority})}function Ze(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let s=n;s<t.length;s++)if(Ao(t[s],r))return n=s+1,!0;return!1})}function Ao(e,t){if(!e)return!1;if(e===t)return!0;let n=t.length;return e.length>n&&e.substr(0,n)===t&&e[n]==="."}var Io=class{constructor(e,t,n,r,s,o,a,i){if(this._rootScopeName=e,this.balancedBracketSelectors=o,this._onigLib=i,this._basicScopeAttributesProvider=new bo(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=a,this._grammar=$n(t,null),this._injections=null,this._tokenTypeMatchers=[],s)for(let l of Object.keys(s)){let c=Qe(l,Ze);for(let u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(let e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){let e={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){let s=r.injections;if(s)for(let a in s)Pn(t,a,s[a],this,r);let o=this._grammarRepository.injections(n);o&&o.forEach(a=>{let i=this.getExternalGrammar(a);if(i){let l=i.injectionSelector;l&&Pn(t,l,i,this,i)}})}return t.sort((s,o)=>s.priority-o.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){let t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){let n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=$n(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){let r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){let r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=qn.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!t||t===Bt.NULL){s=!0;let c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=re.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),p=this.getRule(this._rootId).getName(null,null),f;p?f=Ae.createRootAndLookUpScopeName(p,h,this):f=Ae.createRoot("unknown",h),t=new Bt(null,this._rootId,-1,-1,!1,null,f,f)}else s=!1,t.reset();e=e+`
3`;let o=this.createOnigString(e),a=o.content.length,i=new No(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Kn(this,o,s,0,t,i,!0,r);return Wn(o),{lineLength:a,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function $n(e,t){return e=qs(e),e.repository=e.repository||{},e.repository.$self={$vscodeTextmateLocation:e.$vscodeTextmateLocation,patterns:e.patterns,name:e.scopeName},e.repository.$base=t||e.repository.$self,e}var Ae=class q{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,s=t?.scopePath??null;for(let o of n)s=Tt.push(s,o.scopeNames),r=new q(r,s,o.encodedTokenAttributes);return r}static createRoot(t,n){return new q(null,new Tt(null,t),n)}static createRootAndLookUpScopeName(t,n,r){let s=r.getMetadataForScope(t),o=new Tt(null,t),a=r.themeProvider.themeMatch(o),i=q.mergeAttributes(n,s,a);return new q(null,o,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return q.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let s=-1,o=0,a=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,a=r.backgroundId),re.set(t,n.languageId,n.tokenType,null,s,o,a)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return q._pushAttributed(this,t,n);let r=t.split(/ /g),s=this;for(let o of r)s=q._pushAttributed(s,o,n);return s}static _pushAttributed(t,n,r){let s=r.getMetadataForScope(n),o=t.scopePath.push(n),a=r.themeProvider.themeMatch(o),i=q.mergeAttributes(t.tokenAttributes,s,a);return new q(t,o,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){let n=[],r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===t?n.reverse():void 0}},Bt=class le{constructor(t,n,r,s,o,a,i,l){this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=a,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new le(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(t){return t===null?!1:le._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Ae.equals(t.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.depth!==n.depth||t.ruleId!==n.ruleId||t.endRule!==n.endRule)return!1;t=t.parent,n=n.parent}while(!0)}clone(){return this}static _reset(t){for(;t;)t._enterPos=-1,t._anchorPos=-1,t=t.parent}reset(){le._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,s,o,a,i){return new le(this,t,n,r,s,o,a,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(t){return t.getRule(this.ruleId)}toString(){let t=[];return this._writeString(t,0),"["+t.join(",")+"]"}_writeString(t,n){return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new le(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(t,n){let r=Ae.fromExtension(t?.nameScopesList??null,n.nameScopesList);return new le(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Ae.fromExtension(r,n.contentNameScopesList))}},Ro=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(e,t){this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Qe(n,Ze).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Qe(n,Ze).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(let t of this.unbalancedBracketScopes)if(t(e))return!1;for(let t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},No=class{constructor(e,t,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=e?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){let o=e?.getScopeNames()??[];for(let a of this._tokenTypeOverrides)a.matcher(o)&&(r=re.set(r,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=re.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}let n=e?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:n}),this._lastTokenEndIndex=t}getResult(e,t){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===t-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(e,t){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===t-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(e,t),this._binaryTokens[this._binaryTokens.length-2]=0);let n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},To=class{constructor(e,t){this._onigLib=t,this._theme=e}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(let e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,s){if(!this._grammars.has(e)){let o=this._rawGrammars.get(e);if(!o)return null;this._grammars.set(e,Eo(e,o,t,n,r,s,this,this._onigLib))}return this._grammars.get(e)}},Jn=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new To(Ie.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(Ie.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,n){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:n})}loadGrammarWithConfiguration(e,t,n){return this._loadGrammar(e,t,n.embeddedLanguages,n.tokenTypes,new Ro(n.balancedBracketSelectors||[],n.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,n,r,s){let o=new ao(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(a=>this._loadSingleGrammar(a.scopeName)),o.processQueue();return this._grammarForScopeName(e,t,n,r,s)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){let t=this._options.loadGrammar(e);if(t){let n=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,n)}}addGrammar(e,t=[],n=0,r=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,n,r)}_grammarForScopeName(e,t=0,n=null,r=null,s=null){return this._syncRegistry.grammarForScopeName(e,t,n,r,s)}},et=Bt.NULL;function $e(e,t){let n=typeof e=="string"?{}:{...e.colorReplacements},r=typeof e=="string"?e:e.name;for(let[s,o]of Object.entries(t?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function X(e,t){return e&&(t?.[e?.toLowerCase()]||e)}function rr(e){return Array.isArray(e)?e:[e]}async function Dt(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Me(e){return!e||["plaintext","txt","text","plain"].includes(e)}function sr(e){return e==="ansi"||Me(e)}function Oe(e){return e==="none"}function or(e){return Oe(e)}var Lo=/(\r?\n)/g;function we(e,t=!1){if(e.length===0)return[["",0]];let n=e.split(Lo),r=0,s=[];for(let o=0;o<n.length;o+=2){let a=t?n[o]+(n[o+1]||""):n[o];s.push([a,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}var Zn={light:"#333333",dark:"#bbbbbb"},er={light:"#fffffe",dark:"#1e1e1e"},tr="__shiki_resolved";function tt(e){if(e?.[tr])return e;let t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||="dark",t.colorReplacements={...t.colorReplacements},t.settings||=[];let{bg:n,fg:r}=t;if(!n||!r){let i=t.settings?t.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(r=i.settings.foreground),i?.settings?.background&&(n=i.settings.background),!r&&t?.colors?.["editor.foreground"]&&(r=t.colors["editor.foreground"]),!n&&t?.colors?.["editor.background"]&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Zn.light:Zn.dark),n||(n=t.type==="light"?er.light:er.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let s=0,o=new Map;function a(i){if(o.has(i))return o.get(i);s+=1;let l=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return t.colorReplacements?.[`#${l}`]?a(i):(o.set(i,l),l)}t.settings=t.settings.map(i=>{let l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),c=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!c)return i;let u={...i,settings:{...i.settings}};if(l){let h=a(i.settings.foreground);t.colorReplacements[h]=i.settings.foreground,u.settings.foreground=h}if(c){let h=a(i.settings.background);t.colorReplacements[h]=i.settings.background,u.settings.background=h}return u});for(let i of Object.keys(t.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!t.colors[i]?.startsWith("#")){let l=a(t.colors[i]);t.colorReplacements[l]=t.colors[i],t.colors[i]=l}return Object.defineProperty(t,tr,{enumerable:!1,writable:!1,value:!0}),t}async function Po(e){return[...new Set((await Promise.all(e.filter(t=>!sr(t)).map(async t=>await Dt(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function $o(e){return(await Promise.all(e.map(async t=>or(t)?null:tt(await Dt(t))))).filter(t=>!!t)}function ar(e,t){if(!t)return e;if(t[e]){let n=new Set([e]);for(;t[e];){if(e=t[e],n.has(e))throw new E(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var Mo=class extends Jn{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(e,t,n,r={}){super(e),this._resolver=e,this._themes=t,this._langs=n,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}getTheme(e){return typeof e=="string"?this._resolvedThemes.get(e):this.loadTheme(e)}loadTheme(e){let t=tt(e);return t.name&&(this._resolvedThemes.set(t.name,t),this._loadedThemesCache=null),t}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(e){let t=this._textmateThemeCache.get(e);t||(t=Ie.createFromRawTheme(e),this._textmateThemeCache.set(e,t)),this._syncRegistry.setTheme(t)}getGrammar(e){return e=ar(e,this._alias),this._resolvedGrammars.get(e)}loadLanguage(e){if(this.getGrammar(e.name))return;let t=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(e.name)));this._resolver.addLanguage(e);let n={balancedBracketSelectors:e.balancedBracketSelectors||["*"],unbalancedBracketSelectors:e.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(e.scopeName,e);let r=this.loadGrammarWithConfiguration(e.scopeName,1,n);if(r.name=e.name,this._resolvedGrammars.set(e.name,r),e.aliases&&e.aliases.forEach(s=>{this._alias[s]=e.name}),this._loadedLanguagesCache=null,t.size)for(let s of t)this._syncRegistry?._grammars?.get(s.scopeName)?.dispose(),this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(e){for(let r of e)this.resolveEmbeddedLanguages(r);let t=[...this._langGraph.entries()],n=t.filter(([r,s])=>!s);if(n.length){let r=t.filter(([s,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(a=>n.map(([i])=>i).includes(a)):!1).filter(s=>!n.includes(s));throw new E(`Missing languages ${n.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(let[r,s]of t)this._resolver.addLanguage(s);for(let[r,s]of t)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(e){this._langMap.set(e.name,e),this._langGraph.set(e.name,e);let t=e.embeddedLanguages??e.embeddedLangs;if(t)for(let n of t)this._langGraph.set(n,this._langMap.get(n))}},Oo=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(e,t){this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).includes(e.scopeName)||this._injections.get(t).push(e.scopeName)})}getInjections(e){let t=e.split("."),n=[];for(let r=1;r<=t.length;r++){let s=t.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}},Pe=0;function Ut(e){Pe+=1,e.warnings!==!1&&Pe>=10&&Pe%10===0&&console.warn(`[Shiki] ${Pe} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let t=!1;if(!e.engine)throw new E("`engine` option is required for synchronous mode");let n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(tt),s=new Mo(new Oo(e.engine,n),r,n,e.langAlias),o;function a(y){return ar(y,e.langAlias)}function i(y){w();let C=s.getGrammar(typeof y=="string"?y:y.name);if(!C)throw new E(`Language \`${y}\` not found, you may need to load it first`);return C}function l(y){if(y==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};w();let C=s.getTheme(y);if(!C)throw new E(`Theme \`${y}\` not found, you may need to load it first`);return C}function c(y){w();let C=l(y);return o!==y&&(s.setTheme(C),o=y),{theme:C,colorMap:s.getColorMap()}}function u(){return w(),s.getLoadedThemes()}function h(){return w(),s.getLoadedLanguages()}function p(...y){w(),s.loadLanguages(y.flat(1))}async function f(...y){return p(await Po(y))}function d(...y){w();for(let C of y.flat(1))s.loadTheme(C)}async function b(...y){return w(),d(await $o(y))}function w(){if(t)throw new E("Shiki instance has been disposed")}function m(){t||(t=!0,s.dispose(),Pe-=1)}return{setTheme:c,getTheme:l,getLanguage:i,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:a,loadLanguage:f,loadLanguageSync:p,loadTheme:b,loadThemeSync:d,dispose:m,[Symbol.dispose]:m}}var ir=new WeakMap;function Ge(e,t){ir.set(e,t)}function Ce(e){return ir.get(e)}var nt=class lr{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new lr(Object.fromEntries(rr(n).map(r=>[r,et])),t)}constructor(...t){if(t.length===2){let[n,r]=t;this.lang=r,this._stacks=n}else{let[n,r,s]=t;this.lang=r,this._stacks={[s]:n}}}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return Go(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function Go(e){let t=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);let o=s?.nameScopesList?.scopeName;o&&t.push(o),s.parent&&r(s.parent)}return r(e),t}function Bo(e,t){if(!(e instanceof nt))throw new E("Invalid grammar state");return e.getInternalStack(t)}var Fo=/,/,Do=/ /;function jt(e,t,n={}){let{theme:r=e.getLoadedThemes()[0]}=n;if(Me(e.resolveLangAlias(n.lang||"text"))||Oe(r))return we(t).map(i=>[{content:i[0],offset:i[1]}]);let{theme:s,colorMap:o}=e.setTheme(r),a=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==a.name)throw new E(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${a.name}"`);if(!n.grammarState.themes.includes(s.name))throw new E(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return ur(t,a,s,o,n)}function cr(...e){if(e.length===2)return Ce(e[1]);let[t,n,r={}]=e,{lang:s="text",theme:o=t.getLoadedThemes()[0]}=r;if(Me(s)||Oe(o))throw new E("Plain language does not have grammar state");if(s==="ansi")throw new E("ANSI language does not have grammar state");let{theme:a,colorMap:i}=t.setTheme(o),l=t.getLanguage(s);return new nt(Wt(n,l,a,i,r).stateStack,l.name,a.name)}function ur(e,t,n,r,s){let o=Wt(e,t,n,r,s),a=new nt(o.stateStack,t.name,n.name);return Ge(o.tokens,a),o.tokens}function Wt(e,t,n,r,s){let o=$e(n,s),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:i=500,includeExplanation:l=!1}=s,c=we(e),u=s.grammarState?Bo(s.grammarState,n.name)??et:s.grammarContextCode!=null?Wt(s.grammarContextCode,t,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:et,h=[],p=[];for(let f=0,d=c.length;f<d;f++){let[b,w]=c[f];if(b===""){h=[],p.push([]);continue}if(a>0&&b.length>=a){h=[],p.push([{content:b,offset:w,color:"",fontStyle:0}]);continue}let m,y,C;l&&l!=="tokenType"&&(m=t.tokenizeLine(b,u,i),y=m.tokens,C=0);let k=t.tokenizeLine2(b,u,i),v=k.tokens.length/2;for(let P=0;P<v;P++){let O=k.tokens[2*P],z=P+1<v?k.tokens[2*P+2]:b.length;if(O===z)continue;let ye=k.tokens[2*P+1],At=X(r[re.getForeground(ye)],o),It=re.getFontStyle(ye),H={content:b.substring(O,z),offset:w+O,color:At,fontStyle:It};if(l==="tokenType")H.type=re.getTokenType(ye);else if(l){let vn=[];if(l!=="scopeName")for(let V of n.settings){let be;switch(typeof V.scope){case"string":be=V.scope.split(Fo).map(Rt=>Rt.trim());break;case"object":be=V.scope;break;default:continue}vn.push({settings:V,selectors:be.map(Rt=>Rt.split(Do))})}H.explanation=[];let En=0;for(;O+En<z;){let V=y[C],be=b.substring(V.startIndex,V.endIndex);En+=be.length,H.explanation.push({content:be,scopes:l==="scopeName"?Uo(V.scopes):jo(vn,V.scopes)}),C+=1}}h.push(H)}p.push(h),h=[],u=k.ruleStack}return{tokens:p,stateStack:u}}function Uo(e){return e.map(t=>({scopeName:t}))}function jo(e,t){let n=[];for(let r=0,s=t.length;r<s;r++){let o=t[r];n[r]={scopeName:o,themeMatches:zo(e,o,t.slice(0,r))}}return n}function nr(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function Wo(e,t,n){if(!nr(e.at(-1),t))return!1;let r=e.length-2,s=n.length-1;for(;r>=0&&s>=0;)nr(e[r],n[s])&&(r-=1),s-=1;return r===-1}function zo(e,t,n){let r=[];for(let{selectors:s,settings:o}of e)for(let a of s)if(Wo(a,t,n)){r.push(o);break}return r}function rt(e,t,n,r=jt){let s=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),o=s.map(c=>{let u=r(e,t,{...n,theme:c.theme});return{tokens:u,state:Ce(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),a=Ho(...o.map(c=>c.tokens)),i=a[0].map((c,u)=>c.map((h,p)=>{let f={content:h.content,variants:{},offset:h.offset};return"includeExplanation"in n&&n.includeExplanation&&(f.explanation=h.explanation),a.forEach((d,b)=>{let{content:w,explanation:m,offset:y,...C}=d[u][p];f.variants[s[b].color]=C}),f})),l=o[0].state?new nt(Object.fromEntries(o.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),o[0].state.lang):void 0;return l&&Ge(i,l),i}function Ho(...e){let t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){let s=e.map(l=>l[r]),o=t.map(()=>[]);t.forEach((l,c)=>l.push(o[c]));let a=s.map(()=>0),i=s.map(l=>l[0]);for(;i.every(l=>l);){let l=Math.min(...i.map(c=>c.content.length));for(let c=0;c<n;c++){let u=i[c];u.content.length===l?(o[c].push(u),a[c]+=1,i[c]=s[c][a[c]]):(o[c].push({...u,content:u.content.slice(0,l)}),i[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return t}var hr=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];var K=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};K.prototype.normal={};K.prototype.property={};K.prototype.space=void 0;function zt(e,t){let n={},r={};for(let s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new K(n,r,t)}function Be(e){return e.toLowerCase()}var L=class{constructor(t,n){this.attribute=n,this.property=t}};L.prototype.attribute="";L.prototype.booleanish=!1;L.prototype.boolean=!1;L.prototype.commaOrSpaceSeparated=!1;L.prototype.commaSeparated=!1;L.prototype.defined=!1;L.prototype.mustUseProperty=!1;L.prototype.number=!1;L.prototype.overloadedBoolean=!1;L.prototype.property="";L.prototype.spaceSeparated=!1;L.prototype.space=void 0;var Fe={};Hs(Fe,{boolean:()=>_,booleanish:()=>A,commaOrSpaceSeparated:()=>G,commaSeparated:()=>Q,number:()=>g,overloadedBoolean:()=>st,spaceSeparated:()=>x});var qo=0,_=ce(),A=ce(),st=ce(),g=ce(),x=ce(),Q=ce(),G=ce();function ce(){return 2**++qo}var Ht=Object.keys(Fe),ue=class extends L{constructor(t,n,r,s){let o=-1;if(super(t,n),pr(this,"space",s),typeof r=="number")for(;++o<Ht.length;){let a=Ht[o];pr(this,Ht[o],(r&Fe[a])===Fe[a])}}};ue.prototype.defined=!0;function pr(e,t,n){n&&(e[t]=n)}function U(e){let t={},n={};for(let[r,s]of Object.entries(e.properties)){let o=new ue(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Be(r)]=r,n[Be(o.attribute)]=r}return new K(t,n,e.space)}var qt=U({properties:{ariaActiveDescendant:null,ariaAtomic:A,ariaAutoComplete:null,ariaBusy:A,ariaChecked:A,ariaColCount:g,ariaColIndex:g,ariaColSpan:g,ariaControls:x,ariaCurrent:null,ariaDescribedBy:x,ariaDetails:null,ariaDisabled:A,ariaDropEffect:x,ariaErrorMessage:null,ariaExpanded:A,ariaFlowTo:x,ariaGrabbed:A,ariaHasPopup:null,ariaHidden:A,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:x,ariaLevel:g,ariaLive:null,ariaModal:A,ariaMultiLine:A,ariaMultiSelectable:A,ariaOrientation:null,ariaOwns:x,ariaPlaceholder:null,ariaPosInSet:g,ariaPressed:A,ariaReadOnly:A,ariaRelevant:null,ariaRequired:A,ariaRoleDescription:x,ariaRowCount:g,ariaRowIndex:g,ariaRowSpan:g,ariaSelected:A,ariaSetSize:g,ariaSort:null,ariaValueMax:g,ariaValueMin:g,ariaValueNow:g,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ot(e,t){return t in e?e[t]:t}function at(e,t){return ot(e,t.toLowerCase())}var fr=U({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Q,acceptCharset:x,accessKey:x,action:null,allow:null,allowFullScreen:_,allowPaymentRequest:_,allowUserMedia:_,alpha:_,alt:null,as:null,async:_,autoCapitalize:null,autoComplete:x,autoFocus:_,autoPlay:_,blocking:x,capture:null,charSet:null,checked:_,cite:null,className:x,closedBy:null,colorSpace:null,cols:g,colSpan:g,command:null,commandFor:null,content:null,contentEditable:A,controls:_,controlsList:x,coords:g|Q,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_,defer:_,dir:null,dirName:null,disabled:_,download:st,draggable:A,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_,formTarget:null,headers:x,height:g,hidden:st,high:g,href:null,hrefLang:null,htmlFor:x,httpEquiv:x,id:null,imageSizes:null,imageSrcSet:null,inert:_,inputMode:null,integrity:null,is:null,isMap:_,itemId:null,itemProp:x,itemRef:x,itemScope:_,itemType:x,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_,low:g,manifest:null,max:null,maxLength:g,media:null,method:null,min:null,minLength:g,multiple:_,muted:_,name:null,nonce:null,noModule:_,noValidate:_,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:_,optimum:g,pattern:null,ping:x,placeholder:null,playsInline:_,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_,referrerPolicy:null,rel:x,required:_,reversed:_,rows:g,rowSpan:g,sandbox:x,scope:null,scoped:_,seamless:_,selected:_,shadowRootClonable:_,shadowRootCustomElementRegistry:_,shadowRootDelegatesFocus:_,shadowRootMode:null,shadowRootSerializable:_,shape:null,size:g,sizes:null,slot:null,span:g,spellCheck:A,src:null,srcDoc:null,srcLang:null,srcSet:null,start:g,step:null,style:null,tabIndex:g,target:null,title:null,translate:null,type:null,typeMustMatch:_,useMap:null,value:A,width:g,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:x,axis:null,background:null,bgColor:null,border:g,borderColor:null,bottomMargin:g,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_,declare:_,event:null,face:null,frame:null,frameBorder:null,hSpace:g,leftMargin:g,link:null,longDesc:null,lowSrc:null,marginHeight:g,marginWidth:g,noResize:_,noHref:_,noShade:_,noWrap:_,object:null,profile:null,prompt:null,rev:null,rightMargin:g,rules:null,scheme:null,scrolling:A,standby:null,summary:null,text:null,topMargin:g,valueType:null,version:null,vAlign:null,vLink:null,vSpace:g,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:_,disablePictureInPicture:_,disableRemotePlayback:_,exportParts:Q,part:x,prefix:null,property:null,results:g,security:null,unselectable:null},space:"html",transform:at});var dr=U({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:G,accentHeight:g,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:g,amplitude:g,arabicForm:null,ascent:g,attributeName:null,attributeType:null,azimuth:g,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:g,by:null,calcMode:null,capHeight:g,className:x,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:g,diffuseConstant:g,direction:null,display:null,dur:null,divisor:g,dominantBaseline:null,download:_,dx:null,dy:null,edgeMode:null,editable:null,elevation:g,enableBackground:null,end:null,event:null,exponent:g,externalResourcesRequired:null,fill:null,fillOpacity:g,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Q,g2:Q,glyphName:Q,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:g,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:g,horizOriginX:g,horizOriginY:g,id:null,ideographic:g,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:g,k:g,k1:g,k2:g,k3:g,k4:g,kernelMatrix:G,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:g,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:g,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:g,overlineThickness:g,paintOrder:null,panose1:null,path:null,pathLength:g,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:x,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:g,pointsAtY:g,pointsAtZ:g,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:G,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:G,rev:G,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:G,requiredFeatures:G,requiredFonts:G,requiredFormats:G,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:g,specularExponent:g,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:g,strikethroughThickness:g,string:null,stroke:null,strokeDashArray:G,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:g,strokeOpacity:g,strokeWidth:null,style:null,surfaceScale:g,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:G,tabIndex:g,tableValues:null,target:null,targetX:g,targetY:g,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:G,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:g,underlineThickness:g,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:g,values:null,vAlphabetic:g,vMathematical:g,vectorEffect:null,vHanging:g,vIdeographic:g,version:null,vertAdvY:g,vertOriginX:g,vertOriginY:g,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:g,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ot});var Vt=U({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}});var Xt=U({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:at});var Kt=U({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});var Vo=/[A-Z]/g,gr=/-[a-z]/g,Xo=/^data[-\w.:]+$/i;function Qt(e,t){let n=Be(t),r=t,s=L;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Xo.test(t)){if(t.charAt(4)==="-"){let o=t.slice(5).replace(gr,Qo);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{let o=t.slice(4);if(!gr.test(o)){let a=o.replace(Vo,Ko);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=ue}return new s(r,t)}function Ko(e){return"-"+e.toLowerCase()}function Qo(e){return e.charAt(1).toUpperCase()}var mr=zt([qt,fr,Vt,Xt,Kt],"html"),it=zt([qt,dr,Vt,Xt,Kt],"svg");var yr={}.hasOwnProperty;function br(e,t){let n=t||{};function r(s,...o){let a=r.invalid,i=r.handlers;if(s&&yr.call(s,e)){let l=String(s[e]);a=yr.call(i,l)?i[l]:r.unknown}if(a)return a.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var Yo=/["&'<>`]/g,Jo=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Zo=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,ea=/[|\\{}()[\]^$+*?.]/g,wr=new WeakMap;function Cr(e,t){if(e=e.replace(t.subset?ta(t.subset):Yo,r),t.subset||t.escapeOnly)return e;return e.replace(Jo,n).replace(Zo,r);function n(s,o,a){return t.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),t)}function r(s,o,a){return t.format(s.charCodeAt(0),a.charCodeAt(o+1),t)}}function ta(e){let t=wr.get(e);return t||(t=na(e),wr.set(e,t)),t}function na(e){let t=[],n=-1;for(;++n<e.length;)t.push(e[n].replace(ea,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}var ra=/[\dA-Fa-f]/;function _r(e,t,n){let r="&#x"+e.toString(16).toUpperCase();return n&&t&&!ra.test(String.fromCharCode(t))?r:r+";"}var sa=/\d/;function Sr(e,t,n){let r="&#"+String(e);return n&&t&&!sa.test(String.fromCharCode(t))?r:r+";"}var kr=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"];var lt={nbsp:"\xA0",iexcl:"\xA1",cent:"\xA2",pound:"\xA3",curren:"\xA4",yen:"\xA5",brvbar:"\xA6",sect:"\xA7",uml:"\xA8",copy:"\xA9",ordf:"\xAA",laquo:"\xAB",not:"\xAC",shy:"\xAD",reg:"\xAE",macr:"\xAF",deg:"\xB0",plusmn:"\xB1",sup2:"\xB2",sup3:"\xB3",acute:"\xB4",micro:"\xB5",para:"\xB6",middot:"\xB7",cedil:"\xB8",sup1:"\xB9",ordm:"\xBA",raquo:"\xBB",frac14:"\xBC",frac12:"\xBD",frac34:"\xBE",iquest:"\xBF",Agrave:"\xC0",Aacute:"\xC1",Acirc:"\xC2",Atilde:"\xC3",Auml:"\xC4",Aring:"\xC5",AElig:"\xC6",Ccedil:"\xC7",Egrave:"\xC8",Eacute:"\xC9",Ecirc:"\xCA",Euml:"\xCB",Igrave:"\xCC",Iacute:"\xCD",Icirc:"\xCE",Iuml:"\xCF",ETH:"\xD0",Ntilde:"\xD1",Ograve:"\xD2",Oacute:"\xD3",Ocirc:"\xD4",Otilde:"\xD5",Ouml:"\xD6",times:"\xD7",Oslash:"\xD8",Ugrave:"\xD9",Uacute:"\xDA",Ucirc:"\xDB",Uuml:"\xDC",Yacute:"\xDD",THORN:"\xDE",szlig:"\xDF",agrave:"\xE0",aacute:"\xE1",acirc:"\xE2",atilde:"\xE3",auml:"\xE4",aring:"\xE5",aelig:"\xE6",ccedil:"\xE7",egrave:"\xE8",eacute:"\xE9",ecirc:"\xEA",euml:"\xEB",igrave:"\xEC",iacute:"\xED",icirc:"\xEE",iuml:"\xEF",eth:"\xF0",ntilde:"\xF1",ograve:"\xF2",oacute:"\xF3",ocirc:"\xF4",otilde:"\xF5",ouml:"\xF6",divide:"\xF7",oslash:"\xF8",ugrave:"\xF9",uacute:"\xFA",ucirc:"\xFB",uuml:"\xFC",yacute:"\xFD",thorn:"\xFE",yuml:"\xFF",fnof:"\u0192",Alpha:"\u0391",Beta:"\u0392",Gamma:"\u0393",Delta:"\u0394",Epsilon:"\u0395",Zeta:"\u0396",Eta:"\u0397",Theta:"\u0398",Iota:"\u0399",Kappa:"\u039A",Lambda:"\u039B",Mu:"\u039C",Nu:"\u039D",Xi:"\u039E",Omicron:"\u039F",Pi:"\u03A0",Rho:"\u03A1",Sigma:"\u03A3",Tau:"\u03A4",Upsilon:"\u03A5",Phi:"\u03A6",Chi:"\u03A7",Psi:"\u03A8",Omega:"\u03A9",alpha:"\u03B1",beta:"\u03B2",gamma:"\u03B3",delta:"\u03B4",epsilon:"\u03B5",zeta:"\u03B6",eta:"\u03B7",theta:"\u03B8",iota:"\u03B9",kappa:"\u03BA",lambda:"\u03BB",mu:"\u03BC",nu:"\u03BD",xi:"\u03BE",omicron:"\u03BF",pi:"\u03C0",rho:"\u03C1",sigmaf:"\u03C2",sigma:"\u03C3",tau:"\u03C4",upsilon:"\u03C5",phi:"\u03C6",chi:"\u03C7",psi:"\u03C8",omega:"\u03C9",thetasym:"\u03D1",upsih:"\u03D2",piv:"\u03D6",bull:"\u2022",hellip:"\u2026",prime:"\u2032",Prime:"\u2033",oline:"\u203E",frasl:"\u2044",weierp:"\u2118",image:"\u2111",real:"\u211C",trade:"\u2122",alefsym:"\u2135",larr:"\u2190",uarr:"\u2191",rarr:"\u2192",darr:"\u2193",harr:"\u2194",crarr:"\u21B5",lArr:"\u21D0",uArr:"\u21D1",rArr:"\u21D2",dArr:"\u21D3",hArr:"\u21D4",forall:"\u2200",part:"\u2202",exist:"\u2203",empty:"\u2205",nabla:"\u2207",isin:"\u2208",notin:"\u2209",ni:"\u220B",prod:"\u220F",sum:"\u2211",minus:"\u2212",lowast:"\u2217",radic:"\u221A",prop:"\u221D",infin:"\u221E",ang:"\u2220",and:"\u2227",or:"\u2228",cap:"\u2229",cup:"\u222A",int:"\u222B",there4:"\u2234",sim:"\u223C",cong:"\u2245",asymp:"\u2248",ne:"\u2260",equiv:"\u2261",le:"\u2264",ge:"\u2265",sub:"\u2282",sup:"\u2283",nsub:"\u2284",sube:"\u2286",supe:"\u2287",oplus:"\u2295",otimes:"\u2297",perp:"\u22A5",sdot:"\u22C5",lceil:"\u2308",rceil:"\u2309",lfloor:"\u230A",rfloor:"\u230B",lang:"\u2329",rang:"\u232A",loz:"\u25CA",spades:"\u2660",clubs:"\u2663",hearts:"\u2665",diams:"\u2666",quot:'"',amp:"&",lt:"<",gt:">",OElig:"\u0152",oelig:"\u0153",Scaron:"\u0160",scaron:"\u0161",Yuml:"\u0178",circ:"\u02C6",tilde:"\u02DC",ensp:"\u2002",emsp:"\u2003",thinsp:"\u2009",zwnj:"\u200C",zwj:"\u200D",lrm:"\u200E",rlm:"\u200F",ndash:"\u2013",mdash:"\u2014",lsquo:"\u2018",rsquo:"\u2019",sbquo:"\u201A",ldquo:"\u201C",rdquo:"\u201D",bdquo:"\u201E",dagger:"\u2020",Dagger:"\u2021",permil:"\u2030",lsaquo:"\u2039",rsaquo:"\u203A",euro:"\u20AC"};var xr=["cent","copy","divide","gt","lt","not","para","times"];var vr={}.hasOwnProperty,Yt={},ct;for(ct in lt)vr.call(lt,ct)&&(Yt[lt[ct]]=ct);var oa=/[^\dA-Za-z]/;function Er(e,t,n,r){let s=String.fromCharCode(e);if(vr.call(Yt,s)){let o=Yt[s],a="&"+o;return n&&kr.includes(o)&&!xr.includes(o)&&(!r||t&&t!==61&&oa.test(String.fromCharCode(t)))?a:a+";"}return""}function Ar(e,t,n){let r=_r(e,t,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=Er(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){let o=Sr(e,t,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function Y(e,t){return Cr(e,Object.assign({format:Ar},t))}var aa=/^>|^->|<!--|-->|--!>|<!-$/g,ia=[">"],la=["<",">"];function Ir(e,t,n,r){return r.settings.bogusComments?"<?"+Y(e.value,Object.assign({},r.settings.characterReferences,{subset:ia}))+">":"<!--"+e.value.replace(aa,s)+"-->";function s(o){return Y(o,Object.assign({},r.settings.characterReferences,{subset:la}))}}function Rr(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Jt(e,t){let n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(t);for(;s!==-1;)r++,s=n.indexOf(t,s+t.length);return r}function Nr(e,t){let n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function Tr(e){return e.join(" ").trim()}var ca=/[ \t\n\f\r]/g;function he(e){return typeof e=="object"?e.type==="text"?Lr(e.value):!1:Lr(e)}function Lr(e){return e.replace(ca,"")===""}var I=Pr(1),Zt=Pr(-1),ua=[];function Pr(e){return t;function t(n,r,s){let o=n?n.children:ua,a=(r||0)+e,i=o[a];if(!s)for(;i&&he(i);)a+=e,i=o[a];return i}}var ha={}.hasOwnProperty;function ut(e){return t;function t(n,r,s){return ha.call(e,n.tagName)&&e[n.tagName](n,r,s)}}var De=ut({body:fa,caption:en,colgroup:en,dd:ya,dt:ma,head:en,html:pa,li:ga,optgroup:ba,option:wa,p:da,rp:$r,rt:$r,tbody:_a,td:Mr,tfoot:Sa,th:Mr,thead:Ca,tr:ka});function en(e,t,n){let r=I(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&he(r.value.charAt(0)))}function pa(e,t,n){let r=I(n,t);return!r||r.type!=="comment"}function fa(e,t,n){let r=I(n,t);return!r||r.type!=="comment"}function da(e,t,n){let r=I(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function ga(e,t,n){let r=I(n,t);return!r||r.type==="element"&&r.tagName==="li"}function ma(e,t,n){let r=I(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function ya(e,t,n){let r=I(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function $r(e,t,n){let r=I(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function ba(e,t,n){let r=I(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function wa(e,t,n){let r=I(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function Ca(e,t,n){let r=I(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function _a(e,t,n){let r=I(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function Sa(e,t,n){return!I(n,t)}function ka(e,t,n){let r=I(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Mr(e,t,n){let r=I(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}var Or=ut({body:Ea,colgroup:Aa,head:va,html:xa,tbody:Ia});function xa(e){let t=I(e,-1);return!t||t.type!=="comment"}function va(e){let t=new Set;for(let r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}let n=e.children[0];return!n||n.type==="element"}function Ea(e){let t=I(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&he(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function Aa(e,t,n){let r=Zt(n,t),s=I(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&De(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function Ia(e,t,n){let r=Zt(n,t),s=I(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&De(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}var ht={name:[[`	
4\f\r &/=>`.split(""),`	
5\f\r "&'/=>\``.split("")],[`\0	
6\f\r "&'/<=>`.split(""),`\0	
7\f\r "&'/<=>\``.split("")]],unquoted:[[`	
8\f\r &>`.split(""),`\0	
9\f\r "&'<=>\``.split("")],[`\0	
10\f\r "&'<=>\``.split(""),`\0	
11\f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function Gr(e,t,n,r){let s=r.schema,o=s.space==="svg"?!1:r.settings.omitOptionalTags,a=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase()),i=[],l;s.space==="html"&&e.tagName==="svg"&&(r.schema=it);let c=Ra(r,e.properties),u=r.all(s.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=s,u&&(a=!1),(c||!o||!Or(e,t,n))&&(i.push("<",e.tagName,c?" "+c:""),a&&(s.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(u),!a&&(!o||!De(e,t,n))&&i.push("</"+e.tagName+">"),i.join("")}function Ra(e,t){let n=[],r=-1,s;if(t){for(s in t)if(t[s]!==null&&t[s]!==void 0){let o=Na(e,s,t[s]);o&&n.push(o)}}for(;++r<n.length;){let o=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function Na(e,t,n){let r=Qt(e.schema,t),s=e.settings.allowParseErrors&&e.schema.space==="html"?0:1,o=e.settings.allowDangerousCharacters?0:1,a=e.quote,i;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";let l=Y(r.attribute,Object.assign({},e.settings.characterReferences,{subset:ht.name[s][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Nr:Tr)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?l:(e.settings.preferUnquoted&&(i=Y(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:ht.unquoted[s][o]}))),i!==n&&(e.settings.quoteSmart&&Jt(n,a)>Jt(n,e.alternative)&&(a=e.alternative),i=a+Y(n,Object.assign({},e.settings.characterReferences,{subset:(a==="'"?ht.single:ht.double)[s][o],attribute:!0}))+a),l+(i&&"="+i))}var Ta=["<","&"];function pt(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:Y(e.value,Object.assign({},r.settings.characterReferences,{subset:Ta}))}function Br(e,t,n,r){return r.settings.allowDangerousHtml?e.value:pt(e,t,n,r)}function Fr(e,t,n,r){return r.all(e)}var Dr=br("type",{invalid:La,unknown:Pa,handlers:{comment:Ir,doctype:Rr,element:Gr,raw:Br,root:Fr,text:pt}});function La(e){throw new Error("Expected node, not `"+e+"`")}function Pa(e){let t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}var $a={},Ma={},Oa=[];function tn(e,t){let n=t||$a,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Ga,all:Ba,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||hr,characterReferences:n.characterReferences||Ma,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?it:mr,quote:r,alternative:s}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function Ga(e,t,n){return Dr(e,t,n,this)}function Ba(e){let t=[],n=e&&e.children||Oa,r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}var Ur=/\s+/g;function zr(e,t){if(!t)return e;e.properties||={},e.properties.class||=[],typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Ur)),Array.isArray(e.properties.class)||(e.properties.class=[]);let n=Array.isArray(t)?t:t.split(Ur);for(let r of n)r&&!e.properties.class.includes(r)&&e.properties.class.push(r);return e}function Da(e){let t=we(e,!0).map(([s])=>s);function n(s){if(s===e.length)return{line:t.length-1,character:t.at(-1).length};let o=s,a=0;for(let i of t){if(o<i.length)break;o-=i.length,a++}return{line:a,character:o}}function r(s,o){let a=0;for(let i=0;i<s;i++)a+=t[i].length;return a+=o,a}return{lines:t,indexToPos:n,posToIndex:r}}var Ua=["color","background-color"];function ja(e,t){let n=0,r=[];for(let s of t)s>n&&r.push({...e,content:e.content.slice(n,s),offset:e.offset+n}),n=s;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Wa(e,t){let n=0,r=e.length;for(;n<r;){let s=n+(r-n>>1);e[s]<=t?n=s+1:r=s}return n}function za(e,t){let n=[...t instanceof Set?t:new Set(t)].sort((r,s)=>r-s);return n.length?e.map(r=>r.flatMap(s=>{let o=s.offset+s.content.length,a=Wa(n,s.offset),i=a;for(;i<n.length&&n[i]<o;)i++;if(a===i)return s;let l=n.slice(a,i);for(let c=0;c<l.length;c++)l[c]-=s.offset;return ja(s,l)})):e}function Ha(e,t,n,r,s="css-vars"){let o={content:e.content,explanation:e.explanation,offset:e.offset},a=t.map(u=>ft(e.variants[u])),i=new Set(a.flatMap(u=>Object.keys(u))),l={},c=(u,h)=>{let p=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+t[u]+(h==="color"?"":p)};return a.forEach((u,h)=>{for(let p of i){let f=u[p]||"inherit";if(h===0&&r&&Ua.includes(p))if(r==="light-dark()"&&a.length>1){let d=t.findIndex(y=>y==="light"),b=t.findIndex(y=>y==="dark");if(d===-1||b===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');let w=a[d][p]||"inherit",m=a[b][p]||"inherit";l[p]=`light-dark(${w}, ${m})`,s==="css-vars"&&(l[c(h,p)]=f)}else l[p]=f;else s==="css-vars"&&(l[c(h,p)]=f)}}),o.htmlStyle=l,o}function ft(e){let t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&$.Italic&&(t["font-style"]="italic"),e.fontStyle&$.Bold&&(t["font-weight"]="bold");let n=[];e.fontStyle&$.Underline&&n.push("underline"),e.fontStyle&$.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function rn(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function qa(){let e=new WeakMap;function t(n){if(!e.has(n.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new E(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...r.indexToPos(a),offset:a}}else{let i=r.lines[a.line];if(i===void 0)throw new E(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${r.lines.length}`);let l=a.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new E(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${i.length}`);return{...a,character:l,offset:r.posToIndex(a.line,l)}}},r=Da(n.source),o=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));Va(o),e.set(n.meta,{decorations:o,converter:r,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return za(n,t(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;let r=t(this),s=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new E(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,h,p,f){let d=s[u],b="",w=-1,m=-1;if(h===0&&(w=0),p===0&&(m=0),p===Number.POSITIVE_INFINITY&&(m=d.children.length),w===-1||m===-1)for(let C=0;C<d.children.length;C++)b+=Hr(d.children[C]),w===-1&&b.length===h&&(w=C+1),m===-1&&b.length===p&&(m=C+1);if(w===-1)throw new E(`Failed to find start index for decoration ${JSON.stringify(f.start)}`);if(m===-1)throw new E(`Failed to find end index for decoration ${JSON.stringify(f.end)}`);let y=d.children.slice(w,m);if(!f.alwaysWrap&&y.length===d.children.length)i(d,f,"line");else if(!f.alwaysWrap&&y.length===1&&y[0].type==="element")i(y[0],f,"token");else{let C={type:"element",tagName:"span",properties:{},children:y};i(C,f,"wrapper"),d.children.splice(w,y.length,C)}}function a(u,h){s[u]=i(s[u],h,"line")}function i(u,h,p){let f=h.properties||{},d=h.transform||(b=>b);return u.tagName=h.tagName||"span",u.properties={...u.properties,...f,class:u.properties.class},h.properties?.class&&zr(u,h.properties.class),u=d(u,p)||u,u}let l=[],c=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(let u of c){let{start:h,end:p}=u;if(h.line===p.line)o(h.line,h.character,p.character,u);else if(h.line<p.line){o(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let f=h.line+1;f<p.line;f++)l.unshift(()=>a(f,u));o(p.line,0,p.character,u)}}l.forEach(u=>u())}}}function Va(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.start.offset>n.end.offset)throw new E(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){let s=e[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,a=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,i=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,l=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||a||i||l){if(o&&a||i&&l||i&&n.start.offset===n.end.offset||a&&s.start.offset===s.end.offset)continue;throw new E(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function Hr(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Hr).join(""):""}var Xa=[qa()];function dt(e){let t=Ka(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Xa]}function Ka(e){let t=[],n=[],r=[];for(let s of e)switch(s.enforce){case"pre":t.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:t,post:n,normal:r}}var pe=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],nn={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Qa(e,t){let n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){let r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function jr(e){let t=e.shift();if(t==="2"){let n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){let n=e.shift();if(n)return{type:"table",index:Number(n)}}}function Ya(e){let t=[];for(;e.length>0;){let n=e.shift();if(!n)continue;let r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)nn[r]&&t.push({type:"setDecoration",value:nn[r]});else if(r<=29){let s=nn[r-20];s&&(t.push({type:"resetDecoration",value:s}),s==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:pe[r-30]}});else if(r===38){let s=jr(e);s&&t.push({type:"setForegroundColor",value:s})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:pe[r-40]}});else if(r===48){let s=jr(e);s&&t.push({type:"setBackgroundColor",value:s})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:pe[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:pe[r-100+8]}})}return t}function Ja(){let e=null,t=null,n=new Set;return{parse(r){let s=[],o=0;do{let a=Qa(r,o),i=a.sequence?r.substring(o,a.startPosition):r.substring(o);if(i.length>0&&s.push({value:i,foreground:e,background:t,decorations:new Set(n)}),a.sequence){let l=Ya(a.sequence);for(let c of l)c.type==="resetAll"?(e=null,t=null,n.clear()):c.type==="resetForegroundColor"?e=null:c.type==="resetBackgroundColor"?t=null:c.type==="resetDecoration"&&n.delete(c.value);for(let c of l)c.type==="setForegroundColor"?e=c.value:c.type==="setBackgroundColor"?t=c.value:c.type==="setDecoration"&&n.add(c.value)}o=a.position}while(o<r.length);return s}}}var Za={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function ei(e=Za){function t(i){return e[i]}function n(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let c=0;c<pe.length;c++)r.push(t(pe[c]));let i=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([i[c],i[u],i[h]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function o(i){return s()[i]}function a(i){switch(i.type){case"named":return t(i.name);case"rgb":return n(i.rgb);case"table":return o(i.index)}}return{value:a}}var ti=/#([0-9a-f]{3,8})/i,ni=/var\((--[\w-]+-ansi-[\w-]+)\)/,ri={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function si(e,t,n){let r=$e(e,n),s=we(t),o=ei(Object.fromEntries(pe.map(i=>{let l=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`;return[i,e.colors?.[l]||ri[i]]}))),a=Ja();return s.map(i=>a.parse(i[0]).map(l=>{let c,u;l.decorations.has("reverse")?(c=l.background?o.value(l.background):e.bg,u=l.foreground?o.value(l.foreground):e.fg):(c=l.foreground?o.value(l.foreground):e.fg,u=l.background?o.value(l.background):void 0),c=X(c,r),u=X(u,r),l.decorations.has("dim")&&(c=oi(c));let h=$.None;return l.decorations.has("bold")&&(h|=$.Bold),l.decorations.has("italic")&&(h|=$.Italic),l.decorations.has("underline")&&(h|=$.Underline),l.decorations.has("strikethrough")&&(h|=$.Strikethrough),{content:l.value,offset:i[1],color:c,bgColor:u,fontStyle:h}}))}function oi(e){let t=e.match(ti);if(t){let r=t[1];if(r.length===8){let s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){let s=r[0],o=r[1],a=r[2],i=r[3];return`#${s}${s}${o}${o}${a}${a}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){let s=r[0],o=r[1],a=r[2];return`#${s}${s}${o}${o}${a}${a}80`}}}let n=e.match(ni);return n?`var(${n[1]}-dim)`:e}function sn(e,t,n={}){let r=e.resolveLangAlias(n.lang||"text"),{theme:s=e.getLoadedThemes()[0]}=n;if(!Me(r)&&!Oe(s)&&r==="ansi"){let{theme:o}=e.setTheme(s);return si(o,t,n)}return jt(e,t,n)}function gt(e,t,n){let r,s,o,a,i,l;if("themes"in n){let{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:h="css-vars"}=n,p=Object.entries(n.themes).filter(m=>m[1]).map(m=>({color:m[0],theme:m[1]})).sort((m,y)=>m.color===c?-1:y.color===c?1:0);if(p.length===0)throw new E("`themes` option must not be empty");let f=rt(e,t,n,sn);if(l=Ce(f),c&&c!=="light-dark()"&&!p.some(m=>m.color===c))throw new E(`\`themes\` option must contain the defaultColor key \`${c}\``);let d=p.map(m=>e.getTheme(m.theme)),b=p.map(m=>m.color);o=f.map(m=>m.map(y=>Ha(y,b,u,c,h))),l&&Ge(o,l);let w=p.map(m=>$e(m.theme,n));s=Wr(p,d,w,u,c,"fg",h),r=Wr(p,d,w,u,c,"bg",h),a=`shiki-themes ${d.map(m=>m.name).join(" ")}`,i=c?void 0:[s,r].join(";")}else if("theme"in n){let c=$e(n.theme,n);o=sn(e,t,n);let u=e.getTheme(n.theme);r=X(u.bg,c),s=X(u.fg,c),a=u.name,l=Ce(o)}else throw new E("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:a,rootStyle:i,grammarState:l}}function Wr(e,t,n,r,s,o,a){return e.map((i,l)=>{let c=X(t[l][o],n[l])||"inherit",u=`${r+i.color}${o==="bg"?"-bg":""}:${c}`;if(l===0&&s){if(s==="light-dark()"&&e.length>1){let h=e.findIndex(f=>f.color==="light"),p=e.findIndex(f=>f.color==="dark");if(h===-1||p===-1)throw new E('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${X(t[h][o],n[h])||"inherit"}, ${X(t[p][o],n[p])||"inherit"});${u}`}return c}return a==="css-vars"?u:null}).filter(i=>!!i).join(";")}var qr=/^\s+$/,ai=/^(\s*)(.*?)(\s*)$/;function mt(e,t,n,r={meta:{},options:n,codeToHast:(s,o)=>mt(e,s,o),codeToTokens:(s,o)=>gt(e,s,o)}){let s=t;for(let d of dt(n))s=d.preprocess?.call(r,s,n)||s;let{tokens:o,fg:a,bg:i,themeName:l,rootStyle:c,grammarState:u}=gt(e,s,n),{mergeWhitespaces:h=!0,mergeSameStyleTokens:p=!1}=n;h===!0?o=li(o):h==="never"&&(o=ci(o)),p&&(o=ui(o));let f={...r,get source(){return s}};for(let d of dt(n))o=d.tokens?.call(f,o)||o;return ii(o,{...n,fg:a,bg:i,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},f,u)}function ii(e,t,n,r=Ce(e)){let s=dt(t),o=[],a={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=t,c={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?c.style=t.rootStyle:c.style=`background-color:${t.bg};color:${t.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(let[b,w]of Object.entries(t.meta||{}))b.startsWith("_")||(c[b]=w);let u={type:"element",tagName:"pre",properties:c,children:[],data:t.data},h={type:"element",tagName:"code",properties:{},children:o},p=[],f={...n,structure:i,addClassToHast:zr,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return a},get pre(){return u},get code(){return h},get lines(){return p}};if(e.forEach((b,w)=>{w&&(i==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&o.push({type:"text",value:`
12`}));let m={type:"element",tagName:"span",properties:{class:"line"},children:[]},y=0;for(let C of b){let k={type:"element",tagName:"span",properties:{...C.htmlAttrs},children:[{type:"text",value:C.content}]},v=rn(C.htmlStyle||ft(C));v&&(k.properties.style=v);for(let P of s)k=P?.span?.call(f,k,w+1,y,m,C)||k;i==="inline"?a.children.push(k):i==="classic"&&m.children.push(k),y+=C.content.length}if(i==="classic"){for(let C of s)m=C?.line?.call(f,m,w+1)||m;p.push(m),o.push(m)}else i==="inline"&&p.push(m)}),i==="classic"){for(let b of s)h=b?.code?.call(f,h)||h;u.children.push(h);for(let b of s)u=b?.pre?.call(f,u)||u;a.children.push(u)}else if(i==="inline"){let b=[],w={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(let y of a.children)y.type==="element"&&y.tagName==="br"?(b.push(w),w={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(y.type==="element"||y.type==="text")&&w.children.push(y);b.push(w);let m={type:"element",tagName:"code",properties:{},children:b};for(let y of s)m=y?.code?.call(f,m)||m;a.children=[];for(let y=0;y<m.children.length;y++){y>0&&a.children.push({type:"element",tagName:"br",properties:{},children:[]});let C=m.children[y];C.type==="element"&&a.children.push(...C.children)}}let d=a;for(let b of s)d=b?.root?.call(f,d)||d;return r&&Ge(d,r),d}function li(e){return e.map(t=>{let n=[],r="",s;return t.forEach((o,a)=>{let i=!(o.fontStyle&&(o.fontStyle&$.Underline||o.fontStyle&$.Strikethrough));i&&qr.test(o.content)&&t[a+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(i?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function ci(e){return e.map(t=>t.flatMap(n=>{if(qr.test(n.content))return n;let r=n.content.match(ai);if(!r)return n;let[,s,o,a]=r;if(!s&&!a)return n;let i=[{...n,offset:n.offset+s.length,content:o}];return s&&i.unshift({content:s,offset:n.offset}),a&&i.push({content:a,offset:n.offset+s.length+o.length}),i}))}function ui(e){return e.map(t=>{let n=[];for(let r of t){if(n.length===0){n.push({...r});continue}let s=n.at(-1),o=rn(s.htmlStyle||ft(s)),a=rn(r.htmlStyle||ft(r)),i=s.fontStyle&&(s.fontStyle&$.Underline||s.fontStyle&$.Strikethrough),l=r.fontStyle&&(r.fontStyle&$.Underline||r.fontStyle&$.Strikethrough);!i&&!l&&o===a?s.content+=r.content:n.push({...r})}return n})}var hi=tn;function pi(e,t,n){let r={meta:{},options:n,codeToHast:(o,a)=>mt(e,o,a),codeToTokens:(o,a)=>gt(e,o,a)},s=hi(mt(e,t,n,r));for(let o of dt(n))s=o.postprocess?.call(r,s,n)||s;return s}function fi(e){let t=Ut(e);return{getLastGrammarState:(...n)=>cr(t,...n),codeToTokensBase:(n,r)=>sn(t,n,r),codeToTokensWithThemes:(n,r)=>rt(t,n,r),codeToTokens:(n,r)=>gt(t,n,r),codeToHast:(n,r)=>mt(t,n,r),codeToHtml:(n,r)=>pi(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function di(e){return!e.sticky&&!e.rawOptions?.strategy}function Vr(e,t){return{index:e,captureIndices:t.map(n=>n==null?{start:4294967295,end:4294967295,length:0}:{start:n[0],end:n[1],length:n[1]-n[0]})}}var Xr=class{patterns;options;regexps;lastSearches;constructor(e,t={}){this.patterns=e,this.options=t;let{forgiving:n=!1,cache:r,regexConstructor:s}=t;if(!s)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(o=>{if(typeof o!="string")return o;let a=r?.get(o);if(a){if(a instanceof RegExp)return a;if(n)return null;throw a}try{let i=s(o);return r?.set(o,i),i}catch(i){if(r?.set(o,i),n)return null;throw i}}),this.lastSearches=this.regexps.map(o=>o&&di(o)?{strId:0,searchedFrom:0,matchIndex:-1,indices:null}:null)}findNextMatchSync(e,t,n){let r=typeof e=="string"?e:e.content,s=typeof e=="string"?0:e.id||0,o=-1,a=0,i=null;for(let l=0;l<this.regexps.length;l++){let c=this.regexps[l];if(c)try{let u=s?this.lastSearches[l]:null,h,p;if(u&&u.strId===s&&u.searchedFrom<=t&&(u.matchIndex===-1||u.matchIndex>=t))h=u.matchIndex,p=u.indices;else{c.lastIndex=t;let f=c.exec(r);h=f?f.index:-1,p=f?f.indices:null,u&&(u.strId=s,u.searchedFrom=t,u.matchIndex=h,u.indices=p)}if(h===-1)continue;if(h===t)return Vr(l,p);(o===-1||h<a)&&(o=l,a=h,i=p)}catch(u){if(this.options.forgiving)continue;throw u}}return o===-1?null:Vr(o,i)}},gi=0;function Kr(e){return{content:e,id:++gi}}function se(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Qr(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}var Ue=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),N=String.raw;function J(e,t){if(e==null)throw new Error(t??"Value expected");return e}var ns=N`\[\^?`,rs=`c.? | C(?:-.?)?|${N`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${N`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${N`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${N`o\{[^\}]*\}?`}|${N`\d{1,3}`}`,an=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,yt=new RegExp(N`
13  \\ (?:
14    ${rs}
15    | [gk]<[^>]*>?
16    | [gk]'[^']*'?
17    | .
18  )
19  | \( (?:
20    \? (?:
21      [:=!>({]
22      | <[=!]
23      | <[^>]*>
24      | '[^']*'
25      | ~\|?
26      | #(?:[^)\\]|\\.?)*
27      | [^:)]*[:)]
28    )?
29    | \*[^\)]*\)?
30  )?
31  | (?:${an.source})+
32  | ${ns}
33  | .
34`.replace(/\s+/g,""),"gsu"),on=new RegExp(N`
35  \\ (?:
36    ${rs}
37    | .
38  )
39  | \[:(?:\^?\p{Alpha}+|\^):\]
40  | ${ns}
41  | &&
42  | .
43`.replace(/\s+/g,""),"gsu");function ss(e,t={}){let n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");let r=$i(n.flags),s=[r.extended],o={captureGroup:n.rules.captureGroup,getCurrentModX(){return s.at(-1)},numOpenGroups:0,popModX(){s.pop()},pushModX(h){s.push(h)},replaceCurrentModX(h){s[s.length-1]=h},singleline:n.rules.singleline},a=[],i;for(yt.lastIndex=0;i=yt.exec(e);){let h=mi(o,e,i[0],yt.lastIndex);h.tokens?a.push(...h.tokens):h.token&&a.push(h.token),h.lastIndex!==void 0&&(yt.lastIndex=h.lastIndex)}let l=[],c=0;a.filter(h=>h.type==="GroupOpen").forEach(h=>{h.kind==="capturing"?h.number=++c:h.raw==="("&&l.push(h)}),c||l.forEach((h,p)=>{h.kind="capturing",h.number=p+1});let u=c||l.length;return{tokens:a.map(h=>h.type==="EscapedNumber"?Oi(h,u):h).flat(),flags:r}}function mi(e,t,n,r){let[s,o]=n;if(n==="["||n==="[^"){let a=yi(t,n,r);return{tokens:a.tokens,lastIndex:a.lastIndex}}if(s==="\\"){if("AbBGyYzZ".includes(o))return{token:Yr(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Ai(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:as(n)}}if(o==="K")return{token:is("keep",n)};if(o==="N"||o==="R")return{token:fe("newline",n,{negate:o==="N"})};if(o==="O")return{token:fe("any",n)};if(o==="X")return{token:fe("text_segment",n)};let a=os(n,{inCharClass:!1});return Array.isArray(a)?{tokens:a}:{token:a}}if(s==="("){if(o==="*")return{token:Ti(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:Ni(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:_e("group",n)};if(n==="(?>")return{token:_e("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:_e(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:_e("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:_e("absence_repeater",n)}}throw n==="(?("?new Error(`Unsupported conditional "${n}"`):new Error(`Invalid or unsupported group option "${n}"`)}if(n===")"){if(e.popModX(),e.numOpenGroups--,e.numOpenGroups<0)throw new Error('Unmatched ")"');return{token:xi(n)}}if(e.getCurrentModX()){if(n==="#"){let a=t.indexOf(`
44`,r);return{lastIndex:a===-1?t.length:a}}if(/^\s$/.test(n)){let a=/\s+/y;return a.lastIndex=r,{lastIndex:a.exec(t)?a.lastIndex:r}}}if(n===".")return{token:fe("dot",n)};if(n==="^"||n==="$"){let a=e.singleline?{"^":N`\A`,$:N`\Z`}[n]:n;return{token:Yr(a,n)}}return n==="|"?{token:wi(n)}:an.test(n)?{tokens:Gi(n)}:{token:Z(se(n),n)}}function yi(e,t,n){let r=[Jr(t[1]==="^",t)],s=1,o;for(on.lastIndex=n;o=on.exec(e);){let a=o[0];if(a[0]==="["&&a[1]!==":")s++,r.push(Jr(a[1]==="^",a));else if(a==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(Z(93,a));else if(s--,r.push(Ci(a)),!s)break}else{let i=bi(a);Array.isArray(i)?r.push(...i):r.push(i)}}return{tokens:r,lastIndex:on.lastIndex||e.length}}function bi(e){if(e[0]==="\\")return os(e,{inCharClass:!0});if(e[0]==="["){let t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!Ue.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return fe("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?_i(e):e==="&&"?Si(e):Z(se(e),e)}function os(e,{inCharClass:t}){let n=e[1];if(n==="c"||n==="C")return Ri(e);if("dDhHsSwW".includes(n))return Li(e);if(e.startsWith(N`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Pi(e)}if(/^\\x[89A-Fa-f]\p{AHex}/u.test(e))try{let r=e.split(/\\x/).slice(1).map(a=>parseInt(a,16)),s=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),o=new TextEncoder;return[...s].map(a=>{let i=[...o.encode(a)].map(l=>`\\x${l.toString(16)}`).join("");return Z(se(a),i)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return Z(Mi(e),e);if(Zr.has(n))return Z(Zr.get(n),e);if(/\d/.test(n))return ki(t,e);if(e==="\\")throw new Error(N`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return Z(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function wi(e){return{type:"Alternator",raw:e}}function Yr(e,t){return{type:"Assertion",kind:e,raw:t}}function as(e){return{type:"Backreference",raw:e}}function Z(e,t){return{type:"Character",value:e,raw:t}}function Ci(e){return{type:"CharacterClassClose",raw:e}}function _i(e){return{type:"CharacterClassHyphen",raw:e}}function Si(e){return{type:"CharacterClassIntersector",raw:e}}function Jr(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function fe(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function is(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:J(n.flags),raw:t}}function ki(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function xi(e){return{type:"GroupClose",raw:e}}function _e(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function vi(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Ei(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Ai(e){return{type:"Subroutine",raw:e}}var Ii=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),Zr=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function Ri(e){let t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return Z(se(t.toUpperCase())-64,e)}function Ni(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??="";let s=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),o=ts(n),a=ts(r),i={};if(o&&(i.enable=o),a&&(i.disable=a),e.endsWith(")"))return t.replaceCurrentModX(s),is("flags",e,{flags:i});if(e.endsWith(":"))return t.pushModX(s),t.numOpenGroups++,_e("group",e,{...(o||a)&&{flags:i}});throw new Error(`Unexpected flag modifier "${e}"`)}function Ti(e){let t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);let{name:n,tag:r,args:s}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);let o=s?s.split(",").filter(u=>u!=="").map(u=>/^[+-]?\d+$/.test(u)?+u:u):[],[a,i,l]=o,c=Ii.has(n)?n.toLowerCase():"custom";switch(c){case"fail":case"mismatch":case"skip":if(o.length>0)throw new Error(`Named callout arguments not allowed "${o}"`);break;case"error":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(typeof a=="string")throw new Error(`Named callout argument must be a number "${a}"`);break;case"max":if(!o.length||o.length>2)throw new Error(`Named callout must have one or two arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(o.length===2&&(typeof i=="number"||!/^[<>X]$/.test(i)))throw new Error(`Named callout optional argument two must be '<', '>', or 'X' "${i}"`);break;case"count":case"total_count":if(o.length>1)throw new Error(`Named callout allows only one argument "${o}"`);if(o.length===1&&(typeof a=="number"||!/^[<>X]$/.test(a)))throw new Error(`Named callout optional argument must be '<', '>', or 'X' "${a}"`);break;case"cmp":if(o.length!==3)throw new Error(`Named callout must have three arguments "${o}"`);if(typeof a=="string"&&!/^[A-Za-z_]\w*$/.test(a))throw new Error(`Named callout argument one must be a tag or number "${a}"`);if(typeof i=="number"||!/^(?:[<>!=]=|[<>])$/.test(i))throw new Error(`Named callout argument two must be '==', '!=', '>', '<', '>=', or '<=' "${i}"`);if(typeof l=="string"&&!/^[A-Za-z_]\w*$/.test(l))throw new Error(`Named callout argument three must be a tag or number "${l}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${c}"`)}return vi(c,r??null,s?.split(",")??null,e)}function es(e){let t=null,n,r;if(e[0]==="{"){let{minStr:s,maxStr:o}=/^\{(?<minStr>\d*)(?:,(?<maxStr>\d*))?/.exec(e).groups,a=1e5;if(+s>a||o&&+o>a)throw new Error("Quantifier value unsupported in Oniguruma");if(n=+s,r=o===void 0?+s:o===""?1/0:+o,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Ei(t,n,r,e)}function Li(e){let t=e[1].toLowerCase();return fe({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Pi(e){let{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return fe("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function ts(e){let t={};return e.includes("i")&&(t.ignoreCase=!0),e.includes("m")&&(t.dotAll=!0),e.includes("x")&&(t.extended=!0),Object.keys(t).length?t:null}function $i(e){let t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){let r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function Mi(e){if(/^(?:\\u(?!\p{AHex}{4})|\\x(?!\p{AHex}{1,2}|\{\p{AHex}{1,8}\}))/u.test(e))throw new Error(`Incomplete or invalid escape "${e}"`);let t=e[2]==="{"?/^\\x\{\s*(?<hex>\p{AHex}+)/u.exec(e).groups.hex:e.slice(2);return parseInt(t,16)}function Oi(e,t){let{raw:n,inCharClass:r}=e,s=n.slice(1);if(!r&&(s!=="0"&&s.length===1||s[0]!=="0"&&+s<=t))return[as(n)];let o=[],a=s.match(/^[0-7]+|\d/g);for(let i=0;i<a.length;i++){let l=a[i],c;if(i===0&&l!=="8"&&l!=="9"){if(c=parseInt(l,8),c>127)throw new Error(N`Octal encoded byte above 177 unsupported "${n}"`)}else c=se(l);o.push(Z(c,(i===0?"\\":"")+l))}return o}function Gi(e){let t=[],n=new RegExp(an,"gy"),r;for(;r=n.exec(e);){let s=r[0];if(s[0]==="{"){let o=/^\{(?<min>\d+),(?<max>\d+)\}\??$/.exec(s);if(o){let{min:a,max:i}=o.groups;if(+a>+i&&s.endsWith("?")){n.lastIndex--,t.push(es(s.slice(0,-1)));continue}}}t.push(es(s))}return t}function bt(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;let n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function ls(e){return Bi.has(e.type)}var Bi=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function Ct(e,t={}){let n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=ss(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),s=(p,f)=>{let d=r.tokens[o.nextIndex];switch(o.parent=p,o.nextIndex++,d.type){case"Alternator":return ee();case"Assertion":return Fi(d);case"Backreference":return Di(d,o);case"Character":return Se(d.value,{useLastValid:!!f.isCheckingRangeEnd});case"CharacterClassHyphen":return Ui(d,o,f);case"CharacterClassOpen":return ji(d,o,f);case"CharacterSet":return Wi(d,o);case"Directive":return Ki(d.kind,{flags:d.flags});case"GroupOpen":return zi(d,o,f);case"NamedCallout":return Yi(d.kind,d.tag,d.arguments);case"Quantifier":return Hi(d,o);case"Subroutine":return qi(d,o);default:throw new Error(`Unexpected token type "${d.type}"`)}},o={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:s},a=Zi(Qi(r.flags)),i=a.body[0];for(;o.nextIndex<r.tokens.length;){let p=s(i,{});p.type==="Alternative"?(a.body.push(p),i=p):i.body.push(p)}let{capturingGroups:l,hasNumberedRef:c,namedGroupsByName:u,subroutines:h}=o;if(c&&u.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(let{ref:p}of h)if(typeof p=="number"){if(p>l.length)throw new Error("Subroutine uses a group number that's not defined");p&&(l[p-1].isSubroutined=!0)}else if(u.has(p)){if(u.get(p).length>1)throw new Error(N`Subroutine uses a duplicate group name "\g<${p}>"`);u.get(p)[0].isSubroutined=!0}else throw new Error(N`Subroutine uses a group name that's not defined "\g<${p}>"`);return a}function Fi({kind:e}){return _t(J({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===N`\B`||e===N`\Y`})}function Di({raw:e},t){let n=/^\\k[<']/.test(e),r=n?e.slice(3,-1):e.slice(1),s=(o,a=!1)=>{let i=t.capturingGroups.length,l=!1;if(o>i)if(t.skipBackrefValidation)l=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,wt(a?i+1-o:o,{orphan:l})};if(n){let o=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(o)return s(+o.groups.num,!!o.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return wt(r)}return s(+r)}function Ui(e,t,n){let{tokens:r,walk:s}=t,o=t.parent,a=o.body.at(-1),i=r[t.nextIndex];if(!n.isCheckingRangeEnd&&a&&a.type!=="CharacterClass"&&a.type!=="CharacterClassRange"&&i&&i.type!=="CharacterClassOpen"&&i.type!=="CharacterClassClose"&&i.type!=="CharacterClassIntersector"){let l=s(o,{...n,isCheckingRangeEnd:!0});if(a.type==="Character"&&l.type==="Character")return o.body.pop(),Xi(a,l);throw new Error("Invalid character class range")}return Se(se("-"))}function ji({negate:e},t,n){let{tokens:r,walk:s}=t,o=[je()],a=r[t.nextIndex],i=hs(a);for(;i.type!=="CharacterClassClose";){if(i.type==="CharacterClassIntersector")o.push(je()),t.nextIndex++;else{let c=o.at(-1);c.body.push(s(c,n))}i=hs(r[t.nextIndex],a)}let l=je({negate:e});return o.length===1?l.body=o[0].body:(l.kind="intersection",l.body=o.map(c=>c.body.length===1?c.body[0]:c)),t.nextIndex++,l}function Wi({kind:e,negate:t,value:n},r){let{normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a}=r;if(e==="property"){let i=ke(n);if(Ue.has(i)&&!a?.has(i))e="posix",n=i;else return de(n,{negate:t,normalizeUnknownPropertyNames:s,skipPropertyNameValidation:o,unicodePropertyMap:a})}return e==="posix"?Ji(n,{negate:t}):St(e,{negate:t})}function zi(e,t,n){let{tokens:r,capturingGroups:s,namedGroupsByName:o,skipLookbehindValidation:a,walk:i}=t,l=el(e),c=l.type==="AbsenceFunction",u=us(l),h=u&&l.negate;if(l.type==="CapturingGroup"&&(s.push(l),l.name&&Qr(o,l.name,[]).push(l)),c&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let p=ps(r[t.nextIndex]);for(;p.type!=="GroupClose";){if(p.type==="Alternator")l.body.push(ee()),t.nextIndex++;else{let f=l.body.at(-1),d=i(f,{...n,isInAbsenceFunction:n.isInAbsenceFunction||c,isInLookbehind:n.isInLookbehind||u,isInNegLookbehind:n.isInNegLookbehind||h});if(f.body.push(d),(u||n.isInLookbehind)&&!a){let b="Lookbehind includes a pattern not allowed by Oniguruma";if(h||n.isInNegLookbehind){if(cs(d)||d.type==="CapturingGroup")throw new Error(b)}else if(cs(d)||us(d)&&d.negate)throw new Error(b)}}p=ps(r[t.nextIndex])}return t.nextIndex++,l}function Hi({kind:e,min:t,max:n},r){let s=r.parent,o=s.body.at(-1);if(!o||!ls(o))throw new Error("Quantifier requires a repeatable token");let a=cn(e,t,n,o);return s.body.pop(),a}function qi({raw:e},t){let{capturingGroups:n,subroutines:r}=t,s=e.slice(3,-1),o=/^(?<sign>[-+]?)0*(?<num>[1-9]\d*)$/.exec(s);if(o){let i=+o.groups.num,l=n.length;if(t.hasNumberedRef=!0,s={"":i,"+":l+i,"-":l+1-i}[o.groups.sign],s<1)throw new Error("Invalid subroutine number")}else s==="0"&&(s=0);let a=un(s);return r.push(a),a}function Vi(e,t){if(e!=="repeater")throw new Error(`Unexpected absence function kind "${e}"`);return{type:"AbsenceFunction",kind:e,body:We(t?.body)}}function ee(e){return{type:"Alternative",body:fs(e?.body)}}function _t(e,t){let n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!t?.negate),n}function wt(e,t){let n=!!t?.orphan;return{type:"Backreference",ref:e,...n&&{orphan:n}}}function ln(e,t){let n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!tl(n.name))throw new Error(`Group name "${n.name}" invalid in Oniguruma`);return{type:"CapturingGroup",number:e,...n.name&&{name:n.name},...n.isSubroutined&&{isSubroutined:n.isSubroutined},body:We(t?.body)}}function Se(e,t){let n={useLastValid:!1,...t};if(e>1114111){let r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function je(e){let t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:fs(e?.body)}}function Xi(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function St(e,t){let n=!!t?.negate,r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function Ki(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:J(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function Qi(e){return{type:"Flags",...e}}function F(e){let t=e?.atomic,n=e?.flags;if(t&&n)throw new Error("Atomic group cannot have flags");return{type:"Group",...t&&{atomic:t},...n&&{flags:n},body:We(e?.body)}}function oe(e){let t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:We(e?.body)}}function Yi(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function Ji(e,t){let n=!!t?.negate;if(!Ue.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function cn(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function Zi(e,t){return{type:"Regex",body:We(t?.body),flags:e}}function un(e){return{type:"Subroutine",ref:e}}function de(e,t){let n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t},r=n.unicodePropertyMap?.get(ke(e));if(!r){if(n.normalizeUnknownPropertyNames)r=nl(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(N`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function el({flags:e,kind:t,name:n,negate:r,number:s}){switch(t){case"absence_repeater":return Vi("repeater");case"atomic":return F({atomic:!0});case"capturing":return ln(s,{name:n});case"group":return F({flags:e});case"lookahead":case"lookbehind":return oe({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function We(e){if(e===void 0)e=[ee()];else if(!Array.isArray(e)||!e.length||!e.every(t=>t.type==="Alternative"))throw new Error("Invalid body; expected array of one or more Alternative nodes");return e}function fs(e){if(e===void 0)e=[];else if(!Array.isArray(e)||!e.every(t=>!!t.type))throw new Error("Invalid body; expected array of nodes");return e}function cs(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function us(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function tl(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function nl(e){return e.trim().replace(/[- _]+/g,"_").replace(/[A-Z][a-z]+(?=[A-Z])/g,"$&_").replace(/[A-Za-z]+/g,t=>t[0].toUpperCase()+t.slice(1).toLowerCase())}function ke(e){return e.replace(/[- _]+/g,"").toLowerCase()}function hs(e,t){let n=t;return J(e,`Unclosed character class${n?.type==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function ps(e){return J(e,"Unclosed group")}function ge(e,t,n=null){function r(o,a){for(let i=0;i<o.length;i++){let l=s(o[i],a,i,o);i=Math.max(-1,i+l)}}function s(o,a=null,i=null,l=null){let c=0,u=!1,h={node:o,parent:a,key:i,container:l,root:e,remove(){kt(l).splice(Math.max(0,xe(i)+c),1),c--,u=!0},removeAllNextSiblings(){return kt(l).splice(xe(i)+1)},removeAllPrevSiblings(){let m=xe(i)+c;return c-=m,kt(l).splice(0,Math.max(0,m))},replaceWith(m,y={}){let C=!!y.traverse;l?l[Math.max(0,xe(i)+c)]=m:J(a,"Can't replace root node")[i]=m,C&&s(m,a,i,l),u=!0},replaceWithMultiple(m,y={}){let C=!!y.traverse;if(kt(l).splice(Math.max(0,xe(i)+c),1,...m),c+=m.length-1,C){let k=0;for(let v=0;v<m.length;v++)k+=s(m[v],a,xe(i)+v+k,l)}u=!0},skip(){u=!0}},{type:p}=o,f=t["*"],d=t[p],b=typeof f=="function"?f:f?.enter,w=typeof d=="function"?d:d?.enter;if(b?.(h,n),w?.(h,n),!u)switch(p){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(o.body,o);break;case"Assertion":case"Backreference":case"Character":case"CharacterSet":case"Directive":case"Flags":case"NamedCallout":case"Subroutine":break;case"CharacterClassRange":s(o.min,o,"min"),s(o.max,o,"max");break;case"Quantifier":s(o.body,o,"body");break;case"Regex":r(o.body,o),s(o.flags,o,"flags");break;default:throw new Error(`Unexpected node type "${p}"`)}return d?.exit?.(h,n),f?.exit?.(h,n),c}return s(e),e}function kt(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function xe(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}var ds=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function gs(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function ms(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}var B=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function ze(e,t,n,r){let s=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),o=[!1],a=0,i="";for(let l of e.matchAll(s)){let{0:c,groups:{$skip:u}}=l;if(!u&&(!r||r===B.DEFAULT==!a)){n instanceof Function?i+=n(l,{context:a?B.CHAR_CLASS:B.DEFAULT,negated:o[o.length-1]}):i+=n;continue}c[0]==="["?(a++,o.push(c[1]==="^")):c==="]"&&a&&(a--,o.pop()),i+=c}return i}function hn(e,t,n,r){ze(e,t,n,r)}function rl(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;let s=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");s.lastIndex=n;let o=0,a;for(;a=s.exec(e);){let{0:i,groups:{$skip:l}}=a;if(!l&&(!r||r===B.DEFAULT==!o))return a;i==="["?o++:i==="]"&&o&&o--,s.lastIndex==a.index&&s.lastIndex++}return null}function He(e,t,n){return!!rl(e,t,0,n)}function ys(e,t){let n=/\\?./gsu;n.lastIndex=t;let r=e.length,s=0,o=1,a;for(;a=n.exec(e);){let[i]=a;if(i==="[")s++;else if(s)i==="]"&&s--;else if(i==="(")o++;else if(i===")"&&(o--,!o)){r=a.index;break}}return e.slice(t,r)}var bs=new RegExp(String.raw`(?<noncapturingStart>${ds})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function fn(e,t){let n=t?.hiddenCaptures??[],r=t?.captureTransfers??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};let s="(?>",o="(?:(?=(",a=[0],i=[],l=0,c=0,u=NaN,h;do{h=!1;let p=0,f=0,d=!1,b;for(bs.lastIndex=Number.isNaN(u)?0:u+o.length;b=bs.exec(e);){let{0:w,index:m,groups:{capturingStart:y,noncapturingStart:C}}=b;if(w==="[")p++;else if(p)w==="]"&&p--;else if(w===s&&!d)u=m,d=!0;else if(d&&C)f++;else if(y)d?f++:(l++,a.push(l+c));else if(w===")"&&d){if(!f){c++;let k=l+c;if(e=`${e.slice(0,u)}${o}${e.slice(u+s.length,m)}))<$$${k}>)${e.slice(m+1)}`,h=!0,i.push(k),gs(n,k),r.size){let v=new Map;r.forEach((P,O)=>{v.set(O>=k?O+1:O,P.map(z=>z>=k?z+1:z))}),r=v}break}f--}}}while(h);return n.push(...i),e=ze(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:p,groups:{backrefNum:f,wrappedBackrefNum:d}})=>{if(f){let b=+f;if(b>a.length-1)throw new Error(`Backref "${p}" greater than number of captures`);return`\\${a[b]}`}return`\\${d}`},B.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}var ws=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,pn=new RegExp(String.raw`
45\\(?: \d+
46  | c[A-Za-z]
47  | [gk]<[^>]+>
48  | [pPu]\{[^\}]+\}
49  | u[A-Fa-f\d]{4}
50  | x[A-Fa-f\d]{2}
51  )
52| \((?: \? (?: [:=!>]
53  | <(?:[=!]|[^>]+>)
54  | [A-Za-z\-]+:
55  | \(DEFINE\)
56  ))?
57| (?<qBase>${ws})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
58| \\?.
59`.replace(/\s+/g,""),"gsu");function dn(e){if(!new RegExp(`${ws}\\+`).test(e))return{pattern:e};let t=[],n=null,r=null,s="",o=0,a;for(pn.lastIndex=0;a=pn.exec(e);){let{0:i,index:l,groups:{qBase:c,qMod:u,invalidQ:h}}=a;if(i==="[")o||(r=l),o++;else if(i==="]")o?o--:r=null;else if(!o)if(u==="+"&&s&&!s.startsWith("(")){if(h)throw new Error(`Invalid quantifier "${i}"`);let p=-1;if(/^\{\d+\}$/.test(c))e=ms(e,l+c.length,u,"");else{if(s===")"||s==="]"){let f=s===")"?n:r;if(f===null)throw new Error(`Invalid unmatched "${s}"`);e=`${e.slice(0,f)}(?>${e.slice(f,l)}${c})${e.slice(l+i.length)}`}else e=`${e.slice(0,l-s.length)}(?>${s}${c})${e.slice(l+i.length)}`;p+=4}pn.lastIndex+=p}else i[0]==="("?t.push(l):i===")"&&(n=t.length?t.pop():null);s=i}return{pattern:e}}var j=String.raw,sl=j`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,mn=j`\(\?R=(?<rDepth>[^\)]+)\)|${sl}`,xt=j`\(\?<(?![=!])(?<captureName>[^>]+)>`,xs=j`${xt}|(?<unnamed>\()(?!\?)`,me=new RegExp(j`${xt}|${mn}|\(\?|\\?.`,"gsu"),gn="Cannot use multiple overlapping recursions";function vs(e,t){let{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t},s=t?.captureTransfers??new Map;if(!new RegExp(mn,"su").test(e))return{pattern:e,captureTransfers:s,hiddenCaptures:n};if(r==="plugin"&&He(e,j`\(\?\(DEFINE\)`,B.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");let o=[],a=He(e,j`\\[1-9]`,B.DEFAULT),i=new Map,l=[],c=!1,u=0,h=0,p;for(me.lastIndex=0;p=me.exec(e);){let{0:f,groups:{captureName:d,rDepth:b,gRNameOrNum:w,gRDepth:m}}=p;if(f==="[")u++;else if(u)f==="]"&&u--;else if(b){if(Cs(b),c)throw new Error(gn);if(a)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);let y=e.slice(0,p.index),C=e.slice(me.lastIndex);if(He(C,mn,B.DEFAULT))throw new Error(gn);let k=+b-1;e=_s(y,C,k,!1,n,o,h),s=ks(s,y,k,o.length,0,h);break}else if(w){Cs(m);let y=!1;for(let H of l)if(H.name===w||H.num===+w){if(y=!0,H.hasRecursedWithin)throw new Error(gn);break}if(!y)throw new Error(j`Recursive \g cannot be used outside the referenced group "${r==="external"?w:j`\g<${w}&R=${m}>`}"`);let C=i.get(w),k=ys(e,C);if(a&&He(k,j`${xt}|\((?!\?)`,B.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);let v=e.slice(C,p.index),P=k.slice(v.length+f.length),O=o.length,z=+m-1,ye=_s(v,P,z,!0,n,o,h);s=ks(s,v,z,o.length-O,O,h);let At=e.slice(0,C),It=e.slice(C+k.length);e=`${At}${ye}${It}`,me.lastIndex+=ye.length-f.length-v.length-P.length,l.forEach(H=>H.hasRecursedWithin=!0),c=!0}else if(d)h++,i.set(String(h),me.lastIndex),i.set(d,me.lastIndex),l.push({num:h,name:d});else if(f[0]==="("){let y=f==="(";y&&(h++,i.set(String(h),me.lastIndex)),l.push(y?{num:h}:{})}else f===")"&&l.pop()}return n.push(...o),{pattern:e,captureTransfers:s,hiddenCaptures:n}}function Cs(e){let t=`Max depth must be integer between 2 and 100; used ${e}`;if(!/^[1-9]\d*$/.test(e))throw new Error(t);if(e=+e,e<2||e>100)throw new Error(t)}function _s(e,t,n,r,s,o,a){let i=new Set;r&&hn(e+t,xt,({groups:{captureName:c}})=>{i.add(c)},B.DEFAULT);let l=[n,r?i:null,s,o,a];return`${e}${Ss(`(?:${e}`,"forward",...l)}(?:)${Ss(`${t})`,"backward",...l)}${t}`}function Ss(e,t,n,r,s,o,a){let l=u=>t==="forward"?u+2:n-u+2-1,c="";for(let u=0;u<n;u++){let h=l(u);c+=ze(e,j`${xs}|\\k<(?<backref>[^>]+)>`,({0:p,groups:{captureName:f,unnamed:d,backref:b}})=>{if(b&&r&&!r.has(b))return p;let w=`_$${h}`;if(d||f){let m=a+o.length+1;return o.push(m),ol(s,m),d?p:`(?<${f}${w}>`}return j`\k<${b}${w}>`},B.DEFAULT)}return c}function ol(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function ks(e,t,n,r,s,o){if(e.size&&r){let a=0;hn(t,xs,()=>a++,B.DEFAULT);let i=o-a+s,l=new Map;return e.forEach((c,u)=>{let h=(r-a*n)/n,p=a*n,f=u>i+a?u+r:u,d=[];for(let b of c)if(b<=i)d.push(b);else if(b>i+a+h)d.push(b+r);else if(b<=i+a)for(let w=0;w<=n;w++)d.push(b+a*w);else for(let w=0;w<=n;w++)d.push(b+p+h*w);l.set(f,d)}),l}return e}var T=String.fromCodePoint,S=String.raw,W={},Et=globalThis.RegExp;W.flagGroups=(()=>{try{new Et("(?i:)")}catch{return!1}return!0})();W.unicodeSets=(()=>{try{new Et("[[]]","v")}catch{return!1}return!0})();W.bugFlagVLiteralHyphenIsRange=W.unicodeSets?(()=>{try{new Et(S`[\d\-a]`,"v")}catch{return!0}return!1})():!1;W.bugNestedClassIgnoresNegation=W.unicodeSets&&new Et("[[^a]]","v").test("a");function vt(e,{enable:t,disable:n}){return{dotAll:!n?.dotAll&&!!(t?.dotAll||e.dotAll),ignoreCase:!n?.ignoreCase&&!!(t?.ignoreCase||e.ignoreCase)}}function qe(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function _n(e,t){return Es[e]>=Es[t]}function al(e,t){if(e==null)throw new Error(t??"Value expected");return e}var Es={ES2025:2025,ES2024:2024,ES2018:2018},il={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function Ts(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!il[e.target])throw new Error(`Unexpected target "${e.target}"`);let t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=W.flagGroups?"ES2025":W.unicodeSets?"ES2024":"ES2018"),t}var ll="[	-\r ]",cl=new Set([T(304),T(305)]),te=S`[\p{L}\p{M}\p{N}\p{Pc}]`;function Ls(e){if(cl.has(e))return[e];let t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),s=pl.get(n),o=ul.get(n),a=hl.get(n);return[...r].length===1&&t.add(r),a&&t.add(a),s&&t.add(s),t.add(n),o&&t.add(o),[...t]}var kn=new Map(`C Other
60Cc Control cntrl
61Cf Format
62Cn Unassigned
63Co Private_Use
64Cs Surrogate
65L Letter
66LC Cased_Letter
67Ll Lowercase_Letter
68Lm Modifier_Letter
69Lo Other_Letter
70Lt Titlecase_Letter
71Lu Uppercase_Letter
72M Mark Combining_Mark
73Mc Spacing_Mark
74Me Enclosing_Mark
75Mn Nonspacing_Mark
76N Number
77Nd Decimal_Number digit
78Nl Letter_Number
79No Other_Number
80P Punctuation punct
81Pc Connector_Punctuation
82Pd Dash_Punctuation
83Pe Close_Punctuation
84Pf Final_Punctuation
85Pi Initial_Punctuation
86Po Other_Punctuation
87Ps Open_Punctuation
88S Symbol
89Sc Currency_Symbol
90Sk Modifier_Symbol
91Sm Math_Symbol
92So Other_Symbol
93Z Separator
94Zl Line_Separator
95Zp Paragraph_Separator
96Zs Space_Separator
97ASCII
98ASCII_Hex_Digit AHex
99Alphabetic Alpha
100Any
101Assigned
102Bidi_Control Bidi_C
103Bidi_Mirrored Bidi_M
104Case_Ignorable CI
105Cased
106Changes_When_Casefolded CWCF
107Changes_When_Casemapped CWCM
108Changes_When_Lowercased CWL
109Changes_When_NFKC_Casefolded CWKCF
110Changes_When_Titlecased CWT
111Changes_When_Uppercased CWU
112Dash
113Default_Ignorable_Code_Point DI
114Deprecated Dep
115Diacritic Dia
116Emoji
117Emoji_Component EComp
118Emoji_Modifier EMod
119Emoji_Modifier_Base EBase
120Emoji_Presentation EPres
121Extended_Pictographic ExtPict
122Extender Ext
123Grapheme_Base Gr_Base
124Grapheme_Extend Gr_Ext
125Hex_Digit Hex
126IDS_Binary_Operator IDSB
127IDS_Trinary_Operator IDST
128ID_Continue IDC
129ID_Start IDS
130Ideographic Ideo
131Join_Control Join_C
132Logical_Order_Exception LOE
133Lowercase Lower
134Math
135Noncharacter_Code_Point NChar
136Pattern_Syntax Pat_Syn
137Pattern_White_Space Pat_WS
138Quotation_Mark QMark
139Radical
140Regional_Indicator RI
141Sentence_Terminal STerm
142Soft_Dotted SD
143Terminal_Punctuation Term
144Unified_Ideograph UIdeo
145Uppercase Upper
146Variation_Selector VS
147White_Space space
148XID_Continue XIDC
149XID_Start XIDS`.split(/\s/).map(e=>[ke(e),e])),ul=new Map([["s",T(383)],[T(383),"s"]]),hl=new Map([[T(223),T(7838)],[T(107),T(8490)],[T(229),T(8491)],[T(969),T(8486)]]),pl=new Map([ae(453),ae(456),ae(459),ae(498),...yn(8072,8079),...yn(8088,8095),...yn(8104,8111),ae(8124),ae(8140),ae(8188)]),fl=new Map([["alnum",S`[\p{Alpha}\p{Nd}]`],["alpha",S`\p{Alpha}`],["ascii",S`\p{ASCII}`],["blank",S`[\p{Zs}\t]`],["cntrl",S`\p{Cc}`],["digit",S`\p{Nd}`],["graph",S`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",S`\p{Lower}`],["print",S`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",S`[\p{P}\p{S}]`],["space",S`\p{space}`],["upper",S`\p{Upper}`],["word",S`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",S`\p{AHex}`]]);function dl(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function ae(e){let t=T(e);return[t.toLowerCase(),t]}function yn(e,t){return dl(e,t).map(n=>ae(n))}var Ps=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function gl(e,t){let n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};$s(e);let r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:_n(n.bestEffortTarget,"ES2024"),passedLookbehind:!1,strategy:null,subroutineRefMap:new Map,supportedGNodes:new Set,digitIsAscii:e.flags.digitIsAscii,spaceIsAscii:e.flags.spaceIsAscii,wordIsAscii:e.flags.wordIsAscii};ge(e,ml,r);let s={dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},o={currentFlags:s,prevFlags:null,globalFlags:s,groupOriginByCopy:new Map,groupsByName:new Map,multiplexCapturesToLeftByRef:new Map,openRefs:new Map,reffedNodesByReferencer:new Map,subroutineRefMap:r.subroutineRefMap};ge(e,yl,o);let a={groupsByName:o.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:o.reffedNodesByReferencer};return ge(e,bl,a),e._originMap=o.groupOriginByCopy,e._strategy=r.strategy,e}var ml={AbsenceFunction({node:e,parent:t,replaceWith:n}){let{body:r,kind:s}=e;if(s==="repeater"){let o=F();o.body[0].body.push(oe({negate:!0,body:r}),de("Any"));let a=F();a.body[0].body.push(cn("greedy",0,1/0,o)),n(R(a,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){let s=e.body.filter(o=>o.kind==="flags");for(let o=n+1;o<t.body.length;o++){let a=t.body[o];qe(r,a,[]).push(...s)}},exit({node:e},{flagDirectivesByAlt:t}){if(t.get(e)?.length){let n=Os(t.get(e));if(n){let r=F({flags:n});r.body[0].body=e.body,e.body=[R(r,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:s,remove:o,replaceWith:a},i){let{kind:l,negate:c}=e,{asciiWordBoundaries:u,avoidSubclass:h,supportedGNodes:p,wordIsAscii:f}=i;if(l==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${c?"Y":"y"}"`);if(l==="line_end")a(R(oe({body:[ee({body:[_t("string_end")]}),ee({body:[Se(10)]})]}),t));else if(l==="line_start")a(R(ne(S`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(l==="search_start")if(p.has(e))s.flags.sticky=!0,o();else{let d=r[n-1];if(d&&xl(d))a(R(oe({negate:!0}),t));else{if(h)throw new Error(S`Uses "\G" in a way that requires a subclass`);a(ie(_t("string_start"),t)),i.strategy="clip_search"}}else if(!(l==="string_end"||l==="string_start"))if(l==="string_end_newline")a(R(ne(S`(?=\n?\z)`),t));else if(l==="word_boundary"){if(!f&&!u){let d=`(?:(?<=${te})(?!${te})|(?<!${te})(?=${te}))`,b=`(?:(?<=${te})(?=${te})|(?<!${te})(?!${te}))`;a(R(ne(c?b:d),t))}}else throw new Error(`Unexpected assertion kind "${l}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!wn(n)&&(n=bn(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!wn(r)&&(r=bn(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){let r=je({body:[e]});n(R(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:s,digitIsAscii:o,spaceIsAscii:a,wordIsAscii:i}){let{kind:l,negate:c,value:u}=e;if(o&&(l==="digit"||u==="digit")){n(ie(St("digit",{negate:c}),t));return}if(a&&(l==="space"||u==="space")){n(R(Cn(ne(ll),c),t));return}if(i&&(l==="word"||u==="word")){n(ie(St("word",{negate:c}),t));return}if(l==="any")n(ie(de("Any"),t));else if(l==="digit")n(ie(de("Nd",{negate:c}),t));else if(l!=="dot")if(l==="text_segment"){if(r==="strict")throw new Error(S`Use of "\X" requires non-strict accuracy`);let h="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",p=S`\p{RI}{2}|${h}(?:\u200D${h})*`;n(R(ne(S`(?>\r\n|${s?S`\p{RGI_Emoji}`:p}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(l==="hex")n(ie(de("AHex",{negate:c}),t));else if(l==="newline")n(R(ne(c?`[^
150]`:`(?>\r
151?|[
152\v\f\x85\u2028\u2029])`),t));else if(l==="posix")if(!s&&(u==="graph"||u==="print")){if(r==="strict")throw new Error(`POSIX class "${u}" requires min target ES2024 or non-strict accuracy`);let h={graph:"!-~",print:" -~"}[u];c&&(h=`\0-${T(h.codePointAt(0)-1)}${T(h.codePointAt(2)+1)}-\u{10FFFF}`),n(R(ne(`[${h}]`),t))}else n(R(Cn(ne(fl.get(u)),c),t));else if(l==="property")kn.has(ke(u))||(e.key="sc");else if(l==="space")n(ie(de("space",{negate:c}),t));else if(l==="word")n(R(Cn(ne(te),c),t));else throw new Error(`Unexpected character set kind "${l}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:s,removeAllPrevSiblings:o,removeAllNextSiblings:a}){let{kind:i,flags:l}=e;if(i==="flags")if(!l.enable&&!l.disable)r();else{let c=F({flags:l});c.body[0].body=a(),s(R(c,t),{traverse:!0})}else if(i==="keep"){let c=n.body[0],h=n.body.length===1&&bt(c,{type:"Group"})&&c.body[0].body.length===1?c.body[0]:n;if(t.parent!==h||h.body.length>1)throw new Error(S`Uses "\K" in a way that's unsupported`);let p=oe({behind:!0});p.body[0].body=o(),s(R(p,t))}else throw new Error(`Unexpected directive kind "${i}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;let{enable:t,disable:n}=e.flags;t?.extended&&delete t.extended,n?.extended&&delete n.extended,t?.dotAll&&n?.dotAll&&delete t.dotAll,t?.ignoreCase&&n?.ignoreCase&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){let{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){let{kind:r}=e;if(r==="fail")n(R(oe({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){let t=F();t.body[0].body.push(e.body),e.body=R(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){let n=[],r=!1,s=!1;for(let o of e.body)if(o.body.length===1&&o.body[0].kind==="search_start")o.body.pop();else{let a=Bs(o.body);a?(r=!0,Array.isArray(a)?n.push(...a):n.push(a)):s=!0}r&&!s&&n.forEach(o=>t.add(o))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(S`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!wn(n)&&(n=bn(n,t),e.ref=n)}},yl={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){let{orphan:r,ref:s}=e;r||n.set(e,[...t.get(s).map(({node:o})=>o)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:s,groupsByName:o,multiplexCapturesToLeftByRef:a,openRefs:i,reffedNodesByReferencer:l}){let c=s.get(e);if(c&&i.has(e.number)){let h=ie(As(e.number),t);l.set(h,i.get(e.number)),n(h);return}i.set(e.number,e),a.set(e.number,[]),e.name&&qe(a,e.name,[]);let u=a.get(e.name??e.number);for(let h=0;h<u.length;h++){let p=u[h];if(c===p.node||c&&c===p.origin||e===p.origin){u.splice(h,1);break}}if(a.get(e.number).push({node:e,origin:c}),e.name&&a.get(e.name).push({node:e,origin:c}),e.name){let h=qe(o,e.name,new Map),p=!1;if(c)p=!0;else for(let f of h.values())if(!f.hasDuplicateNameToRemove){p=!0;break}o.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:p})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=vt(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){let{isRecursive:s,ref:o}=e;if(s){let u=t;for(;(u=u.parent)&&!(u.type==="CapturingGroup"&&(u.name===o||u.number===o)););r.reffedNodesByReferencer.set(e,u);return}let a=r.subroutineRefMap.get(o),i=o===0,l=i?As(0):Ms(a,r.groupOriginByCopy,null),c=l;if(!i){let u=Os(_l(a,p=>p.type==="Group"&&!!p.flags)),h=u?vt(r.globalFlags,u):r.globalFlags;wl(h,r.currentFlags)||(c=F({flags:Sl(h)}),c.body[0].body.push(l))}n(R(c,t),{traverse:!i})}},bl={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}let o=r.reffedNodesByReferencer.get(e).filter(a=>Cl(a,e));if(!o.length)n(R(oe({negate:!0}),t));else if(o.length>1){let a=F({atomic:!0,body:o.reverse().map(i=>ee({body:[wt(i.number)]}))});n(R(a,t))}else e.ref=o[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){let n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let r=0;r<n;r++){let s=ln();e.body.at(-1).body.push(s)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function $s(e){ge(e,{"*"({node:t,parent:n}){t.parent=n}})}function wl(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function Cl(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;let r=Gs(n.parent);for(let s of r){if(s===n)break;if(s===e||Fs(s,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function Ms(e,t,n,r){let s=Array.isArray(e)?[]:{};for(let[o,a]of Object.entries(e))o==="parent"?s.parent=Array.isArray(n)?r:n:a&&typeof a=="object"?s[o]=Ms(a,t,s,n):(o==="type"&&a==="CapturingGroup"&&t.set(s,t.get(e)??e),s[o]=a);return s}function As(e){let t=un(e);return t.isRecursive=!0,t}function _l(e,t){let n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function bn(e,t){if(t.has(e))return t.get(e);let n=`$${t.size}_${e.replace(/^[^$_\p{IDS}]|[^$\u200C\u200D\p{IDC}]/ug,"_")}`;return t.set(e,n),n}function Os(e){let t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(s=>{r.enable?.[s]&&(delete n.disable[s],n.enable[s]=!0),r.disable?.[s]&&(n.disable[s]=!0)})}),Object.keys(n.enable).length||delete n.enable,Object.keys(n.disable).length||delete n.disable,n.enable||n.disable?n:null}function Sl({dotAll:e,ignoreCase:t}){let n={};return(e||t)&&(n.enable={},e&&(n.enable.dotAll=!0),t&&(n.enable.ignoreCase=!0)),(!e||!t)&&(n.disable={},!e&&(n.disable.dotAll=!0),!t&&(n.disable.ignoreCase=!0)),n}function Gs(e){if(!e)throw new Error("Node expected");let{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function Bs(e){let t=e.find(n=>n.kind==="search_start"||vl(n,{negate:!1})||!kl(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){let n=[];for(let r of t.body){let s=Bs(r.body);if(!s)return null;Array.isArray(s)?n.push(...s):n.push(s)}return n}return null}function Fs(e,t){let n=Gs(e)??[];for(let r of n)if(r===t||Fs(r,t))return!0;return!1}function kl({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function xl(e){let t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function vl(e,t){let n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&bt(e.body[0],{type:"Assertion",kind:"search_start"})}function wn(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function ne(e,t){let r=Ct(e,{...t,unicodePropertyMap:kn}).body;return r.length>1||r[0].body.length>1?F({body:r}):r[0].body[0]}function Cn(e,t){return e.negate=t,e}function ie(e,t){return e.parent=t,e}function R(e,t){return $s(e),e.parent=t,e}function El(e,t){let n=Ts(t),r=_n(n.target,"ES2024"),s=_n(n.target,"ES2025"),o=n.rules.recursionLimit;if(!Number.isInteger(o)||o<2||o>20)throw new Error("Invalid recursionLimit; use 2-20");let a=null,i=null;if(!s){let f=[e.flags.ignoreCase];ge(e,Al,{getCurrentModI:()=>f.at(-1),popModI(){f.pop()},pushModI(d){f.push(d)},setHasCasedChar(){f.at(-1)?a=!0:i=!0}})}let l={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||a)&&!i)},c=e,u={accuracy:n.accuracy,appliedGlobalFlags:l,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:c,originMap:e._originMap,recursionLimit:o,useAppliedIgnoreCase:!!(!s&&a&&i),useFlagMods:s,useFlagV:r,verbose:n.verbose};function h(f){return u.lastNode=c,c=f,al(Il[f.type],`Unexpected node type "${f.type}"`)(f,u,h)}let p={pattern:e.body.map(h).join("|"),flags:h(e.flags),options:{...e.options}};return r||(delete p.options.force.v,p.options.disable.v=!0,p.options.unicodeSetsPlugin=null),p._captureTransfers=new Map,p._hiddenCaptures=[],u.captureMap.forEach((f,d)=>{f.hidden&&p._hiddenCaptures.push(d),f.transferTo&&qe(p._captureTransfers,f.transferTo,[]).push(d)}),p}var Al={"*":{enter({node:e},t){if(Rs(e)){let n=t.getCurrentModI();t.pushModI(e.flags?vt({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){Rs(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){xn(T(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),Ds(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&Ps.has(e.value)&&t.setHasCasedChar()}},Il={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?S`\B`:S`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){let{body:r,name:s,number:o}=e,a={ignoreCase:t.currentFlags.ignoreCase},i=t.originMap.get(e);return i&&(a.hidden=!0,o>i.number&&(a.transferTo=i.number)),t.captureMap.set(o,a),`(${s?`?<${s}>`:""}${r.map(n).join("|")})`},Character({value:e},t){let n=T(e),r=ve(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&xn(n)){let s=Ls(n);return t.inCharClass?s.join(""):s.length>1?`[${s.join("")}]`:s[0]}return n},CharacterClass(e,t,n){let{kind:r,negate:s,parent:o}=e,{body:a}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");W.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&a.some(Ns)&&(a=[Se(45),...a.filter(c=>!Ns(c))]);let i=()=>`[${s?"^":""}${a.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||W.bugNestedClassIgnoresNegation)&&!s){let u=a.filter(h=>h.type==="CharacterClass"&&h.kind==="union"&&h.negate);if(u.length){let h=F(),p=h.body[0];return h.parent=o,p.parent=h,a=a.filter(f=>!u.includes(f)),e.body=a,a.length?(e.parent=p,p.body.push(e)):h.body.pop(),u.forEach(f=>{let d=ee({body:[f]});f.parent=d,d.parent=h,h.body.push(d)}),n(h)}}t.inCharClass=!0;let c=i();return t.inCharClass=!1,c}let l=a[0];if(r==="union"&&!s&&l&&((!t.useFlagV||!t.verbose)&&o.kind==="union"&&!(W.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&o.kind==="intersection"&&a.length===1&&l.type!=="CharacterClassRange"))return a.map(n).join("");if(!t.useFlagV&&o.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return i()},CharacterClassRange(e,t){let n=e.min.value,r=e.max.value,s={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},o=ve(n,s),a=ve(r,s),i=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){let l=Ds(e);Pl(l).forEach(u=>{i.add(Array.isArray(u)?`${ve(u[0],s)}-${ve(u[1],s)}`:ve(u,s))})}return`${o}-${a}${[...i].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},s){if(e==="dot")return s.currentFlags.dotAll?s.appliedGlobalFlags.dotAll||s.useFlagMods?".":"[^]":S`[^\n]`;if(e==="digit")return t?S`\D`:S`\d`;if(e==="property"){if(s.useAppliedIgnoreCase&&s.currentFlags.ignoreCase&&Ps.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?S`\P`:S`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?S`\W`:S`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},s,o){let a=s.currentFlags;n&&(s.currentFlags=vt(a,n));let i=t.map(o).join("|"),l=!s.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!s.useFlagMods||!n)?i:`(?${$l(e,n,s.useFlagMods)}${i})`;return s.currentFlags=a,l},LookaroundAssertion({body:e,kind:t,negate:n},r,s){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(s).join("|")})`},Quantifier(e,t,n){return n(e.body)+Ml(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");let r=n.recursionLimit;return t===0?`(?R=${r})`:S`\g<${t}&R=${r}>`}},Rl=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),Nl=new Set(["-","\\","]","^","["]),Tl=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),Is=new Map([[9,S`\t`],[10,S`\n`],[11,S`\v`],[12,S`\f`],[13,S`\r`],[8232,S`\u2028`],[8233,S`\u2029`],[65279,S`\uFEFF`]]),Ll=/^\p{Cased}$/u;function xn(e){return Ll.test(e)}function Ds(e,t){let n=!!t?.firstOnly,r=e.min.value,s=e.max.value,o=[];if(r<65&&(s===65535||s>=131071)||r===65536&&s>=131071)return o;for(let a=r;a<=s;a++){let i=T(a);if(!xn(i))continue;let l=Ls(i).filter(c=>{let u=c.codePointAt(0);return u<r||u>s});if(l.length&&(o.push(...l),n))break}return o}function ve(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(Is.has(e))return Is.get(e);if(e<32||e>126&&e<160||e>262143||t&&Ol(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;let s=n?r?Tl:Nl:Rl,o=T(e);return(s.has(o)?"\\":"")+o}function Pl(e){let t=e.map(s=>s.codePointAt(0)).sort((s,o)=>s-o),n=[],r=null;for(let s=0;s<t.length;s++)t[s+1]===t[s]+1?r??=t[s]:r===null?n.push(t[s]):(n.push([r,t[s]]),r=null);return n}function $l(e,t,n){if(e)return">";let r="";if(t&&n){let{enable:s,disable:o}=t;r=(s?.ignoreCase?"i":"")+(s?.dotAll?"s":"")+(o?"-":"")+(o?.ignoreCase?"i":"")+(o?.dotAll?"s":"")}return`${r}:`}function Ml({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function Rs({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function Ol(e){return e>47&&e<58}function Ns({type:e,value:t}){return e==="Character"&&t===45}var Gl=class Sn extends RegExp{#t=new Map;#e=null;#r;#n=null;#s=null;rawOptions={};get source(){return this.#r||"(?:)"}constructor(t,n,r){let s=!!r?.lazyCompile;if(t instanceof RegExp){if(r)throw new Error("Cannot provide options when copying a regexp");let o=t;super(o,n),this.#r=o.source,o instanceof Sn&&(this.#t=o.#t,this.#n=o.#n,this.#s=o.#s,this.rawOptions=o.rawOptions)}else{let o={hiddenCaptures:[],strategy:null,transfers:[],...r};super(s?"":t,n),this.#r=t,this.#t=Fl(o.hiddenCaptures,o.transfers),this.#s=o.strategy,this.rawOptions=r??{}}s||(this.#e=this)}exec(t){if(!this.#e){let{lazyCompile:s,...o}=this.rawOptions;this.#e=new Sn(this.#r,this.flags,o)}let n=this.global||this.sticky,r=this.lastIndex;if(this.#s==="clip_search"&&n&&r){this.lastIndex=0;let s=this.#o(t.slice(r));return s&&(Bl(s,r,t,this.hasIndices),this.lastIndex+=r),s}return this.#o(t)}#o(t){this.#e.lastIndex=this.lastIndex;let n=super.exec.call(this.#e,t);if(this.lastIndex=this.#e.lastIndex,!n||!this.#t.size)return n;let r=[...n];n.length=1;let s;this.hasIndices&&(s=[...n.indices],n.indices.length=1);let o=[0];for(let a=1;a<r.length;a++){let{hidden:i,transferTo:l}=this.#t.get(a)??{};if(i?o.push(null):(o.push(n.length),n.push(r[a]),this.hasIndices&&n.indices.push(s[a])),l&&r[a]!==void 0){let c=o[l];if(!c)throw new Error(`Invalid capture transfer to "${c}"`);if(n[c]=r[a],this.hasIndices&&(n.indices[c]=s[a]),n.groups){this.#n||(this.#n=Dl(this.source));let u=this.#n.get(l);u&&(n.groups[u]=r[a],this.hasIndices&&(n.indices.groups[u]=s[a]))}}}return n}};function Bl(e,t,n,r){if(e.index+=t,e.input=n,r){let s=e.indices;for(let a=0;a<s.length;a++){let i=s[a];i&&(s[a]=[i[0]+t,i[1]+t])}let o=s.groups;o&&Object.keys(o).forEach(a=>{let i=o[a];i&&(o[a]=[i[0]+t,i[1]+t])})}}function Fl(e,t){let n=new Map;for(let r of e)n.set(r,{hidden:!0});for(let[r,s]of t)for(let o of s)qe(n,o,{}).transferTo=r;return n}function Dl(e){let t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map,r=0,s=0,o;for(;o=t.exec(e);){let{0:a,groups:{capture:i,name:l}}=o;a==="["?r++:r?a==="]"&&r--:i&&(s++,l&&n.set(s,l))}return n}function Us(e,t){let n=Ul(e,t);return n.options?new Gl(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function Ul(e,t){let n=Ts(t),r=Ct(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:kn}),s=gl(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),o=El(s,n),a=vs(o.pattern,{captureTransfers:o._captureTransfers,hiddenCaptures:o._hiddenCaptures,mode:"external"}),i=dn(a.pattern),l=fn(i.pattern,{captureTransfers:a.captureTransfers,hiddenCaptures:a.hiddenCaptures}),c={pattern:l.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${o.flags}${o.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{let u=l.hiddenCaptures.sort((d,b)=>d-b),h=Array.from(l.captureTransfers),p=s._strategy,f=c.pattern.length>=n.lazyCompileLength;(u.length||h.length||p||f)&&(c.options={...u.length&&{hiddenCaptures:u},...h.length&&{transfers:h},...p&&{strategy:p},...f&&{lazyCompile:f}})}return c}function js(e,t){return Us(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function Ws(e={}){let t={target:"auto",cache:new Map,...e};return t.regexConstructor||=n=>js(n,{target:t.target}),{createScanner(n){return new Xr(n,t)},createString:Kr}}export{fi as createHighlighterCoreSync,Ws as createJavaScriptRegexEngine};
153
types/index.d.ts 8 lines
1export type CopiedBlock = string
2
3declare module 'claude-code' {
4  interface PluginState {
5    'restyled-chat': { copiedBlock: StateFamily<CopiedBlock> }
6  }
7}
8