- commit
- 9c09657aea5734c73f5c83a728c31be65c1753a0
- parent
- 999118af9359d674c4f9ed004530d15d448825a6
- author
- Dami <dami.etoile@gmail.com>
@@ -204,6 +204,20 @@ jobs:
204204 version: 3.x205205 repo-token: ${{ secrets.GITHUB_TOKEN }}206206 207+ - name: Set up Node.js 24208+ uses: actions/setup-node@v7209+ with:210+ node-version: 24211+212+ - name: Install Node dependencies213+ run: npm ci214+215+ - name: Test and build diagram.zip216+ run: |217+ npm run test:diagramzip218+ npm run build:diagramzip219+ git diff --exit-code -- server/src/main/resources/web/diagramzip220+207221 - name: Build Java server208222 run: task mavenBuild209223 @@ -235,14 +249,6 @@ jobs:
235249 CACHE_FROM_DIR: '/tmp/.buildx-cache'236250 CACHE_TO_DIR: '/tmp/.buildx-cache-new'237251 238- - name: 'Setup Node.js 24'239- uses: actions/setup-node@v7240- with:241- node-version: 24242-243- - name: Install Node dependencies244- run: npm install245-246252 - name: Run smoke tests247253 run: task smokeTests248254 @@ -254,4 +260,3 @@ jobs:
254260 run: |255261 rm -rf /tmp/.buildx-cache256262 mv /tmp/.buildx-cache-new /tmp/.buildx-cache257-@@ -11,6 +11,10 @@ versioned entry and uses it as the GitHub release notes.
1111 1212 ## [Unreleased]1313 14+### Added15+16+- Add the diagram.zip browser editor with syntax highlighting, live SVG preview, zoom and minimap navigation, and URL-based sharing without server-side document storage17+1418 ## [0.32.1] - 2026-08-121519 1620 ### Security@@ -0,0 +1,31 @@
1+# syntax=docker/dockerfile:1.72+3+FROM node:24.19-bookworm-slim AS frontend4+5+WORKDIR /workspace6+COPY package.json package-lock.json ./7+RUN npm ci8+9+COPY diagramzip ./diagramzip10+COPY ci/tests/diagrams ./ci/tests/diagrams11+COPY server/src/main/resources ./server/src/main/resources12+RUN npm run test:diagramzip && npm run build:diagramzip13+14+FROM maven:3.9.11-eclipse-temurin-21 AS server-build15+16+WORKDIR /workspace17+COPY pom.xml ./18+COPY server/pom.xml ./server/pom.xml19+COPY server/src ./server/src20+COPY --from=frontend /workspace/server/src/main/resources/web/diagramzip ./server/src/main/resources/web/diagramzip21+RUN git init --quiet && \22+ git config user.name "diagram.zip build" && \23+ git config user.email "build@diagram.zip" && \24+ git add . && \25+ git commit --quiet --message "Build diagram.zip"26+RUN --mount=type=cache,target=/root/.m2 \27+ mvn --no-transfer-progress -DskipTests -pl server package28+29+FROM yuzutech/kroki:0.32.130+31+COPY --from=server-build --chown=kroki:kroki /workspace/server/target/kroki-server.jar /usr/local/kroki/kroki-server.jar@@ -0,0 +1,15 @@
1+2+<html lang="en">3+ <head>4+ <meta charset="UTF-8">5+ <meta name="viewport" content="width=device-width, initial-scale=1.0">6+ <meta name="theme-color" content="#ffffff">7+ <meta name="description" content="Create diagrams from text and share them as a link.">8+ <link rel="icon" href="/diagram.zip/icon.svg" type="image/svg+xml">9+ <title>diagram.zip</title>10+ </head>11+ <body>12+ <div id="app"></div>13+ <script type="module" src="/src/main.js"></script>14+ </body>15+</html>@@ -0,0 +1,92 @@
1+import { StreamLanguage } from '@codemirror/language'2+import { json } from '@codemirror/lang-json'3+import { sql } from '@codemirror/lang-sql'4+import { xml } from '@codemirror/lang-xml'5+import { yaml } from '@codemirror/lang-yaml'6+7+const DIAGRAM_TYPES = [8+ ['plantuml', 'PlantUML'],9+ ['mermaid', 'Mermaid'],10+ ['graphviz', 'GraphViz'],11+ ['d2', 'D2'],12+ ['c4plantuml', 'C4 PlantUML'],13+ ['blockdiag', 'BlockDiag'],14+ ['seqdiag', 'SeqDiag'],15+ ['actdiag', 'ActDiag'],16+ ['nwdiag', 'NwDiag'],17+ ['packetdiag', 'PacketDiag'],18+ ['rackdiag', 'RackDiag'],19+ ['bpmn', 'BPMN'],20+ ['bytefield', 'Bytefield'],21+ ['dbml', 'DBML'],22+ ['diagramsnet', 'Diagrams.net'],23+ ['ditaa', 'Ditaa'],24+ ['erd', 'ERD'],25+ ['excalidraw', 'Excalidraw'],26+ ['goat', 'GoAT'],27+ ['nomnoml', 'Nomnoml'],28+ ['pikchr', 'Pikchr'],29+ ['structurizr', 'Structurizr'],30+ ['svgbob', 'Svgbob'],31+ ['symbolator', 'Symbolator'],32+ ['tikz', 'TikZ'],33+ ['umlet', 'UMLet'],34+ ['vega', 'Vega'],35+ ['vegalite', 'Vega-Lite'],36+ ['wavedrom', 'WaveDrom'],37+ ['wireviz', 'WireViz'],38+]39+40+export const diagramTypes = DIAGRAM_TYPES.map(([id, label]) => ({ id, label }))41+42+const keywords = new Set([43+ 'actor', 'alt', 'and', 'as', 'class', 'component', 'database', 'direction', 'else', 'end',44+ 'endnote', 'endif', 'endwhile', 'flowchart', 'graph', 'group', 'if', 'interface', 'loop',45+ 'namespace', 'node', 'note', 'package', 'participant', 'rectangle', 'return', 'skinparam',46+ 'start', 'state', 'stop', 'subgraph', 'then', 'title', 'while',47+])48+49+const diagramLanguage = StreamLanguage.define({50+ startState: () => ({ blockComment: false }),51+ token(stream, state) {52+ if (state.blockComment) {53+ if (stream.skipTo('*/')) {54+ stream.match('*/')55+ state.blockComment = false56+ } else {57+ stream.skipToEnd()58+ }59+ return 'blockComment'60+ }61+ if (stream.match('/*')) {62+ state.blockComment = true63+ return 'blockComment'64+ }65+ if (stream.match(/^\s*(?:%%|\/\/|'|#).*/)) return 'lineComment'66+ if (stream.match(/^@(?:start|end)[a-z0-9_]*/i)) return 'keyword'67+ if (stream.match(/^"(?:[^"\\]|\\.)*"/)) return 'string'68+ if (stream.match(/^(?:--?>|<--?|==>|<==|\.\.>|<\.\.|->|<-|=>|<=|--|\.\.)/)) return 'operator'69+ if (stream.match(/^#[0-9a-f]{3,8}\b/i)) return 'color'70+ if (stream.match(/^\b\d+(?:\.\d+)?\b/)) return 'number'71+ if (stream.match(/^\b[a-z_][\w-]*\b/i)) {72+ return keywords.has(stream.current().toLowerCase()) ? 'keyword' : 'variableName'73+ }74+ stream.next()75+ return null76+ },77+})78+79+const jsonTypes = new Set(['bytefield', 'excalidraw', 'vega', 'vegalite', 'wavedrom'])80+const xmlTypes = new Set(['bpmn', 'diagramsnet', 'umlet'])81+82+export function languageFor(type) {83+ if (jsonTypes.has(type)) return json()84+ if (xmlTypes.has(type)) return xml()85+ if (type === 'wireviz') return yaml()86+ if (type === 'dbml') return sql()87+ return diagramLanguage88+}89+90+export function isKnownDiagramType(type) {91+ return diagramTypes.some(diagramType => diagramType.id === type)92+}@@ -0,0 +1,162 @@
1+import bpmn from '../../ci/tests/diagrams/example.bpmn?raw'2+import bytefield from '../../ci/tests/diagrams/bytefield.bf?raw'3+import d2 from '../../ci/tests/diagrams/connections.d2?raw'4+import dbml from '../../ci/tests/diagrams/dbml.dbml?raw'5+import diagramsnet from '../../ci/tests/diagrams/diagramsnet-venn.xml?raw'6+import ditaa from '../../ci/tests/diagrams/components.ditaa?raw'7+import erd from '../../ci/tests/diagrams/schema.erd?raw'8+import excalidraw from '../../ci/tests/diagrams/venn.excalidraw?raw'9+import goat from '../../ci/tests/diagrams/components.goat?raw'10+import nomnoml from '../../ci/tests/diagrams/pirate.nomnoml?raw'11+import nwdiag from '../../ci/tests/diagrams/network.diag?raw'12+import packetdiag from '../../ci/tests/diagrams/packet.diag?raw'13+import pikchr from '../../ci/tests/diagrams/diamond.pikchr?raw'14+import rackdiag from '../../ci/tests/diagrams/rack.diag?raw'15+import svgbob from '../../ci/tests/diagrams/cloud.bob?raw'16+import symbolator from '../../ci/tests/diagrams/component.sv?raw'17+import tikz from '../../ci/tests/diagrams/periodic-table.tex?raw'18+import umlet from '../../ci/tests/diagrams/umlet.xml?raw'19+import vega from '../../ci/tests/diagrams/bar-chart.vega?raw'20+import vegalite from '../../ci/tests/diagrams/discretizing-scale.vlite?raw'21+import wavedrom from '../../ci/tests/diagrams/wavedrom.json5?raw'22+import wireviz from '../../ci/tests/diagrams/wireviz.yaml?raw'23+import { DEFAULT_SOURCE } from './state.js'24+25+const EXAMPLES = {26+ // Narrative formats share one story: Alice and Bob are building Tandem, a27+ // tiny shared to-do app, with help from Alice Agent and Bob Agent.28+ plantuml: DEFAULT_SOURCE,29+ mermaid: `flowchart LR30+ Alice([Alice]) -->|describes the shared list| AliceAgent["Alice Agent"]31+ AliceAgent -->|drafts the experience| Tandem["Tandem App"]32+ Bob([Bob]) -->|reviews the plan| BobAgent["Bob Agent"]33+ BobAgent -->|builds and tests the API| Tandem34+ Tandem -->|keeps tasks in sync| Alice35+ Tandem -->|keeps tasks in sync| Bob`,36+ graphviz: `digraph Tandem {37+ rankdir=LR38+ node [shape=box, style="rounded,filled", fillcolor="#eef2ff"]39+ Alice [shape=oval, fillcolor="#fef3c7"]40+ Bob [shape=oval, fillcolor="#dcfce7"]41+ AliceAgent [label="Alice Agent"]42+ BobAgent [label="Bob Agent"]43+ Tandem [label="Tandem App", fillcolor="#ddd6fe"]44+ Alice -> AliceAgent [label="shares an idea"]45+ AliceAgent -> Tandem [label="proposes the flow"]46+ Bob -> BobAgent [label="asks for an API"]47+ BobAgent -> Tandem [label="ships + tests"]48+ Tandem -> { Alice Bob } [label="syncs tasks"]49+}`,50+ c4plantuml: `@startuml51+!include <C4/C4_Context>52+53+Person(alice, "Alice", "Plans the product and creates shared tasks")54+Person(bob, "Bob", "Builds the app and completes shared tasks")55+System(aliceAgent, "Alice Agent", "Turns Alice's ideas into product flows")56+System(bobAgent, "Bob Agent", "Implements and tests Bob's changes")57+System(tandem, "Tandem App", "A tiny shared to-do list")58+59+Rel(alice, aliceAgent, "Explains what friends need")60+Rel(aliceAgent, tandem, "Proposes task flows")61+Rel(bob, bobAgent, "Requests implementation help")62+Rel(bobAgent, tandem, "Builds and verifies")63+Rel(alice, tandem, "Creates tasks")64+Rel(bob, tandem, "Completes tasks")65+@enduml`,66+ blockdiag: `blockdiag {67+ orientation = portrait68+ Alice -> "Alice Agent" -> "Tandem App";69+ Bob -> "Bob Agent" -> "Tandem App";70+ "Tandem App" -> "Shared task list";71+72+ Alice [color = "#fde68a"];73+ Bob [color = "#bbf7d0"];74+ "Alice Agent" [color = "#bfdbfe"];75+ "Bob Agent" [color = "#bfdbfe"];76+ "Tandem App" [color = "#ddd6fe"];77+ "Shared task list" [color = "#fecdd3"];78+}`,79+ seqdiag: `seqdiag {80+ Alice; "Alice Agent"; "Tandem App"; "Bob Agent"; Bob;81+ Alice -> "Alice Agent" [label = "Sketch our shared errands"];82+ "Alice Agent" -> "Tandem App" [label = "Create task: Buy paint"];83+ "Tandem App" -> "Bob Agent" [label = "Task assigned to Bob"];84+ "Bob Agent" -> Bob [label = "Offer a reminder"];85+ Bob -> "Tandem App" [label = "Mark task complete"];86+ "Tandem App" -> Alice [label = "List synced"];87+}`,88+ actdiag: `actdiag {89+ describe -> shape -> implement -> verify -> share90+91+ lane Alice {92+ label = "Alice"93+ describe [label = "Describe shared tasks"];94+ share [label = "Try Tandem with Bob"];95+ }96+ lane "Alice Agent" {97+ shape [label = "Shape the task flow"];98+ }99+ lane "Bob Agent" {100+ implement [label = "Build Tandem"];101+ verify [label = "Test task sync"];102+ }103+}`,104+ structurizr: `workspace "Tandem" "Alice and Bob build a shared to-do app with their agents" {105+ model {106+ alice = person "Alice" "Plans Tandem and creates tasks"107+ bob = person "Bob" "Builds Tandem and completes tasks"108+ aliceAgent = softwareSystem "Alice Agent" "Shapes Alice's ideas into product flows"109+ bobAgent = softwareSystem "Bob Agent" "Implements and tests Bob's changes"110+ tandem = softwareSystem "Tandem App" "Keeps Alice and Bob's tasks in sync"111+112+ alice -> aliceAgent "Describes the experience"113+ aliceAgent -> tandem "Proposes task flows"114+ bob -> bobAgent "Requests implementation help"115+ bobAgent -> tandem "Builds and tests"116+ alice -> tandem "Creates tasks"117+ bob -> tandem "Completes tasks"118+ }119+ views {120+ systemLandscape "TandemLandscape" {121+ include *122+ autolayout lr123+ }124+ theme default125+ }126+}`,127+128+ // Domain-specific examples stay intact so they remain useful references for129+ // packet layouts, hardware, data visualization, wiring, and renderer syntax.130+ d2,131+ nwdiag,132+ packetdiag,133+ rackdiag,134+ bpmn: bpmn135+ .replaceAll('Examine Situation', 'Bob Agent tests Tandem')136+ .replaceAll('Things OK?', 'Tests pass?')137+ .replaceAll('Notification Sent', 'Alice and Bob share tasks')138+ .replaceAll('Error Propagated', 'Alice Agent revises flow')139+ .replaceAll('Klaus', 'Alice')140+ .replaceAll('Walter', 'Bob'),141+ bytefield,142+ dbml,143+ diagramsnet,144+ ditaa,145+ erd,146+ excalidraw,147+ goat,148+ nomnoml,149+ pikchr,150+ svgbob,151+ symbolator,152+ tikz,153+ umlet,154+ vega,155+ vegalite,156+ wavedrom,157+ wireviz,158+}159+160+export function exampleFor(type) {161+ return EXAMPLES[type] ?? DEFAULT_SOURCE162+}@@ -0,0 +1,286 @@
1+import { basicSetup } from 'codemirror'2+import { Compartment, EditorState } from '@codemirror/state'3+import { EditorView } from '@codemirror/view'4+import { HighlightStyle, syntaxHighlighting } from '@codemirror/language'5+import { tags } from '@lezer/highlight'6+import { diagramTypes, isKnownDiagramType, languageFor } from './diagram-types.js'7+import { exampleFor } from './examples.js'8+import {9+ DEFAULT_DIAGRAM_TYPE,10+ DEFAULT_SOURCE,11+ MAX_IMAGE_URL_LENGTH,12+ decodeEditorHash,13+ encodeEditorHash,14+ imageUrl,15+} from './state.js'16+import { PreviewController } from './preview.js'17+import './style.css'18+19+const DRAFT_KEY = 'diagram.zip:draft:v1'20+// TODO: Reintroduce dark mode once every renderer has a native or renderer-specific dark theme.21+const language = new Compartment()22+let renderTimer23+let applyingExternalState = false24+let activeType25+const typeDrafts = new Map()26+27+document.querySelector('#app').innerHTML = `28+ <main class="app-shell">29+ <header class="app-header">30+ <a class="brand" href="#" aria-label="New diagram"><img class="brand-mark" src="/diagram.zip/icon.svg" alt=""><span>diagram.zip</span></a>31+ <div class="header-meta">32+ <span class="render-status" data-state="idle" role="status">Ready</span>33+ <label class="type-picker">34+ <span class="sr-only">Diagram type</span>35+ <select id="diagram-type"></select>36+ </label>37+ <button class="primary-action" id="share" type="button">Share</button>38+ </div>39+ </header>40+41+ <div class="mobile-tabs" role="tablist" aria-label="Workspace panel">42+ <button type="button" role="tab" aria-selected="true" data-panel="editor">Edit</button>43+ <button type="button" role="tab" aria-selected="false" data-panel="preview">Preview</button>44+ </div>45+46+ <div class="workspace" data-mobile-panel="editor">47+ <section class="editor-panel" aria-label="Diagram source">48+ <div id="editor"></div>49+ </section>50+ <section class="preview-panel" aria-label="Diagram preview">51+ <div class="preview-stage" id="preview-stage">52+ <img id="preview-image" alt="Rendered diagram" draggable="false" hidden>53+ <p class="preview-empty">Your diagram will appear here.</p>54+ <div class="preview-toolbar" aria-label="Preview controls">55+ <button type="button" data-preview-action="zoom-out" aria-label="Zoom out">−</button>56+ <button type="button" data-preview-action="zoom-in" aria-label="Zoom in">+</button>57+ <button type="button" data-preview-action="fit">Fit</button>58+ <button type="button" data-preview-action="one-to-one">1:1</button>59+ </div>60+ <div class="minimap" id="minimap" aria-label="Preview minimap" hidden>61+ <img id="minimap-image" alt="" draggable="false">62+ <span id="minimap-viewport" aria-hidden="true"></span>63+ </div>64+ </div>65+ </section>66+ </div>67+ </main>68+69+ <dialog id="share-dialog" aria-labelledby="share-title">70+ <form method="dialog" class="dialog-card">71+ <div class="dialog-header">72+ <div><p class="dialog-eyebrow">Share</p><h1 id="share-title">Take the diagram with you.</h1></div>73+ <button class="icon-button" value="cancel" aria-label="Close">×</button>74+ </div>75+ <div class="share-options">76+ <label><span>Editable diagram</span><div><input id="editable-link" readonly><button type="button" data-copy="editable-link">Copy</button></div></label>77+ <label><span>SVG image</span><div><input id="image-link" readonly><button type="button" data-copy="image-link">Copy</button></div><small id="image-link-note"></small></label>78+ <label><span>Markdown</span><div><input id="markdown-link" readonly><button type="button" data-copy="markdown-link">Copy</button></div></label>79+ </div>80+ </form>81+ </dialog>82+83+ <div class="toast" id="toast" role="status" aria-live="polite"></div>84+`85+86+const typePicker = document.querySelector('#diagram-type')87+for (const { id, label } of diagramTypes) {88+ typePicker.add(new Option(label, id))89+}90+91+const initialState = loadInitialState()92+typePicker.value = initialState.type93+activeType = initialState.type94+typeDrafts.set(initialState.type, initialState.source)95+96+const syntaxColors = HighlightStyle.define([97+ { tag: tags.keyword, color: 'var(--syntax-keyword)', fontWeight: '650' },98+ { tag: tags.string, color: 'var(--syntax-string)' },99+ { tag: [tags.comment, tags.lineComment, tags.blockComment], color: 'var(--syntax-comment)', fontStyle: 'italic' },100+ { tag: [tags.number, tags.bool], color: 'var(--syntax-number)' },101+ { tag: [tags.operator, tags.punctuation], color: 'var(--syntax-operator)' },102+ { tag: [tags.variableName, tags.typeName], color: 'var(--syntax-variable)' },103+])104+105+const editor = new EditorView({106+ state: EditorState.create({107+ doc: initialState.source,108+ extensions: [109+ basicSetup,110+ language.of(languageFor(initialState.type)),111+ syntaxHighlighting(syntaxColors),112+ EditorView.theme({113+ '&': { height: '100%', backgroundColor: 'transparent' },114+ '.cm-scroller': { fontFamily: 'var(--font-mono)', lineHeight: '1.65' },115+ '.cm-content': { padding: '28px 10px 80px' },116+ '.cm-gutters': { backgroundColor: 'transparent', border: '0', paddingLeft: '12px' },117+ '.cm-activeLine, .cm-activeLineGutter': { backgroundColor: 'var(--editor-active-line)' },118+ '.cm-cursor, .cm-dropCursor': { borderLeftColor: 'var(--ink)' },119+ '&.cm-focused': { outline: 'none' },120+ }),121+ EditorView.updateListener.of(update => {122+ if (update.docChanged && !applyingExternalState) scheduleUpdate()123+ }),124+ ],125+ }),126+ parent: document.querySelector('#editor'),127+})128+129+const preview = new PreviewController({130+ stage: document.querySelector('#preview-stage'),131+ image: document.querySelector('#preview-image'),132+ status: document.querySelector('.render-status'),133+ minimap: document.querySelector('#minimap'),134+ minimapImage: document.querySelector('#minimap-image'),135+ minimapViewport: document.querySelector('#minimap-viewport'),136+})137+138+typePicker.addEventListener('change', () => {139+ typeDrafts.set(activeType, editor.state.doc.toString())140+ const type = typePicker.value141+ const source = typeDrafts.get(type) ?? exampleFor(type)142+ applyState({ type, source, options: {} })143+})144+145+document.querySelector('#share').addEventListener('click', openShareDialog)146+document.querySelector('.brand').addEventListener('click', event => {147+ event.preventDefault()148+ if (!confirm('Start a new diagram?')) return149+ applyState({ type: DEFAULT_DIAGRAM_TYPE, source: DEFAULT_SOURCE, options: {} })150+})151+152+document.querySelectorAll('[data-preview-action]').forEach(button => {153+ button.addEventListener('click', () => {154+ const action = button.dataset.previewAction155+ if (action === 'zoom-out') preview.zoom(0.8)156+ if (action === 'zoom-in') preview.zoom(1.25)157+ if (action === 'fit') preview.fit()158+ if (action === 'one-to-one') preview.oneToOne()159+ })160+})161+162+document.querySelectorAll('.mobile-tabs button').forEach(button => {163+ button.addEventListener('click', () => {164+ document.querySelector('.workspace').dataset.mobilePanel = button.dataset.panel165+ document.querySelectorAll('.mobile-tabs button').forEach(tab => {166+ tab.setAttribute('aria-selected', String(tab === button))167+ })168+ if (button.dataset.panel === 'preview') preview.fit()169+ })170+})171+172+document.querySelectorAll('[data-copy]').forEach(button => {173+ button.addEventListener('click', async () => {174+ const input = document.querySelector(`#${button.dataset.copy}`)175+ await copy(input.value)176+ showToast('Copied')177+ })178+})179+180+window.addEventListener('hashchange', () => {181+ try {182+ applyState(decodeEditorHash(location.hash), false)183+ } catch {184+ showToast('This diagram link could not be opened.')185+ }186+})187+188+window.addEventListener('keydown', event => {189+ if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 's') {190+ event.preventDefault()191+ openShareDialog()192+ }193+})194+195+function currentState() {196+ return { type: typePicker.value, source: editor.state.doc.toString(), options: {} }197+}198+199+function scheduleUpdate(delay = 1200) {200+ clearTimeout(renderTimer)201+ renderTimer = setTimeout(commitState, delay)202+}203+204+function commitState() {205+ const state = currentState()206+ const hash = encodeEditorHash(state)207+ if (location.hash !== hash) history.replaceState(null, '', hash)208+ localStorage.setItem(DRAFT_KEY, JSON.stringify(state))209+ preview.render(state)210+}211+212+function loadInitialState() {213+ if (location.hash.startsWith('#v1/')) {214+ try {215+ const state = decodeEditorHash(location.hash)216+ if (isKnownDiagramType(state.type)) return state217+ } catch {218+ // Fall back to the local draft or starter document.219+ }220+ }221+ try {222+ const draft = JSON.parse(localStorage.getItem(DRAFT_KEY))223+ if (draft && isKnownDiagramType(draft.type) && typeof draft.source === 'string') return { ...draft, options: draft.options ?? {} }224+ } catch {225+ // Ignore invalid local data.226+ }227+ return { type: DEFAULT_DIAGRAM_TYPE, source: DEFAULT_SOURCE, options: {} }228+}229+230+function applyState(state, commit = true) {231+ if (!isKnownDiagramType(state.type)) throw new Error('Unsupported diagram type.')232+ applyingExternalState = true233+ activeType = state.type234+ typeDrafts.set(state.type, state.source)235+ typePicker.value = state.type236+ editor.dispatch({237+ changes: { from: 0, to: editor.state.doc.length, insert: state.source },238+ effects: language.reconfigure(languageFor(state.type)),239+ })240+ applyingExternalState = false241+ if (commit) commitState()242+ else preview.render(currentState())243+}244+245+function openShareDialog() {246+ commitState()247+ const state = currentState()248+ const editableLink = `${location.origin}${location.pathname}${encodeEditorHash(state)}`249+ const svgLink = imageUrl(location.origin, state)250+ const imageLinkTooLong = svgLink.length > MAX_IMAGE_URL_LENGTH251+ const imageLink = document.querySelector('#image-link')252+ const markdownLink = document.querySelector('#markdown-link')253+ const imageCopy = document.querySelector('[data-copy="image-link"]')254+ const markdownCopy = document.querySelector('[data-copy="markdown-link"]')255+ document.querySelector('#editable-link').value = editableLink256+ imageLink.value = imageLinkTooLong ? '' : svgLink257+ imageLink.placeholder = imageLinkTooLong ? 'Unavailable for this diagram' : ''258+ markdownLink.value = imageLinkTooLong ? '' : ``259+ markdownLink.placeholder = imageLinkTooLong ? 'Unavailable for this diagram' : ''260+ imageCopy.disabled = imageLinkTooLong261+ markdownCopy.disabled = imageLinkTooLong262+ document.querySelector('#image-link-note').textContent = imageLinkTooLong263+ ? 'This diagram exceeds the safe image URL limit. Share the editable link instead.'264+ : ''265+ document.querySelector('#share-dialog').showModal()266+}267+268+async function copy(value) {269+ if (navigator.clipboard) return navigator.clipboard.writeText(value)270+ const textarea = document.createElement('textarea')271+ textarea.value = value272+ document.body.append(textarea)273+ textarea.select()274+ document.execCommand('copy')275+ textarea.remove()276+}277+278+function showToast(message) {279+ const toast = document.querySelector('#toast')280+ toast.textContent = message281+ toast.dataset.visible = 'true'282+ clearTimeout(showToast.timeout)283+ showToast.timeout = setTimeout(() => delete toast.dataset.visible, 1800)284+}285+286+commitState()@@ -0,0 +1,263 @@
1+import { imageUrl, MAX_IMAGE_URL_LENGTH } from './state.js'2+3+function clamp(value, minimum, maximum) {4+ return Math.min(Math.max(value, minimum), maximum)5+}6+7+export class PreviewController {8+ constructor({ stage, image, status, minimap, minimapImage, minimapViewport }) {9+ this.stage = stage10+ this.image = image11+ this.status = status12+ this.minimap = minimap13+ this.minimapImage = minimapImage14+ this.minimapViewport = minimapViewport15+ this.scale = 116+ this.x = 017+ this.y = 018+ this.objectUrl = null19+ this.abortController = null20+ this.requestNumber = 021+ this.pendingRender = null22+ this.renderLoop = null23+ this.drag = null24+25+ this.image.addEventListener('load', () => this.fit())26+ this.stage.addEventListener('pointerdown', event => this.startPan(event))27+ this.stage.addEventListener('pointermove', event => this.pan(event))28+ this.stage.addEventListener('pointerup', event => this.endPan(event))29+ this.stage.addEventListener('pointercancel', event => this.endPan(event))30+ this.stage.addEventListener('wheel', event => this.wheelZoom(event), { passive: false })31+ this.minimap.addEventListener('pointerdown', event => this.moveFromMinimap(event))32+ new ResizeObserver(() => this.updateTransform()).observe(this.stage)33+ }34+35+ render({ type, source, options = {} }) {36+ if (!source.trim()) {37+ this.requestNumber++38+ this.pendingRender = null39+ this.abortController?.abort()40+ this.setStatus('Write something to render.', 'idle')41+ return42+ }43+44+ this.pendingRender = { type, source, options, requestNumber: ++this.requestNumber }45+ this.abortController?.abort()46+ if (!this.renderLoop) this.renderLoop = this.drainRenderQueue()47+ return this.renderLoop48+ }49+50+ async drainRenderQueue() {51+ try {52+ while (this.pendingRender) {53+ const render = this.pendingRender54+ this.pendingRender = null55+ await this.performRender(render)56+ }57+ } finally {58+ this.renderLoop = null59+ if (this.pendingRender) this.renderLoop = this.drainRenderQueue()60+ }61+ }62+63+ async performRender({ type, source, options, requestNumber }) {64+ const abortController = new AbortController()65+ this.abortController = abortController66+ this.setStatus('Rendering…', 'loading')67+ this.stage.style.setProperty('--render-background', 'var(--preview-bg)')68+69+ const getUrl = imageUrl(window.location.origin, { type, source, options })70+ const useGet = getUrl.length <= MAX_IMAGE_URL_LENGTH71+ const url = useGet ? getUrl : new URL(`/${encodeURIComponent(type)}/svg`, window.location.origin)72+ if (!useGet) {73+ for (const [name, value] of Object.entries(options)) {74+ url.searchParams.set(name, String(value))75+ }76+ }77+78+ try {79+ const response = await fetch(url, {80+ method: useGet ? 'GET' : 'POST',81+ headers: useGet82+ ? { Accept: 'image/svg+xml' }83+ : { Accept: 'image/svg+xml', 'Content-Type': 'text/plain; charset=utf-8' },84+ body: useGet ? undefined : source,85+ signal: abortController.signal,86+ })87+ if (requestNumber !== this.requestNumber) return88+ if (!response.ok) {89+ throw new Error(await this.errorMessage(response))90+ }91+ this.status.dataset.cache = response.headers.get('X-Diagram-Cache')?.toLowerCase() ?? 'browser'92+ const { blob, background } = this.normalizedSvgBlob(await response.text())93+ this.stage.style.setProperty('--render-background', background)94+ const nextObjectUrl = URL.createObjectURL(blob)95+ const previousObjectUrl = this.objectUrl96+ this.objectUrl = nextObjectUrl97+ this.image.src = nextObjectUrl98+ this.minimapImage.src = nextObjectUrl99+ this.image.hidden = false100+ this.setStatus('Rendered', 'ready')101+ if (previousObjectUrl) URL.revokeObjectURL(previousObjectUrl)102+ } catch (error) {103+ if (error.name === 'AbortError') return104+ this.setStatus(error.message || 'Could not render this diagram.', 'error')105+ } finally {106+ if (this.abortController === abortController) this.abortController = null107+ }108+ }109+110+ async errorMessage(response) {111+ const body = await response.text()112+ const document = new DOMParser().parseFromString(body, 'text/html')113+ const message = document.body.textContent.trim().replace(/\s+/g, ' ')114+ return message || `Render failed with HTTP ${response.status}.`115+ }116+117+ normalizedSvgBlob(source) {118+ const document = new DOMParser().parseFromString(source, 'image/svg+xml')119+ const svg = document.documentElement120+ const viewBox = svg.getAttribute('viewBox')?.trim().split(/[\s,]+/).map(Number)121+ if (svg.nodeName === 'svg' && viewBox?.length === 4 && viewBox.every(Number.isFinite)) {122+ if (!svg.hasAttribute('width')) svg.setAttribute('width', String(viewBox[2]))123+ if (!svg.hasAttribute('height')) svg.setAttribute('height', String(viewBox[3]))124+ source = new XMLSerializer().serializeToString(svg)125+ }126+ const declaredBackground = svg.style.backgroundColor || svg.style.background127+ const background = declaredBackground && declaredBackground !== 'transparent'128+ ? declaredBackground129+ : '#ffffff'130+ return {131+ blob: new Blob([source], { type: 'image/svg+xml' }),132+ background,133+ }134+ }135+136+ setStatus(message, state) {137+ this.status.textContent = message138+ this.status.dataset.state = state139+ }140+141+ zoom(factor) {142+ if (this.image.hidden) return143+ const bounds = this.stage.getBoundingClientRect()144+ this.zoomAt(factor, bounds.width / 2, bounds.height / 2)145+ }146+147+ zoomAt(factor, anchorX, anchorY) {148+ const nextScale = clamp(this.scale * factor, 0.1, 8)149+ const diagramX = (anchorX - this.x) / this.scale150+ const diagramY = (anchorY - this.y) / this.scale151+ this.x = anchorX - diagramX * nextScale152+ this.y = anchorY - diagramY * nextScale153+ this.scale = nextScale154+ this.updateTransform()155+ }156+157+ wheelZoom(event) {158+ if (this.image.hidden || event.target.closest('.preview-toolbar, .minimap')) return159+ event.preventDefault()160+ const bounds = this.stage.getBoundingClientRect()161+ const delta = event.deltaY * (162+ event.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16163+ : event.deltaMode === WheelEvent.DOM_DELTA_PAGE ? bounds.height164+ : 1165+ )166+ this.zoomAt(167+ Math.exp(-clamp(delta, -240, 240) * 0.002),168+ event.clientX - bounds.left,169+ event.clientY - bounds.top,170+ )171+ }172+173+ oneToOne() {174+ if (this.image.hidden) return175+ const bounds = this.stage.getBoundingClientRect()176+ this.scale = 1177+ this.x = (bounds.width - this.image.naturalWidth) / 2178+ this.y = (bounds.height - this.image.naturalHeight) / 2179+ this.updateTransform()180+ }181+182+ fit() {183+ if (!this.image.naturalWidth || !this.image.naturalHeight) return184+ const bounds = this.stage.getBoundingClientRect()185+ const padding = Math.min(64, bounds.width * 0.12)186+ this.scale = clamp(Math.min(187+ (bounds.width - padding * 2) / this.image.naturalWidth,188+ (bounds.height - padding * 2) / this.image.naturalHeight,189+ ), 0.1, 2)190+ this.x = (bounds.width - this.image.naturalWidth * this.scale) / 2191+ this.y = (bounds.height - this.image.naturalHeight * this.scale) / 2192+ this.updateTransform()193+ }194+195+ updateTransform() {196+ this.image.style.transform = `translate(${this.x}px, ${this.y}px) scale(${this.scale})`197+ this.updateMinimap()198+ }199+200+ startPan(event) {201+ if (this.image.hidden || event.button !== 0 || event.target.closest('.preview-toolbar, .minimap')) return202+ this.drag = { pointerId: event.pointerId, x: event.clientX, y: event.clientY, originX: this.x, originY: this.y }203+ this.stage.setPointerCapture(event.pointerId)204+ this.stage.dataset.dragging = 'true'205+ }206+207+ pan(event) {208+ if (!this.drag || event.pointerId !== this.drag.pointerId) return209+ this.x = this.drag.originX + event.clientX - this.drag.x210+ this.y = this.drag.originY + event.clientY - this.drag.y211+ this.updateTransform()212+ }213+214+ endPan(event) {215+ if (!this.drag || event.pointerId !== this.drag.pointerId) return216+ this.drag = null217+ delete this.stage.dataset.dragging218+ }219+220+ moveFromMinimap(event) {221+ if (!this.image.naturalWidth || !this.image.naturalHeight) return222+ const bounds = this.minimap.getBoundingClientRect()223+ const imageFit = Math.min(bounds.width / this.image.naturalWidth, bounds.height / this.image.naturalHeight)224+ const offsetX = (bounds.width - this.image.naturalWidth * imageFit) / 2225+ const offsetY = (bounds.height - this.image.naturalHeight * imageFit) / 2226+ const diagramX = (event.clientX - bounds.left - offsetX) / imageFit227+ const diagramY = (event.clientY - bounds.top - offsetY) / imageFit228+ const stageBounds = this.stage.getBoundingClientRect()229+ this.x = stageBounds.width / 2 - diagramX * this.scale230+ this.y = stageBounds.height / 2 - diagramY * this.scale231+ this.updateTransform()232+ }233+234+ updateMinimap() {235+ if (!this.image.naturalWidth || !this.image.naturalHeight) return236+ const stageBounds = this.stage.getBoundingClientRect()237+ const renderedWidth = this.image.naturalWidth * this.scale238+ const renderedHeight = this.image.naturalHeight * this.scale239+ const fullyVisible = this.x >= 0240+ && this.y >= 0241+ && this.x + renderedWidth <= stageBounds.width242+ && this.y + renderedHeight <= stageBounds.height243+ this.minimap.hidden = fullyVisible244+ if (fullyVisible) return245+246+ const minimapBounds = this.minimap.getBoundingClientRect()247+ const imageFit = Math.min(248+ minimapBounds.width / this.image.naturalWidth,249+ minimapBounds.height / this.image.naturalHeight,250+ )251+ const offsetX = (minimapBounds.width - this.image.naturalWidth * imageFit) / 2252+ const offsetY = (minimapBounds.height - this.image.naturalHeight * imageFit) / 2253+ const visibleLeft = clamp(-this.x / this.scale, 0, this.image.naturalWidth)254+ const visibleTop = clamp(-this.y / this.scale, 0, this.image.naturalHeight)255+ const visibleRight = clamp((stageBounds.width - this.x) / this.scale, 0, this.image.naturalWidth)256+ const visibleBottom = clamp((stageBounds.height - this.y) / this.scale, 0, this.image.naturalHeight)257+258+ this.minimapViewport.style.left = `${offsetX + visibleLeft * imageFit}px`259+ this.minimapViewport.style.top = `${offsetY + visibleTop * imageFit}px`260+ this.minimapViewport.style.width = `${Math.max(4, (visibleRight - visibleLeft) * imageFit)}px`261+ this.minimapViewport.style.height = `${Math.max(4, (visibleBottom - visibleTop) * imageFit)}px`262+ }263+}@@ -0,0 +1,81 @@
1+import { deflate, inflate } from 'pako'2+3+export const HASH_VERSION = 'v1'4+// Leave room below Cloudflare's 16 KB request URL ceiling.5+export const MAX_IMAGE_URL_LENGTH = 15_0006+export const DEFAULT_DIAGRAM_TYPE = 'plantuml'7+export const DEFAULT_SOURCE = `@startuml8+skinparam monochrome true9+skinparam shadowing false10+11+actor Alice12+participant "Alice Agent" as AliceAgent13+participant "Tandem App" as Tandem14+participant "Bob Agent" as BobAgent15+actor Bob16+17+Alice -> AliceAgent: Describe a shared to-do app18+AliceAgent -> Tandem: Draft the task flow19+Bob -> BobAgent: Build and test the API20+BobAgent -> Tandem: Ship task sync21+Alice -> Tandem: Add "Buy paint"22+Tandem -> Bob: Share the new task23+Bob -> Tandem: Mark it done24+Tandem --> Alice: Everyone is in sync25+@enduml`26+27+const encoder = new TextEncoder()28+const decoder = new TextDecoder()29+30+function toBase64Url(bytes) {31+ let binary = ''32+ const chunkSize = 0x800033+ for (let index = 0; index < bytes.length; index += chunkSize) {34+ binary += String.fromCharCode(...bytes.subarray(index, index + chunkSize))35+ }36+ return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '')37+}38+39+function fromBase64Url(value) {40+ const normalized = value.replaceAll('-', '+').replaceAll('_', '/')41+ const padded = normalized + '='.repeat((4 - normalized.length % 4) % 4)42+ const binary = atob(padded)43+ return Uint8Array.from(binary, character => character.charCodeAt(0))44+}45+46+export function encodeText(value) {47+ return toBase64Url(deflate(encoder.encode(value), { level: 9 }))48+}49+50+export function decodeText(value) {51+ return decoder.decode(inflate(fromBase64Url(value)))52+}53+54+export function encodeEditorHash({ type, source, options = {} }) {55+ const payload = JSON.stringify({ source, options })56+ return `#${HASH_VERSION}/${encodeURIComponent(type)}/${encodeText(payload)}`57+}58+59+export function decodeEditorHash(hash) {60+ const [version, encodedType, payload] = hash.replace(/^#/, '').split('/')61+ if (version !== HASH_VERSION || !encodedType || !payload) {62+ throw new Error('Unsupported diagram.zip link.')63+ }64+ const state = JSON.parse(decodeText(payload))65+ if (typeof state.source !== 'string' || typeof state.options !== 'object' || state.options === null || Array.isArray(state.options)) {66+ throw new Error('Invalid diagram.zip link.')67+ }68+ return {69+ type: decodeURIComponent(encodedType),70+ source: state.source,71+ options: state.options,72+ }73+}74+75+export function imageUrl(origin, { type, source, options = {} }) {76+ const url = new URL(`/${encodeURIComponent(type)}/svg/${encodeText(source)}`, origin)77+ for (const [name, value] of Object.entries(options)) {78+ url.searchParams.set(name, String(value))79+ }80+ return url.toString()81+}@@ -0,0 +1,396 @@
1+:root {2+ color-scheme: light;3+ --page: #ffffff;4+ --surface: #ffffff;5+ --surface-raised: #ffffff;6+ --ink: #000000;7+ --muted: #666666;8+ --line: #dddddd;9+ --soft: #f3f3f3;10+ --action-bg: #000000;11+ --action-ink: #ffffff;12+ --danger: #333333;13+ --editor-active-line: rgba(0, 0, 0, .045);14+ --syntax-keyword: #111111;15+ --syntax-string: #333333;16+ --syntax-comment: #858585;17+ --syntax-number: #444444;18+ --syntax-operator: #555555;19+ --syntax-variable: #222222;20+ --dot: rgba(0, 0, 0, .11);21+ --preview-bg: #ffffff;22+ --shadow: 0 22px 70px rgba(0, 0, 0, .12);23+ --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;24+ --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;25+ font-family: var(--font-sans);26+ font-synthesis: none;27+ text-rendering: optimizeLegibility;28+}29+30+* { box-sizing: border-box; }31+32+html, body, #app { height: 100%; }33+34+body {35+ margin: 0;36+ overflow: hidden;37+ background: var(--page);38+ color: var(--ink);39+}40+41+button, input, select { font: inherit; }42+button, select { color: inherit; }43+button { cursor: pointer; }44+45+.sr-only {46+ position: absolute;47+ width: 1px;48+ height: 1px;49+ padding: 0;50+ margin: -1px;51+ overflow: hidden;52+ clip: rect(0, 0, 0, 0);53+ white-space: nowrap;54+ border: 0;55+}56+57+.app-shell {58+ display: grid;59+ grid-template-rows: 58px minmax(0, 1fr);60+ height: 100%;61+}62+63+.app-header {64+ display: flex;65+ align-items: center;66+ justify-content: space-between;67+ gap: 20px;68+ padding: 0 14px 0 20px;69+ border-bottom: 1px solid var(--line);70+ background: color-mix(in srgb, var(--page), transparent 5%);71+ backdrop-filter: blur(14px);72+ z-index: 10;73+}74+75+.brand {76+ display: inline-flex;77+ align-items: center;78+ gap: 10px;79+ color: var(--ink);80+ font-weight: 780;81+ letter-spacing: -.025em;82+ text-decoration: none;83+}84+85+.brand-mark {86+ width: 24px;87+ height: 24px;88+ display: block;89+}90+91+.header-meta {92+ display: flex;93+ align-items: center;94+ gap: 9px;95+ min-width: 0;96+}97+98+.render-status {99+ max-width: min(38vw, 420px);100+ overflow: hidden;101+ color: var(--muted);102+ font-size: 13px;103+ text-overflow: ellipsis;104+ white-space: nowrap;105+}106+107+.render-status[data-state="error"] { color: var(--danger); }108+.render-status[data-state="loading"]::before { content: "◌ "; }109+110+.type-picker select,111+.primary-action,112+.preview-toolbar button,113+.mobile-tabs button,114+.icon-button,115+.share-options button {116+ min-height: 36px;117+ border: 1px solid var(--line);118+ border-radius: 10px;119+ background: var(--surface);120+}121+122+.type-picker select {123+ max-width: 170px;124+ padding: 7px 30px 7px 11px;125+}126+127+.primary-action {128+ padding: 7px 15px;129+ border-color: var(--action-bg);130+ background: var(--action-bg);131+ color: var(--action-ink);132+ font-weight: 720;133+}134+135+.workspace {136+ display: grid;137+ grid-template-columns: minmax(340px, .82fr) minmax(440px, 1.18fr);138+ min-height: 0;139+}140+141+.editor-panel,142+.preview-panel { min-width: 0; min-height: 0; }143+144+.editor-panel {145+ overflow: hidden;146+ border-right: 1px solid var(--line);147+ background: var(--surface);148+}149+150+#editor { height: 100%; }151+152+.cm-editor { color: var(--ink); font-size: 14px; }153+.cm-gutter { color: var(--muted); }154+.cm-selectionBackground { background: color-mix(in srgb, var(--ink), transparent 78%) ; }155+156+.preview-panel { background: var(--preview-bg); }157+158+.preview-stage {159+ position: relative;160+ width: 100%;161+ height: 100%;162+ min-height: 320px;163+ overflow: hidden;164+ touch-action: none;165+ background-image: radial-gradient(var(--dot) 1px, transparent 1px);166+ background-size: 20px 20px;167+ cursor: grab;168+ background-color: var(--render-background, var(--preview-bg));169+}170+171+.preview-stage[data-dragging="true"] { cursor: grabbing; }172+173+#preview-image {174+ position: absolute;175+ top: 0;176+ left: 0;177+ max-width: none;178+ transform-origin: 0 0;179+ user-select: none;180+ -webkit-user-drag: none;181+}182+183+.preview-stage:has(#preview-image:not([hidden])) .preview-empty { display: none; }184+185+.preview-empty {186+ position: absolute;187+ inset: 50% auto auto 50%;188+ margin: 0;189+ color: var(--muted);190+ transform: translate(-50%, -50%);191+}192+193+.preview-toolbar {194+ position: absolute;195+ left: 14px;196+ bottom: 14px;197+ display: flex;198+ gap: 6px;199+ padding: 5px;200+ border: 1px solid var(--line);201+ border-radius: 14px;202+ background: color-mix(in srgb, var(--surface-raised), transparent 7%);203+ box-shadow: var(--shadow);204+ backdrop-filter: blur(12px);205+}206+207+.preview-toolbar button {208+ min-width: 36px;209+ padding: 6px 9px;210+ background: transparent;211+}212+213+.preview-toolbar button:hover { background: var(--soft); }214+215+.minimap {216+ position: absolute;217+ right: 14px;218+ bottom: 14px;219+ width: 168px;220+ height: 108px;221+ overflow: hidden;222+ border: 1px solid var(--line);223+ border-radius: 12px;224+ background: var(--render-background, var(--preview-bg));225+ box-shadow: var(--shadow);226+ cursor: crosshair;227+}228+229+.minimap img {230+ width: 100%;231+ height: 100%;232+ object-fit: contain;233+ pointer-events: none;234+ user-select: none;235+}236+237+#minimap-viewport {238+ position: absolute;239+ min-width: 4px;240+ min-height: 4px;241+ border: 2px solid var(--ink);242+ background: color-mix(in srgb, var(--ink), transparent 82%);243+ pointer-events: none;244+}245+246+.mobile-tabs { display: none; }247+248+dialog {249+ width: min(620px, calc(100% - 28px));250+ max-height: calc(100% - 28px);251+ padding: 0;252+ color: var(--ink);253+ border: 1px solid var(--line);254+ border-radius: 20px;255+ background: var(--surface-raised);256+ box-shadow: var(--shadow);257+}258+259+dialog::backdrop {260+ background: color-mix(in srgb, var(--page), transparent 25%);261+ backdrop-filter: blur(6px);262+}263+264+.dialog-card { padding: 24px; }265+266+.dialog-header {267+ display: flex;268+ align-items: flex-start;269+ justify-content: space-between;270+ gap: 20px;271+ margin-bottom: 24px;272+}273+274+.dialog-eyebrow {275+ margin: 0 0 5px;276+ color: var(--muted);277+ font-size: 12px;278+ font-weight: 800;279+ letter-spacing: .12em;280+ text-transform: uppercase;281+}282+283+.dialog-header h1 {284+ margin: 0;285+ font-size: clamp(25px, 5vw, 38px);286+ line-height: 1.05;287+ letter-spacing: -.045em;288+}289+290+.icon-button {291+ flex: 0 0 auto;292+ width: 38px;293+ padding: 0;294+ font-size: 24px;295+}296+297+.share-options { display: grid; gap: 18px; }298+.share-options label > span { display: block; margin-bottom: 7px; font-weight: 700; }299+.share-options label > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }300+.share-options input {301+ min-width: 0;302+ height: 40px;303+ padding: 8px 10px;304+ color: var(--ink);305+ border: 1px solid var(--line);306+ border-radius: 9px;307+ background: var(--page);308+ font: 12px/1.4 var(--font-mono);309+}310+.share-options button { padding: 7px 13px; font-weight: 700; }311+.share-options button:disabled { cursor: not-allowed; opacity: .42; }312+.share-options small { display: block; margin-top: 6px; color: var(--danger); }313+314+.toast {315+ position: fixed;316+ top: 72px;317+ left: 50%;318+ z-index: 30;319+ padding: 9px 15px;320+ border-radius: 999px;321+ background: var(--ink);322+ color: var(--page);323+ font-size: 13px;324+ font-weight: 740;325+ opacity: 0;326+ transform: translate(-50%, -10px);327+ transition: opacity 140ms ease, transform 140ms ease;328+ pointer-events: none;329+}330+331+.toast[data-visible="true"] { opacity: 1; transform: translate(-50%, 0); }332+333+:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }334+335+@media (max-width: 760px) {336+ .app-shell { grid-template-rows: 58px 42px minmax(0, 1fr); }337+ .render-status { display: none; }338+ .render-status[data-state="error"] {339+ position: fixed;340+ top: 108px;341+ right: 10px;342+ left: 10px;343+ z-index: 20;344+ display: block;345+ max-width: none;346+ max-height: 84px;347+ overflow: auto;348+ padding: 10px 12px;349+ border: 1px solid color-mix(in srgb, var(--danger), transparent 55%);350+ border-radius: 10px;351+ background: var(--surface-raised);352+ box-shadow: var(--shadow);353+ white-space: normal;354+ }355+ .app-header { padding-left: 14px; }356+ .brand span:last-child { display: none; }357+ .type-picker select { max-width: 142px; }358+359+ .mobile-tabs {360+ display: grid;361+ grid-template-columns: 1fr 1fr;362+ gap: 4px;363+ padding: 4px;364+ border-bottom: 1px solid var(--line);365+ background: var(--page);366+ }367+368+ .mobile-tabs button {369+ min-height: 32px;370+ border-color: transparent;371+ background: transparent;372+ color: var(--muted);373+ font-size: 13px;374+ font-weight: 700;375+ }376+377+ .mobile-tabs button[aria-selected="true"] {378+ background: var(--soft);379+ color: var(--ink);380+ }381+382+ .workspace { display: block; }383+ .workspace[data-mobile-panel="editor"] .preview-panel,384+ .workspace[data-mobile-panel="preview"] .editor-panel { display: none; }385+ .editor-panel, .preview-panel { width: 100%; height: 100%; border-right: 0; }386+ .minimap { width: 132px; height: 88px; }387+}388+389+@media (max-width: 390px) {390+ .app-header { gap: 8px; }391+ .header-meta { gap: 6px; }392+ .type-picker select { max-width: 120px; }393+ .primary-action { padding-inline: 11px; }394+ .preview-toolbar { bottom: 10px; left: 10px; }395+ .minimap { right: 10px; bottom: 62px; }396+}@@ -0,0 +1,56 @@
1+import assert from 'node:assert/strict'2+import { readFileSync } from 'node:fs'3+import test from 'node:test'4+import {5+ decodeEditorHash,6+ decodeText,7+ encodeEditorHash,8+ encodeText,9+ imageUrl,10+ MAX_IMAGE_URL_LENGTH,11+} from '../src/state.js'12+13+test('uses the Kroki-compatible zlib + base64url encoding', () => {14+ const source = 'digraph G {Hello->World}\n'15+ assert.equal(encodeText(source), 'eNpLyUwvSizIUHBXqPZIzcnJ17ULzy_KSanlAgB1EAjQ')16+})17+18+test('round trips Unicode text', () => {19+ const source = 'Alice -> Bob: Grüezi 👋 こんにちは'20+ assert.equal(decodeText(encodeText(source)), source)21+})22+23+test('round trips a versioned editor hash', () => {24+ const state = {25+ type: 'mermaid',26+ source: 'flowchart LR\n A --> B',27+ options: { theme: 'neutral' },28+ }29+ assert.deepEqual(decodeEditorHash(encodeEditorHash(state)), state)30+})31+32+test('rejects unsupported and malformed hashes', () => {33+ assert.throws(() => decodeEditorHash('#v2/mermaid/nope'), /Unsupported/)34+ assert.throws(() => decodeEditorHash('#v1/mermaid/nope'))35+})36+37+test('builds an encoded image URL with options', () => {38+ const url = new URL(imageUrl('https://diagram.zip', {39+ type: 'd2',40+ source: 'a -> b',41+ options: { theme: 200 },42+ }))43+ assert.match(url.pathname, /^\/d2\/svg\/[A-Za-z0-9_-]+$/)44+ assert.equal(url.searchParams.get('theme'), '200')45+})46+47+test('keeps shared image URLs below the edge request limit', () => {48+ assert.equal(MAX_IMAGE_URL_LENGTH, 15_000)49+})50+51+test('fits the bundled periodic-table example in a shared image URL', () => {52+ const source = readFileSync(new URL('../../ci/tests/diagrams/periodic-table.tex', import.meta.url), 'utf8')53+ const url = imageUrl('https://diagram.zip', { type: 'tikz', source })54+ assert.ok(url.length > 4096)55+ assert.ok(url.length <= MAX_IMAGE_URL_LENGTH)56+})@@ -0,0 +1,11 @@
1+import { defineConfig } from 'vite'2+import { resolve } from 'node:path'3+4+export default defineConfig({5+ root: resolve(import.meta.dirname),6+ base: '/diagram.zip/',7+ build: {8+ outDir: resolve(import.meta.dirname, '../server/src/main/resources/web/diagramzip'),9+ emptyOutDir: true,10+ },11+})@@ -0,0 +1,44 @@
1+app = "diagram-zip"2+primary_region = "dfw"3+4+[build]5+ dockerfile = "Dockerfile.fly"6+7+[env]8+ KROKI_SAFE_MODE = "secure"9+ KROKI_COMMAND_TIMEOUT = "30s"10+ KROKI_DELEGATE_TIMEOUT_MS = "90000"11+ KROKI_MAX_URI_LENGTH = "16384"12+ KROKI_RENDER_CACHE_MAX_BYTES = "67108864"13+ KROKI_RENDER_CACHE_TTL_SECONDS = "1800"14+ KROKI_MERMAID_HOST = "diagram-zip-mermaid.flycast"15+ KROKI_MERMAID_PORT = "80"16+ KROKI_BPMN_HOST = "diagram-zip-bpmn.flycast"17+ KROKI_BPMN_PORT = "80"18+ KROKI_EXCALIDRAW_HOST = "diagram-zip-excalidraw.flycast"19+ KROKI_EXCALIDRAW_PORT = "80"20+ KROKI_DIAGRAMSNET_HOST = "diagram-zip-diagramsnet.flycast"21+ KROKI_DIAGRAMSNET_PORT = "80"22+23+[http_service]24+ internal_port = 800025+ force_https = true26+ auto_stop_machines = "stop"27+ auto_start_machines = true28+ min_machines_running = 129+30+ [http_service.concurrency]31+ type = "requests"32+ soft_limit = 2033+ hard_limit = 3034+35+ [[http_service.checks]]36+ grace_period = "45s"37+ interval = "30s"38+ method = "GET"39+ timeout = "10s"40+ path = "/health"41+42+[[vm]]43+ size = "shared-cpu-1x"44+ memory = "1gb"@@ -0,0 +1,21 @@
1+app = "diagram-zip-bpmn"2+primary_region = "dfw"3+4+[build]5+ image = "yuzutech/kroki-bpmn:0.32.1"6+7+[http_service]8+ internal_port = 80039+ force_https = false10+ auto_stop_machines = "suspend"11+ auto_start_machines = true12+ min_machines_running = 013+14+ [http_service.concurrency]15+ type = "requests"16+ soft_limit = 417+ hard_limit = 818+19+[[vm]]20+ size = "shared-cpu-1x"21+ memory = "1gb"@@ -0,0 +1,21 @@
1+app = "diagram-zip-diagramsnet"2+primary_region = "dfw"3+4+[build]5+ image = "yuzutech/kroki-diagramsnet:0.32.1"6+7+[http_service]8+ internal_port = 80059+ force_https = false10+ auto_stop_machines = "suspend"11+ auto_start_machines = true12+ min_machines_running = 013+14+ [http_service.concurrency]15+ type = "requests"16+ soft_limit = 417+ hard_limit = 818+19+[[vm]]20+ size = "shared-cpu-1x"21+ memory = "1gb"@@ -0,0 +1,21 @@
1+app = "diagram-zip-excalidraw"2+primary_region = "dfw"3+4+[build]5+ image = "yuzutech/kroki-excalidraw:0.32.1"6+7+[http_service]8+ internal_port = 80049+ force_https = false10+ auto_stop_machines = "suspend"11+ auto_start_machines = true12+ min_machines_running = 013+14+ [http_service.concurrency]15+ type = "requests"16+ soft_limit = 417+ hard_limit = 818+19+[[vm]]20+ size = "shared-cpu-1x"21+ memory = "1gb"@@ -0,0 +1,21 @@
1+app = "diagram-zip-mermaid"2+primary_region = "dfw"3+4+[build]5+ image = "yuzutech/kroki-mermaid:0.32.1"6+7+[http_service]8+ internal_port = 80029+ force_https = false10+ auto_stop_machines = "suspend"11+ auto_start_machines = true12+ min_machines_running = 013+14+ [http_service.concurrency]15+ type = "requests"16+ soft_limit = 617+ hard_limit = 1018+19+[[vm]]20+ size = "shared-cpu-1x"21+ memory = "1gb"@@ -8,17 +8,1087 @@
88 "name": "kroki-ci",99 "version": "1.0.0",1010 "dependencies": {11- "blocked-at": "^1.2.0"11+ "@codemirror/lang-json": "^6.0.2",12+ "@codemirror/lang-sql": "^6.10.0",13+ "@codemirror/lang-xml": "^6.1.0",14+ "@codemirror/lang-yaml": "^6.1.3",15+ "@codemirror/language": "^6.12.4",16+ "@lezer/highlight": "^1.2.3",17+ "blocked-at": "^1.2.0",18+ "codemirror": "^6.0.2",19+ "pako": "^3.0.1"20+ },21+ "devDependencies": {22+ "vite": "^8.2.2"1223 },1324 "engines": {1425 "node": ">=24"1526 }1627 },28+ "node_modules/@codemirror/autocomplete": {29+ "version": "6.20.3",30+ "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz",31+ "integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==",32+ "license": "MIT",33+ "dependencies": {34+ "@codemirror/language": "^6.0.0",35+ "@codemirror/state": "^6.0.0",36+ "@codemirror/view": "^6.17.0",37+ "@lezer/common": "^1.0.0"38+ }39+ },40+ "node_modules/@codemirror/commands": {41+ "version": "6.11.0",42+ "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.0.tgz",43+ "integrity": "sha512-/K4Rl5BN0OtTiPWmJCdqODu38XnDMsDxKY5rgrPnCkutPTJf2wVbkoixLfealF5Kwse/s8P8M5jAiURiwSwnFA==",44+ "license": "MIT",45+ "dependencies": {46+ "@codemirror/language": "^6.0.0",47+ "@codemirror/state": "^6.7.0",48+ "@codemirror/view": "^6.27.0",49+ "@lezer/common": "^1.1.0"50+ }51+ },52+ "node_modules/@codemirror/lang-json": {53+ "version": "6.0.2",54+ "resolved": "https://registry.npmjs.org/@codemirror/lang-json/-/lang-json-6.0.2.tgz",55+ "integrity": "sha512-x2OtO+AvwEHrEwR0FyyPtfDUiloG3rnVTSZV1W8UteaLL8/MajQd8DpvUb2YVzC+/T18aSDv0H9mu+xw0EStoQ==",56+ "license": "MIT",57+ "dependencies": {58+ "@codemirror/language": "^6.0.0",59+ "@lezer/json": "^1.0.0"60+ }61+ },62+ "node_modules/@codemirror/lang-sql": {63+ "version": "6.10.0",64+ "resolved": "https://registry.npmjs.org/@codemirror/lang-sql/-/lang-sql-6.10.0.tgz",65+ "integrity": "sha512-6ayPkEd/yRw0XKBx5uAiToSgGECo/GY2NoJIHXIIQh1EVwLuKoU8BP/qK0qH5NLXAbtJRLuT73hx7P9X34iO4w==",66+ "license": "MIT",67+ "dependencies": {68+ "@codemirror/autocomplete": "^6.0.0",69+ "@codemirror/language": "^6.0.0",70+ "@codemirror/state": "^6.0.0",71+ "@lezer/common": "^1.2.0",72+ "@lezer/highlight": "^1.0.0",73+ "@lezer/lr": "^1.0.0"74+ }75+ },76+ "node_modules/@codemirror/lang-xml": {77+ "version": "6.1.0",78+ "resolved": "https://registry.npmjs.org/@codemirror/lang-xml/-/lang-xml-6.1.0.tgz",79+ "integrity": "sha512-3z0blhicHLfwi2UgkZYRPioSgVTo9PV5GP5ducFH6FaHy0IAJRg+ixj5gTR1gnT/glAIC8xv4w2VL1LoZfs+Jg==",80+ "license": "MIT",81+ "dependencies": {82+ "@codemirror/autocomplete": "^6.0.0",83+ "@codemirror/language": "^6.4.0",84+ "@codemirror/state": "^6.0.0",85+ "@codemirror/view": "^6.0.0",86+ "@lezer/common": "^1.0.0",87+ "@lezer/xml": "^1.0.0"88+ }89+ },90+ "node_modules/@codemirror/lang-yaml": {91+ "version": "6.1.3",92+ "resolved": "https://registry.npmjs.org/@codemirror/lang-yaml/-/lang-yaml-6.1.3.tgz",93+ "integrity": "sha512-AZ8DJBuXGVHybpBQhmZtgew5//4hv3tdkXnr3vDmOUMJRuB6vn/uuwtmTOTlqEaQFg3hQSVeA90NmvIQyUV6FQ==",94+ "license": "MIT",95+ "dependencies": {96+ "@codemirror/autocomplete": "^6.0.0",97+ "@codemirror/language": "^6.0.0",98+ "@codemirror/state": "^6.0.0",99+ "@lezer/common": "^1.2.0",100+ "@lezer/highlight": "^1.2.0",101+ "@lezer/lr": "^1.0.0",102+ "@lezer/yaml": "^1.0.0"103+ }104+ },105+ "node_modules/@codemirror/language": {106+ "version": "6.12.4",107+ "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.4.tgz",108+ "integrity": "sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==",109+ "license": "MIT",110+ "dependencies": {111+ "@codemirror/state": "^6.0.0",112+ "@codemirror/view": "^6.23.0",113+ "@lezer/common": "^1.5.0",114+ "@lezer/highlight": "^1.0.0",115+ "@lezer/lr": "^1.0.0",116+ "style-mod": "^4.0.0"117+ }118+ },119+ "node_modules/@codemirror/lint": {120+ "version": "6.9.7",121+ "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz",122+ "integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==",123+ "license": "MIT",124+ "dependencies": {125+ "@codemirror/state": "^6.0.0",126+ "@codemirror/view": "^6.42.0",127+ "crelt": "^1.0.5"128+ }129+ },130+ "node_modules/@codemirror/search": {131+ "version": "6.7.1",132+ "resolved": "https://registry.npmjs.org/@codemirror/search/-/search-6.7.1.tgz",133+ "integrity": "sha512-uMe5UO6PamJtSHrXhhHOzSX3ReWtiJrva6GnPMwSOrZtiExb5X5eExhr2OUZQVvdxPsKpY3Ro2mFbQadpPWmHA==",134+ "license": "MIT",135+ "dependencies": {136+ "@codemirror/state": "^6.0.0",137+ "@codemirror/view": "^6.37.0",138+ "crelt": "^1.0.5"139+ }140+ },141+ "node_modules/@codemirror/state": {142+ "version": "6.7.1",143+ "resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.7.1.tgz",144+ "integrity": "sha512-9QzNDgE4EYDnAHfrTlR2lwiPciiOymLtwKK+8yHQzCc7GXhAP9xdEbEJFy2IWB1j9UGUl9BsgMmTo/ImA02T7A==",145+ "license": "MIT",146+ "dependencies": {147+ "@marijn/find-cluster-break": "^1.0.0"148+ }149+ },150+ "node_modules/@codemirror/view": {151+ "version": "6.43.9",152+ "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.9.tgz",153+ "integrity": "sha512-sTuUzTpPMFebRhg6dawChoKKgndIwfjmJgKVxBefPElcU2NwQ6AFroupk0SFqEerQyZOGRfDNnSN8Dw/lMAsXw==",154+ "license": "MIT",155+ "dependencies": {156+ "@codemirror/state": "^6.7.0",157+ "crelt": "^1.0.6",158+ "style-mod": "^4.1.0",159+ "w3c-keyname": "^2.2.4"160+ }161+ },162+ "node_modules/@lezer/common": {163+ "version": "1.5.2",164+ "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.2.tgz",165+ "integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==",166+ "license": "MIT"167+ },168+ "node_modules/@lezer/highlight": {169+ "version": "1.2.3",170+ "resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz",171+ "integrity": "sha512-qXdH7UqTvGfdVBINrgKhDsVTJTxactNNxLk7+UMwZhU13lMHaOBlJe9Vqp907ya56Y3+ed2tlqzys7jDkTmW0g==",172+ "license": "MIT",173+ "dependencies": {174+ "@lezer/common": "^1.3.0"175+ }176+ },177+ "node_modules/@lezer/json": {178+ "version": "1.0.3",179+ "resolved": "https://registry.npmjs.org/@lezer/json/-/json-1.0.3.tgz",180+ "integrity": "sha512-BP9KzdF9Y35PDpv04r0VeSTKDeox5vVr3efE7eBbx3r4s3oNLfunchejZhjArmeieBH+nVOpgIiBJpEAv8ilqQ==",181+ "license": "MIT",182+ "dependencies": {183+ "@lezer/common": "^1.2.0",184+ "@lezer/highlight": "^1.0.0",185+ "@lezer/lr": "^1.0.0"186+ }187+ },188+ "node_modules/@lezer/lr": {189+ "version": "1.4.10",190+ "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz",191+ "integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==",192+ "license": "MIT",193+ "dependencies": {194+ "@lezer/common": "^1.0.0"195+ }196+ },197+ "node_modules/@lezer/xml": {198+ "version": "1.0.6",199+ "resolved": "https://registry.npmjs.org/@lezer/xml/-/xml-1.0.6.tgz",200+ "integrity": "sha512-CdDwirL0OEaStFue/66ZmFSeppuL6Dwjlk8qk153mSQwiSH/Dlri4GNymrNWnUmPl2Um7QfV1FO9KFUyX3Twww==",201+ "license": "MIT",202+ "dependencies": {203+ "@lezer/common": "^1.2.0",204+ "@lezer/highlight": "^1.0.0",205+ "@lezer/lr": "^1.0.0"206+ }207+ },208+ "node_modules/@lezer/yaml": {209+ "version": "1.0.4",210+ "resolved": "https://registry.npmjs.org/@lezer/yaml/-/yaml-1.0.4.tgz",211+ "integrity": "sha512-2lrrHqxalACEbxIbsjhqGpSW8kWpUKuY6RHgnSAFZa6qK62wvnPxA8hGOwOoDbwHcOFs5M4o27mjGu+P7TvBmw==",212+ "license": "MIT",213+ "dependencies": {214+ "@lezer/common": "^1.2.0",215+ "@lezer/highlight": "^1.0.0",216+ "@lezer/lr": "^1.4.0"217+ }218+ },219+ "node_modules/@marijn/find-cluster-break": {220+ "version": "1.0.3",221+ "resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.3.tgz",222+ "integrity": "sha512-FY+MKLBoTsLNJF/eLWaOsXGdz6uh3Iu1axjPf6TUq92IYumcTcXWHoS747JARLkcdlJ/Waiaxc5wQfFO8jC6NA==",223+ "license": "MIT"224+ },225+ "node_modules/@oxc-project/types": {226+ "version": "0.146.0",227+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.146.0.tgz",228+ "integrity": "sha512-XC0QsnnhVe7sLIWmYmdPw7x5P0h4W8vUU3Nv1ySgWXtvCz8NizoAEpGXA0sOYoJQV2Rl13LgURAHQ5cI5ILCSA==",229+ "dev": true,230+ "license": "MIT",231+ "funding": {232+ "url": "https://github.com/sponsors/Boshen"233+ }234+ },235+ "node_modules/@rolldown/binding-android-arm-eabi": {236+ "version": "1.2.5",237+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.5.tgz",238+ "integrity": "sha512-DLe/i+l8ynIBY7XEQ191TeZvCoowIGa18R+dIV30GW7DiOtp74i/xX8hs8GUjW5ARV7VZuie3d6AumSmCwbeRA==",239+ "cpu": [240+ "arm"241+ ],242+ "dev": true,243+ "license": "MIT",244+ "optional": true,245+ "os": [246+ "android"247+ ],248+ "engines": {249+ "node": "^20.19.0 || >=22.12.0"250+ }251+ },252+ "node_modules/@rolldown/binding-android-arm64": {253+ "version": "1.2.5",254+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.5.tgz",255+ "integrity": "sha512-zXcwKlQApYAOELHd8PwKDFkagYF9Wy4e0RJ+0qnzl9Pjnpj75TEG8ufv40p2J7kCEfwZAsNiuzRIyNNMWT38ig==",256+ "cpu": [257+ "arm64"258+ ],259+ "dev": true,260+ "license": "MIT",261+ "optional": true,262+ "os": [263+ "android"264+ ],265+ "engines": {266+ "node": "^20.19.0 || >=22.12.0"267+ }268+ },269+ "node_modules/@rolldown/binding-darwin-arm64": {270+ "version": "1.2.5",271+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.5.tgz",272+ "integrity": "sha512-dK4QakI42nzWgJT5sm4y4y/O//D4OxM75/cH28RLV+nzIN9AY+YsbuUVrUTjlLjXR6vpyxFbSsbmNuJ6BP9sww==",273+ "cpu": [274+ "arm64"275+ ],276+ "dev": true,277+ "license": "MIT",278+ "optional": true,279+ "os": [280+ "darwin"281+ ],282+ "engines": {283+ "node": "^20.19.0 || >=22.12.0"284+ }285+ },286+ "node_modules/@rolldown/binding-darwin-x64": {287+ "version": "1.2.5",288+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.5.tgz",289+ "integrity": "sha512-fqSALaUu1Wjd1nK2uW2kJDWdLCc8lx1IcY+MTY26Aurfdx19anlzhqXOgCFbBFQnlFDTn4TC1/7Nz4Bl2mLP3A==",290+ "cpu": [291+ "x64"292+ ],293+ "dev": true,294+ "license": "MIT",295+ "optional": true,296+ "os": [297+ "darwin"298+ ],299+ "engines": {300+ "node": "^20.19.0 || >=22.12.0"301+ }302+ },303+ "node_modules/@rolldown/binding-freebsd-x64": {304+ "version": "1.2.5",305+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.5.tgz",306+ "integrity": "sha512-/vCnNxlkxs9tKxNDcyWUePpJ/PgTzxIaVhoM5SmG8UV+GR/IcPam4VYxi7GIMo7PSDuNqlJqvprqii9NqqVCMw==",307+ "cpu": [308+ "x64"309+ ],310+ "dev": true,311+ "license": "MIT",312+ "optional": true,313+ "os": [314+ "freebsd"315+ ],316+ "engines": {317+ "node": "^20.19.0 || >=22.12.0"318+ }319+ },320+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {321+ "version": "1.2.5",322+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.5.tgz",323+ "integrity": "sha512-abk0NLA519LxRCszmbE0jYKuQ9YPocOXTiOXOo6Yr+YAT95VH+PtqYAjOJvGKt3viEd/x4qzabAlwd5bHOOARg==",324+ "cpu": [325+ "arm"326+ ],327+ "dev": true,328+ "license": "MIT",329+ "optional": true,330+ "os": [331+ "linux"332+ ],333+ "engines": {334+ "node": "^20.19.0 || >=22.12.0"335+ }336+ },337+ "node_modules/@rolldown/binding-linux-arm64-gnu": {338+ "version": "1.2.5",339+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.5.tgz",340+ "integrity": "sha512-Y7eALiJ8lr0M2HH103Js+g7V34wf6snlpZLAsHI90uLhr3PVlNsbFVAXJC9d/V6BnPyKtpSwI+NcB/RLxsQxuA==",341+ "cpu": [342+ "arm64"343+ ],344+ "dev": true,345+ "libc": [346+ "glibc"347+ ],348+ "license": "MIT",349+ "optional": true,350+ "os": [351+ "linux"352+ ],353+ "engines": {354+ "node": "^20.19.0 || >=22.12.0"355+ }356+ },357+ "node_modules/@rolldown/binding-linux-arm64-musl": {358+ "version": "1.2.5",359+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.5.tgz",360+ "integrity": "sha512-xMvZgnbZg4YVnR/AX2b3oOPDTFYJvUVaJg5FedA/LuvexAtXibZQej4cnTkw3rjsJ/ggUROB64TdtETiim+FYA==",361+ "cpu": [362+ "arm64"363+ ],364+ "dev": true,365+ "libc": [366+ "musl"367+ ],368+ "license": "MIT",369+ "optional": true,370+ "os": [371+ "linux"372+ ],373+ "engines": {374+ "node": "^20.19.0 || >=22.12.0"375+ }376+ },377+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {378+ "version": "1.2.5",379+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.5.tgz",380+ "integrity": "sha512-GRjeqTUDHTo5GwntsLaAMcBahG3nlpjftXWZLN73HiYQlhwEowvarFgQnRnQZtIp4keXX7quXFbG38uPZBa2EA==",381+ "cpu": [382+ "ppc64"383+ ],384+ "dev": true,385+ "libc": [386+ "glibc"387+ ],388+ "license": "MIT",389+ "optional": true,390+ "os": [391+ "linux"392+ ],393+ "engines": {394+ "node": "^20.19.0 || >=22.12.0"395+ }396+ },397+ "node_modules/@rolldown/binding-linux-s390x-gnu": {398+ "version": "1.2.5",399+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.5.tgz",400+ "integrity": "sha512-vLNTR45F2Uwc8AufkNXPmB4VliaXs+FvcheEogIzOXzO4l+LzieXF5A/TWxLy5HtqpsRCHUfd0lPVrrdgXdLHQ==",401+ "cpu": [402+ "s390x"403+ ],404+ "dev": true,405+ "libc": [406+ "glibc"407+ ],408+ "license": "MIT",409+ "optional": true,410+ "os": [411+ "linux"412+ ],413+ "engines": {414+ "node": "^20.19.0 || >=22.12.0"415+ }416+ },417+ "node_modules/@rolldown/binding-linux-x64-gnu": {418+ "version": "1.2.5",419+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.5.tgz",420+ "integrity": "sha512-Mgj59/HTuYeK9Gz2MA+mBWKnHsAgkBSec15ZMb1st3oIfFbX7gCjOae7GydHhzcyQi9Z/7M1QuN9bR3oFqF0jQ==",421+ "cpu": [422+ "x64"423+ ],424+ "dev": true,425+ "libc": [426+ "glibc"427+ ],428+ "license": "MIT",429+ "optional": true,430+ "os": [431+ "linux"432+ ],433+ "engines": {434+ "node": "^20.19.0 || >=22.12.0"435+ }436+ },437+ "node_modules/@rolldown/binding-linux-x64-musl": {438+ "version": "1.2.5",439+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.5.tgz",440+ "integrity": "sha512-mY8AP0/ichsbhAxGnLa3d3+MwV0EfgrPND2bplI3Ym8T6R2pJ0N87bvrKVwNXmdy3jnr6eQBecdqx/HMknBmpA==",441+ "cpu": [442+ "x64"443+ ],444+ "dev": true,445+ "libc": [446+ "musl"447+ ],448+ "license": "MIT",449+ "optional": true,450+ "os": [451+ "linux"452+ ],453+ "engines": {454+ "node": "^20.19.0 || >=22.12.0"455+ }456+ },457+ "node_modules/@rolldown/binding-openharmony-arm64": {458+ "version": "1.2.5",459+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.5.tgz",460+ "integrity": "sha512-8SLssA2oweAxyRgDp789ACfRb/3P+zNRJpzZxSizxF9m8NUDQ4+3xjo8ttjhVGGw6Qxb70oZiEtIjaKikCO7Yw==",461+ "cpu": [462+ "arm64"463+ ],464+ "dev": true,465+ "license": "MIT",466+ "optional": true,467+ "os": [468+ "openharmony"469+ ],470+ "engines": {471+ "node": "^20.19.0 || >=22.12.0"472+ }473+ },474+ "node_modules/@rolldown/binding-win32-arm64-msvc": {475+ "version": "1.2.5",476+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.5.tgz",477+ "integrity": "sha512-vGbruD5zquhoc8D9SViXgN2FBJtNdTyQ4DtG+SWiEGlJiAzoKcZ2xp+xuXCffhubVdt0NJlTZqkeRuERy7g8Cw==",478+ "cpu": [479+ "arm64"480+ ],481+ "dev": true,482+ "license": "MIT",483+ "optional": true,484+ "os": [485+ "win32"486+ ],487+ "engines": {488+ "node": "^20.19.0 || >=22.12.0"489+ }490+ },491+ "node_modules/@rolldown/binding-win32-x64-msvc": {492+ "version": "1.2.5",493+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.5.tgz",494+ "integrity": "sha512-e/SXpgISz+IoqVcSSI0rx/d/he8zqLex+/rCWpnHpmVfmPIUjag9H6P7zotf0gJHwPUhQxZ/mF8tr6acebT9yw==",495+ "cpu": [496+ "x64"497+ ],498+ "dev": true,499+ "license": "MIT",500+ "optional": true,501+ "os": [502+ "win32"503+ ],504+ "engines": {505+ "node": "^20.19.0 || >=22.12.0"506+ }507+ },508+ "node_modules/@rolldown/pluginutils": {509+ "version": "1.0.1",510+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",511+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",512+ "dev": true,513+ "license": "MIT"514+ },17515 "node_modules/blocked-at": {18516 "version": "1.2.0",19517 "resolved": "https://registry.npmjs.org/blocked-at/-/blocked-at-1.2.0.tgz",20518 "integrity": "sha512-Ba9yhK4KcFrgqEPgsU0qVGiMimf+VrD9QJo9pgwjg4yl0GXwgOJS8IRx2rPepQjalrmUdGTqX47bSuJLUMLX7w==",21519 "license": "ISC"520+ },521+ "node_modules/codemirror": {522+ "version": "6.0.2",523+ "resolved": "https://registry.npmjs.org/codemirror/-/codemirror-6.0.2.tgz",524+ "integrity": "sha512-VhydHotNW5w1UGK0Qj96BwSk/Zqbp9WbnyK2W/eVMv4QyF41INRGpjUhFJY7/uDNuudSc33a/PKr4iDqRduvHw==",525+ "license": "MIT",526+ "dependencies": {527+ "@codemirror/autocomplete": "^6.0.0",528+ "@codemirror/commands": "^6.0.0",529+ "@codemirror/language": "^6.0.0",530+ "@codemirror/lint": "^6.0.0",531+ "@codemirror/search": "^6.0.0",532+ "@codemirror/state": "^6.0.0",533+ "@codemirror/view": "^6.0.0"534+ }535+ },536+ "node_modules/crelt": {537+ "version": "1.0.7",538+ "resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",539+ "integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",540+ "license": "MIT"541+ },542+ "node_modules/detect-libc": {543+ "version": "2.1.2",544+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",545+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",546+ "dev": true,547+ "license": "Apache-2.0",548+ "engines": {549+ "node": ">=8"550+ }551+ },552+ "node_modules/fdir": {553+ "version": "6.5.0",554+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",555+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",556+ "dev": true,557+ "license": "MIT",558+ "engines": {559+ "node": ">=12.0.0"560+ },561+ "peerDependencies": {562+ "picomatch": "^3 || ^4"563+ },564+ "peerDependenciesMeta": {565+ "picomatch": {566+ "optional": true567+ }568+ }569+ },570+ "node_modules/fsevents": {571+ "version": "2.3.3",572+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",573+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",574+ "dev": true,575+ "hasInstallScript": true,576+ "license": "MIT",577+ "optional": true,578+ "os": [579+ "darwin"580+ ],581+ "engines": {582+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"583+ }584+ },585+ "node_modules/lightningcss": {586+ "version": "1.33.0",587+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",588+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",589+ "dev": true,590+ "license": "MPL-2.0",591+ "dependencies": {592+ "detect-libc": "^2.0.3"593+ },594+ "engines": {595+ "node": ">= 12.0.0"596+ },597+ "funding": {598+ "type": "opencollective",599+ "url": "https://opencollective.com/parcel"600+ },601+ "optionalDependencies": {602+ "lightningcss-android-arm64": "1.33.0",603+ "lightningcss-darwin-arm64": "1.33.0",604+ "lightningcss-darwin-x64": "1.33.0",605+ "lightningcss-freebsd-x64": "1.33.0",606+ "lightningcss-linux-arm-gnueabihf": "1.33.0",607+ "lightningcss-linux-arm64-gnu": "1.33.0",608+ "lightningcss-linux-arm64-musl": "1.33.0",609+ "lightningcss-linux-x64-gnu": "1.33.0",610+ "lightningcss-linux-x64-musl": "1.33.0",611+ "lightningcss-win32-arm64-msvc": "1.33.0",612+ "lightningcss-win32-x64-msvc": "1.33.0"613+ }614+ },615+ "node_modules/lightningcss-android-arm64": {616+ "version": "1.33.0",617+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",618+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",619+ "cpu": [620+ "arm64"621+ ],622+ "dev": true,623+ "license": "MPL-2.0",624+ "optional": true,625+ "os": [626+ "android"627+ ],628+ "engines": {629+ "node": ">= 12.0.0"630+ },631+ "funding": {632+ "type": "opencollective",633+ "url": "https://opencollective.com/parcel"634+ }635+ },636+ "node_modules/lightningcss-darwin-arm64": {637+ "version": "1.33.0",638+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",639+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",640+ "cpu": [641+ "arm64"642+ ],643+ "dev": true,644+ "license": "MPL-2.0",645+ "optional": true,646+ "os": [647+ "darwin"648+ ],649+ "engines": {650+ "node": ">= 12.0.0"651+ },652+ "funding": {653+ "type": "opencollective",654+ "url": "https://opencollective.com/parcel"655+ }656+ },657+ "node_modules/lightningcss-darwin-x64": {658+ "version": "1.33.0",659+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",660+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",661+ "cpu": [662+ "x64"663+ ],664+ "dev": true,665+ "license": "MPL-2.0",666+ "optional": true,667+ "os": [668+ "darwin"669+ ],670+ "engines": {671+ "node": ">= 12.0.0"672+ },673+ "funding": {674+ "type": "opencollective",675+ "url": "https://opencollective.com/parcel"676+ }677+ },678+ "node_modules/lightningcss-freebsd-x64": {679+ "version": "1.33.0",680+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",681+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",682+ "cpu": [683+ "x64"684+ ],685+ "dev": true,686+ "license": "MPL-2.0",687+ "optional": true,688+ "os": [689+ "freebsd"690+ ],691+ "engines": {692+ "node": ">= 12.0.0"693+ },694+ "funding": {695+ "type": "opencollective",696+ "url": "https://opencollective.com/parcel"697+ }698+ },699+ "node_modules/lightningcss-linux-arm-gnueabihf": {700+ "version": "1.33.0",701+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",702+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",703+ "cpu": [704+ "arm"705+ ],706+ "dev": true,707+ "license": "MPL-2.0",708+ "optional": true,709+ "os": [710+ "linux"711+ ],712+ "engines": {713+ "node": ">= 12.0.0"714+ },715+ "funding": {716+ "type": "opencollective",717+ "url": "https://opencollective.com/parcel"718+ }719+ },720+ "node_modules/lightningcss-linux-arm64-gnu": {721+ "version": "1.33.0",722+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",723+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",724+ "cpu": [725+ "arm64"726+ ],727+ "dev": true,728+ "libc": [729+ "glibc"730+ ],731+ "license": "MPL-2.0",732+ "optional": true,733+ "os": [734+ "linux"735+ ],736+ "engines": {737+ "node": ">= 12.0.0"738+ },739+ "funding": {740+ "type": "opencollective",741+ "url": "https://opencollective.com/parcel"742+ }743+ },744+ "node_modules/lightningcss-linux-arm64-musl": {745+ "version": "1.33.0",746+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",747+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",748+ "cpu": [749+ "arm64"750+ ],751+ "dev": true,752+ "libc": [753+ "musl"754+ ],755+ "license": "MPL-2.0",756+ "optional": true,757+ "os": [758+ "linux"759+ ],760+ "engines": {761+ "node": ">= 12.0.0"762+ },763+ "funding": {764+ "type": "opencollective",765+ "url": "https://opencollective.com/parcel"766+ }767+ },768+ "node_modules/lightningcss-linux-x64-gnu": {769+ "version": "1.33.0",770+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",771+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",772+ "cpu": [773+ "x64"774+ ],775+ "dev": true,776+ "libc": [777+ "glibc"778+ ],779+ "license": "MPL-2.0",780+ "optional": true,781+ "os": [782+ "linux"783+ ],784+ "engines": {785+ "node": ">= 12.0.0"786+ },787+ "funding": {788+ "type": "opencollective",789+ "url": "https://opencollective.com/parcel"790+ }791+ },792+ "node_modules/lightningcss-linux-x64-musl": {793+ "version": "1.33.0",794+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",795+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",796+ "cpu": [797+ "x64"798+ ],799+ "dev": true,800+ "libc": [801+ "musl"802+ ],803+ "license": "MPL-2.0",804+ "optional": true,805+ "os": [806+ "linux"807+ ],808+ "engines": {809+ "node": ">= 12.0.0"810+ },811+ "funding": {812+ "type": "opencollective",813+ "url": "https://opencollective.com/parcel"814+ }815+ },816+ "node_modules/lightningcss-win32-arm64-msvc": {817+ "version": "1.33.0",818+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",819+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",820+ "cpu": [821+ "arm64"822+ ],823+ "dev": true,824+ "license": "MPL-2.0",825+ "optional": true,826+ "os": [827+ "win32"828+ ],829+ "engines": {830+ "node": ">= 12.0.0"831+ },832+ "funding": {833+ "type": "opencollective",834+ "url": "https://opencollective.com/parcel"835+ }836+ },837+ "node_modules/lightningcss-win32-x64-msvc": {838+ "version": "1.33.0",839+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",840+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",841+ "cpu": [842+ "x64"843+ ],844+ "dev": true,845+ "license": "MPL-2.0",846+ "optional": true,847+ "os": [848+ "win32"849+ ],850+ "engines": {851+ "node": ">= 12.0.0"852+ },853+ "funding": {854+ "type": "opencollective",855+ "url": "https://opencollective.com/parcel"856+ }857+ },858+ "node_modules/nanoid": {859+ "version": "3.3.18",860+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",861+ "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",862+ "dev": true,863+ "funding": [864+ {865+ "type": "github",866+ "url": "https://github.com/sponsors/ai"867+ }868+ ],869+ "license": "MIT",870+ "bin": {871+ "nanoid": "bin/nanoid.cjs"872+ },873+ "engines": {874+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"875+ }876+ },877+ "node_modules/pako": {878+ "version": "3.0.1",879+ "resolved": "https://registry.npmjs.org/pako/-/pako-3.0.1.tgz",880+ "integrity": "sha512-GupotUUI0mlhugKjUs4bjOwLt3nrehy9Ys2dxC0GtgVef5cnKggkDMmf2bq2poCCuVXopWPmqsc9VDT2iJUy+w==",881+ "funding": [882+ {883+ "type": "github",884+ "url": "https://github.com/sponsors/puzrin"885+ },886+ {887+ "type": "github",888+ "url": "https://github.com/sponsors/nodeca"889+ }890+ ],891+ "license": "(MIT AND Zlib)"892+ },893+ "node_modules/picocolors": {894+ "version": "1.1.1",895+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",896+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",897+ "dev": true,898+ "license": "ISC"899+ },900+ "node_modules/picomatch": {901+ "version": "4.0.5",902+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",903+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",904+ "dev": true,905+ "license": "MIT",906+ "engines": {907+ "node": ">=12"908+ },909+ "funding": {910+ "url": "https://github.com/sponsors/jonschlinkert"911+ }912+ },913+ "node_modules/postcss": {914+ "version": "8.5.26",915+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",916+ "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",917+ "dev": true,918+ "funding": [919+ {920+ "type": "opencollective",921+ "url": "https://opencollective.com/postcss/"922+ },923+ {924+ "type": "tidelift",925+ "url": "https://tidelift.com/funding/github/npm/postcss"926+ },927+ {928+ "type": "github",929+ "url": "https://github.com/sponsors/ai"930+ }931+ ],932+ "license": "MIT",933+ "dependencies": {934+ "nanoid": "^3.3.17",935+ "picocolors": "^1.1.1",936+ "source-map-js": "^1.2.1"937+ },938+ "engines": {939+ "node": "^10 || ^12 || >=14"940+ }941+ },942+ "node_modules/rolldown": {943+ "version": "1.2.5",944+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.5.tgz",945+ "integrity": "sha512-VD2IE5PUG4Oj8zz2VGykiYd5wbnjdIiSsNQb8Qu5B+noEp+A78mu2iVvpp27g8es14Tk9rofNs5Tku9iQCS4fA==",946+ "dev": true,947+ "license": "MIT",948+ "dependencies": {949+ "@oxc-project/types": "=0.146.0",950+ "@rolldown/pluginutils": "^1.0.0"951+ },952+ "bin": {953+ "rolldown": "bin/cli.mjs"954+ },955+ "engines": {956+ "node": "^20.19.0 || >=22.12.0"957+ },958+ "optionalDependencies": {959+ "@rolldown/binding-android-arm-eabi": "1.2.5",960+ "@rolldown/binding-android-arm64": "1.2.5",961+ "@rolldown/binding-darwin-arm64": "1.2.5",962+ "@rolldown/binding-darwin-x64": "1.2.5",963+ "@rolldown/binding-freebsd-x64": "1.2.5",964+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.5",965+ "@rolldown/binding-linux-arm64-gnu": "1.2.5",966+ "@rolldown/binding-linux-arm64-musl": "1.2.5",967+ "@rolldown/binding-linux-ppc64-gnu": "1.2.5",968+ "@rolldown/binding-linux-s390x-gnu": "1.2.5",969+ "@rolldown/binding-linux-x64-gnu": "1.2.5",970+ "@rolldown/binding-linux-x64-musl": "1.2.5",971+ "@rolldown/binding-openharmony-arm64": "1.2.5",972+ "@rolldown/binding-win32-arm64-msvc": "1.2.5",973+ "@rolldown/binding-win32-x64-msvc": "1.2.5"974+ }975+ },976+ "node_modules/source-map-js": {977+ "version": "1.2.1",978+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",979+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",980+ "dev": true,981+ "license": "BSD-3-Clause",982+ "engines": {983+ "node": ">=0.10.0"984+ }985+ },986+ "node_modules/style-mod": {987+ "version": "4.1.3",988+ "resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",989+ "integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==",990+ "license": "MIT"991+ },992+ "node_modules/tinyglobby": {993+ "version": "0.2.17",994+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",995+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",996+ "dev": true,997+ "license": "MIT",998+ "dependencies": {999+ "fdir": "^6.5.0",1000+ "picomatch": "^4.0.4"1001+ },1002+ "engines": {1003+ "node": ">=12.0.0"1004+ },1005+ "funding": {1006+ "url": "https://github.com/sponsors/SuperchupuDev"1007+ }1008+ },1009+ "node_modules/vite": {1010+ "version": "8.2.2",1011+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz",1012+ "integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==",1013+ "dev": true,1014+ "license": "MIT",1015+ "dependencies": {1016+ "lightningcss": "^1.33.0",1017+ "picomatch": "^4.0.5",1018+ "postcss": "^8.5.26",1019+ "rolldown": "~1.2.4",1020+ "tinyglobby": "^0.2.17"1021+ },1022+ "bin": {1023+ "vite": "bin/vite.js"1024+ },1025+ "engines": {1026+ "node": "^20.19.0 || >=22.12.0"1027+ },1028+ "funding": {1029+ "url": "https://github.com/vitejs/vite?sponsor=1"1030+ },1031+ "optionalDependencies": {1032+ "fsevents": "~2.3.3"1033+ },1034+ "peerDependencies": {1035+ "@types/node": "^20.19.0 || >=22.12.0",1036+ "@vitejs/devtools": "^0.4.0 || ^0.5.0",1037+ "esbuild": "^0.27.0 || ^0.28.0",1038+ "jiti": ">=1.21.0",1039+ "less": "^4.0.0",1040+ "sass": "^1.70.0",1041+ "sass-embedded": "^1.70.0",1042+ "stylus": ">=0.54.8",1043+ "sugarss": "^5.0.0",1044+ "terser": "^5.16.0",1045+ "tsx": "^4.8.1",1046+ "yaml": "^2.4.2"1047+ },1048+ "peerDependenciesMeta": {1049+ "@types/node": {1050+ "optional": true1051+ },1052+ "@vitejs/devtools": {1053+ "optional": true1054+ },1055+ "esbuild": {1056+ "optional": true1057+ },1058+ "jiti": {1059+ "optional": true1060+ },1061+ "less": {1062+ "optional": true1063+ },1064+ "sass": {1065+ "optional": true1066+ },1067+ "sass-embedded": {1068+ "optional": true1069+ },1070+ "stylus": {1071+ "optional": true1072+ },1073+ "sugarss": {1074+ "optional": true1075+ },1076+ "terser": {1077+ "optional": true1078+ },1079+ "tsx": {1080+ "optional": true1081+ },1082+ "yaml": {1083+ "optional": true1084+ }1085+ }1086+ },1087+ "node_modules/w3c-keyname": {1088+ "version": "2.2.8",1089+ "resolved": "https://registry.npmjs.org/w3c-keyname/-/w3c-keyname-2.2.8.tgz",1090+ "integrity": "sha512-dpojBhNsCNN7T82Tm7k26A6G9ML3NkhDsnw9n/eoxSRlVBB4CEtIQ/KTCLI2Fwf3ataSXRhYFkQi3SlnFwPvPQ==",1091+ "license": "MIT"221092 }231093 }241094 }@@ -8,13 +8,27 @@
88 },99 "private": true,1010 "scripts": {11+ "build:diagramzip": "vite build --config diagramzip/vite.config.js",12+ "dev:diagramzip": "vite --config diagramzip/vite.config.js",1113 "test": "node --test-force-exit ci/tests/smoke.js",14+ "test:diagramzip": "node --test diagramzip/test/*.test.js",1215 "update-versions": "node ci/tasks/update-versions.js"1316 },1417 "volta": {1518 "node": "24.19.0"1619 },1720 "dependencies": {18- "blocked-at": "^1.2.0"21+ "@codemirror/lang-json": "^6.0.2",22+ "@codemirror/lang-sql": "^6.10.0",23+ "@codemirror/lang-xml": "^6.1.0",24+ "@codemirror/lang-yaml": "^6.1.3",25+ "@codemirror/language": "^6.12.4",26+ "@lezer/highlight": "^1.2.3",27+ "blocked-at": "^1.2.0",28+ "codemirror": "^6.0.2",29+ "pako": "^3.0.1"30+ },31+ "devDependencies": {32+ "vite": "^8.2.2"1933 }2034 }@@ -19,6 +19,7 @@ import io.vertx.ext.web.Router;
1919 import io.vertx.ext.web.RoutingContext;2020 import io.vertx.ext.web.handler.BodyHandler;2121 import io.vertx.ext.web.handler.CorsHandler;22+import io.vertx.ext.web.handler.StaticHandler;2223 2324 import java.util.*;2425 import java.util.stream.Collectors;@@ -92,7 +93,7 @@ public class Server extends AbstractVerticle {
9293 .allowedMethods(allowedMethods));9394 9495 Commander commander = new Commander(config);95- DiagramRegistry registry = new DiagramRegistry(router, bodyHandler);96+ DiagramRegistry registry = new DiagramRegistry(router, bodyHandler, new RenderCache(config));9697 registry.register(new Plantuml(vertx, config), "plantuml");9798 registry.register(new Plantuml(vertx, config), "c4plantuml");9899 registry.register(new Ditaa(vertx, config), "ditaa");@@ -139,12 +140,14 @@ public class Server extends AbstractVerticle {
139140 router.get("/healthz") // k8s liveness default URL (alias)140141 .handler(healthHandlerService);141142 142- // hello143- List<ServiceVersion> serviceVersions = healthHandler.getServiceVersions();144- String krokiBuildHash = healthHandler.getKrokiBuildHash();145- String krokiVersionNumber = healthHandler.getKrokiVersionNumber();143+ // diagram.zip144+ router.route("/diagram.zip/*")145+ .handler(StaticHandler.create("web/diagramzip")146+ .setFilesReadOnly(true)147+ .setCachingEnabled(true)148+ .setMaxAgeSeconds(31536000));146149 router.get("/")147- .handler(new HelloHandler(vertx, serviceVersions, krokiVersionNumber, krokiBuildHash).create());150+ .handler(new DiagramZipHandler(vertx).create());148151 149152 // Default route150153 Route route = router.route("/*");@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
77 88 import java.io.*;99 import java.util.Arrays;10+import java.util.concurrent.CancellationException;1011 1112 public class Commander {1213 @@ -35,48 +36,62 @@ public class Commander {
3536 }3637 3738 public byte[] execute(byte[] source, String... cmd) throws IOException, InterruptedException, IllegalStateException {39+ return execute(new RenderCancellation(), source, cmd);40+ }41+42+ public byte[] execute(RenderCancellation cancellation, byte[] source, String... cmd) throws IOException, InterruptedException, IllegalStateException {3843 ProcessBuilder builder = new ProcessBuilder();3944 builder.command(cmd);4045 //builder.redirectError(ProcessBuilder.Redirect.PIPE);4146 //builder.redirectInput(ProcessBuilder.Redirect.PIPE);4247 Process process = builder.start();48+ cancellation.register(process);4349 44- ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();45- Thread processStdoutReader = readProcessStdout(process, stdoutBuffer);46- ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();47- Thread readProcessStderr = readProcessStderr(process, stderrBuffer);48-49- OutputStream stdin = process.getOutputStream();50- stdin.write(source);51- try {52- stdin.flush();53- } catch (IOException e) {54- logger.error("Error while flushing stdin on command: " + Arrays.toString(cmd), e);55- throw e;56- }5750 try {58- stdin.close();59- } catch (IOException e) {60- logger.error("Error while closing stdin on command: " + Arrays.toString(cmd), e);61- throw e;62- }51+ ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();52+ Thread processStdoutReader = readProcessStdout(process, stdoutBuffer, cancellation);53+ ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();54+ Thread readProcessStderr = readProcessStderr(process, stderrBuffer, cancellation);6355 64- process.waitFor(this.commandTimeout.duration(), this.commandTimeout.timeUnit());65- // writing to stdout is asynchronous, wait until there is no more data in the stdout stream66- processStdoutReader.join(readStdoutTimeout.millis());67- // writing to stderr is asynchronous, wait until there is no more data in the stderr stream68- readProcessStderr.join(readStderrTimeout.millis());69- byte[] output = stdoutBuffer.toByteArray();56+ OutputStream stdin = process.getOutputStream();57+ stdin.write(source);58+ try {59+ stdin.flush();60+ } catch (IOException e) {61+ if (cancellation.isCancelled()) throw new CancellationException("Render cancelled because no clients are waiting for it.");62+ logger.error("Error while flushing stdin on command: " + Arrays.toString(cmd), e);63+ throw e;64+ }65+ try {66+ stdin.close();67+ } catch (IOException e) {68+ if (cancellation.isCancelled()) throw new CancellationException("Render cancelled because no clients are waiting for it.");69+ logger.error("Error while closing stdin on command: " + Arrays.toString(cmd), e);70+ throw e;71+ }7072 71- if (process.isAlive()) {72- process.destroyForcibly();73- throw new InterruptedIOException("Process was forcibly killed (not responding after " + this.commandTimeout + " seconds)");73+ process.waitFor(this.commandTimeout.duration(), this.commandTimeout.timeUnit());74+ // writing to stdout is asynchronous, wait until there is no more data in the stdout stream75+ processStdoutReader.join(readStdoutTimeout.millis());76+ // writing to stderr is asynchronous, wait until there is no more data in the stderr stream77+ readProcessStderr.join(readStderrTimeout.millis());78+ byte[] output = stdoutBuffer.toByteArray();79+80+ if (cancellation.isCancelled()) {81+ throw new CancellationException("Render cancelled because no clients are waiting for it.");82+ }83+ if (process.isAlive()) {84+ process.destroyForcibly();85+ throw new InterruptedIOException("Process was forcibly killed (not responding after " + this.commandTimeout + " seconds)");86+ }87+ int exitValue = process.exitValue();88+ return commandStatusHandler.handle(exitValue, output, stderrBuffer.toByteArray());89+ } finally {90+ cancellation.unregister(process);7491 }75- int exitValue = process.exitValue();76- return commandStatusHandler.handle(exitValue, output, stderrBuffer.toByteArray());7792 }7893 79- private static Thread readProcessStdout(final Process process, final ByteArrayOutputStream buffer) {94+ private static Thread readProcessStdout(final Process process, final ByteArrayOutputStream buffer, RenderCancellation cancellation) {8095 InputStream input = process.getInputStream();8196 Thread thread = new Thread(() -> {8297 byte[] data = new byte[2048];@@ -86,14 +101,14 @@ public class Commander {
86101 buffer.write(data, 0, index);87102 }88103 } catch (IOException e) {89- throw new RuntimeException("Unable to read stdout", e);104+ if (!cancellation.isCancelled()) throw new RuntimeException("Unable to read stdout", e);90105 }91106 });92107 thread.start();93108 return thread;94109 }95110 96- private static Thread readProcessStderr(final Process process, final ByteArrayOutputStream buffer) {111+ private static Thread readProcessStderr(final Process process, final ByteArrayOutputStream buffer, RenderCancellation cancellation) {97112 InputStream input = process.getErrorStream();98113 Thread thread = new Thread(() -> {99114 byte[] data = new byte[2048];@@ -103,7 +118,7 @@ public class Commander {
103118 buffer.write(data, 0, index);104119 }105120 } catch (IOException e) {106- throw new RuntimeException("Unable to read stderr", e);121+ if (!cancellation.isCancelled()) throw new RuntimeException("Unable to read stderr", e);107122 }108123 });109124 thread.start();@@ -8,8 +8,12 @@ import io.vertx.core.Future;
88 import io.vertx.core.Vertx;99 import io.vertx.core.buffer.Buffer;1010 import io.vertx.core.http.HttpClient;11+import io.vertx.core.http.HttpClientRequest;12+import io.vertx.core.http.HttpClientResponse;1113 import io.vertx.core.http.HttpHeaders;14+import io.vertx.core.http.HttpMethod;1215 import io.vertx.core.http.PoolOptions;16+import io.vertx.core.http.RequestOptions;1317 import io.vertx.core.json.DecodeException;1418 import io.vertx.core.json.JsonObject;1519 import io.vertx.ext.web.client.HttpRequest;@@ -20,6 +24,8 @@ import org.slf4j.Logger;
2024 import org.slf4j.LoggerFactory;2125 2226 import java.net.ConnectException;27+import java.net.URLEncoder;28+import java.nio.charset.StandardCharsets;2329 2430 public class Delegator {2531 @@ -39,6 +45,7 @@ public class Delegator {
3945 // <host>:<port>") well before the companion itself is actually overloaded.4046 private static final int DEFAULT_MAX_POOL_SIZE = 10;4147 private final WebClient webClient;48+ private final HttpClient httpClient;4249 private final long timeoutMs;4350 4451 public Delegator(Vertx vertx) {@@ -48,7 +55,7 @@ public class Delegator {
4855 public Delegator(Vertx vertx, JsonObject config) {4956 Integer configuredPoolSize = config.getInteger("KROKI_DELEGATE_MAX_POOL_SIZE");5057 int maxPoolSize = configuredPoolSize != null && configuredPoolSize > 0 ? configuredPoolSize : DEFAULT_MAX_POOL_SIZE;51- HttpClient httpClient = vertx.httpClientBuilder()58+ this.httpClient = vertx.httpClientBuilder()5259 // https://vertx.io/docs/vertx-web-client/java/#_handling_30x_redirections5360 // > By default the client follows redirections5461 // But..@@ -76,6 +83,82 @@ public class Delegator {
7683 .sendBuffer(Buffer.buffer(body));7784 }7885 86+ public Future<DelegatedResponse> delegateCancellable(String host, int port, String requestURI, String body,87+ JsonObject options, RenderCancellation cancellation) {88+ String uri = requestURI + encodeOptions(options);89+ RequestOptions requestOptions = new RequestOptions()90+ .setMethod(HttpMethod.POST)91+ .setHost(host)92+ .setPort(port)93+ .setURI(uri)94+ .setFollowRedirects(true)95+ .setTimeout(timeoutMs);96+ return httpClient.request(requestOptions).compose(request -> {97+ request.putHeader(HttpHeaders.ACCEPT, HttpHeaderValues.APPLICATION_JSON);98+ cancellation.onCancel(request::cancel);99+ return request.send(Buffer.buffer(body));100+ }).compose(response -> response.body().map(bodyBuffer -> new DelegatedResponse(response, bodyBuffer)));101+ }102+103+ private static String encodeOptions(JsonObject options) {104+ if (options.isEmpty()) return "";105+ StringBuilder query = new StringBuilder("?");106+ options.stream().forEach(entry -> {107+ if (query.length() > 1) query.append('&');108+ query.append(URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8));109+ query.append('=');110+ query.append(URLEncoder.encode(entry.getValue() == null ? "" : entry.getValue().toString(), StandardCharsets.UTF_8));111+ });112+ return query.toString();113+ }114+115+ public static Future<Buffer> handleCancellable(String host, int port, String requestURI,116+ Future<DelegatedResponse> httpResponseFuture) {117+ return httpResponseFuture.compose(httpResponse -> {118+ if (httpResponse.statusCode == 200) {119+ return Future.succeededFuture(httpResponse.body);120+ }121+ logging.delegate(httpResponse.statusCode, httpResponse.body.toString(), host, port, requestURI);122+ String contentType = httpResponse.contentType;123+ if (contentType != null && contentType.toLowerCase().startsWith(HttpHeaderValues.APPLICATION_JSON.toString())) {124+ try {125+ JsonObject json = httpResponse.body.toJsonObject();126+ Object error = json.getValue("error");127+ if (error instanceof String) {128+ return Future.failedFuture(new BadRequestException((String) error, httpResponse.statusCode));129+ }130+ if (error instanceof JsonObject) {131+ JsonObject errorObject = (JsonObject) error;132+ String message = errorObject.getString("name", "Error") + ": "133+ + errorObject.getString("message", "Unexpected error") + "\n"134+ + errorObject.getString("stacktrace", "");135+ return Future.failedFuture(new BadRequestException(message, httpResponse.statusCode));136+ }137+ } catch (DecodeException ignored) {138+ // Fall through to a generic status error.139+ }140+ }141+ return Future.failedFuture(new HttpException(httpResponse.statusCode));142+ }, failure -> {143+ if (failure instanceof ConnectException) {144+ return Future.failedFuture(new ServiceUnavailableException(failure.getMessage()));145+ }146+ return Future.failedFuture(failure);147+ });148+ }149+150+ public static class DelegatedResponse {151+ private final int statusCode;152+ private final String contentType;153+ private final Buffer body;154+155+ private DelegatedResponse(HttpClientResponse response, Buffer body) {156+ this.statusCode = response.statusCode();157+ this.contentType = response.getHeader(HttpHeaders.CONTENT_TYPE);158+ this.body = body;159+ }160+ }161+79162 public static Future<Buffer> handle(String host, int port, String requestURI, Future<HttpResponse<Buffer>> httpResponseFuture) {80163 return httpResponseFuture.compose(httpResponse -> {81164 if (httpResponse.statusCode() == 200) {@@ -0,0 +1,60 @@
1+package io.kroki.server.action;2+3+import java.util.Set;4+import java.util.concurrent.ConcurrentHashMap;5+import java.util.concurrent.CopyOnWriteArrayList;6+import java.util.concurrent.atomic.AtomicBoolean;7+8+public class RenderCancellation {9+10+ private final AtomicBoolean cancelled = new AtomicBoolean();11+ private final Set<Process> processes = ConcurrentHashMap.newKeySet();12+ private final CopyOnWriteArrayList<Runnable> listeners = new CopyOnWriteArrayList<>();13+14+ public boolean isCancelled() {15+ return cancelled.get();16+ }17+18+ public void register(Process process) {19+ if (cancelled.get()) {20+ terminate(process);21+ return;22+ }23+ processes.add(process);24+ if (cancelled.get() && processes.remove(process)) {25+ terminate(process);26+ }27+ }28+29+ public void unregister(Process process) {30+ processes.remove(process);31+ }32+33+ public void onCancel(Runnable listener) {34+ if (cancelled.get()) {35+ listener.run();36+ return;37+ }38+ listeners.add(listener);39+ if (cancelled.get() && listeners.remove(listener)) {40+ listener.run();41+ }42+ }43+44+ public void cancel() {45+ if (!cancelled.compareAndSet(false, true)) {46+ return;47+ }48+ processes.forEach(RenderCancellation::terminate);49+ processes.clear();50+ listeners.forEach(Runnable::run);51+ listeners.clear();52+ }53+54+ private static void terminate(Process process) {55+ process.descendants().forEach(child -> {56+ if (child.isAlive()) child.destroyForcibly();57+ });58+ if (process.isAlive()) process.destroyForcibly();59+ }60+}@@ -39,7 +39,7 @@ public class InvalidRequestHandler implements Handler<HttpServerRequest> {
3939 new ErrorInfo(4040 cause,4141 responseStatus.code(),42- "The request URI's length exceeds " + maxInitialLineLength + ". You can update this value by setting KROKI_MAX_URI_LENGTH environment variable. Please read: https://docs.kroki.io/kroki/setup/configuration/#_max_uri_length for more information.",42+ "This image link is too large to open. Use a shorter diagram or share the editable diagram.zip link instead.",4343 null4444 )4545 ));@@ -140,10 +140,12 @@ public class Logging {
140140 }141141 142142 public void delegate(HttpResponse<Buffer> httpResponse, String host, int port, String requestURI) {143+ delegate(httpResponse.statusCode(), httpResponse.bodyAsString(), host, port, requestURI);144+ }145+146+ public void delegate(int statusCode, String responseBody, String host, int port, String requestURI) {143147 try {144148 String path = host + ":" + port + requestURI;145- int statusCode = httpResponse.statusCode();146- String responseBody = httpResponse.bodyAsString();147149 MDC.put("action", "delegate");148150 MDC.put("method", "POST");149151 MDC.put("path", path);@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -53,13 +54,18 @@ public class Blockdiag implements DiagramService {
5354 5455 5556 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {57+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());58+ }59+60+ 61+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5662 return vertx.executeBlocking(() -> {57- byte[] result = bin(sourceDecoded.getBytes(), serviceName, fileFormat, options);63+ byte[] result = bin(cancellation, sourceDecoded.getBytes(), serviceName, fileFormat, options);5864 return Buffer.buffer(result);5965 });6066 }6167 62- private byte[] bin(byte[] source, String serviceName, FileFormat fileFormat, JsonObject options) throws IOException, InterruptedException, IllegalStateException {68+ private byte[] bin(RenderCancellation cancellation, byte[] source, String serviceName, FileFormat fileFormat, JsonObject options) throws IOException, InterruptedException, IllegalStateException {6369 List<String> commands = new ArrayList<>();6470 commands.add(binPath);6571 commands.add("--module=" + serviceName);@@ -82,6 +88,6 @@ public class Blockdiag implements DiagramService {
8288 commands.add("--nodoctype");8389 }8490 commands.add("-"); // read from stdin85- return commander.execute(source, commands.toArray(new String[0]));91+ return commander.execute(cancellation, source, commands.toArray(new String[0]));8692 }8793 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Delegator;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -56,4 +57,11 @@ public class Bpmn implements DiagramService {
5657 Future<HttpResponse<Buffer>> httpResponseFuture = this.delegator.delegate(host, port, requestURI, sourceDecoded, options);5758 return Delegator.handle(host, port, requestURI, httpResponseFuture);5859 }60+61+ 62+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {63+ String requestURI = "/" + serviceName + "/" + fileFormat.getName();64+ return Delegator.handleCancellable(host, port, requestURI,65+ delegator.delegateCancellable(host, port, requestURI, sourceDecoded, options, cancellation));66+ }5967 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -53,13 +54,18 @@ public class Bytefield implements DiagramService {
5354 5455 5556 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {57+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());58+ }59+60+ 61+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5662 return vertx.executeBlocking(() -> {57- byte[] result = bytefield(sourceDecoded.getBytes());63+ byte[] result = bytefield(cancellation, sourceDecoded.getBytes());5864 return Buffer.buffer(result);5965 });6066 }6167 62- private byte[] bytefield(byte[] source) throws IOException, InterruptedException, IllegalStateException {63- return commander.execute(source, binPath);68+ private byte[] bytefield(RenderCancellation cancellation, byte[] source) throws IOException, InterruptedException, IllegalStateException {69+ return commander.execute(cancellation, source, binPath);6470 }6571 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -80,13 +81,18 @@ public class D2 implements DiagramService {
8081 8182 8283 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {84+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());85+ }86+87+ 88+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {8389 return vertx.executeBlocking(() -> {84- byte[] result = d2(sourceDecoded.getBytes(), options);90+ byte[] result = d2(cancellation, sourceDecoded.getBytes(), options);8591 return Buffer.buffer(result);8692 });8793 }8894 89- private byte[] d2(byte[] source, JsonObject options) throws IOException, InterruptedException, IllegalStateException {95+ private byte[] d2(RenderCancellation cancellation, byte[] source, JsonObject options) throws IOException, InterruptedException, IllegalStateException {9096 List<String> commands = new ArrayList<>();9197 commands.add(binPath);9298 String layout = options.getString("layout");@@ -141,6 +147,6 @@ public class D2 implements DiagramService {
141147 commands.add("--scale=" + scale);142148 }143149 commands.add("-"); // read from stdin144- return commander.execute(source, commands.toArray(new String[0]));150+ return commander.execute(cancellation, source, commands.toArray(new String[0]));145151 }146152 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -51,13 +52,18 @@ public class Dbml implements DiagramService {
5152 5253 5354 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {55+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());56+ }57+58+ 59+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5460 return vertx.executeBlocking(() -> {55- byte[] result = dbmlRenderer(sourceDecoded.getBytes(), fileFormat.getName());61+ byte[] result = dbmlRenderer(cancellation, sourceDecoded.getBytes(), fileFormat.getName());5662 return Buffer.buffer(result);5763 });5864 }5965 60- private byte[] dbmlRenderer(byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {61- return commander.execute(source, binPath);66+ private byte[] dbmlRenderer(RenderCancellation cancellation, byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {67+ return commander.execute(cancellation, source, binPath);6268 }6369 }@@ -24,6 +24,7 @@ import java.util.HashMap;
2424 import java.util.List;2525 import java.util.Map;2626 import java.util.stream.Collectors;27+import java.util.concurrent.CancellationException;2728 2829 public class DiagramHandler {2930 @@ -31,15 +32,21 @@ public class DiagramHandler {
3132 private final DiagramService service;3233 private final Logging logging;3334 private final DiagramResponse diagramResponse;35+ private final RenderCache renderCache;3436 3537 public DiagramHandler(DiagramService service) {3638 this(service, null);3739 }3840 3941 public DiagramHandler(DiagramService service, Caching caching) {42+ this(service, caching, new RenderCache(new JsonObject()));43+ }44+45+ public DiagramHandler(DiagramService service, Caching caching, RenderCache renderCache) {4046 this.service = service;4147 this.logging = new Logging(logger);4248 this.diagramResponse = new DiagramResponse(caching);49+ this.renderCache = renderCache;4350 }4451 4552 public Handler<RoutingContext> createRequestReceived(String serviceName) {@@ -189,18 +196,27 @@ public class DiagramHandler {
189196 190197 public void convert(RoutingContext routingContext, String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {191198 long start = System.currentTimeMillis();192- Future<Buffer> result = service.convert(sourceDecoded, serviceName, fileFormat, options);193- result.onComplete(buffer -> {199+ RenderCache.RenderRequest render = renderCache.render(serviceName + "@" + service.getVersion(), fileFormat, sourceDecoded, options,200+ cancellation -> service.convert(sourceDecoded, serviceName, fileFormat, options, cancellation));201+ HttpServerResponse response = routingContext.response();202+ response.putHeader("X-Diagram-Cache", render.status().name());203+ response.closeHandler(ignored -> render.release());204+ render.future().onComplete(buffer -> {205+ render.release();194206 logging.convert(routingContext, start, serviceName, fileFormat);195207 if (buffer == null) {196208 routingContext.fail(new BadRequestException("The service did not return a response."));197209 } else {198- HttpServerResponse response = routingContext.response();199210 if (!response.closed()) {200211 diagramResponse.end(response, sourceDecoded, fileFormat, buffer);201212 }202213 }203- }, routingContext::fail);214+ }, failure -> {215+ render.release();216+ if (!response.closed() && !(failure instanceof CancellationException)) {217+ routingContext.fail(failure);218+ }219+ });204220 }205221 206222 public DiagramService getService() {@@ -6,6 +6,7 @@ import io.kroki.server.response.Caching;
66 import io.vertx.core.http.HttpMethod;77 import io.vertx.ext.web.Router;88 import io.vertx.ext.web.handler.BodyHandler;9+import io.vertx.core.json.JsonObject;910 1011 import java.util.HashMap;1112 import java.util.List;@@ -18,14 +19,20 @@ public class DiagramRegistry {
1819 private final Map<String, DiagramHandler> registry = new HashMap<>();1920 private final Router router;2021 private final BodyHandler bodyHandler;22+ private final RenderCache renderCache;2123 2224 public DiagramRegistry(Router router, BodyHandler bodyHandler) {25+ this(router, bodyHandler, new RenderCache(new JsonObject()));26+ }27+28+ public DiagramRegistry(Router router, BodyHandler bodyHandler, RenderCache renderCache) {2329 this.router = router;2430 this.bodyHandler = bodyHandler;31+ this.renderCache = renderCache;2532 }2633 2734 public void register(DiagramService diagramService, String... names) {28- DiagramHandler diagramHandler = new DiagramHandler(diagramService, new Caching(diagramService.getVersion()));35+ DiagramHandler diagramHandler = new DiagramHandler(diagramService, new Caching(diagramService.getVersion()), renderCache);2936 for (String name : names) {3037 registry.put(name, diagramHandler);3138 router.get("/" + name + "/:output_format/:source_encoded")@@ -1,5 +1,6 @@
11 package io.kroki.server.service;22 3+import io.kroki.server.action.RenderCancellation;34 import io.kroki.server.decode.SourceDecoder;45 import io.kroki.server.format.FileFormat;56 import io.vertx.core.AsyncResult;@@ -19,4 +20,9 @@ public interface DiagramService {
1920 String getVersion();2021 2122 Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options);23+24+ default Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options,25+ RenderCancellation cancellation) {26+ return convert(sourceDecoded, serviceName, fileFormat, options);27+ }2228 }@@ -0,0 +1,40 @@
1+package io.kroki.server.service;2+3+import io.vertx.core.Handler;4+import io.vertx.core.Vertx;5+import io.vertx.core.http.HttpHeaders;6+import io.vertx.core.http.HttpServerResponse;7+import io.vertx.ext.web.RoutingContext;8+9+public class DiagramZipHandler {10+11+ private static final String CONTENT_SECURITY_POLICY = String.join("; ",12+ "default-src 'none'",13+ "script-src 'self'",14+ "style-src 'self' 'unsafe-inline'",15+ "img-src 'self' blob: data:",16+ "connect-src 'self'",17+ "font-src 'self'",18+ "base-uri 'none'",19+ "form-action 'none'",20+ "frame-ancestors 'none'"21+ );22+23+ private final String page;24+25+ public DiagramZipHandler(Vertx vertx) {26+ this.page = vertx.fileSystem().readFileBlocking("web/diagramzip/index.html").toString();27+ }28+29+ public Handler<RoutingContext> create() {30+ return routingContext -> {31+ HttpServerResponse response = routingContext.response();32+ response.putHeader(HttpHeaders.CONTENT_TYPE, "text/html; charset=utf-8");33+ response.putHeader(HttpHeaders.CACHE_CONTROL, "no-cache");34+ response.putHeader("Content-Security-Policy", CONTENT_SECURITY_POLICY);35+ response.putHeader("Referrer-Policy", "no-referrer");36+ response.putHeader("X-Content-Type-Options", "nosniff");37+ response.end(page);38+ };39+ }40+}@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Delegator;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -58,4 +59,11 @@ public class Diagramsnet implements DiagramService {
5859 Future<HttpResponse<Buffer>> httpResponseFuture = this.delegator.delegate(host, port, requestURI, sourceDecoded, options);5960 return Delegator.handle(host, port, requestURI, httpResponseFuture);6061 }62+63+ 64+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {65+ String requestURI = "/" + serviceName + "/" + fileFormat.getName();66+ return Delegator.handleCancellable(host, port, requestURI,67+ delegator.delegateCancellable(host, port, requestURI, sourceDecoded, options, cancellation));68+ }6169 }@@ -1,5 +1,6 @@
11 package io.kroki.server.service;22 3+import io.kroki.server.action.RenderCancellation;34 import io.kroki.server.decode.DiagramSource;45 import io.kroki.server.decode.SourceDecoder;56 import io.kroki.server.error.DecodeException;@@ -47,8 +48,13 @@ public class Ditaa implements DiagramService {
4748 4849 4950 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {51+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());52+ }53+54+ 55+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5056 return vertx.executeBlocking(() -> {51- byte[] result = this.command.convert(sourceDecoded, fileFormat, options);57+ byte[] result = this.command.convert(cancellation, sourceDecoded, fileFormat, options);5258 return Buffer.buffer(result);5359 });5460 }@@ -2,6 +2,7 @@ package io.kroki.server.service;
22 33 import io.kroki.server.Main;44 import io.kroki.server.action.Commander;5+import io.kroki.server.action.RenderCancellation;56 import io.kroki.server.format.FileFormat;67 import io.vertx.core.json.JsonObject;78 import org.slf4j.Logger;@@ -24,6 +25,10 @@ public class DitaaCommand {
2425 }2526 2627 public byte[] convert(String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {28+ return convert(new RenderCancellation(), source, format, options);29+ }30+31+ public byte[] convert(RenderCancellation cancellation, String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {2732 List<String> commands = new ArrayList<>();2833 commands.add(binPath);2934 if (format.equals(FileFormat.SVG)) {@@ -66,6 +71,6 @@ public class DitaaCommand {
6671 }6772 commands.add("-");6873 logger.info("commands: {}", Arrays.toString(commands.toArray(new String[0])));69- return commander.execute(source.getBytes(), commands.toArray(new String[0]));74+ return commander.execute(cancellation, source.getBytes(), commands.toArray(new String[0]));7075 }7176 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -52,14 +53,19 @@ public class Erd implements DiagramService {
5253 5354 5455 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {56+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());57+ }58+59+ 60+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5561 return vertx.executeBlocking(() -> {56- byte[] result = erd(sourceDecoded.getBytes(), fileFormat == FileFormat.JPEG ? "jpg" : fileFormat.getName());62+ byte[] result = erd(cancellation, sourceDecoded.getBytes(), fileFormat == FileFormat.JPEG ? "jpg" : fileFormat.getName());5763 return Buffer.buffer(result);5864 });5965 }6066 61- private byte[] erd(byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {67+ private byte[] erd(RenderCancellation cancellation, byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {6268 // Supported format: bmp, dot, eps, gif, jpg, pdf, plain, png, ps, ps2, svg, tiff63- return commander.execute(source, binPath, "--fmt=" + format);69+ return commander.execute(cancellation, source, binPath, "--fmt=" + format);6470 }6571 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Delegator;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -56,4 +57,11 @@ public class Excalidraw implements DiagramService {
5657 Future<HttpResponse<Buffer>> httpResponseFuture = this.delegator.delegate(host, port, requestURI, sourceDecoded, options);5758 return Delegator.handle(host, port, requestURI, httpResponseFuture);5859 }60+61+ 62+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {63+ String requestURI = "/" + serviceName + "/" + fileFormat.getName();64+ return Delegator.handleCancellable(host, port, requestURI,65+ delegator.delegateCancellable(host, port, requestURI, sourceDecoded, options, cancellation));66+ }5967 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -54,6 +55,11 @@ public class Goat implements DiagramService {
5455 5556 5657 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {58+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());59+ }60+61+ 62+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5763 return vertx.executeBlocking(() -> {5864 List<String> commands = new ArrayList<>();5965 commands.add(binPath);@@ -79,7 +85,7 @@ public class Goat implements DiagramService {
7985 // Currently GoAT only supports passing custom CSS via files.8086 // It would be best if we can inline it directly instead.8187 82- byte[] result = commander.execute(sourceDecoded.getBytes(), commands.toArray(new String[0]));88+ byte[] result = commander.execute(cancellation, sourceDecoded.getBytes(), commands.toArray(new String[0]));8389 return Buffer.buffer(result);8490 });8591 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -53,13 +54,18 @@ public class Graphviz implements DiagramService {
5354 5455 5556 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {57+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());58+ }59+60+ 61+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5662 return vertx.executeBlocking(() -> {57- byte[] result = dot(sourceDecoded.getBytes(), fileFormat.getName(), options);63+ byte[] result = dot(cancellation, sourceDecoded.getBytes(), fileFormat.getName(), options);5864 return Buffer.buffer(result);5965 });6066 }6167 62- private byte[] dot(byte[] source, String format, JsonObject options) throws IOException, InterruptedException, IllegalStateException {68+ private byte[] dot(RenderCancellation cancellation, byte[] source, String format, JsonObject options) throws IOException, InterruptedException, IllegalStateException {6369 List<String> commands = new ArrayList<>();6470 commands.add(binPath);6571 // Supported format:@@ -90,6 +96,6 @@ public class Graphviz implements DiagramService {
9096 commands.add("-E" + name + "=" + options.getString(fieldName));9197 }9298 }93- return commander.execute(source, commands.toArray(new String[0]));99+ return commander.execute(cancellation, source, commands.toArray(new String[0]));94100 }95101 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Delegator;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -66,4 +67,12 @@ public class Mermaid implements DiagramService {
6667 Future<HttpResponse<Buffer>> httpResponseFuture = this.delegator.delegate(host, port, requestURI, sourceDecoded, options);6768 return Delegator.handle(host, port, requestURI, httpResponseFuture);6869 }70+71+ 72+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {73+ String requestURI = "/" + serviceName + "/" + fileFormat.getName();74+ options.put("safeMode", safeMode.name().toLowerCase());75+ return Delegator.handleCancellable(host, port, requestURI,76+ delegator.delegateCancellable(host, port, requestURI, sourceDecoded, options, cancellation));77+ }6978 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -51,13 +52,18 @@ public class Nomnoml implements DiagramService {
5152 5253 5354 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {55+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());56+ }57+58+ 59+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5460 return vertx.executeBlocking(() -> {55- byte[] result = nomnoml(sourceDecoded.getBytes());61+ byte[] result = nomnoml(cancellation, sourceDecoded.getBytes());5662 return Buffer.buffer(result);5763 });5864 }5965 60- private byte[] nomnoml(byte[] source) throws IOException, InterruptedException, IllegalStateException {61- return commander.execute(source, binPath);66+ private byte[] nomnoml(RenderCancellation cancellation, byte[] source) throws IOException, InterruptedException, IllegalStateException {67+ return commander.execute(cancellation, source, binPath);6268 }6369 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -51,13 +52,18 @@ public class Pikchr implements DiagramService {
5152 5253 5354 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {55+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());56+ }57+58+ 59+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5460 return vertx.executeBlocking(() -> {55- byte[] result = pikchr(sourceDecoded.getBytes());61+ byte[] result = pikchr(cancellation, sourceDecoded.getBytes());5662 return Buffer.buffer(result);5763 });5864 }5965 60- private byte[] pikchr(byte[] source) throws IOException, InterruptedException, IllegalStateException {61- return commander.execute(source, binPath, "--svg-only", "-");66+ private byte[] pikchr(RenderCancellation cancellation, byte[] source) throws IOException, InterruptedException, IllegalStateException {67+ return commander.execute(cancellation, source, binPath, "--svg-only", "-");6268 }6369 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.DitaaContext;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.BadRequestException;@@ -187,6 +188,11 @@ public class Plantuml implements DiagramService {
187188 188189 189190 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {191+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());192+ }193+194+ 195+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {190196 String source;191197 try {192198 source = sanitize(sourceDecoded, this.safeMode, this.includeWhitelist);@@ -206,7 +212,7 @@ public class Plantuml implements DiagramService {
206212 // found a ditaa context, delegate to the optimized ditaa service207213 return vertx.executeBlocking(() -> {208214 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();209- ditaaCommand.convert(ditaaContext.getSource(), fileFormat, options);215+ ditaaCommand.convert(cancellation, ditaaContext.getSource(), fileFormat, options);210216 return Buffer.buffer(outputStream.toByteArray());211217 });212218 } else {@@ -218,7 +224,7 @@ public class Plantuml implements DiagramService {
218224 // add !theme directive just after the @start directive219225 sourceWithTheme = START_BLOCK_RX.matcher(primeSource).replaceAll("$1!theme " + theme + "\n");220226 }221- byte[] data = this.plantumlCommand.convert(sourceWithTheme, fileFormat, options);227+ byte[] data = this.plantumlCommand.convert(cancellation, sourceWithTheme, fileFormat, options);222228 return Buffer.buffer(data);223229 });224230 }@@ -2,6 +2,7 @@ package io.kroki.server.service;
22 33 import io.kroki.server.action.CommandStatusHandler;44 import io.kroki.server.action.Commander;5+import io.kroki.server.action.RenderCancellation;56 import io.kroki.server.error.BadRequestException;67 import io.kroki.server.format.FileFormat;78 import io.kroki.server.security.SafeMode;@@ -94,11 +95,15 @@ public class PlantumlCommand {
9495 }9596 9697 public byte[] convert(String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {98+ return convert(new RenderCancellation(), source, format, options);99+ }100+101+ public byte[] convert(RenderCancellation cancellation, String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {97102 List<String> commandArgs = buildCommandArgs(format, options);98103 99104 logger.debug("Executing PlantUML command: {}", commandArgs);100105 101- byte[] result = commander.execute(source.getBytes(), commandArgs.toArray(new String[0]));106+ byte[] result = commander.execute(cancellation, source.getBytes(), commandArgs.toArray(new String[0]));102107 if (format == FileFormat.BASE64) {103108 final String encodedBytes = "data:image/png;base64," + Base64.getUrlEncoder().encodeToString(result).replaceAll("\\s", "");104109 return encodedBytes.getBytes();@@ -0,0 +1,176 @@
1+package io.kroki.server.service;2+3+import com.github.benmanes.caffeine.cache.Cache;4+import com.github.benmanes.caffeine.cache.Caffeine;5+import io.kroki.server.action.RenderCancellation;6+import io.kroki.server.format.FileFormat;7+import io.vertx.core.Future;8+import io.vertx.core.Promise;9+import io.vertx.core.buffer.Buffer;10+import io.vertx.core.json.JsonObject;11+12+import java.nio.charset.StandardCharsets;13+import java.time.Duration;14+import java.util.Objects;15+import java.util.TreeMap;16+import java.util.concurrent.ConcurrentHashMap;17+import java.util.concurrent.atomic.AtomicBoolean;18+import java.util.concurrent.atomic.AtomicInteger;19+import java.util.function.Function;20+21+public class RenderCache {22+23+ private static final long DEFAULT_MAX_BYTES = 64L * 1024 * 1024;24+ private static final long DEFAULT_TTL_SECONDS = 30L * 60;25+26+ private final Cache<Key, Buffer> completed;27+ private final ConcurrentHashMap<Key, InFlight> inFlight = new ConcurrentHashMap<>();28+29+ public RenderCache(JsonObject config) {30+ long maxBytes = config.getLong("KROKI_RENDER_CACHE_MAX_BYTES", DEFAULT_MAX_BYTES);31+ long ttlSeconds = config.getLong("KROKI_RENDER_CACHE_TTL_SECONDS", DEFAULT_TTL_SECONDS);32+ this.completed = Caffeine.newBuilder()33+ .maximumWeight(Math.max(1, maxBytes))34+ .weigher((Key key, Buffer value) -> key.weight(value))35+ .expireAfterAccess(Duration.ofSeconds(Math.max(1, ttlSeconds)))36+ .build();37+ }38+39+ public RenderRequest render(String serviceName, FileFormat fileFormat, String source, JsonObject options,40+ Function<RenderCancellation, Future<Buffer>> loader) {41+ Key key = new Key(serviceName, fileFormat, source, options);42+ Buffer cached = completed.getIfPresent(key);43+ if (cached != null) {44+ return RenderRequest.completed(cached);45+ }46+47+ while (true) {48+ InFlight existing = inFlight.get(key);49+ if (existing != null) {50+ return existing.subscribe(CacheStatus.COALESCED);51+ }52+53+ InFlight created = new InFlight(key);54+ if (inFlight.putIfAbsent(key, created) == null) {55+ RenderRequest request = created.subscribe(CacheStatus.MISS);56+ created.start(loader);57+ return request;58+ }59+ }60+ }61+62+ public enum CacheStatus {63+ HIT,64+ MISS,65+ COALESCED66+ }67+68+ public static class RenderRequest {69+ private final Future<Buffer> future;70+ private final CacheStatus status;71+ private final Runnable release;72+ private final AtomicBoolean released = new AtomicBoolean();73+74+ private RenderRequest(Future<Buffer> future, CacheStatus status, Runnable release) {75+ this.future = future;76+ this.status = status;77+ this.release = release;78+ }79+80+ private static RenderRequest completed(Buffer buffer) {81+ return new RenderRequest(Future.succeededFuture(buffer), CacheStatus.HIT, () -> {});82+ }83+84+ public Future<Buffer> future() {85+ return future;86+ }87+88+ public CacheStatus status() {89+ return status;90+ }91+92+ public void release() {93+ if (released.compareAndSet(false, true)) release.run();94+ }95+ }96+97+ private class InFlight {98+ private final Key key;99+ private final Promise<Buffer> promise = Promise.promise();100+ private final RenderCancellation cancellation = new RenderCancellation();101+ private final AtomicInteger subscribers = new AtomicInteger();102+103+ private InFlight(Key key) {104+ this.key = key;105+ }106+107+ private RenderRequest subscribe(CacheStatus status) {108+ subscribers.incrementAndGet();109+ return new RenderRequest(promise.future(), status, () -> {110+ if (subscribers.decrementAndGet() == 0 && !promise.future().isComplete()) {111+ cancellation.cancel();112+ }113+ });114+ }115+116+ private void start(Function<RenderCancellation, Future<Buffer>> loader) {117+ final Future<Buffer> render;118+ try {119+ render = loader.apply(cancellation);120+ } catch (Throwable throwable) {121+ finish(Future.failedFuture(throwable));122+ return;123+ }124+ render.onComplete(this::finish);125+ }126+127+ private void finish(io.vertx.core.AsyncResult<Buffer> result) {128+ inFlight.remove(key, this);129+ if (result.succeeded()) {130+ completed.put(key, result.result());131+ promise.complete(result.result());132+ } else {133+ promise.fail(result.cause());134+ }135+ }136+ }137+138+ private static class Key {139+ private final String serviceName;140+ private final FileFormat fileFormat;141+ private final String source;142+ private final String options;143+ private final int byteLength;144+145+ private Key(String serviceName, FileFormat fileFormat, String source, JsonObject options) {146+ this.serviceName = serviceName;147+ this.fileFormat = fileFormat;148+ this.source = source;149+ this.options = new JsonObject(new TreeMap<>(options.getMap())).encode();150+ this.byteLength = serviceName.getBytes(StandardCharsets.UTF_8).length151+ + source.getBytes(StandardCharsets.UTF_8).length152+ + this.options.getBytes(StandardCharsets.UTF_8).length;153+ }154+155+ private int weight(Buffer value) {156+ long weight = (long) byteLength + value.length();157+ return (int) Math.min(Integer.MAX_VALUE, Math.max(1, weight));158+ }159+160+ 161+ public boolean equals(Object object) {162+ if (this == object) return true;163+ if (!(object instanceof Key)) return false;164+ Key key = (Key) object;165+ return serviceName.equals(key.serviceName)166+ && fileFormat == key.fileFormat167+ && source.equals(key.source)168+ && options.equals(key.options);169+ }170+171+ 172+ public int hashCode() {173+ return Objects.hash(serviceName, fileFormat, source, options);174+ }175+ }176+}@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -53,13 +54,18 @@ public class Svgbob implements DiagramService {
5354 5455 5556 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {57+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());58+ }59+60+ 61+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5662 return vertx.executeBlocking(() -> {57- byte[] result = svgbob(sourceDecoded.getBytes(), options);63+ byte[] result = svgbob(cancellation, sourceDecoded.getBytes(), options);5864 return Buffer.buffer(result);5965 });6066 }6167 62- private byte[] svgbob(byte[] source, JsonObject options) throws IOException, InterruptedException, IllegalStateException {68+ private byte[] svgbob(RenderCancellation cancellation, byte[] source, JsonObject options) throws IOException, InterruptedException, IllegalStateException {6369 List<String> commands = new ArrayList<>();6470 commands.add(binPath);6571 addOption("background", options, commands);@@ -69,7 +75,7 @@ public class Svgbob implements DiagramService {
6975 addOption("scale", options, commands);7076 addOption("stroke-width", options, commands);7177 String[] args = commands.toArray(new String[0]);72- return commander.execute(source, args);78+ return commander.execute(cancellation, source, args);7379 }7480 7581 private void addOption(String optionKey, JsonObject options, List<String> commands) {@@ -1,5 +1,6 @@
11 package io.kroki.server.service;22 3+import io.kroki.server.action.RenderCancellation;34 import io.kroki.server.decode.DiagramSource;45 import io.kroki.server.decode.SourceDecoder;56 import io.kroki.server.error.DecodeException;@@ -47,8 +48,13 @@ public class Symbolator implements DiagramService {
4748 4849 4950 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {51+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());52+ }53+54+ 55+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5056 return vertx.executeBlocking(() -> {51- byte[] result = this.command.convert(sourceDecoded, fileFormat, options);57+ byte[] result = this.command.convert(cancellation, sourceDecoded, fileFormat, options);5258 return Buffer.buffer(result);5359 });5460 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.format.FileFormat;56 import io.vertx.core.json.JsonObject;67 @@ -19,6 +20,10 @@ public class SymbolatorCommand {
1920 }2021 2122 public byte[] convert(String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {23+ return convert(new RenderCancellation(), source, format, options);24+ }25+26+ public byte[] convert(RenderCancellation cancellation, String source, FileFormat format, JsonObject options) throws IOException, InterruptedException {2227 List<String> commands = new ArrayList<>();2328 commands.add(binPath);2429 // Set input to stdin@@ -75,6 +80,6 @@ public class SymbolatorCommand {
7580 commands.add("--libname ");7681 commands.add(libname);7782 }78- return commander.execute(source.getBytes(), commands.toArray(new String[0]));83+ return commander.execute(cancellation, source.getBytes(), commands.toArray(new String[0]));7984 }8085 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -54,17 +55,22 @@ public class TikZ implements DiagramService {
5455 5556 5657 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {58+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());59+ }60+61+ 62+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5763 return vertx.executeBlocking(() -> {58- byte[] result = tikz2svg(sourceDecoded.getBytes(), fileFormat.getName());64+ byte[] result = tikz2svg(cancellation, sourceDecoded.getBytes(), fileFormat.getName());5965 return Buffer.buffer(result);6066 });6167 }6268 63- private byte[] tikz2svg(byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {69+ private byte[] tikz2svg(RenderCancellation cancellation, byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {6470 List<String> commands = new ArrayList<>();6571 commands.add(binPath);6672 commands.add(format);6773 commands.add(String.valueOf(safeMode.value));68- return commander.execute(source, commands.toArray(new String[0]));74+ return commander.execute(cancellation, source, commands.toArray(new String[0]));6975 }7076 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -53,16 +54,21 @@ public class Umlet implements DiagramService {
5354 5455 5556 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {57+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());58+ }59+60+ 61+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5662 return vertx.executeBlocking(() -> {57- byte[] result = umlet(sourceDecoded.getBytes(), fileFormat.getName());63+ byte[] result = umlet(cancellation, sourceDecoded.getBytes(), fileFormat.getName());5864 return Buffer.buffer(result);5965 });6066 }6167 62- private byte[] umlet(byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {68+ private byte[] umlet(RenderCancellation cancellation, byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {6369 List<String> commands = new ArrayList<>();6470 commands.add(binPath);6571 commands.add(format);66- return commander.execute(source, commands.toArray(new String[0]));72+ return commander.execute(cancellation, source, commands.toArray(new String[0]));6773 }6874 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -60,15 +61,20 @@ public class Vega implements DiagramService {
6061 6162 6263 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {64+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());65+ }66+67+ 68+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {6369 return vertx.executeBlocking(() -> {64- byte[] result = vega(sourceDecoded.getBytes(), fileFormat.getName());70+ byte[] result = vega(cancellation, sourceDecoded.getBytes(), fileFormat.getName());6571 return Buffer.buffer(result);6672 });6773 }6874 69- private byte[] vega(byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {75+ private byte[] vega(RenderCancellation cancellation, byte[] source, String format) throws IOException, InterruptedException, IllegalStateException {7076 String vegaSafeMode = safeMode == SafeMode.UNSAFE ? "unsafe" : "secure";71- return commander.execute(source, binPath,77+ return commander.execute(cancellation, source, binPath,7278 "--output-format=" + format,7379 "--safe-mode=" + vegaSafeMode,7480 "--spec-format=" + specFormat.name().toLowerCase());@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -50,8 +51,13 @@ public class Wavedrom implements DiagramService {
5051 5152 5253 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {54+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());55+ }56+57+ 58+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5359 return vertx.executeBlocking(() -> {54- byte[] result = commander.execute(sourceDecoded.getBytes(), binPath);60+ byte[] result = commander.execute(cancellation, sourceDecoded.getBytes(), binPath);5561 return Buffer.buffer(result);5662 });5763 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.decode.DiagramSource;56 import io.kroki.server.decode.SourceDecoder;67 import io.kroki.server.error.DecodeException;@@ -50,8 +51,13 @@ public class Wireviz implements DiagramService {
5051 5152 5253 public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options) {54+ return convert(sourceDecoded, serviceName, fileFormat, options, new RenderCancellation());55+ }56+57+ 58+ public Future<Buffer> convert(String sourceDecoded, String serviceName, FileFormat fileFormat, JsonObject options, RenderCancellation cancellation) {5359 return vertx.executeBlocking(() -> {54- byte[] result = commander.execute(sourceDecoded.getBytes(), binPath,60+ byte[] result = commander.execute(cancellation, sourceDecoded.getBytes(), binPath,5561 "--format=" + fileFormat.getName(),5662 "-");5763 return Buffer.buffer(result);@@ -0,0 +1,1696 @@
1+(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=[],t=[];(()=>{let n=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o`.split(`,`).map(e=>e?parseInt(e,36):1);for(let r=0,i=0;r<n.length;r++)(r%2?t:e).push(i+=n[r])})();function n(n){if(n<768)return!1;for(let r=0,i=e.length;;){let a=r+i>>1;if(n<e[a])i=a;else if(n>=t[a])r=a+1;else return!0;if(r==i)return!1}}function r(e){return e>=127462&&e<=127487}var i=8205;function a(e,t,n=!0,r=!0){return(n?o:s)(e,t,r)}function o(e,t,a){if(t==e.length)return t;t&&l(e.charCodeAt(t))&&u(e.charCodeAt(t-1))&&t--;let o=c(e,t);for(t+=d(o);t<e.length;){let s=c(e,t);if(o==i||s==i||a&&n(s))t+=d(s),o=s;else if(r(s)){let n=0,i=t-2;for(;i>=0&&r(c(e,i));)n++,i-=2;if(n%2==0)break;t+=2}else break}return t}function s(e,t,n){for(;t>1;){let r=o(e,t-2,n);if(r<t)return r;t--}return 0}function c(e,t){let n=e.charCodeAt(t);if(!u(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return l(r)?(n-55296<<10)+(r-56320)+65536:n}function l(e){return e>=56320&&e<57344}function u(e){return e>=55296&&e<56320}function d(e){return e<65536?1:2}var f=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=S(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),m.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=S(this,e,t);let n=[];return this.decompose(e,t,n,0),m.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new v(this),i=new v(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new v(this,e)}iterRange(e,t=this.length){return new y(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new b(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new p(t):m.from(p.split(t,[]))}},p=class e extends f{constructor(e,t=h(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new x(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(_(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=g(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=S(this,t,n);let i=g(this.text,g(r.text,_(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):m.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`2+`){[e,t]=S(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},m=class e extends f{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=S(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`3+`){[e,t]=S(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new p(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof p&&c&&(n=u[u.length-1])instanceof p&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new p(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};f.empty=new p([``],0);function h(e){let t=-1;for(let n of e)t+=n.length+1;return t}function g(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function _(e,t,n){return g(e,[``],t,n)}var v=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof p?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof p?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`4+`,this;e--}else if(r instanceof p){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof p?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},y=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new v(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},b=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(f.prototype[Symbol.iterator]=function(){return this.iter()},v.prototype[Symbol.iterator]=y.prototype[Symbol.iterator]=b.prototype[Symbol.iterator]=function(){return this});var x=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function S(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function C(e,t,n=!0,r=!0){return a(e,t,n,r)}function w(e){return e>=56320&&e<57344}function T(e){return e>=55296&&e<56320}function E(e,t){let n=e.charCodeAt(t);if(!T(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return w(r)?(n-55296<<10)+(r-56320)+65536:n}function D(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function O(e){return e<65536?1:2}var ee=/\r\n?|\n/,k=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(k||={}),te=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){ae(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:se(this,e)}mapDesc(e,t=!1){return e.empty?this:oe(this,e,t)}mapPos(e,t=-1,n=k.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=k.Simple&&c>=e&&(n==k.TrackDel&&r<e&&c>e||n==k.TrackBefore&&r<e||n==k.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},ne=class e extends te{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return ae(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return oe(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(f.empty);r.push(a?t.slice(i,i+a):f.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:se(this,e,!0)}map(e,t=!1){return e.empty?this:oe(this,e,t,!0)}iterChanges(e,t=!1){ae(this,e,t)}get desc(){return te.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new ce(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);re(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;re(n,e,t),t>0&&ie(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);re(n,e,-1),re(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:te.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&re(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?f.of(l.split(r||ee)):l:f.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&re(i,e-o,-1),re(i,s-e,d),ie(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(f.empty);r[e]=f.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function re(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function ie(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(f.empty);e.push(n)}}function ae(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=f.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function oe(e,t,n,r=!1){let i=[],a=r?[]:null,o=new ce(e),s=new ce(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);re(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(re(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(re(i,0,o.ins),a&&ie(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;re(i,t,e<o.i?o.ins:0),a&&e<o.i&&ie(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?ne.createSet(i,a):te.create(i);else throw Error(`Mismatched change set lengths`)}function se(e,t,n=!1){let r=[],i=n?[]:null,a=new ce(e),o=new ce(t);for(let e=!1;;)if(a.done&&o.done)return i?ne.createSet(r,i):te.create(r);else if(a.ins==0)re(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)re(r,0,o.ins,e),i&&ie(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;re(r,t,n,e),i&&n&&ie(i,r,o.text)}else o.ins==-1?(re(r,a.off?0:a.len,t,e),i&&ie(i,r,a.textBit(t))):(re(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&ie(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var ce=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?f.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?f.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},le=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return A.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return A.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return A.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},A=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>le.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return le.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?le.create(t,e,a|32,n):le.create(e,t,a,n)}static undirectionalRange(e,t){return le.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function ue(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var de=0,j=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=de++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:fe),!!t.static,t.enables)}of(e){return new pe([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new pe(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new pe(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function fe(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var pe=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=de++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||he(e,c)){let r=t(e);if(a?!me(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Oe(o,c);if(this.dependencies.every(t=>t instanceof j?o.facet(t)===e.facet(t):t instanceof ve?o.field(t,!1)==e.field(t,!1):!0)||(a?me(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function me(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function he(e,t){let n=!1;for(let r of t)De(e,r)&1&&(n=!0);return n}function ge(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=Oe(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)De(e,t);return e.values[o]=s(e),1},update(e,n){if(!he(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=he(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&fe(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var _e=j.define({static:!0}),ve=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(de++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(_e).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(_e),i=n.facet(_e),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,_e.of({field:this,create:e})]}get extension(){return this}},ye={lowest:4,low:3,default:2,high:1,highest:0};function be(e){return t=>new Se(t,e)}var xe={highest:be(ye.highest),high:be(ye.high),default:be(ye.default),low:be(ye.low),lowest:be(ye.lowest)},Se=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Ce=class e{of(e){return new we(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},we=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Te=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Ee(t,n,o))e instanceof ve?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,fe(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>ge(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function Ee(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof we&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof we){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Se)a(e.inner,e.prec);else if(e instanceof ve)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof pe)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,ye.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,ye.default),r.reduce((e,t)=>e.concat(t))}function De(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Oe(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var ke=j.define(),Ae=j.define({combine:e=>e.some(e=>e),static:!0}),je=j.define({combine:e=>e.length?e[0]:void 0,static:!0}),Me=j.define(),Ne=j.define(),Pe=j.define(),Fe=j.define({combine:e=>e.length?e[0]:!1}),Ie=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Le}},Le=class{of(e){return new Ie(this,e)}},Re=class{constructor(e){this.map=e}of(e){return new M(this,e)}},M=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Re(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};M.reconfigure=M.define(),M.appendConfig=M.define();var ze=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&ue(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};ze.time=Ie.define(),ze.userEvent=Ie.define(),ze.addToHistory=Ie.define(),ze.remote=Ie.define();function Be(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function Ve(e,t,n){let r,i,a;return n?(r=t.changes,i=ne.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:M.mapEffects(e.effects,r).concat(M.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function He(e,t,n){let r=t.selection,i=qe(t.annotations);return t.userEvent&&(i=i.concat(ze.userEvent.of(t.userEvent))),{changes:t.changes instanceof ne?t.changes:ne.of(t.changes||[],n,e.facet(je)),selection:r&&(r instanceof A?r:A.single(r.anchor,r.head)),effects:qe(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Ue(e,t,n){let r=He(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=Ve(r,He(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=ze.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Ge(n?We(i):i)}function We(e){let t=e.startState,n=!0;for(let r of t.facet(Me)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:Be(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=ne.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=ze.create(t,r,e.selection&&e.selection.map(i),M.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(Ne);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof ze?i:Array.isArray(i)&&i.length==1&&i[0]instanceof ze?i[0]:Ue(t,qe(i),!1)}return e}function Ge(e){let t=e.startState,n=t.facet(Pe),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=Ve(r,He(t,a,e.changes.newLength),!0))}return r==e?e:ze.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var Ke=[];function qe(e){return e==null?Ke:Array.isArray(e)?e:[e]}var N=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(N||={}),Je=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ye;try{Ye=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function Xe(e){if(Ye)return Ye.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>``&&(n.toUpperCase()!=n.toLowerCase()||Je.test(n)))return!0}return!1}function Ze(e){return t=>{if(!/\S/.test(t))return N.Space;if(Xe(t))return N.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return N.Word;return N.Other}}var P=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)De(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`);return}return De(this,n),Oe(this,n)}update(...e){return Ue(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Ce.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(M.reconfigure)?(n=null,r=e.value):e.is(M.appendConfig)&&(n=null,r=qe(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Te.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Ae)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:A.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=qe(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=M.mapEffects(a,c).concat(M.mapEffects(qe(o.effects),l))}return{changes:r,selection:A.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof ne?t:ne.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return f.of(t.split(this.facet(e.lineSeparator)||ee))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(De(this,t),Oe(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof ve&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:A.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Te.resolve(t.extensions||[],new Map),r=t.doc instanceof f?t.doc:f.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||ee)),i=t.selection?t.selection instanceof A?t.selection:A.single(t.selection.anchor,t.selection.head):A.single(0);return ue(i,r.length),n.staticFacet(Ae)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`5+`}get readOnly(){return this.facet(Fe)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(ke))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return Ze(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=C(t,a,!1);if(i(t.slice(e,a))!=N.Word)break;a=e}for(;o<r;){let e=C(t,o);if(i(t.slice(o,e))!=N.Word)break;o=e}return a==o?null:A.range(a+n,o+n)}};P.allowMultipleSelections=Ae,P.tabSize=j.define({combine:e=>e.length?e[0]:4}),P.lineSeparator=je,P.readOnly=Fe,P.phrases=j.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),P.languageData=ke,P.changeFilter=Me,P.transactionFilter=Ne,P.transactionExtender=Pe,Ce.reconfigure=M.define();function Qe(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(a!==i&&i!==void 0){if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var $e=class{eq(e){return this==e}range(e,t=e){return tt.create(e,t,this)}};$e.prototype.startSide=$e.prototype.endSide=0,$e.prototype.point=!1,$e.prototype.mapMode=k.TrackDel;function et(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var tt=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function nt(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var rt=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n){let r=[],i=[],a=[],o=-1,s=-1;for(let e=0;e<this.value.length;e++){let c=this.value[e],l=this.from[e]+t,u=this.to[e]+t,d,f;if(l==u){let e=n.mapPos(l,c.startSide,c.mapMode);if(e==null||(d=f=e,c.startSide!=c.endSide&&(f=n.mapPos(l,c.endSide),f<d)))continue}else if(d=n.mapPos(l,c.startSide),f=n.mapPos(u,c.endSide),d>f||d==f&&c.startSide>0&&c.endSide<=0)continue;(f-d||c.endSide-c.startSide)<0||(o<0&&(o=d),c.point&&(s=Math.max(s,f-d)),r.push(c),i.push(d-o),a.push(f-o))}return{mapped:r.length?new e(i,a,r,s):null,pos:o}}},F=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(nt)),this.isEmpty)return n.length?e.of(n):this;let s=new st(this,null,-1).goto(0),c=0,l=[],u=new at;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value)||l.push(tt.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],o=this.chunk[e],s=t.touchesRange(a,a+o.length);if(s===!1)i=Math.max(i,o.maxPoint),n.push(o),r.push(t.mapPos(a));else if(s===!0){let{mapped:e,pos:s}=o.map(a,t);e&&(i=Math.max(i,e.maxPoint),n.push(e),r.push(s))}}let a=this.nextLayer.map(t);return n.length==0?a:new e(r,n,a||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return ct.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return ct.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=ot(a,o,n),c=new ut(a,s,i),l=new ut(o,s,i);n.iterGaps((e,t,n)=>dt(c,e,l,t,n,r)),n.empty&&n.length==0&&dt(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=1e9-1;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=ot(i,a),s=new ut(i,o,0).goto(n),c=new ut(a,o,0).goto(n);for(;;){if(s.to!=c.to||!ft(s.active,c.active)||s.point&&(!c.point||!et(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new ut(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new at;for(let r of e instanceof tt?[e]:t?it(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};F.empty=new F([],[],null,-1);function it(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(nt(t,r)>0)return e.slice().sort(nt);t=r}return e}F.empty.nextLayer=F.empty;var at=class e{finishChunk(e){this.chunks.push(new rt(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addInner(t,n,r)||(this.nextLayer||=new e).add(t,n,r)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(F.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=F.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function ot(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var st=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},ct=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new st(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)lt(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)lt(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),lt(this.heap,0)}}};function lt(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var ut=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=ct.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){pt(this.active,e),pt(this.activeTo,e),pt(this.activeRank,e),this.minActive=ht(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;mt(this.active,t,n),mt(this.activeTo,t,r),mt(this.activeRank,t,i),e&&mt(e,t,this.cursor.from),this.minActive=ht(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&pt(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function dt(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&et(e.point,n.point)&&ft(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&a.boundChange(s),d>s&&!ft(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function ft(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!et(e[n],t[n]))return!1;return!0}function pt(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function mt(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function ht(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function gt(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=C(e,i));return r}function _t(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=C(e,r)}return r===!0?-1:e.length}for(var vt=`ͼ`,yt=typeof Symbol>`u`?`__ͼ`:Symbol.for(vt),bt=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),xt=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},St=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`6+`)}static newName(){let e=xt[yt]||1;return xt[yt]=e+1,vt+e.toString(36)}static mount(e,t,n){let r=e[bt],i=n&&n.nonce;r?i&&r.setNonce(i):r=new wt(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Ct=new Map,wt=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Ct.get(n);if(t)return e[bt]=t;this.sheet=new r.CSSStyleSheet,Ct.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[bt]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let t=0;t<e.length;t++){let a=e[t],o=this.modules.indexOf(a);if(o<i&&o>-1&&(this.modules.splice(o,1),i--,o=-1),o==-1){if(this.modules.splice(i++,0,a),n)for(let e=0;e<a.rules.length;e++)n.insertRule(a.rules[e],r++)}else{for(;i<o;)r+=this.modules[i++].rules.length;r+=a.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`7+`;this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},Tt={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Et={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Dt=typeof navigator<`u`&&/Mac/.test(navigator.platform),Ot=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),kt=0;kt<10;kt++)Tt[48+kt]=Tt[96+kt]=String(kt);for(var kt=1;kt<=24;kt++)Tt[kt+111]=`F`+kt;for(var kt=65;kt<=90;kt++)Tt[kt]=String.fromCharCode(kt+32),Et[kt]=String.fromCharCode(kt);for(var At in Tt)Et.hasOwnProperty(At)||(Et[At]=Tt[At]);function jt(e){var t=!(Dt&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ot&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Et:Tt)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function I(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)Mt(e,arguments[t]);return e}function Mt(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null){if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)Mt(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}}var Nt=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},Pt=typeof document<`u`?document:{documentElement:{style:{}}},Ft=/Edge\/(\d+)/.exec(Nt.userAgent),It=/MSIE \d/.test(Nt.userAgent),Lt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Nt.userAgent),Rt=!!(It||Lt||Ft),zt=!Rt&&/gecko\/(\d+)/i.test(Nt.userAgent),Bt=!Rt&&/Chrome\/(\d+)/.exec(Nt.userAgent),Vt=`webkitFontSmoothing`in Pt.documentElement.style,Ht=!Rt&&/Apple Computer/.test(Nt.vendor),Ut=Ht&&(/Mobile\/\w+/.test(Nt.userAgent)||Nt.maxTouchPoints>2),L={mac:Ut||/Mac/.test(Nt.platform),windows:/Win/.test(Nt.platform),linux:/Linux|X11/.test(Nt.platform),ie:Rt,ie_version:It?Pt.documentMode||6:Lt?+Lt[1]:Ft?+Ft[1]:0,gecko:zt,gecko_version:zt?+(/Firefox\/(\d+)/.exec(Nt.userAgent)||[0,0])[1]:0,chrome:!!Bt,chrome_version:Bt?+Bt[1]:0,ios:Ut,android:/Android\b/.test(Nt.userAgent),webkit:Vt,webkit_version:Vt?+(/\bAppleWebKit\/(\d+)/.exec(Nt.userAgent)||[0,0])[1]:0,safari:Ht,safari_version:Ht?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Nt.userAgent)||[0,0])[1]:0,tabSize:Pt.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function Wt(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var Gt=Object.create(null);function Kt(e,t,n){if(e==t)return!0;e||=Gt,t||=Gt;let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function qt(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function Jt(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function Yt(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var Xt=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Zt=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(Zt||={}),R=class extends $e{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new Qt(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new en(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=tn(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new en(e,n,r,t,e.widget||null,!0)}static line(e){return new $t(e)}static set(e,t=!1){return F.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};R.none=F.empty;var Qt=class e extends R{constructor(e){let{start:t,end:n}=tn(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?Wt(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Gt}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&Kt(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};Qt.prototype.point=!1;var $t=class e extends R{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&Kt(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};$t.prototype.mapMode=k.TrackBefore,$t.prototype.point=!0;var en=class e extends R{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?k.TrackBefore:k.TrackAfter:k.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?Zt.WidgetBefore:Zt.WidgetAfter:Zt.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&nn(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};en.prototype.point=!0;function tn(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function nn(e,t){return e==t||!!(e&&t&&e.compare(t))}function rn(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var an=class e extends $e{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&Kt(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||Gt,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return F.of(e,t)}};an.prototype.startSide=an.prototype.endSide=-1;function on(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function sn(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function cn(e,t){if(!t.anchorNode)return!1;try{return sn(e,t.anchorNode)}catch{return!1}}function ln(e){return e.nodeType==3?En(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function un(e,t,n,r){return n?pn(e,t,n,r,-1)||pn(e,t,n,r,1):!1}function dn(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function fn(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function pn(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:mn(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||n.nodeType!=1)return!1;t=dn(e)+(i<0?0:1),e=n}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable==`false`)return!1;t=i<0?mn(e):0}else return!1}}function mn(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function hn(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function gn(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function _n(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function vn(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(u.nodeType==1){let e,f=u==c.body,p=1,m=1;if(f)e=gn(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=_n(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g){if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function yn(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(a.nodeType==1)!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var bn=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?mn(t):0),n,Math.min(e.focusOffset,n?mn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function xn(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function Sn(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var Cn=null;L.safari&&L.safari_version>=26&&(Cn=!1);function wn(e){if(e.setActive)return e.setActive();if(Cn)return e.focus(Cn);let t=xn(e);e.focus(Cn==null?{get preventScroll(){return Cn={preventScroll:!0},!0}}:void 0),Cn||(Cn=!1,Sn(t))}var Tn;function En(e,t,n=t){let r=Tn||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function Dn(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function On(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function kn(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,mn(n));;)if(r){if(n.nodeType!=1)return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=mn(n))}else if(n==e)return!0;else r=dn(n),n=n.parentNode}function An(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function jn(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r>0)return{node:n,offset:r};else if(n.nodeType==1&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=mn(n)}else if(n.parentNode&&!fn(n))r=dn(n),n=n.parentNode;else return null}function Mn(e,t){for(let n=e,r=t;;)if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};else if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!fn(n))r=dn(n)+1,n=n.parentNode;else return null}var Nn=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,dn(t),n)}static after(t,n){return new e(t.parentNode,dn(t)+1,n)}},z=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(z||={}),Pn=z.LTR,Fn=z.RTL;function In(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var Ln=In(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),Rn=In(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),zn=Object.create(null),Bn=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);zn[t]=n,zn[n]=-t}function Vn(e){return e<=247?Ln[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?Rn[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var Hn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,Un=class{get dir(){return this.level%2?Fn:Pn}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function Wn(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Wn(r.inner,i.inner))return!1}return!0}var B=[];function Gn(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=Vn(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),B[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=B[e];if(i==128)e<s-1&&t==B[e+1]&&t&24?i=B[e]=t:B[e]=256;else if(i==64){let i=e+1;for(;i<s&&B[i]==64;)i++;let a=e&&t==8||i<n&&B[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)B[t]=a;e=i-1}else i==8&&r==1&&(B[e]=1);t=i,i&7&&(r=i)}}}function Kn(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=zn[n=e.charCodeAt(t)]){if(r<0){for(let e=s-3;e>=0;e-=3)if(Bn[e+1]==-r){let n=Bn[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(B[t]=B[Bn[e]]=r),s=e;break}}else if(Bn.length==189)break;else Bn[s++]=t,Bn[s++]=n,Bn[s++]=c}else if((o=B[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=Bn[t+2];if(n&2)break;if(e)Bn[t+2]|=2;else{if(n&4)break;Bn[t+2]|=4}}}}}function qn(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=B[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(B[o]==256)o++;else break;let l=a==1,u=l==((o<t?B[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),B[--t]=u;c=o}else a=o,c++}}}function Jn(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=B[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(B[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new Un(c,m.from,f)),Yn(e,m.direction==Pn==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?B[p]!=s:B[p]==s))break;else p++;d?Jn(e,c,p,r+1,i,d,o):c<p&&o.push(new Un(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=B[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(B[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new Un(m.to,c,f)),Yn(e,m.direction==Pn==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?B[p-1]!=s:B[p-1]==s))break;else p--;d?Jn(e,p,c,r+1,i,d,o):p<c&&o.push(new Un(p,c,f)),c=p}}function Yn(e,t,n,r,i,a,o){let s=t%2?2:1;Gn(e,i,a,r,s),Kn(e,i,a,r,s),qn(i,a,r,s),Jn(e,i,a,t,n,r,o)}function Xn(e,t,n){if(!e)return[new Un(0,0,+(t==Fn))];if(t==Pn&&!n.length&&!Hn.test(e))return Zn(e.length);if(n.length)for(;e.length>B.length;)B[B.length]=256;let r=[],i=t==Pn?0:1;return Yn(e,i,i,n,0,e.length,r),r}function Zn(e){return[new Un(0,e,0)]}var Qn=``;function $n(e,t,n,r,i){let a=r.head-e.from,o=Un.find(t,a,r.bidiLevel??-1,r.assoc),s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=C(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),Qn=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];return u&&l==c&&u.level+ +!i<s.level?A.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level):A.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function er(e,t,n){for(let r=t;r<n;r++){let t=Vn(e.charCodeAt(r));if(t==1)return Pn;if(t==2||t==4)return Fn}return Pn}var tr=j.define(),nr=j.define(),rr=j.define(),ir=j.define(),ar=j.define(),or=j.define(),sr=j.define(),cr=j.define(),lr=j.define(),ur=j.define({combine:e=>e.some(e=>e)}),dr=j.define({combine:e=>e.some(e=>e)}),fr=j.define(),pr=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(A.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},mr=M.define({map:(e,t)=>e.map(t)}),hr=M.define();function gr(e,t,n){let r=e.facet(ir);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var _r=j.define({combine:e=>!e.length||e[0]}),vr=0,yr=j.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),V=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(yr.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(yr.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(vr++,t,r,i,e=>{let t=[];return o&&t.push(Cr.of(t=>{let n=t.plugin(e);return n?o(n):R.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},br=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){gr(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(gr(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){gr(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},xr=j.define(),Sr=j.define(),Cr=j.define(),wr=j.define(),Tr=j.define(),Er=j.define(),Dr=j.define();function Or(e,t){let n=e.state.facet(Dr);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return F.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=er(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var kr=j.define();function Ar(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(kr)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var jr=j.define(),Mr=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},Nr=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=ne.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new Mr(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},Pr=[],H=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return Pr}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&qt(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=dn(this.dom),r=this.length?e>0:t>0;return new Nn(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Lr)return e;return null}static get(e){return e.cmTile}},Fr=class extends H{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=Ir(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=Ir(r);this.length=a}};function Ir(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var Lr=class extends Fr{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=H.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof Rr)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},Rr=class e extends Fr{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},zr=class e extends Fr{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||a.isHidden&&(t>0&&!(a.flags&32)||n&&Vr(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u<c||d.flags&16&&!d.isHidden&&t>=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):Br(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Nn(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new Nn(e.dom,0);e==n.tile&&(a=!0)}}return new Nn(this.dom,0)}};function Br(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=ln(t);return n[n.length-1]||null}function Vr(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var Hr=class e extends Fr{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},Ur=class e extends H{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,n){let r=this.dom.nodeValue.length;e>r&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?L.chrome||L.gecko||(e?(i--,o=1):a<r&&(a++,o=-1)):t<0?i--:a<r&&a++;let s=En(this.dom,i,a).getClientRects();if(!s.length)return null;let c=s[(o?o<0:t>=0)?0:s.length-1];return L.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:hn(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Wr=class e extends H{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return hn(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return hn(n,!r)}}get overrideDOMText(){if(!this.length)return f.empty;let{root:e}=this;if(!e)return f.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},Gr=class extends H{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return f.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:hn(r,t>0==n)}},Kr=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i<t&&e){let a=Math.min(e,t-i);n&&n.skip(r,i,i+a),e-=a,i+=a}if(i==t)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(!e)break}else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},qr=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},Jr=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new Ur(a.dom,a.text+e);t.parent=i}else i.append(r||Ur.of(e,this.cache.find(Ur)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?ii(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof Hr&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(ii(n.dom)),r=i;else{if(this.cache.reused.get(n)){let e=H.get(n.dom);e&&e.setDOM(ii(n.dom))}let e=Hr.of(n.mark,n.dom);r.append(e),r=e}this.cache.reused.set(n,2)}let i=H.get(e.text);i&&this.cache.reused.set(i,2);let a=new Ur(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=ti;let n=zr.start(e,t||this.cache.find(zr)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof Hr&&a.mark.eq(i))n=a,t--;else{let e=Hr.of(i,this.cache.find(Hr,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!$r(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(L.ios&&$r(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(oi,0,32)||new Wr(oi.toDOM(),0,oi,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new qr(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof Rr&&n.wrapper.eq(t.wrapper))e=n;else{let n=Rr.of(t.wrapper,this.cache.find(Rr,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(Gr,void 0,1);return n&&(n.flags=t),n||new Gr(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},Yr=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},Xr=[Wr,zr,Ur,Hr,Gr,Rr,Lr];for(let e=0;e<Xr.length;e++)Xr[e].bucket=e;var Zr=class{constructor(e){this.view=e,this.buckets=Xr.map(()=>[]),this.index=Xr.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=0;e<i.length;e++){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new Wr(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},Qr=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new Zr(e),this.text=new Yr(e.state.doc),this.builder=new Jr(this.cache,new Lr(e,e.contentDOM),F.iter(n)),this.cache.reused.set(t,2),this.old=new Kr(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=ri(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?Wr.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof Gr)this.cache.add(e);else if(e instanceof Hr)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof Hr&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof Hr&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=F.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof en){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?ai.block:ai.inline),c=ei(a),l=this.cache.findWidget(i,t-e,c)||Wr.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=ni(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i<t;){let s=this.text.next(Math.min(512,t-i));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),i++):(r.ensureLine(n),r.addText(s,a,i==e?o:a.length),i+=s.length),n=null}i=a.length}});i>-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=H.get(r);if(r==this.view.contentDOM)break;e instanceof Hr?t.push(e):e?.isLine()?n=e:e instanceof Rr||(r.nodeName==`DIV`&&!n&&r!=this.view.contentDOM?n=new zr(r,ti):n||t.push(Hr.of(new Qt({tagName:r.nodeName.toLowerCase(),attributes:Yt(r)}),r)))}return{line:n,marks:t}}};function $r(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function ei(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var ti={class:`cm-line`};function ni(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r?e:(e||={class:`cm-line`},n&&Wt(n,e),r&&(e.class+=` `+r),e)}function ri(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof Hr&&t.push(r.mark)}return t}function ii(e){let t=H.get(e);return t&&t.setDOM(e.cloneNode()),e}var ai=class extends Xt{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};ai.inline=new ai(`span`),ai.block=new ai(`div`);var oi=new class extends Xt{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},si=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=R.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Lr(e,e.contentDOM),this.updateInner([new Mr(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!vi(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?di(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new Mr(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(L.ie||L.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=mi(i,this.decorations,e.changes);o.length&&(t=Mr.extendWithRanges(t,o));let s=gi(a,this.blockWrappers,e.changes);return s.length&&(t=Mr.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new Qr(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&H.get(t.text)&&r.cache.reused.set(H.get(t.text),2),this.tile=r.run(e,t),ci(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=L.chrome||L.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof yi&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(hr)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet(_r)||n.tabIndex>-1)&&cn(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),L.gecko&&s.empty&&!this.hasComposition&&li(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new Nn(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!un(c.node,c.offset,u.anchorNode,u.anchorOffset)||!un(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{L.android&&L.chrome&&n.contains(u.focusNode)&&_i(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=on(this.view.root);if(e){if(s.empty){if(L.gecko){let e=fi(c.node,c.offset);if(e&&e!=3){let t=(e==1?jn:Mn)(c.node,c.offset);t&&(c=new Nn(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new Nn(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Nn(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&un(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=on(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=mn(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!H.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof yi?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=C(e.text,t);if(n==t)return null;let r=En(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==z.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof Rr)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?ln(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?z.RTL:z.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=ln(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=ln(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(R.replace({widget:new yi(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return R.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Cr).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Tr).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(F.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(wr).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(fr))try{if(t(this.view,e.range,e))return!0}catch(e){gr(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=Ar(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(vn(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==z.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);if(e){let t=xn(e.dom);e.dom.scrollIntoView({block:`nearest`}),Sn(t,!1)}}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){ci(this.tile)}};function ci(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)ci(n,t)}}function li(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function ui(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=jn(n.focusNode,n.focusOffset),i=Mn(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=H.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=H.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function di(e,t,n){let r=ui(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new Mr(c.mapPos(a),c.mapPos(o),a,o),text:i}}function fi(e,t){return e.nodeType==1?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var pi=class{constructor(){this.changes=[]}compareRange(e,t){rn(e,t,this.changes)}comparePoint(e,t){rn(e,t,this.changes)}boundChange(e){rn(e,e,this.changes)}};function mi(e,t,n){let r=new pi;return F.compare(e,t,n,r),r.changes}var hi=class{constructor(){this.changes=[]}compareRange(e,t){rn(e,t,this.changes)}comparePoint(){}boundChange(e){rn(e,e,this.changes)}};function gi(e,t,n){let r=new hi;return F.compare(e,t,n,r),r.changes}function _i(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable==`false`)return!0;return!1}function vi(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var yi=class extends Xt{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function bi(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return A.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=C(i.text,a,!1):s=C(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=C(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=C(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return A.undirectionalRange(o+i.from,s+i.from)}function xi(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+_t(o,a,e.state.tabSize)}function Si(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==Zt.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function Ci(e,t,n,r){let i=Si(e,t.head,t.assoc||-1),a=!r||i.type!=Zt.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==z.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return A.cursor(o,n?-1:1)}return A.cursor(n?i.to:i.from,n?-1:1)}function wi(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=$n(i,a,o,s,n),l=Qn;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`8+`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=e.visualLineSide(i,!n)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function Ti(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==N.Space&&(i=t),i==t}}function Ei(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return A.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=ji(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return A.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return A.cursor(i.pos,i.assoc,void 0,o)}}function Di(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function Oi(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=Di(e,i.from,0);t!=i.from&&(a=A.cursor(t,-1))}else{let t=Di(e,i.from,-1),n=Di(e,i.to,1);(t!=i.from||n!=i.to)&&(a=i.undirectional?A.undirectionalRange(i.from,i.to):A.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?A.create(n,t.mainIndex):t}function ki(e,t,n){let r=Di(e.state.facet(Er).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:A.cursor(r,r<n.from?1:-1)}var Ai=class{constructor(e,t){this.pos=e,this.assoc=t}};function ji(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new Ai(0,1);if(c>e.viewState.docHeight)return new Ai(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==Zt.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==Zt.Text){let t=xi(e,i,l,o,s);return new Ai(t,t==l.from?1:-1)}}if(l.type!=Zt.Text)return c<(l.top+l.bottom)/2?new Ai(l.from,1):new Ai(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new Mi(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var Mi=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[Un.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[Un.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){for(let e=1;e<n;e++){let t=f+e;if(t>=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e<p.length;e++){let t=p[e];if(!(t.width==0&&p.length>1)){if(t.bottom<this.y)(!s||s.bottom<t.bottom)&&(s=t),m=1;else if(t.top>this.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right<this.x?this.x-t.right:0,n=Math.abs(e);n<u&&(l=f,u=n,d=t),e&&(m=e<0==(this.baseDir==z.LTR)?-1:1)}}}m==-1&&(!o||this.baseDirAt(e[f],1))?i=f:m==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}if(!d){if(!c&&!s)return{i:e[0],after:!1};let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==z.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=C(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return En(e.dom,i,a).getClientRects()});return r.after?new Ai(n[r.i+1],-1):new Ai(n[r.i],1)}scanTile(e,t){if(!e.length)return new Ai(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(n.dom.nodeType==1?n.dom:En(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new Ai(n[r.i+1],-1):new Ai(a,1)}},Ni=``,Pi=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(P.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ni}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=H.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=H.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:fn(r))||fn(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!Ii(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=H.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(Fi(e,n.node,n.offset)?t:0))}};function Fi(e,t,n){for(;;){if(!t||n<mn(t))return!1;if(t==e)return!0;n=dn(t)+1,t=t.parentNode}}function Ii(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let t=H.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var Li=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},Ri=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=zi(e.docView.tile,t,n,0))){let t=i||a?[]:Wi(e),n=new Pi(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=Gi(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!sn(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!sn(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((L.ios||L.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(A.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=A.create([A.cursor(n,r)])}else this.newSel=A.single(r,n)}}};function zi(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return zi(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Bi(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||L.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,Ni),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:f.of(t.text.slice(a.from-e,u).split(Ni))}:(d=Ui(l,t.text,s-e,c))&&(L.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==``&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:f.of(t.text.slice(d.from,d.toB).split(Ni))})}else r&&(!e.hasFocus&&i.facet(_r)||Ki(r,a))&&(r=null);if(!n&&!r)return!1;if((L.mac||L.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=A.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:f.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:L.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`9+ `&&e.lineWrapping&&(r&&=A.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:f.of([` `])}),n)return Vi(e,n,r,o);if(r&&!Ki(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=Oi(i.facet(Er).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function Vi(e,t,n,r=-1){if(L.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(L.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&Dn(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&Dn(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Dn(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=Hi(e,t,n);return e.state.facet(or).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function Hi(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=Di(i.facet(Er).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:A.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&ui(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?A.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function Ui(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function Wi(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new Li(n,r)),(i!=n||a!=r)&&t.push(new Li(i,a))),t}function Gi(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?A.single(n+t,r+t):null}function Ki(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var qi=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,L.safari&&e.contentDOM.addEventListener(`input`,()=>null),L.gecko&&Aa(e.contentDOM.ownerDocument)}handleEvent(e){!sa(this.view,e)||this.ignoreDuringComposition(e)||e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e)))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Xi(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&$i.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),L.android&&L.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(L.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Zi.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||Qi.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return t.shiftKey&&L.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&Ji(this.view.win)&&(t.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,Dn(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:L.safari&&!L.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function Ji(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function Yi(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){gr(n.state,e)}}}function Xi(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(Yi(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(Yi(t.value,r))}}for(let e in ca)n(e).handlers.push(ca[e]);for(let e in la)n(e).observers.push(la[e]);return t}var Zi=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],Qi=`dthko`,$i=[16,17,18,20,91,92,224,225],ea=6;function ta(e){return Math.max(0,e)*.7+8}function na(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var ra=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=yn(e.contentDOM),this.atoms=e.state.facet(Er).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(P.allowMultipleSelections)&&ia(e,t),this.dragging=oa(e,t)&&ya(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&na(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=Ar(this.view);e.clientX-s.left<=r+ea?t=-ta(r-e.clientX):e.clientX+s.right>=a-ea&&(t=ta(e.clientX-a)),e.clientY-s.top<=i+ea?n=-ta(i-e.clientY):e.clientY+s.bottom>=o-ea&&(n=ta(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=Oi(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function ia(e,t){let n=e.state.facet(tr);return n.length?n[0](t):L.mac?t.metaKey:t.ctrlKey}function aa(e,t){let n=e.state.facet(nr);return n.length?n[0](t):L.mac?!t.altKey:!t.ctrlKey}function oa(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=on(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function sa(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=H.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var ca=Object.create(null),la=Object.create(null),ua=L.ie&&L.ie_version<15||L.ios&&L.webkit_version<604;function da(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),pa(e,n.value)},50)}function fa(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function pa(e,t){t=fa(e.state,cr,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(Ta!=null&&n.selection.ranges.every(e=>e.empty)&&Ta==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:A.cursor(r.from+c.length)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:A.cursor(e.from+t.length)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}la.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,L.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},la.wheel=la.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},ca.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),la.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},la.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},la.touchend=(e,t)=>{e.inputState.touchActive=!1},ca.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(rr))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=ba(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new ra(e,t,n,r)),r&&e.observer.ignore(()=>{wn(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function ma(e,t,n,r){if(r==1)return A.cursor(t,n);if(r==2)return bi(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,A.undirectionalRange(a,o)}}var ha=L.ie&&L.ie_version<=11,ga=null,_a=0,va=0;function ya(e){if(!ha)return e.detail;let t=ga,n=va;return ga=e,va=Date.now(),_a=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(_a+1)%3:1}function ba(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=ya(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=ma(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=ma(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?A.range(i,a,l.assoc):A.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=xa(i,s.pos))?c:o?i.addRange(l):A.create([l])}}}function xa(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return A.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}ca.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=A.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,fa(e.state,lr,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},ca.dragend=e=>(e.inputState.draggedContent=null,!1);function Sa(e,t,n,r){if(n=fa(e.state,cr,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&aa(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}ca.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Sa(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return Sa(e,t,n,!0),!0}return!1},ca.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=ua?null:t.clipboardData;return n?(pa(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(da(e),!1)};function Ca(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function wa(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:fa(e,lr,t.join(e.lineBreak)),ranges:n,linewise:r}}var Ta=null;ca.copy=ca.cut=(e,t)=>{if(!cn(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=wa(e.state);if(!n&&!i)return!1;Ta=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=ua?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Ca(e,n),!1)};var Ea=Ie.define();function Da(e,t){let n=[];for(let r of e.facet(sr)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Ea.of(!0)}):null}function Oa(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Da(e.state,t);n?e.dispatch(n):e.update([])}},10)}la.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Oa(e)},la.blur=e=>{e.observer.clearSelectionRange(),Oa(e)},la.compositionstart=la.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},la.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,L.chrome&&L.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},la.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},ca.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return Vi(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(L.chrome&&L.android&&(n=Zi.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return L.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),L.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>la.compositionend(e,t),20),!1};var ka=new Set;function Aa(e){ka.has(e)||(ka.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var ja=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],Ma=!1;function Na(){Ma=!1}var Pa=class{constructor(e){this.lineWrapping=e,this.doc=f.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return ja.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=ja.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},Fa=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Ia=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?Zt.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof en?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},U=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(U||={}),La=.001,Ra=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>La&&(Ma=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,U.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,U.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,U.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=qa.build(n.setDoc(a),e,l,u);i=za(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new Ha(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r){if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=0;return t[n-1]==null?(o=1,n--):t[n]??(o=1,r++),new Wa(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function za(e,t){return e==t?e:(e.constructor!=t.constructor&&(Ma=!0),t)}Ra.prototype.size=1;var Ba=R.replace({}),Va=class extends Ra{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Ia(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Ia(r,0,n,this.spaceAbove,Ba):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,U.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Ha=class e extends Va{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new Ia(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof Ua&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Ua?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):Ra.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},Ua=class e extends Ra{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new Ia(a.from,a.length,l,c,0)}{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new Ia(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==U.ByHeight)return this.blockAt(e,n,r,i);if(t==U.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new Ia(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new Ia(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new Ia(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return Ra.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=La&&(s=-2);let c=new Ha(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=Ra.of(r);return(s<0||Math.abs(c.height-this.height)>=La||Math.abs(s-this.heightMetrics(t,n).perLine)>=La)&&(Ma=!0),za(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},Wa=class extends Ra{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==U.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==U.ByPosNoHeight?U.ByPosNoHeight:U.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,U.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,c.from-1,n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(c.to+1,t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&Ga(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),Ga(i,e)}return Ra.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?Ra.of(this.break?[e,null,t]:[e,t]):(this.left=za(this.left,e),this.right=za(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function Ga(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof Ua&&(r=e[t+1])instanceof Ua&&e.splice(t-1,3,new Ua(n.length+1+r.length))}var Ka=5,qa=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof Ha?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new Ha(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new Va(a,r,n)):(a||i||r>=Ka)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new Ha(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new Ua(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ha)return e;let t=new Ha(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ha)&&!this.isCovered?this.nodes.push(new Ha(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof Ha&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return F.spans(n,r,i,a,0),a.finish(r)}};function Ja(e,t,n){let r=new Ya;return F.compare(e,t,n,r,0),r.changes}var Ya=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&rn(e,t,this.changes,5)}};function Xa(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(t.nodeType==1){let n=t,r=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&r.overflow!=`visible`){let r=n.getBoundingClientRect();a=Math.max(a,r.left),o=Math.min(o,r.right),s=Math.max(s,r.top),c=Math.min(t==e.parentNode?i.innerHeight:c,r.bottom)}t=r.position==`absolute`||r.position==`fixed`?n.offsetParent:n.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function Za(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function Qa(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var $a=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return R.replace({widget:new eo(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},eo=class extends Xt{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},to=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=so,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=z.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(Sr).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new Pa(n),this.stateDeco=co(t),this.heightMap=Ra.empty().applyChanges(this.stateDeco,f.empty,this.heightOracle.setDoc(t.doc),[new Mr(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=R.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new no(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?so:new lo(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(uo(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=co(this.state);let r=e.changedRanges,i=Mr.extendWithRanges(r,Ja(n,this.stateDeco,e?e.changes:ne.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Na(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||Ma)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(dr)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?z.RTL:z.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=_n(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let p=yn(this.view.contentDOM,!1).y;p!=this.scrollParent&&(this.scrollParent=p,this.scrollAnchorHeight=-1,this.scrollOffset=0);let m=this.getScrollOffset();this.scrollOffset!=m&&(this.scrollAnchorHeight=-1,this.scrollOffset=m),this.scrolledToBottom=An(this.scrollParent||e.win);let h=(this.printing?Qa:Xa)(t,this.paddingTop),g=h.top-this.pixelViewport.top,_=h.bottom-this.pixelViewport.bottom;this.pixelViewport=h;let v=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(v!=this.inView&&(this.inView=v,v&&(s=!0)),!this.inView&&!this.scrollTarget&&!Za(e.dom))return 0;let y=o.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(y-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,y/o),t),a&&(e.docView.minWidth=0,c|=16)}g>0&&_>0?l=Math.max(g,_):g<0&&_<0&&(l=Math.min(g,_)),Na();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?Ra.empty().applyChanges(this.stateDeco,f.empty,this.heightOracle,[new Mr(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new Fa(n.from,i))}Ma&&(c|=2)}let b=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new no(r.lineAt(a-n*1e3,U.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,U.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,U.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new no(r.lineAt(o-500,U.ByHeight,i,0,0).from,r.lineAt(o+n+500,U.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new no(this.heightMap.lineAt(n,U.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,U.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,U.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new $a(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=z.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=oo(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(A.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new $a(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=Zt.Text)return;let i=ro(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=ao(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=io(i,n),l=io(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=ao(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=io(i,f),l=io(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=ao(r,n)-ao(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){$a.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=R.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];F.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||uo(this.heightMap.lineAt(e,U.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||uo(this.heightMap.lineAt(this.scaler.fromDOM(e),U.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return uo(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},no=class{constructor(e,t){this.from=e,this.to=t}};function ro(e,t,n){let r=[],i=e,a=0;return F.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function io({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function ao(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function oo(e,t){for(let n of e)if(t(n))return n}var so={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function co(e){let t=e.facet(Cr).filter(e=>typeof e!=`function`),n=e.facet(Tr).filter(e=>typeof e!=`function`);return n.length&&t.push(F.join(n)),t}var lo=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,U.ByPos,e,0,0).top,o=t.lineAt(i,U.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function uo(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Ia(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>uo(e,t)):e._content)}var fo=j.define({combine:e=>e.join(` `)}),po=j.define({combine:e=>e.indexOf(!0)>-1}),mo=St.newName(),ho=St.newName(),go=St.newName(),_o={"&light":`.`+ho,"&dark":`.`+go};function vo(e,t,n){return new St(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var yo=vo(`.`+mo,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{userSelect:`none`,position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},".cm-panels-top":{top:`0`},".cm-panels-bottom":{bottom:`0`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`text-top`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{backgroundImage:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)`,backgroundPosition:`center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},_o),bo={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},xo=L.ie&&L.ie_version<=11,So=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new bn,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(L.ie&&L.ie_version<=11||L.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&L.android&&e.constructor.EDIT_CONTEXT!==!1&&!(L.chrome&&L.chrome_version<126)&&(this.editContext=new Eo(e),e.state.facet(_r)&&(e.contentDOM.editContext=this.editContext.editContext)),xo&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type==`change`||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(_r)?n.root.activeElement!=this.dom:!cn(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(L.ie&&L.ie_version<=11||L.android&&L.chrome)&&!n.state.selection.main.empty&&r.focusNode&&un(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=on(e.root);if(!t)return!1;let n=L.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&To(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=cn(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&kn(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,bo),xo&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),xo&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Dn(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&cn(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new Ri(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Bi(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!Ki(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=Co(t,e.previousSibling||e.target.previousSibling,-1),r=Co(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return e.type==`characterData`?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(_r)!=e.state.facet(_r)&&(e.view.contentDOM.editContext=e.state.facet(_r)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function Co(e,t,n){for(;t;){let r=H.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function wo(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return un(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function To(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return wo(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?wo(e,n):null}var Eo=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=Ui(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=A.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));Ki(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:f.of(n.text.slice(l.from,l.toB).split(`10+`))};if((L.mac||L.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:f.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);Vi(e,u,A.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(R.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:hr.of(R.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=on(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},W=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||On(e.parent)||document,this.viewState=new to(this,e.state||P.create(e)),e.scrollTo&&e.scrollTo.is(mr)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(yr).map(e=>new br(e));for(let e of this.plugins)e.update(this);this.observer=new So(this),this.inputState=new qi(this),this.inputState.ensureHandlers(this.plugins),this.docView=new si(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof ze?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(Ea))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=Da(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(P.phrases)!=this.state.facet(P.phrases))return this.setState(a);i=Nr.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new pr(t.empty?t:A.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(mr)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=ko.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(jr)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(fo)!=i.state.facet(fo)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(ar))try{e(i)}catch(e){gr(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!Bi(this,u)&&l.force&&Dn(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new to(this,e),this.plugins=e.facet(yr).map(e=>new br(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new si(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(yr),n=e.state.facet(yr);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new br(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){gr(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(An(n||this.win))i=-1,a=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}}this.updateState=1;let o=this.viewState.measure();if(!o&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let s=[];o&4||([this.measureRequests,s]=[s,this.measureRequests]);let c=s.map(e=>{try{return e.read(this)}catch(e){return gr(this.state,e),Oo}}),l=Nr.create(this,this.state,[]),u=!1;l.flags|=o,t?t.flags|=o:t=l,this.updateState=2,l.empty||(this.updatePlugins(l),this.inputState.update(l),this.updateAttrs(),u=this.docView.update(l),u&&this.docViewUpdate());for(let e=0;e<s.length;e++)if(c[e]!=Oo)try{let t=s[e];t.write&&t.write(c[e],this)}catch(e){gr(this.state,e)}if(u&&this.docView.updateSelection(!0),!l.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}{let e=((i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)-a)/this.scaleY;if((e>1||e<-1)&&!(L.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ar))e(t)}get themeClasses(){return mo+` `+(this.state.facet(po)?go:ho)+` `+this.state.facet(fo)}updateAttrs(){let e=Ao(this,xr,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(_r)?`true`:`false`,class:`cm-content`,style:`${L.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),Ao(this,Sr,t);let n=this.observer.ignore(()=>{let n=Jt(this.contentDOM,this.contentAttrs,t),r=Jt(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&(this.announceDOM.textContent=``),n=!1;let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(jr);let t=this.state.facet(e.cspNonce);St.mount(this.root,this.styleModules.concat(yo).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return ki(this,e,wi(this,e,t,n))}moveByGroup(e,t){return ki(this,e,wi(this,e,t,t=>Ti(this,e.head,t)))}visualLineSide(e,t){let n=this.bidiSpans(e),r=this.textDirectionAt(e.from),i=n[t?n.length-1:0];return A.cursor(i.side(t,r)+e.from,i.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,n=!0){return Ci(this,e,t,n)}moveVertically(e,t,n){return ki(this,e,Ei(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=ji(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),ji(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[Un.find(r,e-n.from,-1,t)];return this.docView.coordsAt(e,t,i.dir==z.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(ur)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Do)return Zn(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||Wn(r.isolates,n=Or(this,e))))return r.order;n||=Or(this,e);let r=Xn(e.text,t,n);return this.bidiCache.push(new ko(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||L.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{wn(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return mr.of(new pr(typeof e==`number`?A.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return mr.of(new pr(A.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return V.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return V.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=St.newName(),r=[fo.of(n),jr.of(vo(`.${n}`,e))];return t&&t.dark&&r.push(po.of(!0)),r}static baseTheme(e){return xe.lowest(jr.of(vo(`.`+mo,e,_o)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&H.get(t)||H.get(e))?.root?.view||null}};W.styleModule=jr,W.inputHandler=or,W.clipboardInputFilter=cr,W.clipboardOutputFilter=lr,W.scrollHandler=fr,W.focusChangeEffect=sr,W.perLineTextDirection=ur,W.exceptionSink=ir,W.updateListener=ar,W.editable=_r,W.mouseSelectionStyle=rr,W.dragMovesSelection=nr,W.clickAddsSelectionRange=tr,W.decorations=Cr,W.blockWrappers=wr,W.outerDecorations=Tr,W.atomicRanges=Er,W.bidiIsolatedRanges=Dr,W.cursorScrollMargin=j.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),W.scrollMargins=kr,W.darkTheme=po,W.cspNonce=j.define({combine:e=>e.length?e[0]:``}),W.contentAttributes=Sr,W.editorAttributes=xr,W.lineWrapping=W.contentAttributes.of({class:`cm-lineWrapping`}),W.announce=M.define();var Do=4096,Oo={},ko=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:z.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function Ao(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&Wt(a,n)}return n}var jo=L.mac?`mac`:L.windows?`win`:L.linux?`linux`:`key`;function Mo(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function No(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var Po=xe.default(W.domEventHandlers({keydown(e,t){return Uo(Lo(t.state),e,t,`editor`)}})),Fo=j.define({enables:Po}),Io=new WeakMap;function Lo(e){let t=e.facet(Fo),n=Io.get(t);return n||Io.set(t,n=Vo(t.reduce((e,t)=>e.concat(t),[]))),n}function Ro(e,t,n){return Uo(Lo(e.state),t,e,n)}var zo=null,Bo=4e3;function Vo(e,t=jo){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>Mo(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=zo={view:t,prefix:n,scope:e};return setTimeout(()=>{zo==r&&(zo=null)},Bo),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,Ho))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var Ho=null;function Uo(e,t,n,r){Ho=t;let i=jt(t),a=O(E(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;zo&&zo.view==n&&zo.scope==r&&(o=zo.prefix+` `,$i.indexOf(t.keyCode)<0&&(c=!0,zo=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+No(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(L.windows&&t.ctrlKey&&t.altKey)&&!(L.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Tt[t.keyCode])&&p!=i?(d(f[o+No(p,t,!0)])||t.shiftKey&&(m=Et[t.keyCode])!=i&&m!=p&&d(f[o+No(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+No(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),Ho=null,s}var Wo=class e{constructor(e,t,n,r,i){this.className=e,this.left=t,this.top=n,this.width=r,this.height=i}draw(){let e=document.createElement(`div`);return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+`px`,e.style.top=this.top+`px`,this.width!=null&&(e.style.width=this.width+`px`),e.style.height=this.height+`px`}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let a=Go(t);return[new e(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}return qo(t,n,r)}};function Go(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==z.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function Ko(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),o=(i.top+i.bottom)/2,s=e.posAtCoords({x:a.left+1,y:o}),c=e.posAtCoords({x:a.right-1,y:o});return s==null||c==null?r:{from:Math.max(r.from,Math.min(s,c)),to:Math.min(r.to,Math.max(s,c))}}function qo(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),a=e.textDirection==z.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),c=Go(e),l=o.querySelector(`.cm-line`),u=l&&window.getComputedStyle(l),d=s.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=s.right-(u?parseInt(u.paddingRight):0),p=Si(e,r,1),m=Si(e,i,-1),h=p.type==Zt.Text?p:null,g=m.type==Zt.Text?m:null;if(h&&(e.lineWrapping||p.widgetLineBreaks)&&(h=Ko(e,r,1,h)),g&&(e.lineWrapping||m.widgetLineBreaks)&&(g=Ko(e,i,-1,g)),h&&g&&h.from==g.from&&h.to==g.to)return v(y(n.from,n.to,h));{let t=h?y(n.from,null,h):b(p,!1),r=g?y(null,n.to,g):b(m,!0),i=[];return(h||p).to<(g||m).from-(h&&g?1:0)||p.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<r.top?i.push(_(d,t.bottom,f,r.top)):t.bottom<r.top&&e.elementAtHeight((t.bottom+r.top)/2).type==Zt.Text&&(t.bottom=r.top=(t.bottom+r.top)/2),v(t).concat(i).concat(v(r))}function _(e,n,r,i){return new Wo(t,e-c.left,n-c.top,Math.max(0,r-e),i-n)}function v({top:e,bottom:t,horizontal:n}){let r=[];for(let i=0;i<n.length;i+=2)r.push(_(n[i],e,n[i+1],t));return r}function y(t,n,r){let i=1e9,o=-1e9,s=[];function c(t,n,c,l,u){let p=e.coordsAtPos(t,t==r.to?-2:2),m=e.coordsAtPos(c,c==r.from?2:-2);!p||!m||(i=Math.min(p.top,m.top,i),o=Math.max(p.bottom,m.bottom,o),u==z.LTR?s.push(a&&n?d:p.left,a&&l?f:m.right):s.push(!a&&l?d:m.left,!a&&n?f:p.right))}let l=t??r.from,u=n??r.to;for(let r of e.visibleRanges)if(r.to>l&&r.from<u)for(let i=Math.max(r.from,l),a=Math.min(r.to,u);;){let r=e.state.doc.lineAt(i);for(let o of e.bidiSpans(r)){let e=o.from+r.from,s=o.to+r.from;if(e>=a)break;s>i&&c(Math.max(e,i),t==null&&e<=l,Math.min(s,a),n==null&&s>=u,o.dir)}if(i=r.to+1,i>=a)break}return s.length==0&&c(l,t==null,u,n==null,e.textDirection),{top:i,bottom:o,horizontal:s}}function b(e,t){let n=s.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}function Jo(e,t){return e.constructor==t.constructor&&e.eq(t)}var Yo=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement(`div`)),this.dom.classList.add(`cm-layer`),t.above&&this.dom.classList.add(`cm-layer-above`),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute(`aria-hidden`,`true`),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(Xo)!=e.state.facet(Xo)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(Xo);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>!Jo(e,this.drawn[t]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,L.webkit&&(this.dom.style.display=this.dom.firstChild?``:`none`)}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},Xo=j.define();function Zo(e){return[V.define(t=>new Yo(t,e)),Xo.of(e)]}var Qo=j.define({combine(e){return Qe(e,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function $o(e={}){return[Qo.of(e),ts,rs,as,dr.of(!0)]}function es(e){return e.startState.facet(Qo)!=e.state.facet(Qo)}var ts=Zo({above:!0,markers(e){let{state:t}=e,n=t.facet(Qo),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor&&!(a&&L.ios&&n.iosSelectionHandles)){let t=a?`cm-cursor cm-cursor-primary`:`cm-cursor cm-cursor-secondary`,n=i.empty?i:A.cursor(i.head,i.assoc);for(let i of Wo.forRange(e,t,n))r.push(i)}}return r},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName=t.style.animationName==`cm-blink`?`cm-blink2`:`cm-blink`);let n=es(e);return n&&ns(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){ns(t.state,e)},class:`cm-cursorLayer`});function ns(e,t){t.style.animationDuration=e.facet(Qo).cursorBlinkRate+`ms`}var rs=Zo({above:!1,markers(e){let t=[],{main:n,ranges:r}=e.state.selection;for(let n of r)if(!n.empty)for(let r of Wo.forRange(e,`cm-selectionBackground`,n))t.push(r);if(L.ios&&!n.empty&&e.state.facet(Qo).iosSelectionHandles){for(let r of Wo.forRange(e,`cm-selectionHandle cm-selectionHandle-start`,A.cursor(n.from,1)))t.push(r);for(let r of Wo.forRange(e,`cm-selectionHandle cm-selectionHandle-end`,A.cursor(n.to,1)))t.push(r)}return t},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||es(e)},class:`cm-selectionLayer`}),is=L.gecko&&L.gecko_version==153?`#ffffff01`:`transparent`,as=xe.highest(W.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${is} !important`},caretColor:`transparent !important`},".cm-content":{caretColor:`transparent !important`,"& :focus":{caretColor:`initial !important`,"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}}})),os=M.define({map(e,t){return e==null?null:t.mapPos(e)}}),ss=ve.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(os)?t.value:e,e)}}),cs=V.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(ss);n==null?this.cursor!=null&&((t=this.cursor)==null||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement(`div`)),this.cursor.className=`cm-dropCursor`),(e.startState.field(ss)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(ss),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+`px`,this.cursor.style.top=e.top/n+`px`,this.cursor.style.height=e.height/n+`px`):this.cursor.style.left=`-100000px`}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(ss)!=e&&this.view.dispatch({effects:os.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function ls(){return[ss,cs]}function us(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),o=n,s;!a.next().done;o+=a.value.length)if(!a.lineBreak)for(;s=t.exec(a.value);)i(o+s.index,s)}function ds(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:a}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),a=Math.min(e.state.doc.lineAt(a).to,a+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=a:r.push({from:i,to:a});return r}var fs=class{constructor(e){let{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:a=1e3}=e;if(!t.global)throw RangeError(`The regular expression given to MatchDecorator should have its 'g' flag set`);if(this.regexp=t,r)this.addMatch=(e,t,n,i)=>r(i,n,n+e[0].length,e,t);else if(typeof n==`function`)this.addMatch=(e,t,r,i)=>{let a=n(e,t,r);a&&i(r,r+e[0].length,a)};else if(n)this.addMatch=(e,t,r,i)=>i(r,r+e[0].length,n);else throw RangeError(`Either 'decorate' or 'decoration' should be provided to MatchDecorator`);this.boundary=i,this.maxLength=a}createDeco(e){let t=new at,n=t.add.bind(t);for(let{from:t,to:r}of ds(e,this.maxLength))us(e.state.doc,this.regexp,t,r,(t,r)=>this.addMatch(r,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((t,i,a,o)=>{o>=e.view.viewport.from&&a<=e.view.viewport.to&&(n=Math.min(a,n),r=Math.max(o,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let a=Math.max(i.from,n),o=Math.min(i.to,r);if(o>=a){let n=e.state.doc.lineAt(a),r=n.to<o?e.state.doc.lineAt(o):n,s=Math.max(i.from,n.from),c=Math.min(i.to,r.to);if(this.boundary){for(;a>n.from;a--)if(this.boundary.test(n.text[a-1-n.from])){s=a;break}for(;o<r.to;o++)if(this.boundary.test(r.text[o-r.from])){c=o;break}}let l=[],u,d=(e,t,n)=>l.push(n.range(e,t));if(n==r)for(this.regexp.lastIndex=s-n.from;(u=this.regexp.exec(n.text))&&u.index<c-n.from;)this.addMatch(u,e,u.index+n.from,d);else us(e.state.doc,this.regexp,s,c,(t,n)=>this.addMatch(n,e,t,d));t=t.update({filterFrom:s,filterTo:c,filter:(e,t)=>e<s||t>c,add:l})}}return t}},ps=/x/.unicode==null?`g`:`gu`,ms=RegExp(`[\0-\b11+--\u2028\u2029-]`,ps),hs={0:`null`,7:`bell`,8:`backspace`,10:`newline`,11:`vertical tab`,13:`carriage return`,27:`escape`,8203:`zero width space`,8204:`zero width non-joiner`,8205:`zero width joiner`,8206:`left-to-right mark`,8207:`right-to-left mark`,8232:`line separator`,8237:`left-to-right override`,8238:`right-to-left override`,8294:`left-to-right isolate`,8295:`right-to-left isolate`,8297:`pop directional isolate`,8233:`paragraph separator`,65279:`zero width no-break space`,65532:`object replacement`},gs=null;function _s(){if(gs==null&&typeof document<`u`&&document.body){let e=document.body.style;gs=(e.tabSize??e.MozTabSize)!=null}return gs||!1}var vs=j.define({combine(e){let t=Qe(e,{render:null,specialChars:ms,addSpecialChars:null});return(t.replaceTabs=!_s())&&(t.specialChars=RegExp(` |`+t.specialChars.source,ps)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+`|`+t.addSpecialChars.source,ps)),t}});function ys(e={}){return[vs.of(e),xs()]}var bs=null;function xs(){return bs||=V.fromClass(class{constructor(e){this.view=e,this.decorations=R.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(vs)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new fs({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=E(t[0],0);if(a==9){let e=i.lineAt(r),t=n.state.tabSize,a=gt(e.text,t,r-e.from);return R.replace({widget:new Ts((t-a%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=R.replace({widget:new ws(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(vs);e.startState.facet(vs)==t?this.decorations=this.decorator.updateDeco(e,this.decorations):(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view))}},{decorations:e=>e.decorations})}var Ss=`•`;function Cs(e){return e>=32?Ss:e==10?``:String.fromCharCode(9216+e)}var ws=class extends Xt{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Cs(this.code),n=e.state.phrase(`Control character`)+` `+(hs[this.code]||`0x`+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement(`span`);return i.textContent=t,i.title=n,i.setAttribute(`aria-label`,n),i.className=`cm-specialChar`,i}ignoreEvent(){return!1}},Ts=class extends Xt{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement(`span`);return e.textContent=` `,e.className=`cm-tab`,e.style.width=this.width+`px`,e}ignoreEvent(){return!1}};function Es(){return Os}var Ds=R.line({class:`cm-activeLine`}),Os=V.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(Ds.range(i.from)),t=i.from)}return R.set(n)}},{decorations:e=>e.decorations}),ks=2e3;function As(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>ks||n.off>ks||t.col<0||n.col<0){let o=Math.min(t.off,n.off),s=Math.max(t.off,n.off);for(let t=r;t<=i;t++){let n=e.doc.line(t);n.length<=s&&a.push(A.range(n.from+o,n.to+s))}}else{let o=Math.min(t.col,n.col),s=Math.max(t.col,n.col);for(let t=r;t<=i;t++){let n=e.doc.line(t),r=_t(n.text,o,e.tabSize,!0);if(r<0)a.push(A.cursor(n.to));else{let t=_t(n.text,s,e.tabSize);a.push(A.range(n.from+r,n.from+t))}}}return a}function js(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function Ms(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,a=i>ks?-1:i==r.length?js(e,t.clientX):gt(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Ns(e,t){let n=Ms(e,t),r=e.state.selection;return n?{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(n.line).from),i=e.state.doc.lineAt(t);n={line:i.number,col:n.col,off:Math.min(n.off,i.length)},r=r.map(e.changes)}},get(t,i,a){let o=Ms(e,t);if(!o)return r;let s=As(e.state,n,o);return s.length?a?A.create(s.concat(r.ranges)):A.create(s):r}}:null}function Ps(e){let t=e?.eventFilter||(e=>e.altKey&&e.button==0);return W.mouseSelectionStyle.of((e,n)=>t(n)?Ns(e,n):null)}var Fs={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Is={style:`cursor: crosshair`};function Ls(e={}){let[t,n]=Fs[e.key||`Alt`],r=V.fromClass(class{constructor(e){this.view=e,this.isDown=!1}set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){(e.keyCode==t||!n(e))&&this.set(!1)},mousemove(e){this.set(n(e))}}});return[r,W.contentAttributes.of(e=>e.plugin(r)?.isDown?Is:null)]}var Rs=`-10000px`,zs=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function Bs(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var Vs=j.define({combine:e=>({position:L.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Bs})}),Hs=new WeakMap,Us=V.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(Vs);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new zs(e,qs,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(Vs);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=Rs,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(L.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}let r=this.view.scrollDOM.getBoundingClientRect(),i=Ar(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Vs).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=Rs;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=Hs.get(c)??d.bottom-d.top,g=c.offset||Ks,_=this.view.textDirection==z.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=Rs;continue}Hs.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,Ws(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,Ws(l,v/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=Rs}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Ws(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Gs=W.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),Ks={x:0,y:0},qs=j.define({enables:[Us,Gs]}),Js=j.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),Ys=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new zs(e,Js,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},Xs=qs.compute([Js],e=>{let t=e.facet(Js);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:Ys.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Zs=j.define(),Qs=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener(`mouseleave`,this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener(`mousemove`,this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let n=e.coordsAtPos(r);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==z.RTL?-1:1;i=t.x<n.left?-o:o}this.activateHover(e,r,i)}activateHover(e,t,n,r){let i=this.source(e,t,n),a=t=>{if(t&&!(Array.isArray(t)&&!t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>gr(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(Us),t=e?e.manager.tooltips.findIndex(e=>e.create==Ys.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!ec(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!tc(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},$s=4;function ec(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-$s&&t.clientX<=r+$s&&t.clientY>=i-$s&&t.clientY<=a+$s}function tc(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.right<r||o.top>i||Math.min(o.bottom,s)<i)return!1;let c=e.posAtCoords({x:r,y:i},!1);return c>=t&&c<=n}function nc(e,t={}){let n=M.define(),r=new WeakMap,i=ve.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,k.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(ac)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>Js.from(e)}),a=V.define(a=>new Qs(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,Zs.of(a),Xs]}}function rc(e,t,n,r={}){let i=e.state.facet(Zs).map(t=>e.plugin(t)).filter(e=>!!e);if(r.tooltip&&r.tooltip.active){let e=i.find(e=>e.field==r.tooltip.active);e&&(i=[e])}for(let a of i)a.activateHover(e,t,n,r.until??(()=>!1))}function ic(e,t){let n=e.plugin(Us);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var ac=M.define(),oc=j.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function sc(e,t){let n=e.plugin(cc),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var cc=V.fromClass(class{constructor(e){this.input=e.state.facet(dc),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(oc);this.top=new lc(e,!0,t.topContainer),this.bottom=new lc(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(oc);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new lc(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new lc(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(dc);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),lc=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=uc(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=uc(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function uc(e){let t=e.nextSibling;return e.remove(),t}var dc=j.define({enables:cc});function fc(e,t){let n,r=new Promise(e=>n=e),i=e=>gc(e,t,n);e.state.field(pc,!1)?e.dispatch({effects:mc.of(i)}):e.dispatch({effects:M.appendConfig.of(pc.init(()=>[i]))});let a=hc.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(pc).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}var pc=ve.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(mc)?e=[n.value].concat(e):n.is(hc)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>dc.computeN([e],t=>t.field(e))}),mc=M.define(),hc=M.define();function gc(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=I(`form`),t.input){let e=I(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(I(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(I(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=I(`div`,r,I(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var _c=class extends $e{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};_c.prototype.elementClass=``,_c.prototype.toDOM=void 0,_c.prototype.mapMode=k.TrackBefore,_c.prototype.startSide=_c.prototype.endSide=-1,_c.prototype.point=!0;var vc=j.define(),yc=j.define(),bc={class:``,renderEmptyElements:!1,elementStyle:``,markers:()=>F.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:`before`},xc=j.define();function Sc(e){return[wc(),xc.of({...bc,...e})]}var Cc=j.define({combine:e=>e.some(e=>e)});function wc(e){let t=[Tc];return e&&e.fixed===!1&&t.push(Cc.of(!0)),t}var Tc=V.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement(`div`),this.dom.className=`cm-gutters cm-gutters-before`,this.dom.setAttribute(`aria-hidden`,`true`),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.gutters=e.state.facet(xc).map(t=>new kc(e,t)),this.fixed=!e.state.facet(Cc);for(let e of this.gutters)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position=`sticky`),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement(`div`),this.domAfter.className=`cm-gutters cm-gutters-after`,this.domAfter.setAttribute(`aria-hidden`,`true`),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+`px`,this.domAfter.style.position=this.fixed?`sticky`:``,this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+`px`;this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(Cc)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?`sticky`:``,this.domAfter&&(this.domAfter.style.position=this.fixed?`sticky`:``)),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=F.iter(this.view.state.facet(vc),this.view.viewport.from),r=[],i=this.gutters.map(e=>new Oc(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(e.type)){let t=!0;for(let a of e.type)if(a.type==Zt.Text&&t){Dc(n,r,a.from);for(let e of i)e.line(this.view,a,r);t=!1}else if(a.widget)for(let e of i)e.widget(this.view,a)}else if(e.type==Zt.Text){Dc(n,r,e.from);for(let t of i)t.line(this.view,e,r)}else if(e.widget)for(let t of i)t.widget(this.view,e);for(let e of i)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(xc),n=e.state.facet(xc),r=e.docChanged||e.heightChanged||e.viewportChanged||!F.eq(e.startState.facet(vc),e.state.facet(vc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(r=!0);else{r=!0;let i=[];for(let r of n){let n=t.indexOf(r);n<0?i.push(new kc(this.view,r)):(this.gutters[n].update(e),i.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),i.indexOf(e)<0&&e.destroy();for(let e of i)e.config.side==`after`?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>W.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==z.LTR?{left:r,right:i}:{right:r,left:i}})});function Ec(e){return Array.isArray(e)?e:[e]}function Dc(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var Oc=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=F.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==r.elements.length){let t=new Ac(e,a,i,n);r.elements.push(t),r.dom.appendChild(t.dom)}else r.elements[this.i].update(e,a,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];Dc(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let a=this.gutter;r.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let n of e.state.facet(yc)){let i=n(e,t.widget,t);i&&(r||=[]).push(i)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},kc=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement(`div`),this.dom.className=`cm-gutter`+(this.config.class?` `+this.config.class:``);for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,a;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let e=i.getBoundingClientRect();a=(e.top+e.bottom)/2}else a=r.clientY;let o=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[n](e,o,r)&&r.preventDefault()});this.markers=Ec(t.markers(e)),t.initialSpacer&&(this.spacer=new Ac(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+=`visibility: hidden; pointer-events: none`)}update(e){let t=this.markers;if(this.markers=Ec(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!F.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},Ac=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement(`div`),this.dom.className=`cm-gutterElement`,this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+`px`),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+`px`:``),jc(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n=`cm-gutterElement`,r=this.dom.firstChild;for(let i=0,a=0;;){let o=a,s=i<t.length?t[i++]:null,c=!1;if(s){let e=s.elementClass;e&&(n+=` `+e);for(let e=a;e<this.markers.length;e++)if(this.markers[e].compare(s)){o=e,c=!0;break}}else o=this.markers.length;for(;a<o;){let e=this.markers[a++];if(e.toDOM){e.destroy(r);let t=r.nextSibling;r.remove(),r=t}}if(!s)break;s.toDOM&&(c?r=r.nextSibling:this.dom.insertBefore(s.toDOM(e),r)),c&&a++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function jc(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var Mc=j.define(),Nc=j.define(),Pc=j.define({combine(e){return Qe(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let r=n[e],i=t[e];n[e]=r?(e,t,n)=>r(e,t,n)||i(e,t,n):i}return n}})}}),Fc=class extends _c{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function Ic(e,t){return e.state.facet(Pc).formatNumber(t,e.state)}var Lc=xc.compute([Pc],e=>({class:`cm-lineNumbers`,renderEmptyElements:!1,markers(e){return e.state.facet(Mc)},lineMarker(e,t,n){return n.some(e=>e.toDOM)?null:new Fc(Ic(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let r of e.state.facet(Nc)){let i=r(e,t,n);if(i)return i}return null},lineMarkerChange:e=>e.startState.facet(Pc)!=e.state.facet(Pc),initialSpacer(e){return new Fc(Ic(e,zc(e.state.doc.lines)))},updateSpacer(e,t){let n=Ic(t.view,zc(t.view.state.doc.lines));return n==e.number?e:new Fc(n)},domEventHandlers:e.facet(Pc).domEventHandlers,side:`before`}));function Rc(e={}){return[Pc.of(e),wc(),Lc]}function zc(e){let t=9;for(;t<e;)t=t*10+9;return t}var Bc=new class extends _c{constructor(){super(...arguments),this.elementClass=`cm-activeLineGutter`}},Vc=vc.compute([`selection`],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(Bc.range(i)))}return F.of(t)});function Hc(){return Vc}var Uc=1024,Wc=0,Gc=class{constructor(e,t){this.from=e,this.to=t}},G=class{constructor(e={}){this.id=Wc++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Jc.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};G.closedBy=new G({deserialize:e=>e.split(` `)}),G.openedBy=new G({deserialize:e=>e.split(` `)}),G.group=new G({deserialize:e=>e.split(` `)}),G.isolate=new G({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),G.contextHash=new G({perNode:!0}),G.lookAhead=new G({perNode:!0}),G.mounted=new G({perNode:!0});var Kc=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[G.mounted.id]}},qc=Object.create(null),Jc=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):qc,r=!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(G.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(G.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Jc.none=new Jc(``,Object.create(null),0,8);var Yc=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new Jc(e.name,r,e.id,e.flags):e)}return new e(n)}},Xc=new WeakMap,Zc=new WeakMap,K;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(K||={});var q=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=Kc.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new dl(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new dl(Xc.get(this)||this.topNode);return r.moveTo(e,t),Xc.set(this,r._tree),r}get topNode(){return new rl(this,0,0,null)}resolve(e,t=0){let n=tl(Xc.get(this)||this.topNode,e,t,!1);return Xc.set(this,n),n}resolveInner(e,t=0){let n=tl(Zc.get(this)||this.topNode,e,t,!0);return Zc.set(this,n),n}resolveStack(e,t=0){return ul(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&K.IncludeAnonymous)>0;for(let e=this.cursor(a|K.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:gl(Jc.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Jc.none,t,n,r)))}static build(e){return pl(e)}};q.empty=new q(Jc.none,[],[],0);var Qc=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},$c=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Jc.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(el(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function el(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function tl(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof rl&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:K.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof rl&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var nl=class{cursor(e=0){return new dl(this,e)}getChild(e,t=null,n=null){let r=il(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return il(this,e,t,n)}resolve(e,t=0){return tl(this,e,t,!1)}resolveInner(e,t=0){return tl(this,e,t,!0)}matchContext(e){return al(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},rl=class e extends nl{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(!(!(a&K.EnterBracketed&&l instanceof q&&(d=Kc.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length)&&!el(i,r,u,u+l.length))){if(l instanceof $c){if(a&K.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new sl(new ol(o,l,t,u),null,e)}else if(a&K.IncludeAnonymous||!l.type.isAnonymous||fl(l)){let s;if(!(a&K.IgnoreMounts)&&(s=Kc.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&K.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&K.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&K.IgnoreOverlays)&&(i=Kc.get(this._tree))&&i.overlay){let a=t-this.from,o=r&K.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function il(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function al(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var ol=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},sl=class e extends nl{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&K.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new q(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function cl(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof rl&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new ll(i,n)}var ll=class{constructor(e,t){this.heads=e,this.node=t}get next(){return cl(this.heads)}};function ul(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof rl?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=Kc.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new rl(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(tl(o,t,n,!1))}}return i?cl(i):r}var dl=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~K.EnterBracketed,e instanceof rl)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof rl?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&K.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&K.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&K.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&K.IncludeAnonymous||e instanceof $c||!e.type.isAnonymous||fl(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new sl(this.buffer,t,this.stack[e]);return this.bufferNode=new sl(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return al(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return al(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function fl(e){return e.children.some(e=>e instanceof $c||!e.type.isAnonymous||fl(e))}function pl(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Uc,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new Qc(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,ee,k=S-e;if(C-S<=r&&(ee=h(o.pos-t,y))){let t=new Uint16Array(ee.size-ee.skip),r=o.pos-ee.size,i=t.length;for(;o.pos>r;)i=g(ee.start,t,i);O=new $c(t,C-ee.start,n),k=ee.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=gl(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(k)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new $c(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof q){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(G.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[G.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[G.lookAhead,i];o=o?[e].concat(o):[e]}return new q(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new q(s[e.topID],_.reverse(),v.reverse(),y)}var ml=new WeakMap;function hl(e,t){if(!e.isAnonymous||t instanceof $c||t.type!=e)return 1;let n=ml.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof q)){n=1;break}n+=hl(e,r)}ml.set(t,n)}return n}function gl(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=hl(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=hl(e,t[s]);for(s++;s<i;s++){let n=hl(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(gl(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var _l=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},vl=class{startParse(e,t,n){return typeof e==`string`&&(e=new yl(e)),n=n?n.length?n.map(e=>new Gc(e.from,e.to)):[new Gc(0,0)]:[new Gc(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},yl=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new G({perNode:!0});var bl=0,xl=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=bl++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Cl(e);return e=>e.modified.indexOf(t)>-1?e:Cl.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Sl=0,Cl=class e{constructor(e){this.name=e,this.instances=[],this.id=Sl++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&wl(n,e.modified));if(r)return r;let i=[],a=new xl(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Tl(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function wl(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Tl(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function El(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new Ol(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Dl.add(t)}var Dl=new G({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new Ol(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),Ol=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Ol.empty=new Ol([],2,null);function kl(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Al(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function jl(e,t,n,r=0,i=e.length){let a=new Ml(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Ml=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Nl(e)||Ol.empty,u=Al(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(G.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Nl(e){let t=e.type.prop(Dl);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var J=xl.define,Pl=J(),Fl=J(),Il=J(Fl),Ll=J(Fl),Rl=J(),zl=J(Rl),Bl=J(Rl),Vl=J(),Hl=J(Vl),Ul=J(),Wl=J(),Gl=J(),Kl=J(Gl),ql=J(),Y={comment:Pl,lineComment:J(Pl),blockComment:J(Pl),docComment:J(Pl),name:Fl,variableName:J(Fl),typeName:Il,tagName:J(Il),propertyName:Ll,attributeName:J(Ll),className:J(Fl),labelName:J(Fl),namespace:J(Fl),macroName:J(Fl),literal:Rl,string:zl,docString:J(zl),character:J(zl),attributeValue:J(zl),number:Bl,integer:J(Bl),float:J(Bl),bool:J(Rl),regexp:J(Rl),escape:J(Rl),color:J(Rl),url:J(Rl),keyword:Ul,self:J(Ul),null:J(Ul),atom:J(Ul),unit:J(Ul),modifier:J(Ul),operatorKeyword:J(Ul),controlKeyword:J(Ul),definitionKeyword:J(Ul),moduleKeyword:J(Ul),operator:Wl,derefOperator:J(Wl),arithmeticOperator:J(Wl),logicOperator:J(Wl),bitwiseOperator:J(Wl),compareOperator:J(Wl),updateOperator:J(Wl),definitionOperator:J(Wl),typeOperator:J(Wl),controlOperator:J(Wl),punctuation:Gl,separator:J(Gl),bracket:Kl,angleBracket:J(Kl),squareBracket:J(Kl),paren:J(Kl),brace:J(Kl),content:Vl,heading:Hl,heading1:J(Hl),heading2:J(Hl),heading3:J(Hl),heading4:J(Hl),heading5:J(Hl),heading6:J(Hl),contentSeparator:J(Vl),list:J(Vl),quote:J(Vl),emphasis:J(Vl),strong:J(Vl),link:J(Vl),monospace:J(Vl),strikethrough:J(Vl),inserted:J(),deleted:J(),changed:J(),invalid:J(),meta:ql,documentMeta:J(ql),annotation:J(ql),processingInstruction:J(ql),definition:xl.defineModifier(`definition`),constant:xl.defineModifier(`constant`),function:xl.defineModifier(`function`),standard:xl.defineModifier(`standard`),local:xl.defineModifier(`local`),special:xl.defineModifier(`special`)};for(let e in Y){let t=Y[e];t instanceof xl&&(t.name=e)}kl([{tag:Y.link,class:`tok-link`},{tag:Y.heading,class:`tok-heading`},{tag:Y.emphasis,class:`tok-emphasis`},{tag:Y.strong,class:`tok-strong`},{tag:Y.keyword,class:`tok-keyword`},{tag:Y.atom,class:`tok-atom`},{tag:Y.bool,class:`tok-bool`},{tag:Y.url,class:`tok-url`},{tag:Y.labelName,class:`tok-labelName`},{tag:Y.inserted,class:`tok-inserted`},{tag:Y.deleted,class:`tok-deleted`},{tag:Y.literal,class:`tok-literal`},{tag:Y.string,class:`tok-string`},{tag:Y.number,class:`tok-number`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],class:`tok-string2`},{tag:Y.variableName,class:`tok-variableName`},{tag:Y.local(Y.variableName),class:`tok-variableName tok-local`},{tag:Y.definition(Y.variableName),class:`tok-variableName tok-definition`},{tag:Y.special(Y.variableName),class:`tok-variableName2`},{tag:Y.definition(Y.propertyName),class:`tok-propertyName tok-definition`},{tag:Y.typeName,class:`tok-typeName`},{tag:Y.namespace,class:`tok-namespace`},{tag:Y.className,class:`tok-className`},{tag:Y.macroName,class:`tok-macroName`},{tag:Y.propertyName,class:`tok-propertyName`},{tag:Y.operator,class:`tok-operator`},{tag:Y.comment,class:`tok-comment`},{tag:Y.meta,class:`tok-meta`},{tag:Y.invalid,class:`tok-invalid`},{tag:Y.punctuation,class:`tok-punctuation`}]);var Jl=new G;function Yl(e){return j.define({combine:e?t=>t.concat(e):void 0})}var Xl=new G,Zl=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,P.prototype.hasOwnProperty(`tree`)||Object.defineProperty(P.prototype,"tree",{get(){return X(this)}}),this.parser=t,this.extension=[cu.of(this),P.languageData.of((e,t,n)=>{let r=Ql(e,t,n),i=r.type.prop(Jl);if(!i)return[];let a=e.facet(i),o=r.type.prop(Xl);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return Ql(e,t,n).type.prop(Jl)==this.data}findRegions(e){let t=e.facet(cu);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Jl)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(G.mounted);if(i){if(i.tree.prop(Jl)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof q&&r(i,e.positions[n]+t)}};return r(X(e),0),n}get allowsNesting(){return!0}};Zl.setState=M.define();function Ql(e,t,n){let r=e.facet(cu),i=X(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,K.ExcludeBuffers|K.EnterBracketed))e.type.isTop&&(i=e);return i}var $l=class e extends Zl{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=Yl(t.languageData);return new e(n,t.parser.configure({props:[Jl.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function X(e){let t=e.field(Zl.state,!1);return t?t.tree:q.empty}var eu=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},tu=null,nu=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],q.empty,0,r,[],null)}startParse(){return this.parser.startParse(new eu(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=q.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(_l.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(_l.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=tu;tu=this;try{return e()}finally{tu=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=ru(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=_l.applyChanges(r,e),i=q.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=ru(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends vl{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=tu;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new q(Jc.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return tu}};function ru(e,t,n){return _l.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var iu=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=nu.create(t.facet(cu).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};Zl.state=ve.define({create:iu.init,update(e,t){for(let e of t.effects)if(e.is(Zl.setState))return e.value;return t.startState.facet(cu)==t.state.facet(cu)?e.apply(t):iu.init(t.state)}});var au=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(au=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var ou=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,su=V.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Zl.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Zl.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=au(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(Zl.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!ou?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>ou&&ou()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:Zl.setState.of(new iu(i.context))})),this.chunkBudget>0&&!(s&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>gr(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),cu=j.define({combine(e){return e.length?e[0]:null},enables:e=>[Zl.state,su,W.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),lu=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},uu=j.define(),du=j.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function fu(e){let t=e.facet(du);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function pu(e,t){let n=``,r=e.tabSize,i=e.facet(du)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function mu(e,t){e instanceof P&&(e=new hu(e));for(let n of e.state.facet(uu)){let r=n(e,t);if(r!==void 0)return r}let n=X(e.state);return n.length>=t?_u(e,n,t):null}var hu=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=fu(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return gt(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},gu=new G;function _u(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return vu(r,e,n)}function vu(e,t,n){for(let r=e;r;r=r.next){let e=bu(r.node);if(e)return e(Su.create(t,n,r))}return 0}function yu(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function bu(e){let t=e.type.prop(gu);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(G.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>Eu(e,!0,1,void 0,n&&!yu(e)?t.from:void 0)}return e.parent==null?xu:null}function xu(){return 0}var Su=class e extends hu{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(Cu(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return vu(this.context.next,this.base,this.pos)}};function Cu(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function wu(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function Tu({closing:e,align:t=!0,units:n=1}){return r=>Eu(r,t,n,e)}function Eu(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?wu(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function Du({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Ou=200;function ku(){return P.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Ou)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=mu(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=pu(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Au=j.define(),ju=new G;function Mu(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function Nu(e,t,n){let r=X(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(ju);if(s&&(i.to<r.length-50||r.length==e.doc.length||!Pu(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function Pu(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function Fu(e,t,n){for(let r of e.facet(Au)){let i=r(e,t,n);if(i)return i}return Nu(e,t,n)}function Iu(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var Lu=M.define({map:Iu}),Ru=M.define({map:Iu});function zu(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var Bu=ve.define({create(){return R.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Vu(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(Lu)&&!Uu(e,r.value.from,r.value.to)?n.push(r.value):r.is(Ru)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(Xu),i=n.map(e=>(r?R.replace({widget:new ed(r(t.state,e))}):$u).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=Vu(e,t.selection.main.head)),e},provide:e=>W.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push($u.range(r,i))}return R.set(t,!0)}});function Vu(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function Hu(e,t,n){var r;let i=null;return(r=e.field(Bu,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Uu(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function Wu(e,t){return e.field(Bu,!1)?t:t.concat(M.appendConfig.of(Zu()))}var Gu=e=>{for(let t of zu(e)){let n=Fu(e.state,t.from,t.to);if(n)return e.dispatch({effects:Wu(e.state,[Lu.of(n),qu(e,n)])}),!0}return!1},Ku=e=>{if(!e.state.field(Bu,!1))return!1;let t=[];for(let n of zu(e)){let r=Hu(e.state,n.from,n.to);r&&t.push(Ru.of(r),qu(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function qu(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return W.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var Ju=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Gu},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Ku},{key:`Ctrl-Alt-[`,run:e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=Fu(t,i.from,i.to);a&&n.push(Lu.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:Wu(e.state,n)}),!!n.length}},{key:`Ctrl-Alt-]`,run:e=>{let t=e.state.field(Bu,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(Ru.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],Yu={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},Xu=j.define({combine(e){return Qe(e,Yu)}});function Zu(e){let t=[Bu,id];return e&&t.push(Xu.of(e)),t}function Qu(e,t){let{state:n}=e,r=n.facet(Xu),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Hu(e.state,n.from,n.to);r&&e.dispatch({effects:Ru.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var $u=R.replace({widget:new class extends Xt{toDOM(e){return Qu(e,null)}}}),ed=class extends Xt{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Qu(e,this.value)}},td={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},nd=class extends _c{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function rd(e={}){let t={...td,...e},n=new nd(t,!0),r=new nd(t,!1),i=V.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(cu)!=e.state.facet(cu)||e.startState.field(Bu,!1)!=e.state.field(Bu,!1)||X(e.startState)!=X(e.state)||t.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new at;for(let i of e.viewportLineBlocks){let a=Hu(e.state,i.from,i.to)?r:Fu(e.state,i.from,i.to)?n:null;a&&t.add(i.from,i.from,a)}return t.finish()}}),{domEventHandlers:a}=t;return[i,Sc({class:`cm-foldGutter`,markers(e){return e.plugin(i)?.markers||F.empty},initialSpacer(){return new nd(t,!1)},domEventHandlers:{...a,click:(e,t,n)=>{if(a.click&&a.click(e,t,n))return!0;let r=Hu(e.state,t.from,t.to);if(r)return e.dispatch({effects:Ru.of(r)}),!0;let i=Fu(e.state,t.from,t.to);return i?(e.dispatch({effects:Lu.of(i)}),!0):!1}}}),Zu()]}var id=W.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),ad=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=St.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof Zl?e=>e.prop(Jl)==a.data:a?e=>e==a:void 0,this.style=kl(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new St(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},od=j.define(),sd=j.define({combine(e){return e.length?[e[0]]:null}});function cd(e){let t=e.facet(od);return t.length?t:e.facet(sd)}function ld(e,t){let n=[dd],r;return e instanceof ad&&(e.module&&n.push(W.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(sd.of(e)):r?n.push(od.computeN([W.darkTheme],t=>t.facet(W.darkTheme)==(r==`dark`)?[e]:[])):n.push(od.of(e)),n}var ud=class{constructor(e){this.markCache=Object.create(null),this.tree=X(e.state),this.decorations=this.buildDeco(e,cd(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=X(e.state),n=cd(e.state),r=n!=cd(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return R.none;let n=new at;for(let{from:r,to:i}of e.visibleRanges)jl(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=R.mark({class:r})))},r,i);return n.finish()}},dd=xe.high(V.fromClass(ud,{decorations:e=>e.decorations})),fd=ad.define([{tag:Y.meta,color:`#404740`},{tag:Y.link,textDecoration:`underline`},{tag:Y.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Y.emphasis,fontStyle:`italic`},{tag:Y.strong,fontWeight:`bold`},{tag:Y.strikethrough,textDecoration:`line-through`},{tag:Y.keyword,color:`#708`},{tag:[Y.atom,Y.bool,Y.url,Y.contentSeparator,Y.labelName],color:`#219`},{tag:[Y.literal,Y.inserted],color:`#164`},{tag:[Y.string,Y.deleted],color:`#a11`},{tag:[Y.regexp,Y.escape,Y.special(Y.string)],color:`#e40`},{tag:Y.definition(Y.variableName),color:`#00f`},{tag:Y.local(Y.variableName),color:`#30a`},{tag:[Y.typeName,Y.namespace],color:`#085`},{tag:Y.className,color:`#167`},{tag:[Y.special(Y.variableName),Y.macroName],color:`#256`},{tag:Y.definition(Y.propertyName),color:`#00c`},{tag:Y.comment,color:`#940`},{tag:Y.invalid,color:`#f00`}]),pd=W.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),md=1e4,hd=`()[]{}`,gd=j.define({combine(e){return Qe(e,{afterCursor:!0,brackets:hd,maxScanDistance:md,renderMatch:yd})}}),_d=R.mark({class:`cm-matchingBracket`}),vd=R.mark({class:`cm-nonmatchingBracket`});function yd(e){let t=[],n=e.matched?_d:vd;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function bd(e){let t=[],n=e.facet(gd);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Ed(e,r.head,-1,n)||r.head>0&&Ed(e,r.head-1,1,n)||n.afterCursor&&(Ed(e,r.head,1,n)||r.head<e.doc.length&&Ed(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return R.set(t,!0)}var xd=[V.fromClass(class{constructor(e){this.paused=!1,this.decorations=bd(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=bd(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),pd];function Sd(e={}){return[gd.of(e),xd]}var Cd=new G;function wd(e,t,n){let r=e.prop(t<0?G.openedBy:G.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function Td(e){let t=e.type.prop(Cd);return t?t(e.node):e}function Ed(e,t,n,r={}){let i=r.maxScanDistance||md,a=r.brackets||hd,o=X(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=wd(r.type,n,a);if(i&&r.from<r.to){let o=Td(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return Dd(e,t,n,r,o,i,a)}}return Od(e,t,n,o,s.type,i,a)}function Dd(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=Td(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(wd(u.type,n,o))l++;else if(wd(u.type,-n,o)){if(l==0){let e=Td(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Od(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function kd(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var Ad=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=kd(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??kd(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function jd(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Md,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Bd,mergeTokens:e.mergeTokens!==!1}}function Md(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var Nd=new WeakMap,Pd=class e extends Zl{constructor(e){let t=Yl(e.languageData),n=jd(e),r,i=new class extends vl{createParse(e,t,n){return new Rd(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Xd(t,this),r=this,this.streamParser=n,this.stateAfter=new G({perNode:!0}),this.tokenTable=e.tokenTable?new Kd(n.tokenTable):qd}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=Nd.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Fd(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new Ad(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)zd(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&Nd.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Fd(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof q&&s<i&&Fd(e,o,s,r,i);if(c)return c}return null}function Id(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof q){if(!(c=Id(e,s,n-o,r-o,i)))break;return i?new q(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Ld(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&Fd(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Id(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?fu(i):4),tree:q.empty}}var Rd=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=nu.get(),a=r[0].from,{state:o,tree:s}=Ld(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(fu(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=nu.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`12+`&&(t=``);else{let e=t.indexOf(`13+`);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new Ad(t,e?e.state.tabSize:4,e?fu(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=zd(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=q.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Hd,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new q(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new q(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function zd(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var Bd=Object.create(null),Vd=[Jc.none],Hd=new Yc(Vd),Ud=[],Wd=Object.create(null),Gd=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Gd[e]=Yd(Bd,t);var Kd=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Gd)}resolve(e){return e?this.table[e]||(this.table[e]=Yd(this.extra,e)):0}},qd=new Kd(Bd);function Jd(e,t){Ud.indexOf(e)>-1||(Ud.push(e),console.warn(t))}function Yd(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Y[n];r?typeof r==`function`?t.length?t=t.map(r):Jd(n,`Modifier ${n} used at start of tag`):t.length?Jd(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Jd(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=Wd[i];if(a)return a.id;let o=Wd[i]=Jc.define({id:Vd.length,name:r,props:[El({[r]:n})]});return Vd.push(o),o.id}function Xd(e,t){let n=Jc.define({id:Vd.length,name:`Document`,props:[Jl.add(()=>e),gu.add(()=>e=>t.getIndent(e))],top:!0});return Vd.push(n),n}z.RTL,z.LTR;var Zd=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=nf(e.state,n.from);return r.line?$d(e):r.block?tf(e):!1};function Qd(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var $d=Qd(cf,0),ef=Qd(sf,0),tf=Qd((e,t)=>sf(e,t,of(t)),0);function nf(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var rf=50;function af(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-rf,r),o=e.sliceDoc(i,i+rf),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+rf),d=e.sliceDoc(i-rf,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function of(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function sf(e,t,n=t.selection.ranges){let r=n.map(e=>nf(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>af(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function cf(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=nf(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var lf=Ie.define(),uf=Ie.define(),df=j.define(),ff=j.define({combine(e){return Qe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),pf=ve.define({create(){return Mf.empty},update(e,t){let n=t.state.facet(ff),r=t.annotation(lf);if(r){let i=bf.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?xf(o,o.length,n.minDepth,i):Df(o,t.startState.selection),new Mf(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(uf);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(ze.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=bf.fromTransaction(t),o=t.annotation(ze.time),s=t.annotation(ze.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new Mf(e.done.map(bf.fromJSON),e.undone.map(bf.fromJSON))}});function mf(e={}){return[pf,ff.of(e),W.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?gf:e.inputType==`historyRedo`?_f:null;return n?(e.preventDefault(),n(t)):!1}})]}function hf(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(pf,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var gf=hf(0,!1),_f=hf(1,!1),vf=hf(0,!0),yf=hf(1,!0),bf=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&ne.fromJSON(t.changes),[],t.mapped&&te.fromJSON(t.mapped),t.startSelection&&A.fromJSON(t.startSelection),t.selectionsAfter.map(A.fromJSON))}static fromTransaction(t,n){let r=Tf;for(let e of t.startState.facet(df)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Tf)}static selection(t){return new e(void 0,Tf,void 0,void 0,t)}};function xf(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function Sf(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Cf(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function wf(e,t){return e.length?t.length?e.concat(t):e:t}var Tf=[],Ef=200;function Df(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Ef));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),xf(e,e.length-1,1e9,n.setSelAfter(r)))}return[bf.selection([t])]}function Of(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function kf(e,t){if(!e.length)return e;let n=e.length,r=Tf;for(;n;){let i=Af(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[bf.selection(r)]:Tf}function Af(e,t,n){let r=wf(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Tf,n);if(!e.changes)return bf.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new bf(i,M.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var jf=/^(input\.type|delete)($|\.)/,Mf=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||jf.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,Sf(s.changes,t.changes))||r==`input.type.compose`)?xf(o,o.length-1,i.minDepth,new bf(t.changes.compose(s.changes),wf(M.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,Tf)):xf(o,o.length,i.minDepth,t),new e(o,Tf,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:Tf;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Cf(a[a.length-1],t)?this:new e(Df(this.done,t),this.undone,n,r)}addMapping(t){return new e(kf(this.done,t),kf(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:lf.of({side:e,rest:Of(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?Tf:r.slice(0,r.length-1);return i.mapped&&(n=kf(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:lf.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};Mf.empty=new Mf(Tf,Tf);var Nf=[{key:`Mod-z`,run:gf,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:_f,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:_f,preventDefault:!0},{key:`Mod-u`,run:vf,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:yf,preventDefault:!0}];function Pf(e,t){return A.create(e.ranges.map(t),e.mainIndex)}function Ff(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function If({state:e,dispatch:t},n){let r=Pf(e.selection,n);return!r.eq(e.selection,!0)&&(t(Ff(e,r)),!0)}function Lf(e,t){return A.cursor(t?e.to:e.from)}function Rf(e,t){return If(e,n=>n.empty?e.moveByChar(n,t):Lf(n,t))}function zf(e){return e.textDirectionAt(e.state.selection.main.head)==z.LTR}var Bf=e=>Rf(e,!zf(e)),Vf=e=>Rf(e,zf(e));function Hf(e,t){return If(e,n=>n.empty?e.moveByGroup(n,t):Lf(n,t))}var Uf=e=>Hf(e,!zf(e)),Wf=e=>Hf(e,zf(e));typeof Intl<`u`&&Intl.Segmenter;function Gf(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Kf(e,t,n){let r=X(e).resolveInner(t.head),i=n?G.closedBy:G.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Gf(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?Ed(e,r.from,1):Ed(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,A.cursor(s,n?-1:1)}var qf=e=>If(e,t=>Kf(e.state,t,!zf(e))),Jf=e=>If(e,t=>Kf(e.state,t,zf(e)));function Yf(e,t){return If(e,n=>{if(!n.empty)return Lf(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var Xf=e=>Yf(e,!1),Zf=e=>Yf(e,!0);function Qf(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(W.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function $f(e,t){let n=Qf(e),{state:r}=e,i=Pf(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):Lf(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=W.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(Ff(r,i),{effects:a}),!0}var ep=e=>$f(e,!1),tp=e=>$f(e,!0);function np(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=A.cursor(r.from+n))}return i}var rp=e=>If(e,t=>np(e,t,!0)),ip=e=>If(e,t=>np(e,t,!1)),ap=e=>If(e,t=>np(e,t,!zf(e))),op=e=>If(e,t=>np(e,t,zf(e))),sp=e=>If(e,t=>A.cursor(e.lineBlockAt(t.head).from,1)),cp=e=>If(e,t=>A.cursor(e.lineBlockAt(t.head).to,-1));function lp(e,t,n){let r=!1,i=Pf(e.selection,t=>{let i=Ed(e,t.head,-1)||Ed(e,t.head,1)||t.head>0&&Ed(e,t.head-1,1)||t.head<e.doc.length&&Ed(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?A.range(t.anchor,a):A.cursor(a)});return r?(t(Ff(e,i)),!0):!1}var up=({state:e,dispatch:t})=>lp(e,t,!1);function dp(e,t,n){let r=Pf(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=A.range(e.head,e.anchor));let r=n(e);return A.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Ff(e.state,r)),!0)}function fp(e,t){return dp(e,t,n=>e.moveByChar(n,t))}var pp=e=>fp(e,!zf(e)),mp=e=>fp(e,zf(e));function hp(e,t){return dp(e,t,n=>e.moveByGroup(n,t))}var gp=e=>hp(e,!zf(e)),_p=e=>hp(e,zf(e)),vp=e=>{let t=!zf(e);return dp(e,t,n=>Kf(e.state,n,t))},yp=e=>{let t=zf(e);return dp(e,t,n=>Kf(e.state,n,t))};function bp(e,t){return dp(e,t,n=>e.moveVertically(n,t))}var xp=e=>bp(e,!1),Sp=e=>bp(e,!0);function Cp(e,t){return dp(e,t,n=>e.moveVertically(n,t,Qf(e).height))}var wp=e=>Cp(e,!1),Tp=e=>Cp(e,!0),Ep=e=>dp(e,!0,t=>np(e,t,!0)),Dp=e=>dp(e,!1,t=>np(e,t,!1)),Op=e=>{let t=!zf(e);return dp(e,t,n=>np(e,n,t))},kp=e=>{let t=zf(e);return dp(e,t,n=>np(e,n,t))},Ap=e=>dp(e,!1,t=>A.cursor(e.lineBlockAt(t.head).from)),jp=e=>dp(e,!0,t=>A.cursor(e.lineBlockAt(t.head).to)),Mp=({state:e,dispatch:t})=>(t(Ff(e,{anchor:0})),!0),Np=({state:e,dispatch:t})=>(t(Ff(e,{anchor:e.doc.length})),!0),Pp=({state:e,dispatch:t})=>(t(Ff(e,{anchor:e.selection.main.anchor,head:0})),!0),Fp=({state:e,dispatch:t})=>(t(Ff(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Ip=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Lp=({state:e,dispatch:t})=>{let n=nm(e).map(({from:t,to:n})=>A.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:A.create(n),userEvent:`select`})),!0},Rp=({state:e,dispatch:t})=>{let n=Pf(e.selection,t=>{let n=X(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return A.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Ff(e,n)),!0)};function zp(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Ff(n,A.create(i,i.length-1))),!0)}var Bp=e=>zp(e,!1),Vp=e=>zp(e,!0),Hp=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=A.create([n.main]):n.main.empty||(r=A.create([A.cursor(n.main.head)])),r?(t(Ff(e,r)),!0):!1};function Up(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=Wp(e,o,!1)):o>i&&(n=`delete.forward`,o=Wp(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=Wp(e,i,!1),a=Wp(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:A.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?W.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function Wp(e,t,n){if(e instanceof W)for(let r of e.state.facet(W.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var Gp=(e,t,n)=>Up(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=gt(s,a.tabSize)%fu(a)||fu(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=C(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=C(o.text,c-o.from,!1,!1)+o.from);return c}),Kp=e=>Gp(e,!1,!0),qp=e=>Gp(e,!0,!1),Jp=(e,t)=>Up(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=C(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Yp=e=>Jp(e,!1),Xp=e=>Jp(e,!0),Zp=e=>Up(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),Qp=e=>Up(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),$p=e=>Up(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),em=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:f.of([``,``])},range:A.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},tm=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:C(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:C(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:A.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function nm(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function rm(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of nm(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(A.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(A.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:A.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var im=({state:e,dispatch:t})=>rm(e,t,!1),am=({state:e,dispatch:t})=>rm(e,t,!0);function om(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of nm(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var sm=({state:e,dispatch:t})=>om(e,t,!1),cm=({state:e,dispatch:t})=>om(e,t,!0),lm=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(nm(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=Pf(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function um(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=X(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(G.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var dm=pm(!1),fm=pm(!0);function pm(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&um(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new hu(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=mu(s,r);for(c??=gt(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,pu(t,c)];return o&&l.push(pu(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:f.of(l)},range:A.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function mm(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:A.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var hm=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new hu(e,{overrideIndentation:e=>n[e]??-1}),i=mm(e,(t,i,a)=>{let o=mu(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=pu(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},gm=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(mm(e,(t,n)=>{n.push({from:t.from,insert:e.facet(du)})}),{userEvent:`input.indent`})),!0),_m=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(mm(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=gt(r,e.tabSize),a=0,o=pu(e,Math.max(0,i-fu(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),vm=e=>(e.setTabFocusMode(),!0),ym=[{key:`Ctrl-b`,run:Bf,shift:pp,preventDefault:!0},{key:`Ctrl-f`,run:Vf,shift:mp},{key:`Ctrl-p`,run:Xf,shift:xp},{key:`Ctrl-n`,run:Zf,shift:Sp},{key:`Ctrl-a`,run:sp,shift:Ap},{key:`Ctrl-e`,run:cp,shift:jp},{key:`Ctrl-d`,run:qp},{key:`Ctrl-h`,run:Kp},{key:`Ctrl-k`,run:Zp},{key:`Ctrl-Alt-h`,run:Yp},{key:`Ctrl-o`,run:em},{key:`Ctrl-t`,run:tm},{key:`Ctrl-v`,run:tp}],bm=[{key:`ArrowLeft`,run:Bf,shift:pp,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Uf,shift:gp,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:ap,shift:Op,preventDefault:!0},{key:`ArrowRight`,run:Vf,shift:mp,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Wf,shift:_p,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:op,shift:kp,preventDefault:!0},{key:`ArrowUp`,run:Xf,shift:xp,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Mp,shift:Pp},{mac:`Ctrl-ArrowUp`,run:ep,shift:wp},{key:`ArrowDown`,run:Zf,shift:Sp,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Np,shift:Fp},{mac:`Ctrl-ArrowDown`,run:tp,shift:Tp},{key:`PageUp`,run:ep,shift:wp},{key:`PageDown`,run:tp,shift:Tp},{key:`Home`,run:ip,shift:Dp,preventDefault:!0},{key:`Mod-Home`,run:Mp,shift:Pp},{key:`End`,run:rp,shift:Ep,preventDefault:!0},{key:`Mod-End`,run:Np,shift:Fp},{key:`Enter`,run:dm,shift:dm},{key:`Mod-a`,run:Ip},{key:`Backspace`,run:Kp,shift:Kp,preventDefault:!0},{key:`Delete`,run:qp,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Yp,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:Xp,preventDefault:!0},{mac:`Mod-Backspace`,run:Qp,preventDefault:!0},{mac:`Mod-Delete`,run:$p,preventDefault:!0}].concat(ym.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),xm=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:qf,shift:vp},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:Jf,shift:yp},{key:`Alt-ArrowUp`,run:im},{key:`Shift-Alt-ArrowUp`,run:sm},{key:`Alt-ArrowDown`,run:am},{key:`Shift-Alt-ArrowDown`,run:cm},{key:`Mod-Alt-ArrowUp`,run:Bp},{key:`Mod-Alt-ArrowDown`,run:Vp},{key:`Escape`,run:Hp},{key:`Mod-Enter`,run:fm},{key:`Alt-l`,mac:`Ctrl-l`,run:Lp},{key:`Mod-i`,run:Rp,preventDefault:!0},{key:`Mod-[`,run:_m},{key:`Mod-]`,run:gm},{key:`Mod-Alt-\\`,run:hm},{key:`Shift-Mod-k`,run:lm},{key:`Shift-Mod-\\`,run:up},{key:`Mod-/`,run:Zd},{key:`Alt-A`,mac:`Ctrl-A`,run:ef},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:vm}].concat(bm),Sm=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,Cm=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Sm(e)):Sm,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return E(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=D(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=O(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(Cm.prototype[Symbol.iterator]=function(){return this});var wm={from:-1,to:-1,match:/.*/.exec(``),precise:!0},Tm=`gm`+(/x/.unicode==null?``:`u`),Em=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=wm,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new km(e,t,n,r,i);this.re=new RegExp(t,Tm+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=jm(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=jm(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Dm=new WeakMap,Om=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Dm.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Dm.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Dm.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},km=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=wm,this.matchPos=jm(e,r),this.re=new RegExp(t,Tm+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Om.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=jm(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Om.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Em.prototype[Symbol.iterator]=km.prototype[Symbol.iterator]=function(){return this});function Am(e){try{return new RegExp(e,Tm),!0}catch{return!1}}function jm(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Mm=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=fc(e,{label:t.phrase(`Go to line`),input:{type:`text`,name:`line`,value:n},focus:!0,submitLabel:t.phrase(`go`)});return i.then(n=>{let i=n&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(n.elements.line.value);if(!i){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,o,s,c,l]=i,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/t.doc.lines),d=Math.round(t.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=t.doc.line(Math.max(1,Math.min(t.doc.lines,d))),p=A.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[r,W.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Nm={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Pm=j.define({combine(e){return Qe(e,Nm,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Fm(e){let t=[Vm,Bm];return e&&t.push(Pm.of(e)),t}var Im=R.mark({class:`cm-selectionMatch`}),Lm=R.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function Rm(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=N.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=N.Word)}function zm(e,t,n,r){return e(t.sliceDoc(n,n+1))==N.Word&&e(t.sliceDoc(r-1,r))==N.Word}var Bm=V.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Pm),{state:n}=e,r=n.selection;if(r.ranges.length>1)return R.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return R.none;let e=n.wordAt(i.head);if(!e)return R.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return R.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(Rm(o,n,i.from,i.to)&&zm(o,n,i.from,i.to)))return R.none}else if(a=n.sliceDoc(i.from,i.to),!a)return R.none}let s=[];for(let r of e.visibleRanges){let e=new Cm(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||Rm(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(Lm.range(r,a)):(r>=i.to||a<=i.from)&&s.push(Im.range(r,a)),s.length>t.maxMatches))return R.none}}return R.set(s)}},{decorations:e=>e.decorations}),Vm=W.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),Hm=({state:e,dispatch:t})=>{let{selection:n}=e,r=A.create(n.ranges.map(t=>e.wordAt(t.head)||A.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function Um(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new Cm(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new Cm(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var Wm=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return Hm({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=Um(e,r);return i?(t(e.update({selection:e.selection.addRange(A.range(i.from,i.to),!1),effects:W.scrollIntoView(i.to)})),!0):!1},Gm=j.define({combine(e){return Qe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Th(e),scrollToMatch:e=>W.scrollIntoView(e)})}}),Km=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Am(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`14+`:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new rh(this):new Zm(this)}getCursor(e,t=0,n){let r=e.doc?e:P.create({doc:e});return n??=r.doc.length,this.regexp?$m(this,r,t,n):Ym(this,r,t,n)}},qm=class{constructor(e){this.spec=e}};function Jm(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function Ym(e,t,n,r){let i;return e.wholeWord&&(i=Xm(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=Jm(e.test,t,i)),new Cm(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function Xm(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(eh(i,n-a))!=N.Word||t(th(i,n-a))!=N.Word)&&(t(th(i,r-a))!=N.Word||t(eh(i,r-a))!=N.Word))}var Zm=class extends qm{constructor(e){super(e)}nextMatch(e,t,n){let r=Ym(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=Ym(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=Ym(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=Ym(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=Ym(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Qm(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function $m(e,t,n,r){let i;return e.wholeWord&&(i=nh(t.charCategorizer(t.selection.main.head))),e.test&&(i=Qm(e.test,t,i)),new Em(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function eh(e,t){return e.slice(C(e,t,!1),t)}function th(e,t){return e.slice(t,C(e,t))}function nh(e){return(t,n,r)=>!r[0].length||(e(eh(r.input,r.index))!=N.Word||e(th(r.input,r.index))!=N.Word)&&(e(th(r.input,r.index+r[0].length))!=N.Word||e(eh(r.input,r.index+r[0].length))!=N.Word)}var rh=class extends qm{nextMatch(e,t,n){let r=$m(this.spec,e,n,e.doc.length).next();return r.done&&(r=$m(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=$m(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=$m(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=$m(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},ih=M.define(),ah=M.define(),oh=ve.define({create(e){return new sh(yh(e).create(),null)},update(e,t){for(let n of t.effects)n.is(ih)?e=new sh(n.value.create(),e.panel):n.is(ah)&&(e=new sh(e.query,n.value?vh:null));return e},provide:e=>dc.from(e,e=>e.panel)}),sh=class{constructor(e,t){this.query=e,this.panel=t}},ch=R.mark({class:`cm-searchMatch`}),lh=R.mark({class:`cm-searchMatch cm-searchMatch-selected`}),uh=V.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(oh))}update(e){let t=e.state.field(oh);(t!=e.startState.field(oh)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return R.none;let{view:n}=this,r=new at;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?lh:ch)})}return r.finish()}},{decorations:e=>e.decorations});function dh(e){return t=>{let n=t.state.field(oh,!1);return n&&n.query.spec.valid?e(t,n):Sh(t)}}var fh=dh((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=A.single(r.from,r.to),a=e.state.facet(Gm);return e.dispatch({selection:i,effects:[kh(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),xh(e),!0}),ph=dh((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=A.single(i.from,i.to),o=e.state.facet(Gm);return e.dispatch({selection:a,effects:[kh(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),xh(e),!0}),mh=dh((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:A.create(n.map(e=>A.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),hh=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new Cm(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(A.range(t.value.from,t.value.to))}return t(e.update({selection:A.create(a,o),userEvent:`select.search.matches`})),!0},gh=dh((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(W.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=A.single(o.from,o.to).map(d),u.push(kh(e,o)),u.push(n.facet(Gm).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),_h=dh((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:W.announce.of(r),userEvent:`input.replace.all`}),!0});function vh(e){return e.state.facet(Gm).createPanel(e)}function yh(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(Gm);return new Km({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function bh(e){let t=sc(e,vh);return t&&t.dom.querySelector(`[main-field]`)}function xh(e){let t=bh(e);t&&t==e.root.activeElement&&t.select()}var Sh=e=>{let t=e.state.field(oh,!1);if(t&&t.panel){let n=bh(e);if(n&&n!=e.root.activeElement){let r=yh(e.state,t.query.spec);r.valid&&e.dispatch({effects:ih.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[ah.of(!0),t?ih.of(yh(e.state,t.query.spec)):M.appendConfig.of(jh)]});return!0},Ch=e=>{let t=e.state.field(oh,!1);if(!t||!t.panel)return!1;let n=sc(e,vh);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:ah.of(!1)}),!0},wh=[{key:`Mod-f`,run:Sh,scope:`editor search-panel`},{key:`F3`,run:fh,shift:ph,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:fh,shift:ph,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Ch,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:hh},{key:`Mod-Alt-g`,run:Mm},{key:`Mod-d`,run:Wm,preventDefault:!0}],Th=class{constructor(e){this.view=e;let t=this.query=e.state.field(oh).query.spec;this.commit=this.commit.bind(this),this.searchField=I(`input`,{value:t.search,placeholder:Eh(e,`Find`),"aria-label":Eh(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=I(`input`,{value:t.replace,placeholder:Eh(e,`Replace`),"aria-label":Eh(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=I(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=I(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=I(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return I(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=I(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>fh(e),[Eh(e,`next`)]),n(`prev`,()=>ph(e),[Eh(e,`previous`)]),n(`select`,()=>mh(e),[Eh(e,`all`)]),I(`label`,null,[this.caseField,Eh(e,`match case`)]),I(`label`,null,[this.reField,Eh(e,`regexp`)]),I(`label`,null,[this.wordField,Eh(e,`by word`)]),...e.state.readOnly?[]:[I(`br`),this.replaceField,n(`replace`,()=>gh(e),[Eh(e,`replace`)]),n(`replaceAll`,()=>_h(e),[Eh(e,`replace all`)])],I(`button`,{name:`close`,onclick:()=>Ch(e),"aria-label":Eh(e,`close`),type:`button`},[`×`])])}commit(){let e=new Km({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ih.of(e)}))}keydown(e){Ro(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?ph:fh)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),gh(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(ih)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Gm).top}};function Eh(e,t){return e.state.phrase(t)}var Dh=30,Oh=/[\s\.,:;?!]/;function kh(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Dh),o=Math.min(i,n+Dh),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Dh;e++)if(!Oh.test(s[e+1])&&Oh.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Dh;e--)if(!Oh.test(s[e-1])&&Oh.test(s[e])){s=s.slice(0,e);break}}return W.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Ah=W.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),jh=[oh,xe.low(uh),Ah],Mh=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=X(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(zh(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function Nh(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function Ph(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=Nh(t)+Nh(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Fh(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Ph(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function Ih(e,t){return n=>{for(let t=X(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Lh=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function Rh(e){return e.selection.main.from}function zh(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var Bh=Ie.define();function Vh(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:A.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var Hh=new WeakMap;function Uh(e){if(!Array.isArray(e))return e;let t=Hh.get(e);return t||Hh.set(e,t=Fh(e)),t}var Wh=M.define(),Gh=M.define(),Kh=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=E(e,t),r=O(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(E(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=E(e,0),i=O(r),a=i==e.length?0:-100;if(r!=t[0]){if(r==n[0])a+=-200;else return null}return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=E(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=O(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=E(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=D(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=O(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?O(E(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},qh=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},Jh=j.define({combine(e){return Qe(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Xh,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>Yh(e(n),t(n)),optionClass:(e,t)=>n=>Yh(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function Yh(e,t){return e?t?e+` `+t:e:t}function Xh(e,t,n,r,i,a){let o=e.textDirection==z.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var Zh=M.define();function Qh(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function $h(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var eg=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(Jh);this.optionContent=Qh(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=$h(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:Zh.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(Jh).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:Gh.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=$h(r.length,i,e.state.facet(Jh).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=$h(t.options.length,t.selected,this.view.state.facet(Jh).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>gr(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&ng(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(Jh).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function tg(e,t){return n=>new eg(n,e,t)}function ng(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function rg(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function ig(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(Jh);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Lh(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new qh(n):new Kh(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Lh(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):rg(e.completion)>rg(c)&&(s[s.length-1]=e),c=e.completion}return s}var ag=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,ug(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=ig(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(Jh).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,ug(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:yg,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},og=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(dg,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Jh),i=(r.override||n.languageDataAt(`autocomplete`,Rh(n)).map(Uh)).map(e=>(this.active.find(t=>t.source==e)||new pg(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(gg));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!sg(i,this.active)||o?a=ag.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new pg(e.source,0):e));for(let e of t.effects)e.is(Zh)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?cg:lg}};function sg(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var cg={"aria-autocomplete":`list`},lg={};function ug(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var dg=[];function fg(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(Bh);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var pg=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=fg(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(Wh))i=new e(i.source,1,n.value);else if(n.is(Gh))i=new e(i.source,0);else if(n.is(gg))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Rh(e.state))}},mg=class e extends pg{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=Rh(t.state);if(o>a||!r||n&2&&(Rh(t.startState)==this.from||o<this.limit))return new pg(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return hg(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new Mh(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??Rh(t.state)):new pg(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new pg(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function hg(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):zh(e,!0).test(i)}var gg=M.define({map(e,t){return e.map(e=>e.map(t))}}),_g=ve.define({create(){return og.start()},update(e,t){return e.update(t)},provide:e=>[qs.from(e,e=>e.tooltip),W.contentAttributes.from(e,e=>e.attrs)]});function vg(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(_g).active.find(e=>e.source==t.source);return r instanceof mg&&(typeof n==`string`?e.dispatch({...Vh(e.state,n,r.from,r.to),annotations:Bh.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var yg=tg(_g,vg);function bg(e,t=`option`){return n=>{let r=n.state.field(_g,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Jh).interactionDelay)return!1;let i=1,a;t==`page`&&(a=ic(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:Zh.of(s)}),!0}}var xg=e=>{let t=e.state.field(_g,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Jh).interactionDelay?!1:vg(e,t.open.options[t.open.selected])},Sg=e=>e.state.field(_g,!1)?(e.dispatch({effects:Wh.of(!0)}),!0):!1,Cg=e=>{let t=e.state.field(_g,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:Gh.of(null)}),!0)},wg=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Tg=50,Eg=1e3,Dg=V.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(_g).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(_g),n=e.state.facet(Jh);if(!e.selectionSet&&!e.docChanged&&e.startState.field(_g)==t)return;let r=e.transactions.some(e=>{let t=fg(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>Tg&&Date.now()-n.time>Eg){for(let e of n.context.abortListeners)try{e()}catch(e){gr(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(Wh)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(_g);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Jh).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new Mh(t,Rh(t),e.explicit,this.view),r=new wg(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:Gh.of(null)}),gr(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Jh).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Jh),n=this.view.state.field(_g);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=Rh(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new mg(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new pg(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:gg.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(_g,!1);if(t&&t.tooltip&&this.view.state.facet(Jh).closeOnBlur){let n=t.open&&ic(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Gh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Wh.of(!1)}),20),this.composing=0}}}),Og=typeof navigator==`object`&&/Win/.test(navigator.platform),kg=xe.highest(W.domEventHandlers({keydown(e,t){let n=t.state.field(_g,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Og&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&vg(t,r),!1}})),Ag=W.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),jg={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},Mg=M.define({map(e,t){return t.mapPos(e,-1,k.TrackAfter)??void 0}}),Ng=new class extends $e{};Ng.startSide=1,Ng.endSide=-1;var Pg=ve.define({create(){return F.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(Mg)&&(e=e.update({add:[Ng.range(n.value,n.value+1)]}));return e}});function Fg(){return[Bg,Pg]}var Ig=`()[]{}<>«»»«[]{}`;function Lg(e){for(let t=0;t<16;t+=2)if(Ig.charCodeAt(t)==e)return Ig.charAt(t+1);return D(e<128?e:e+1)}function Rg(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||jg}var zg=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),Bg=W.inputHandler.of((e,t,n,r)=>{if((zg?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&O(E(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Hg(e.state,r);return a?(e.dispatch(a),!0):!1}),Vg=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Rg(e,e.selection.main.head).brackets||jg.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=Gg(e.doc,t.head);for(let i of n)if(i==r&&Wg(e.doc,t.head)==Lg(E(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:A.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function Hg(e,t){let n=Rg(e,e.selection.main.head),r=n.brackets||jg.brackets;for(let i of r){let a=Lg(E(i,0));if(t==i)return a==i?Jg(e,i,r.indexOf(i+i+i)>-1,n):Kg(e,i,a,n.before||jg.before);if(t==a&&Ug(e,e.selection.main.from))return qg(e,i,a)}return null}function Ug(e,t){let n=!1;return e.field(Pg).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function Wg(e,t){let n=e.sliceString(t,t+2);return n.slice(0,O(E(n,0)))}function Gg(e,t){let n=e.sliceString(t-2,t);return O(E(n,0))==n.length?n:n.slice(1)}function Kg(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:Mg.of(a.to+t.length),range:A.range(a.anchor+t.length,a.head+t.length)};let o=Wg(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:Mg.of(a.head+t.length),range:A.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function qg(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&Wg(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:A.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function Jg(e,t,n,r){let i=r.stringPrefixes||jg.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:Mg.of(r.to+t.length),range:A.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=Wg(e.doc,o),c;if(s==t){if(Yg(e,o))return{changes:{insert:t+t,from:o},effects:Mg.of(o+t.length),range:A.cursor(o+t.length)};if(Ug(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:A.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=Zg(e,o-2*t.length,i))>-1&&Yg(e,c))return{changes:{insert:t+t+t+t,from:o},effects:Mg.of(o+t.length),range:A.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=N.Word&&Zg(e,o,i)>-1&&!Xg(e,o,t,i))return{changes:{insert:t+t,from:o},effects:Mg.of(o+t.length),range:A.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function Yg(e,t){let n=X(e).resolveInner(t+1);return n.parent&&n.from==t}function Xg(e,t,n,r){let i=X(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function Zg(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=N.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=N.Word)return n}return-1}function Qg(e={}){return[kg,_g,Jh.of(e),Dg,e_,Ag]}var $g=[{key:`Ctrl-Space`,run:Sg},{mac:"Alt-`",run:Sg},{mac:`Alt-i`,run:Sg},{key:`Escape`,run:Cg},{key:`ArrowDown`,run:bg(!0)},{key:`ArrowUp`,run:bg(!1)},{key:`PageDown`,run:bg(!0,`page`)},{key:`PageUp`,run:bg(!1,`page`)},{key:`Enter`,run:xg}],e_=xe.highest(Fo.computeN([Jh],e=>e.facet(Jh).defaultKeymap?[$g]:[])),t_=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},n_=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(g_).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new at,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=D_(s);if(i)o.add(n,n,R.widget({widget:new b_(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,R.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,r_(f))}};function r_(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new t_(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new t_(r.from,n,r.diagnostic)}}),r}function i_(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(g_).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(o_))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function a_(e,t){return e.field(l_,!1)?t:t.concat(M.appendConfig.of(k_))}var o_=M.define(),s_=M.define(),c_=M.define(),l_=ve.define({create(){return new n_(R.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=r_(n,e.selected.diagnostic,i)||r_(n,null,i)}!n.size&&i&&t.state.facet(g_).autoPanel&&(i=null),e=new n_(n,i,r)}for(let n of t.effects)if(n.is(o_)){let r=t.state.facet(g_).autoPanel?n.value.length?S_.open:null:e.panel;e=n_.init(n.value,r,t.state)}else n.is(s_)?e=new n_(e.diagnostics,n.value?S_.open:null,e.selected):n.is(c_)&&(e=new n_(e.diagnostics,e.panel,n.value));return e},provide:e=>[dc.from(e,e=>e.panel),W.decorations.from(e,e=>e.diagnostics)]}),u_=R.mark({class:`cm-lintRange cm-lintRange-active`});function d_(e,t,n){let{diagnostics:r}=e.state.field(l_),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(g_).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:!0,create(){return{dom:f_(e,i)}}}:null}function f_(e,t){return I(`ul`,{class:`cm-tooltip-lint`},t.map(t=>y_(e,t,!1)))}var p_=e=>{let t=e.state.field(l_,!1);(!t||!t.panel)&&e.dispatch({effects:a_(e.state,[s_.of(!0)])});let n=sc(e,S_.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},m_=e=>{let t=e.state.field(l_,!1);return!t||!t.panel?!1:(e.dispatch({effects:s_.of(!1)}),!0)},h_=[{key:`Mod-Shift-m`,run:p_,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(l_,!1);if(!t)return!1;let n=e.state.selection.main,r=r_(t.diagnostics,null,n.to+1);return!r&&(r=r_(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),rc(e,r.from,1,{tooltip:O_,until:e=>e.docChanged||e.newSelection.main.head<r.from||e.newSelection.main.head>r.to}),!0)}}],g_=j.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...Qe(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:__,tooltipFilter:__,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function __(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function v_(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function y_(e,t,n){let r=n?v_(t.actions):[];return I(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},I(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=r_(e.state.field(l_).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),I(`u`,s.slice(c,c+1)),s.slice(c+1)];return I(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&I(`div`,{class:`cm-diagnosticSource`},t.source))}var b_=class extends Xt{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return I(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},x_=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=y_(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},S_=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)m_(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=v_(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=r_(this.view.state.field(l_).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=I(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=I(`div`,{class:`cm-panel-lint`},this.list,I(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>m_(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(l_).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(l_),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new x_(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new x_(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=r_(this.view.state.field(l_).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:c_.of(t)})}static open(t){return new e(t)}};function C_(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function w_(e){return C_(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var T_=W.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:w_(`#f11`)},".cm-lintRange-warning":{backgroundImage:w_(`orange`)},".cm-lintRange-info":{backgroundImage:w_(`#999`)},".cm-lintRange-hint":{backgroundImage:w_(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function E_(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function D_(e){let t=`hint`,n=1;for(let r of e){let e=E_(r.severity);e>n&&(n=e,t=r.severity)}return t}var O_=nc(d_,{hideOn:i_}),k_=[l_,W.decorations.compute([l_],e=>{let{selected:t,panel:n}=e.field(l_);return!t||!n||t.from==t.to?R.none:R.set([u_.range(t.from,t.to)])}),O_,T_],A_=[Rc(),Hc(),ys(),mf(),rd(),$o(),ls(),P.allowMultipleSelections.of(!0),ku(),ld(fd,{fallback:!0}),Sd(),Fg(),Qg(),Ps(),Ls(),Es(),Fm(),Fo.of([...Vg,...xm,...wh,...Nf,...Ju,...$g,...h_])],j_=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new M_(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=r.dynamicPrecedence(n);if(a&&(this.score+=a),t==0){n<r.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(r.getGoto(this.state,n,!0),this.reducePos),n<r.minRepeatTerm&&this.storeNode(n,this.reducePos,this.reducePos,i?8:4,!0),this.reduceContext(n,this.reducePos);return}let o=this.stack.length-(t-1)*3-(e&262144?6:0),s=o?this.stack[o-2]:this.p.ranges[0].from;n<r.minRepeatTerm&&s==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let c=this.reducePos-s;c>=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=s,this.p.lastBigReductionSize=c));let l=o?this.stack[o-1]:0,u=this.bufferBase+this.buffer.length-l;if(n<r.minRepeatTerm||e&131072){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(n,s,e,u+4,!0)}if(e&262144)this.state=this.stack[o];else{let e=this.stack[o-3];this.state=r.getGoto(e,n,!0)}for(;this.stack.length>o;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this.buffer.length;if(e>0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(n,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new N_(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;r<t.length;r+=2)(i=t[r+1])!=this.state&&this.p.parser.hasAction(i,e)&&n.push(t[r],i);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let r=t[e+1];n.some((e,t)=>t&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let r=t[e+1];if(r==this.state)continue;let i=this.split();i.pushState(r,this.pos),i.storeNode(0,i.pos,i.pos,4,!0),i.shiftContext(t[e],this.pos),i.reducePos=this.pos,i.score-=200,n.push(i)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if(!(t&65536))return!1;if(!e.validAction(this.state,t)){let n=t>>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new M_(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},M_=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},N_=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},P_=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new e(this.stack,this.pos,this.index)}};function F_(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r<e.length;){let a=0;for(;;){let t=e.charCodeAt(r++),n=!1;if(t==126){a=65535;break}t>=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var I_=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},L_=new I_,R_=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=L_,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let e=this.ranges[--r];i-=n.from-e.to,n=e}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(t==null)return-1;if(n=t,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw RangeError(`Token end out of bounds`);this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1:this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk=``,this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=L_,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk=``,this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},z_=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;H_(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};z_.prototype.contextual=z_.prototype.fallback=z_.prototype.extend=!1;var B_=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?F_(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(H_(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};B_.prototype.contextual=z_.prototype.fallback=z_.prototype.extend=!1;var V_=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function H_(e,t,n,r,i,a){let o=0,s=1<<r,{dialect:c}=n.p.parser;scan:for(;(s&e[o])!=0;){let n=e[o+1];for(let r=o+3;r<n;r+=2)if((e[r+1]&s)>0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||W_(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l<u;){let i=l+u>>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r<s)u=i;else if(r>=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function U_(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function W_(e,t,n,r){let i=U_(n,r,t);return i<0||U_(n,r,e)<i}var G_=typeof process<`u`&&/\bparse\b/.test({}.LOG),K_=null;function q_(e,t,n){let r=e.cursor(K.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var J_=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?q_(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?q_(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],a=this.start[t]+n.positions[r];if(a>e)return this.nextStart=a,null;if(i instanceof q){if(a==e){if(a<this.safeFrom)return null;let e=a+i.length;if(e<=this.safeTo){let t=i.prop(G.lookAhead);if(!t||e+t<this.fragment.to)return i}}this.index[t]++,a+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},Y_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new I_)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;r<i.length;r++){if(!(1<<r&a))continue;let c=i[r],l=this.tokens[r];if(!(n&&!c.fallback)&&((c.contextual||l.start!=e.pos||l.mask!=a||l.context!=o)&&(this.updateCachedToken(l,c,e),l.mask=a,l.context=o),l.lookAhead>l.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new I_,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new I_,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r<t.specialized.length;r++)if(t.specialized[r]==e.value){let i=t.specializers[r](this.stream.read(e.start,e.end),n);if(i>=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;t<r;t+=3)if(this.actions[t]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:a}=e.p,{data:o}=a;for(let e=0;e<2;e++)for(let s=a.stateSlot(i,e?2:1);;s+=3){if(o[s]==65535){if(o[s+1]==1)s=nv(o,s+2);else{r==0&&o[s+1]==2&&(r=this.putAction(nv(o,s+2),t,n,r));break}}o[s]==t&&(r=this.putAction(nv(o,s+1),t,n,r))}return r}},X_=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new R_(t,r),this.tokens=new Y_(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[j_.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new J_(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;a<e.length;a++){let o=e[a];for(;;){if(this.tokens.mainToken=null,o.pos>t)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&rv(r);if(e)return G_&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw G_&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return G_&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e<n.length-1;e++){let t=n[e];for(let r=e+1;r<n.length;r++){let i=n[r];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e<n.length;e++)n[e].pos<this.minStackPos&&(this.minStackPos=n[e].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw RangeError(`Can't move stoppedAt forward`);this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=G_?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(r);o;){let r=this.parser.nodeSet.types[o.type.id]==o.type?i.getGoto(e.state,o.type.id):-1;if(r>-1&&o.length&&(!t||(o.prop(G.contextHash)||0)==n))return e.useNode(o,r),G_&&console.log(a+this.stackID(e)+` (via reuse of ${i.getName(o.type.id)})`),!0;if(!(o instanceof q)||o.children.length==0||o.positions[0]>0)break;let s=o.children[0];if(s instanceof q&&o.positions[0]==0)o=s;else break}}let o=i.stateSlot(e.state,4);if(o>0)return e.reduce(o),G_&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;o<s.length;){let c=s[o++],l=s[o++],u=s[o++],d=o==s.length||!n,f=d?e:e.split(),p=this.tokens.mainToken;if(f.apply(c,l,p?p.start:f.pos,u),G_&&console.log(a+this.stackID(f)+` (via ${c&65536?`reduce of ${i.getName(c&65535)}`:`shift`} for ${i.getName(l)} @ ${r}${f==e?``:`, split`})`),d)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return Z_(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a<e.length;a++){let o=e[a],s=t[a<<1],c=t[(a<<1)+1],l=G_?this.stackID(o)+` -> `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),G_&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(G_&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)G_&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))G_&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),G_&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),Z_(o,n)):(!r||r.score<u.score)&&(r=u)}return r}stackToTree(e){return e.close(),q.build({buffer:P_.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(K_||=new WeakMap).get(e);return t||K_.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function Z_(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var Q_=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},$_=e=>e,ev=class{constructor(e){this.start=e.start,this.shift=e.shift||$_,this.reduce=e.reduce||$_,this.reuse=e.reuse||$_,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},tv=class e extends vl{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(` `);this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push(``);let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),r=[];for(let e=0;e<t.length;e++)r.push([]);function i(e,t,n){r[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];typeof e==`string`&&(e=G[e]);for(let n=1;n<t.length;){let r=t[n++];if(r>=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new Yc(t.map((t,i)=>Jc.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Uc;let a=F_(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(iv),this.states=F_(e.states,Uint32Array),this.data=F_(e.stateData),this.goto=F_(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>typeof e==`number`?new z_(a,e):e),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let r=new X_(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i<n;i++)if(r[i]==e)return o;if(a)return-1}}hasAction(e,t){let n=this.data;for(let r=0;r<2;r++)for(let i=this.stateSlot(e,r?2:1),a;;i+=3){if((a=n[i])==65535){if(n[i+1]==1)a=n[i=nv(n,i+2)];else if(n[i+1]==2)return nv(n,i+2);else break}if(a==t||a==0)return nv(n,i+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=nv(this.data,n+2);else break}r=t(nv(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=nv(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=iv(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],i;(i=this.data[n++])!=65535;)(r||=new Uint8Array(this.maxTerm+1))[i]=1;return new Q_(e,n,r)}static deserialize(t){return new e(t)}};function nv(e,t){return e[t]|e[t+1]<<16}function rv(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||e!=null&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function iv(e){if(e.external){let t=+!!e.extend;return(n,r)=>e.external(n,r)<<1|t}return e.get}var av=El({String:Y.string,Number:Y.number,"True False":Y.bool,PropertyName:Y.propertyName,Null:Y.null,", :":Y.separator,"[ ]":Y.squareBracket,"{ }":Y.brace}),ov=tv.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:`#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O`,goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:`⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array`,maxTerm:25,nodeProps:[[`isolate`,-2,6,11,``],[`openedBy`,7,`{`,14,`[`],[`closedBy`,8,`}`,15,`]`]],propSources:[av],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),sv=$l.define({name:`json`,parser:ov.configure({props:[gu.add({Object:Du({except:/^\s*\}/}),Array:Du({except:/^\s*\]/})}),ju.add({"Object Array":Mu})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function cv(){return new lu(sv)}var lv=36,uv=1,dv=2,fv=3,pv=4,mv=5,hv=6,gv=7,_v=8,vv=9,yv=10,bv=11,xv=12,Sv=13,Cv=14,wv=15,Tv=16,Ev=17,Dv=18,Ov=19,kv=20,Av=21,jv=22,Mv=23,Nv=24;function Pv(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function Fv(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Iv(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function Lv(e,t){scan:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue scan;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function Rv(e,t){let n=`[{<(`.indexOf(String.fromCharCode(t)),r=n<0?t:`]}>)`.charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function zv(e,t){for(;!(e.next!=95&&!Pv(e.next));)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function Bv(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),Iv(e,t,!1)}else zv(e)}function Vv(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function Hv(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function Uv(e){for(;!(e.next<0||e.next==10);)e.advance()}function Wv(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var Gv=` \r15+`;function Kv(e,t,n){let r=Object.create(null);r.true=r.false=mv,r.null=r.unknown=hv;for(let t of e.split(` `))t&&(r[t]=kv);for(let e of t.split(` `))e&&(r[e]=Av);for(let e of(n||``).split(` `))e&&(r[e]=Nv);return r}var qv=`array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying `,Jv=`absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone `,Yv={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:`*+-%<>!=&|~^/`,specialVar:`?`,identifierQuotes:`"`,caseInsensitiveIdentifiers:!1,words:Kv(Jv,qv)};function Xv(e,t,n,r){let i={};for(let t in Yv)i[t]=(e.hasOwnProperty(t)?e:Yv)[t];return t&&(i.words=Kv(t,n||``,r)),i}function Zv(e){return new V_(t=>{let{next:n}=t;if(t.advance(),Wv(n,Gv)){for(;Wv(t.next,Gv);)t.advance();t.acceptToken(lv)}else if(n==36&&e.doubleDollarQuotedStrings){let e=zv(t,``);t.next==36&&(t.advance(),Lv(t,e),t.acceptToken(fv))}else if(n==39||n==34&&e.doubleQuotedStrings)Iv(t,n,e.backslashEscapes),t.acceptToken(fv);else if(n==35&&e.hashComments||n==47&&t.next==47&&e.slashComments)Uv(t),t.acceptToken(uv);else if(n==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))Uv(t),t.acceptToken(uv);else if(n==47&&t.next==42){t.advance();for(let e=1;;){let n=t.next;if(t.next<0)break;if(t.advance(),n==42&&t.next==47){if(e--,t.advance(),!e)break}else n==47&&t.next==42&&(e++,t.advance())}t.acceptToken(dv)}else if((n==101||n==69)&&t.next==39)t.advance(),Iv(t,39,!0),t.acceptToken(fv);else if((n==110||n==78)&&t.next==39&&e.charSetCasts)t.advance(),Iv(t,39,e.backslashEscapes),t.acceptToken(fv);else if(n==95&&e.charSetCasts)for(let n=0;;n++){if(t.next==39&&n>1){t.advance(),Iv(t,39,e.backslashEscapes),t.acceptToken(fv);break}if(!Pv(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(n==113||n==81)&&t.next==39&&t.peek(1)>0&&!Wv(t.peek(1),Gv)){let e=t.peek(1);t.advance(2),Rv(t,e),t.acceptToken(fv)}else if(Wv(n,e.identifierQuotes))Iv(t,n==91?93:n,!1),t.acceptToken(Ov);else if(n==40)t.acceptToken(gv);else if(n==41)t.acceptToken(_v);else if(n==123)t.acceptToken(vv);else if(n==125)t.acceptToken(yv);else if(n==91)t.acceptToken(bv);else if(n==93)t.acceptToken(xv);else if(n==59)t.acceptToken(Sv);else if(e.unquotedBitLiterals&&n==48&&t.next==98)t.advance(),Vv(t),t.acceptToken(jv);else if((n==98||n==66)&&(t.next==39||t.next==34)){let n=t.next;t.advance(),e.treatBitsAsBytes?(Iv(t,n,e.backslashEscapes),t.acceptToken(Mv)):(Vv(t,n),t.acceptToken(jv))}else if(n==48&&(t.next==120||t.next==88)||(n==120||n==88)&&t.next==39){let e=t.next==39;for(t.advance();Fv(t.next);)t.advance();e&&t.next==39&&t.advance(),t.acceptToken(pv)}else if(n==46&&t.next>=48&&t.next<=57)Hv(t,!0),t.acceptToken(pv);else if(n==46)t.acceptToken(Cv);else if(n>=48&&n<=57)Hv(t,!1),t.acceptToken(pv);else if(Wv(n,e.operatorChars)){for(;Wv(t.next,e.operatorChars);)t.advance();t.acceptToken(wv)}else if(Wv(n,e.specialVar))t.next==n&&t.advance(),Bv(t),t.acceptToken(Ev);else if(n==58||n==44)t.acceptToken(Tv);else if(Pv(n)){let r=zv(t,String.fromCharCode(n));t.acceptToken(t.next==46||t.peek(-r.length-1)==46?Dv:e.words[r.toLowerCase()]??Dv)}})}var Qv=Zv(Yv),$v=tv.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:`⚠ LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement`,maxTerm:38,nodeProps:[[`isolate`,-4,1,2,3,19,``]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:`RORO`,tokenizers:[0,Qv],topRules:{Script:[0,25]},tokenPrec:0});function ey(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function ty(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function ny(e){return e&&(e.name==`Identifier`||e.name==`QuotedIdentifier`)}function ry(e,t){if(t.name==`CompositeIdentifier`){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)ny(r)&&n.push(ty(e,r));return n}return[ty(e,t)]}function iy(e,t){for(let n=[];;){if(!t||t.name!=`.`)return n;let r=ey(t);if(!ny(r))return n;n.unshift(ty(e,r)),t=ey(r)}}function ay(e,t){let n=X(e).resolveInner(t,-1),r=sy(e.doc,n);return n.name==`Identifier`||n.name==`QuotedIdentifier`||n.name==`Keyword`?{from:n.from,quoted:n.name==`QuotedIdentifier`?e.doc.sliceString(n.from,n.from+1):null,parents:iy(e.doc,ey(n)),aliases:r}:n.name==`.`?{from:t,quoted:null,parents:iy(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var oy=new Set(`where group having order union intersect except all distinct limit offset fetch for`.split(` `));function sy(e,t){let n;for(let e=t;!n;e=e.parent){if(!e)return null;e.name==`Statement`&&(n=e)}let r=null;for(let t=n.firstChild,i=!1,a=null;t;t=t.nextSibling){let n=t.name==`Keyword`?e.sliceString(t.from,t.to).toLowerCase():null,o=null;if(!i)i=n==`from`;else if(n==`as`&&a&&ny(t.nextSibling))o=ty(e,t.nextSibling);else if(n&&oy.has(n))break;else a&&ny(t)&&(o=ty(e,t));o&&(r||=Object.create(null),r[o]=ry(e,a)),a=/Identifier$/.test(t.name)?t:null}return r}function cy(e,t,n){return n.map(n=>({...n,label:n.label[0]==e?n.label:e+n.label+t,apply:void 0}))}var ly=/^\w*$/,uy=/^[`'"\[]?\w*[`'"\]]?$/;function dy(e){return e.self&&typeof e.self.label==`string`}var fy=class e{constructor(e,t){this.idQuote=e,this.idCaseInsensitive=t,this.list=[],this.children=void 0}child(t){let n=this.children||=Object.create(null);return n[t]||(t&&!this.list.some(e=>e.label==t)&&this.list.push(py(t,`type`,this.idQuote,this.idCaseInsensitive)),n[t]=new e(this.idQuote,this.idCaseInsensitive))}maybeChild(e){return this.children?this.children[e]:null}addCompletion(e){let t=this.list.findIndex(t=>t.label==e.label);t>-1?this.list[t]=e:this.list.push(e)}addCompletions(e){for(let t of e)this.addCompletion(typeof t==`string`?py(t,`property`,this.idQuote,this.idCaseInsensitive):t)}addNamespace(e){Array.isArray(e)?this.addCompletions(e):dy(e)?this.addNamespace(e.children):this.addNamespaceObject(e)}addNamespaceObject(e){for(let t of Object.keys(e)){let n=e[t],r=null,i=t.replace(/\\?\./g,e=>e==`.`?`\0`:e).split(`\0`),a=this;dy(n)&&(r=n.self,n=n.children);for(let e=0;e<i.length;e++)r&&e==i.length-1&&a.addCompletion(r),a=a.child(i[e].replace(/\\\./g,`.`));a.addNamespace(n)}}};function py(e,t,n,r){return RegExp(`^[a-z_][a-z_\\d]*$`,r?`i`:``).test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+my(n)}}function my(e){return e===`[`?`]`:e}function hy(e,t,n,r,i,a){let o=new fy(a?.spec.identifierQuotes?.[0]||`"`,!!a?.spec.caseInsensitiveIdentifiers),s=i?o.child(i):null;return o.addNamespace(e),t&&(s||o).addCompletions(t),n&&o.addCompletions(n),s&&o.addCompletions(s.list),r&&o.addCompletions((s||o).child(r).list),e=>{let{parents:t,from:n,quoted:i,empty:a,aliases:c}=ay(e.state,e.pos);if(a&&!e.explicit)return null;c&&t.length==1&&(t=c[t[0]]||t);let l=o;for(let e of t){for(;!l.children||!l.children[e];)if(l==o&&s)l=s;else if(l==s&&r)l=l.child(r);else return null;let t=l.maybeChild(e);if(!t)return null;l=t}let u=l.list;if(l==o&&c&&(u=u.concat(Object.keys(c).map(e=>({label:e,type:`constant`})))),i){let t=i[0],r=my(t);return{from:n,to:e.state.sliceDoc(e.pos,e.pos+1)==r?e.pos+1:void 0,options:cy(t,r,u),validFor:uy}}return{from:n,options:u,validFor:ly}}}function gy(e){return e==Av?`type`:e==kv?`keyword`:`variable`}function _y(e,t,n){return Ih([`QuotedIdentifier`,`String`,`LineComment`,`BlockComment`,`.`],Fh(Object.keys(e).map(r=>n(t?r.toUpperCase():r,gy(e[r])))))}var vy=$v.configure({props:[gu.add({Statement:Du()}),ju.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),El({Keyword:Y.keyword,Type:Y.typeName,Builtin:Y.standard(Y.name),Bits:Y.number,Bytes:Y.string,Bool:Y.bool,Null:Y.null,Number:Y.number,String:Y.string,Identifier:Y.name,QuotedIdentifier:Y.special(Y.string),SpecialVar:Y.special(Y.name),LineComment:Y.lineComment,BlockComment:Y.blockComment,Operator:Y.operator,"Semi Punctuation":Y.punctuation,"( )":Y.paren,"{ }":Y.brace,"[ ]":Y.squareBracket})]}),yy=class e{constructor(e,t,n){this.dialect=e,this.language=t,this.spec=n}get extension(){return this.language.extension}configureLanguage(t,n){return new e(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=Xv(t,t.keywords,t.types,t.builtin),r=$l.define({name:`sql`,parser:vy.configure({tokenizers:[{from:Qv,to:Zv(n)}]}),languageData:{commentTokens:{line:`--`,block:{open:`/*`,close:`*/`}},closeBrackets:{brackets:[`(`,`[`,`{`,`'`,`"`,"`"]}}});return new e(n,r,t)}};function by(e,t){return{label:e,type:t,boost:-1}}function xy(e,t=!1,n){return _y(e.dialect.words,t,n||by)}function Sy(e){return e.schema?hy(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||Ty):()=>null}function Cy(e){return e.schema?(e.dialect||Ty).language.data.of({autocomplete:Sy(e)}):[]}function wy(e={}){let t=e.dialect||Ty;return new lu(t.language,[Cy(e),t.language.data.of({autocomplete:xy(t,e.upperCaseKeywords,e.keywordCompletion)})])}var Ty=yy.define({});Jv+``,qv+``;var Ey=`accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill`;qv+``,Jv+``+Ey,Jv+``+Ey,Jv+``,qv+``,Jv+``,qv+``,qv+``,Jv+``,qv+``;var Dy=1,Oy=2,ky=3,Ay=4,jy=5,My=36,Ny=37,Py=38,Fy=11,Iy=13;function Ly(e){return e==45||e==46||e==58||e>=65&&e<=90||e==95||e>=97&&e<=122||e>=161}function Ry(e){return e==9||e==10||e==13||e==32}var zy=null,By=null,Vy=0;function Hy(e,t){let n=e.pos+t;if(By==e&&Vy==n)return zy;for(;Ry(e.peek(t));)t++;let r=``;for(;;){let n=e.peek(t);if(!Ly(n))break;r+=String.fromCharCode(n),t++}return By=e,Vy=n,zy=r||null}function Uy(e,t){this.name=e,this.parent=t}var Wy=new ev({start:null,shift(e,t,n,r){return t==Dy?new Uy(Hy(r,1)||``,e):e},reduce(e,t){return t==Fy&&e?e.parent:e},reuse(e,t,n,r){let i=t.type.id;return i==Dy||i==Iy?new Uy(Hy(r,1)||``,e):e},strict:!1}),Gy=new V_((e,t)=>{if(e.next==60){if(e.advance(),e.next==47){e.advance();let n=Hy(e,0);if(!n)return e.acceptToken(jy);if(t.context&&n==t.context.name)return e.acceptToken(Oy);for(let r=t.context;r;r=r.parent)if(r.name==n)return e.acceptToken(ky,-2);e.acceptToken(Ay)}else if(e.next!=33&&e.next!=63)return e.acceptToken(Dy)}},{contextual:!0});function Ky(e,t){return new V_(n=>{let r=0,i=t.charCodeAt(0);scan:for(;!(n.next<0);n.advance(),r++)if(n.next==i){for(let e=1;e<t.length;e++)if(n.peek(e)!=t.charCodeAt(e))continue scan;break}r&&n.acceptToken(e)})}var qy=Ky(My,`-->`),Jy=Ky(Ny,`?>`),Yy=Ky(Py,`]]>`),Xy=El({Text:Y.content,"StartTag StartCloseTag EndTag SelfCloseEndTag":Y.angleBracket,TagName:Y.tagName,"MismatchedCloseTag/TagName":[Y.tagName,Y.invalid],AttributeName:Y.attributeName,AttributeValue:Y.attributeValue,Is:Y.definitionOperator,"EntityReference CharacterReference":Y.character,Comment:Y.blockComment,ProcessingInst:Y.processingInstruction,DoctypeDecl:Y.documentMeta,Cdata:Y.special(Y.string)}),Zy=tv.deserialize({version:14,states:",lOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DT'#DTOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QOOOP,59Q,59QOOOO'#Cx'#CxO#mOpO,59TO#uO!bO,59TOOOP'#C|'#C|O$TOaO,59RO$[OpO'#CoOOOP,59R,59ROOOQ'#C}'#C}O$dOrO,59^OOOP,59^,59^OOOS'#DO'#DOO$lOtO,59_OOOP,59_,59_O$tOpO,59`O$|OpO,59`OOOP-E6t-E6tOOOW-E6u-E6uOOOP1G.l1G.lOOOO-E6v-E6vO%UO!bO1G.oO%UO!bO1G.oO%dOpO'#CkO%lO!bO'#CyO%zO!bO1G.oOOOP1G.o1G.oOOOP1G.w1G.wOOOP-E6z-E6zOOOP1G.m1G.mO&VOpO,59ZO&_OpO,59ZOOOQ-E6{-E6{OOOP1G.x1G.xOOOS-E6|-E6|OOOP1G.y1G.yO&gOpO1G.zO&gOpO1G.zOOOP1G.z1G.zO&oO!bO7+$ZO&}O!bO7+$ZOOOP7+$Z7+$ZOOOP7+$c7+$cO'YOpO,59VO'bOpO,59VO'mO!bO,59eOOOO-E6w-E6wO'{OpO1G.uO'{OpO1G.uOOOP1G.u1G.uO(TOpO7+$fOOOP7+$f7+$fO(]O!bO<<GuOOOP<<Gu<<GuOOOP<<G}<<G}O'bOpO1G.qO'bOpO1G.qO(hO#tO'#CnO(vO&jO'#CnOOOO1G.q1G.qO)UOpO7+$aOOOP7+$a7+$aOOOP<<HQ<<HQOOOPAN=aAN=aOOOPAN=iAN=iO'bOpO7+$]OOOO7+$]7+$]OOOO'#Cz'#CzO)^O#tO,59YOOOO,59Y,59YOOOO'#C{'#C{O)lO&jO,59YOOOP<<G{<<G{OOOO<<Gw<<GwOOOO-E6x-E6xOOOO1G.t1G.tOOOO-E6y-E6y",stateData:")z~OPQOSVOTWOVWOWWOXWOiXOyPO!QTO!SUO~OvZOx]O~O^`Oz^O~OPQOQcOSVOTWOVWOWWOXWOyPO!QTO!SUO~ORdO~P!SOteO!PgO~OuhO!RjO~O^lOz^O~OvZOxoO~O^qOz^O~O[vO`sOdwOz^O~ORyO~P!SO^{Oz^O~OteO!P}O~OuhO!R!PO~O^!QOz^O~O[!SOz^O~O[!VO`sOd!WOz^O~Oa!YOz^O~Oz^O[mX`mXdmX~O[!VO`sOd!WO~O^!]Oz^O~O[!_Oz^O~O[!aOz^O~O[!cO`sOd!dOz^O~O[!cO`sOd!dO~Oa!eOz^O~Oz^O{!gO}!hO~Oz^O[ma`madma~O[!kOz^O~O[!lOz^O~O[!mO`sOd!nO~OW!qOX!qO{!sO|!qO~OW!tOX!tO}!sO!O!tO~O[!vOz^O~OW!qOX!qO{!yO|!qO~OW!tOX!tO}!yO!O!tO~O",goto:"%cxPPPPPPPPPPyyP!PP!VPP!`!jP!pyyyP!v!|#S$[$k$q$w$}%TPPPP%ZXWORYbXRORYb_t`qru!T!U!bQ!i!YS!p!e!fR!w!oQdRRybXSORYbQYORmYQ[PRn[Q_QQkVjp_krz!R!T!X!Z!^!`!f!j!oQr`QzcQ!RlQ!TqQ!XsQ!ZtQ!^{Q!`!QQ!f!YQ!j!]R!o!eQu`S!UqrU![u!U!bR!b!TQ!r!gR!x!rQ!u!hR!z!uQbRRxbQfTR|fQiUR!OiSXOYTaRb",nodeNames:`⚠ StartTag StartCloseTag MissingCloseTag StartCloseTag StartCloseTag Document Text EntityReference CharacterReference Cdata Element EndTag OpenTag TagName Attribute AttributeName Is AttributeValue CloseTag SelfCloseEndTag SelfClosingTag Comment ProcessingInst MismatchedCloseTag DoctypeDecl`,maxTerm:50,context:Wy,nodeProps:[[`closedBy`,1,`SelfCloseEndTag EndTag`,13,`CloseTag MissingCloseTag`],[`openedBy`,12,`StartTag StartCloseTag`,19,`OpenTag`,20,`StartTag`],[`isolate`,-6,13,18,19,21,22,24,``]],propSources:[Xy],skippedNodes:[0],repeatNodeCount:9,tokenData:"!)v~R!YOX$qXY)iYZ)iZ]$q]^)i^p$qpq)iqr$qrs*vsv$qvw+fwx/ix}$q}!O0[!O!P$q!P!Q2z!Q![$q![!]4n!]!^$q!^!_8U!_!`!#t!`!a!$l!a!b!%d!b!c$q!c!}4n!}#P$q#P#Q!'W#Q#R$q#R#S4n#S#T$q#T#o4n#o%W$q%W%o4n%o%p$q%p&a4n&a&b$q&b1p4n1p4U$q4U4d4n4d4e$q4e$IS4n$IS$I`$q$I`$Ib4n$Ib$Kh$q$Kh%#t4n%#t&/x$q&/x&Et4n&Et&FV$q&FV;'S4n;'S;:j8O;:j;=`)c<%l?&r$q?&r?Ah4n?Ah?BY$q?BY?Mn4n?MnO$qi$zXVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qa%nVVP!O`Ov%gwx&Tx!^%g!^!_&o!_;'S%g;'S;=`'W<%lO%gP&YTVPOv&Tw!^&T!_;'S&T;'S;=`&i<%lO&TP&lP;=`<%l&T`&tS!O`Ov&ox;'S&o;'S;=`'Q<%lO&o`'TP;=`<%l&oa'ZP;=`<%l%gX'eWVP|WOr'^rs&Tsv'^w!^'^!^!_'}!_;'S'^;'S;=`(i<%lO'^W(ST|WOr'}sv'}w;'S'};'S;=`(c<%lO'}W(fP;=`<%l'}X(lP;=`<%l'^h(vV|W!O`Or(ors&osv(owx'}x;'S(o;'S;=`)]<%lO(oh)`P;=`<%l(oi)fP;=`<%l$qo)t`VP|W!O`zUOX$qXY)iYZ)iZ]$q]^)i^p$qpq)iqr$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk+PV{YVP!O`Ov%gwx&Tx!^%g!^!_&o!_;'S%g;'S;=`'W<%lO%g~+iast,n![!]-r!c!}-r#R#S-r#T#o-r%W%o-r%p&a-r&b1p-r4U4d-r4e$IS-r$I`$Ib-r$Kh%#t-r&/x&Et-r&FV;'S-r;'S;:j/c?&r?Ah-r?BY?Mn-r~,qQ!Q![,w#l#m-V~,zQ!Q![,w!]!^-Q~-VOX~~-YR!Q![-c!c!i-c#T#Z-c~-fS!Q![-c!]!^-Q!c!i-c#T#Z-c~-ug}!O-r!O!P-r!Q![-r![!]-r!]!^/^!c!}-r#R#S-r#T#o-r$}%O-r%W%o-r%p&a-r&b1p-r1p4U-r4U4d-r4e$IS-r$I`$Ib-r$Je$Jg-r$Kh%#t-r&/x&Et-r&FV;'S-r;'S;:j/c?&r?Ah-r?BY?Mn-r~/cOW~~/fP;=`<%l-rk/rW}bVP|WOr'^rs&Tsv'^w!^'^!^!_'}!_;'S'^;'S;=`(i<%lO'^k0eZVP|W!O`Or$qrs%gsv$qwx'^x}$q}!O1W!O!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk1aZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a2S!a;'S$q;'S;=`)c<%lO$qk2_X!PQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qm3TZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a3v!a;'S$q;'S;=`)c<%lO$qm4RXdSVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qo4{!P`S^QVP|W!O`Or$qrs%gsv$qwx'^x}$q}!O4n!O!P4n!P!Q$q!Q![4n![!]4n!]!^$q!^!_(o!_!c$q!c!}4n!}#R$q#R#S4n#S#T$q#T#o4n#o$}$q$}%O4n%O%W$q%W%o4n%o%p$q%p&a4n&a&b$q&b1p4n1p4U4n4U4d4n4d4e$q4e$IS4n$IS$I`$q$I`$Ib4n$Ib$Je$q$Je$Jg4n$Jg$Kh$q$Kh%#t4n%#t&/x$q&/x&Et4n&Et&FV$q&FV;'S4n;'S;:j8O;:j;=`)c<%l?&r$q?&r?Ah4n?Ah?BY$q?BY?Mn4n?MnO$qo8RP;=`<%l4ni8]Y|W!O`Oq(oqr8{rs&osv(owx'}x!a(o!a!b!#U!b;'S(o;'S;=`)]<%lO(oi9S_|W!O`Or(ors&osv(owx'}x}(o}!O:R!O!f(o!f!g;e!g!}(o!}#ODh#O#W(o#W#XLp#X;'S(o;'S;=`)]<%lO(oi:YX|W!O`Or(ors&osv(owx'}x}(o}!O:u!O;'S(o;'S;=`)]<%lO(oi;OV!QP|W!O`Or(ors&osv(owx'}x;'S(o;'S;=`)]<%lO(oi;lX|W!O`Or(ors&osv(owx'}x!q(o!q!r<X!r;'S(o;'S;=`)]<%lO(oi<`X|W!O`Or(ors&osv(owx'}x!e(o!e!f<{!f;'S(o;'S;=`)]<%lO(oi=SX|W!O`Or(ors&osv(owx'}x!v(o!v!w=o!w;'S(o;'S;=`)]<%lO(oi=vX|W!O`Or(ors&osv(owx'}x!{(o!{!|>c!|;'S(o;'S;=`)]<%lO(oi>jX|W!O`Or(ors&osv(owx'}x!r(o!r!s?V!s;'S(o;'S;=`)]<%lO(oi?^X|W!O`Or(ors&osv(owx'}x!g(o!g!h?y!h;'S(o;'S;=`)]<%lO(oi@QY|W!O`Or?yrs@psv?yvwA[wxBdx!`?y!`!aCr!a;'S?y;'S;=`Db<%lO?ya@uV!O`Ov@pvxA[x!`@p!`!aAy!a;'S@p;'S;=`B^<%lO@pPA_TO!`A[!`!aAn!a;'SA[;'S;=`As<%lOA[PAsOiPPAvP;=`<%lA[aBQSiP!O`Ov&ox;'S&o;'S;=`'Q<%lO&oaBaP;=`<%l@pXBiX|WOrBdrsA[svBdvwA[w!`Bd!`!aCU!a;'SBd;'S;=`Cl<%lOBdXC]TiP|WOr'}sv'}w;'S'};'S;=`(c<%lO'}XCoP;=`<%lBdiC{ViP|W!O`Or(ors&osv(owx'}x;'S(o;'S;=`)]<%lO(oiDeP;=`<%l?yiDoZ|W!O`Or(ors&osv(owx'}x!e(o!e!fEb!f#V(o#V#WIr#W;'S(o;'S;=`)]<%lO(oiEiX|W!O`Or(ors&osv(owx'}x!f(o!f!gFU!g;'S(o;'S;=`)]<%lO(oiF]X|W!O`Or(ors&osv(owx'}x!c(o!c!dFx!d;'S(o;'S;=`)]<%lO(oiGPX|W!O`Or(ors&osv(owx'}x!v(o!v!wGl!w;'S(o;'S;=`)]<%lO(oiGsX|W!O`Or(ors&osv(owx'}x!c(o!c!dH`!d;'S(o;'S;=`)]<%lO(oiHgX|W!O`Or(ors&osv(owx'}x!}(o!}#OIS#O;'S(o;'S;=`)]<%lO(oiI]V|W!O`yPOr(ors&osv(owx'}x;'S(o;'S;=`)]<%lO(oiIyX|W!O`Or(ors&osv(owx'}x#W(o#W#XJf#X;'S(o;'S;=`)]<%lO(oiJmX|W!O`Or(ors&osv(owx'}x#T(o#T#UKY#U;'S(o;'S;=`)]<%lO(oiKaX|W!O`Or(ors&osv(owx'}x#h(o#h#iK|#i;'S(o;'S;=`)]<%lO(oiLTX|W!O`Or(ors&osv(owx'}x#T(o#T#UH`#U;'S(o;'S;=`)]<%lO(oiLwX|W!O`Or(ors&osv(owx'}x#c(o#c#dMd#d;'S(o;'S;=`)]<%lO(oiMkX|W!O`Or(ors&osv(owx'}x#V(o#V#WNW#W;'S(o;'S;=`)]<%lO(oiN_X|W!O`Or(ors&osv(owx'}x#h(o#h#iNz#i;'S(o;'S;=`)]<%lO(oi! RX|W!O`Or(ors&osv(owx'}x#m(o#m#n! n#n;'S(o;'S;=`)]<%lO(oi! uX|W!O`Or(ors&osv(owx'}x#d(o#d#e!!b#e;'S(o;'S;=`)]<%lO(oi!!iX|W!O`Or(ors&osv(owx'}x#X(o#X#Y?y#Y;'S(o;'S;=`)]<%lO(oi!#_V!SP|W!O`Or(ors&osv(owx'}x;'S(o;'S;=`)]<%lO(ok!$PXaQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qo!$wX[UVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk!%mZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a!&`!a;'S$q;'S;=`)c<%lO$qk!&kX!RQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$qk!'aZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_#P$q#P#Q!(S#Q;'S$q;'S;=`)c<%lO$qk!(]ZVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_!`$q!`!a!)O!a;'S$q;'S;=`)c<%lO$qk!)ZXxQVP|W!O`Or$qrs%gsv$qwx'^x!^$q!^!_(o!_;'S$q;'S;=`)c<%lO$q",tokenizers:[Gy,qy,Jy,Yy,0,1,2,3,4],topRules:{Document:[0,6]},tokenPrec:0});function Qy(e,t){let n=t&&t.getChild(`TagName`);return n?e.sliceString(n.from,n.to):``}function $y(e,t){let n=t&&t.firstChild;return!n||n.name!=`OpenTag`?``:Qy(e,n)}function eb(e,t,n){let r=t&&t.getChildren(`Attribute`).find(e=>e.from<=n&&e.to>=n),i=r&&r.getChild(`AttributeName`);return i?e.sliceString(i.from,i.to):``}function tb(e){for(let t=e&&e.parent;t;t=t.parent)if(t.name==`Element`)return t;return null}function nb(e,t){let n=X(e).resolveInner(t,-1),r=null;for(let e=n;!r&&e.parent;e=e.parent)(e.name==`OpenTag`||e.name==`CloseTag`||e.name==`SelfClosingTag`||e.name==`MismatchedCloseTag`)&&(r=e);if(r&&(r.to>t||r.lastChild.type.isError)){let e=r.parent;if(n.name==`TagName`)return r.name==`CloseTag`||r.name==`MismatchedCloseTag`?{type:`closeTag`,from:n.from,context:e}:{type:`openTag`,from:n.from,context:tb(e)};if(n.name==`AttributeName`)return{type:`attrName`,from:n.from,context:r};if(n.name==`AttributeValue`)return{type:`attrValue`,from:n.from,context:r};let i=n==r||n.name==`Attribute`?n.childBefore(t):n;return i?.name==`StartTag`?{type:`openTag`,from:t,context:tb(e)}:i?.name==`StartCloseTag`&&i.to<=t?{type:`closeTag`,from:t,context:e}:i?.name==`Is`?{type:`attrValue`,from:t,context:r}:i?{type:`attrName`,from:t,context:r}:null}if(n.name==`StartCloseTag`)return{type:`closeTag`,from:t,context:n.parent};for(;n.parent&&n.to==t&&!n.lastChild?.type.isError;)n=n.parent;return n.name==`Element`||n.name==`Text`||n.name==`Document`?{type:`tag`,from:t,context:n.name==`Element`?n:tb(n)}:null}var rb=class{constructor(e,t,n){this.attrs=t,this.attrValues=n,this.children=[],this.name=e.name,this.completion=Object.assign(Object.assign({type:`type`},e.completion||{}),{label:this.name}),this.openCompletion=Object.assign(Object.assign({},this.completion),{label:`<`+this.name}),this.closeCompletion=Object.assign(Object.assign({},this.completion),{label:`</`+this.name+`>`,boost:2}),this.closeNameCompletion=Object.assign(Object.assign({},this.completion),{label:this.name+`>`}),this.text=e.textContent?e.textContent.map(e=>({label:e,type:`text`})):[]}},ib=/^[:\-\.\w\u00b7-\uffff]*$/;function ab(e){return Object.assign(Object.assign({type:`property`},e.completion||{}),{label:e.name})}function ob(e){return typeof e==`string`?{label:`"${e}"`,type:`constant`}:/^"/.test(e.label)?e:Object.assign(Object.assign({},e),{label:`"${e.label}"`})}function sb(e,t){let n=[],r=[],i=Object.create(null);for(let e of t){let t=ab(e);n.push(t),e.global&&r.push(t),e.values&&(i[e.name]=e.values.map(ob))}let a=[],o=[],s=Object.create(null);for(let t of e){let e=r,c=i;t.attributes&&(e=e.concat(t.attributes.map(e=>typeof e==`string`?n.find(t=>t.label==e)||{label:e,type:`property`}:(e.values&&(c==i&&(c=Object.create(c)),c[e.name]=e.values.map(ob)),ab(e)))));let l=new rb(t,e,c);s[l.name]=l,a.push(l),t.top&&o.push(l)}o.length||(o=a);for(let t=0;t<a.length;t++){let n=e[t],r=a[t];if(n.children)for(let e of n.children)s[e]&&r.children.push(s[e]);else r.children=a}return e=>{let{doc:t}=e.state,n=nb(e.state,e.pos);if(!n||n.type==`tag`&&!e.explicit)return null;let{type:c,from:l,context:u}=n;if(c==`openTag`){let e=o,n=$y(t,u);return n&&(e=s[n]?.children||a),{from:l,options:e.map(e=>e.completion),validFor:ib}}if(c==`closeTag`){let n=$y(t,u);return n?{from:l,to:e.pos+ +(t.sliceString(e.pos,e.pos+1)==`>`),options:[s[n]?.closeNameCompletion||{label:n+`>`,type:`type`}],validFor:ib}:null}if(c==`attrName`)return{from:l,options:s[Qy(t,u)]?.attrs||r,validFor:ib};if(c==`attrValue`){let n=eb(t,u,l);if(!n)return null;let r=(s[Qy(t,u)]?.attrValues||i)[n];return!r||!r.length?null:{from:l,to:e.pos+ +(t.sliceString(e.pos,e.pos+1)==`"`),options:r,validFor:/^"[^"]*"?$/}}if(c==`tag`){let n=$y(t,u),r=s[n],i=[],c=u&&u.lastChild;n&&(!c||c.name!=`CloseTag`||Qy(t,c)!=n)&&i.push(r?r.closeCompletion:{label:`</`+n+`>`,type:`type`,boost:2});let d=i.concat((r?.children||(u?a:o)).map(e=>e.openCompletion));if(u&&r?.text.length){let t=u.firstChild;t.to>e.pos-20&&!/\S/.test(e.state.sliceDoc(t.to,e.pos))&&(d=d.concat(r.text))}return{from:l,options:d,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}return null}}var cb=$l.define({name:`xml`,parser:Zy.configure({props:[gu.add({Element(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),ju.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!=`OpenTag`?null:{from:t.to,to:n.name==`CloseTag`?n.from:e.to}}}),Cd.add({"OpenTag CloseTag":e=>e.getChild(`TagName`)})]}),languageData:{commentTokens:{block:{open:`<!--`,close:`-->`}},indentOnInput:/^\s*<\/$/}});function lb(e={}){let t=[cb.data.of({autocomplete:sb(e.elements||[],e.attributes||[])})];return e.autoCloseTags!==!1&&t.push(db),new lu(cb,t)}function ub(e,t,n=e.length){if(!t)return``;let r=t.firstChild,i=r&&r.getChild(`TagName`);return i?e.sliceString(i.from,Math.min(i.to,n)):``}var db=W.inputHandler.of((e,t,n,r,i)=>{if(e.composing||e.state.readOnly||t!=n||r!=`>`&&r!=`/`||!cb.isActiveAt(e.state,t,-1))return!1;let a=i(),{state:o}=a,s=o.changeByRange(e=>{let{head:t}=e,n=o.doc.sliceString(t-1,t)==r,i=X(o).resolveInner(t,-1),a;if(n&&r==`>`&&i.name==`EndTag`){let n=i.parent;if(n.parent?.lastChild?.name!=`CloseTag`&&(a=ub(o.doc,n.parent,t)))return{range:e,changes:{from:t,to:t+ +(o.doc.sliceString(t,t+1)===`>`),insert:`</${a}>`}}}else if(n&&r==`/`&&i.name==`StartCloseTag`){let e=i.parent;if(i.from==t-2&&e.lastChild?.name!=`CloseTag`&&(a=ub(o.doc,e,t))){let e=t+ +(o.doc.sliceString(t,t+1)===`>`),n=`${a}>`;return{range:A.cursor(t+n.length,-1),changes:{from:t,to:e,insert:n}}}}return{range:e}});return!s.changes.empty&&(e.dispatch([a,o.update(s,{userEvent:`input.complete`,scrollIntoView:!0})]),!0)}),fb=63,pb=64,mb=1,hb=2,gb=3,_b=4,vb=5,yb=6,bb=7,xb=65,Sb=66,Cb=8,wb=9,Tb=10,Eb=11,Db=12,Ob=13,kb=19,Ab=20,jb=29,Mb=33,Nb=34,Pb=47,Fb=0,Ib=1,Lb=2,Rb=3,zb=4,Bb=class{constructor(e,t,n){this.parent=e,this.depth=t,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n}};Bb.top=new Bb(null,-1,Fb);function Vb(e,t){for(let n=0,r=t-e.pos-1;;r--,n++){let t=e.peek(r);if(Ub(t)||t==-1)return n}}function Hb(e){return e==32||e==9}function Ub(e){return e==10||e==13}function Wb(e){return Hb(e)||Ub(e)}function Gb(e){return e<0||Wb(e)}var Kb=new ev({start:Bb.top,reduce(e,t){return e.type==Rb&&(t==Ab||t==Nb)?e.parent:e},shift(e,t,n,r){if(t==gb)return new Bb(e,Vb(r,r.pos),Ib);if(t==xb||t==vb)return new Bb(e,Vb(r,r.pos),Lb);if(t==fb)return e.parent;if(t==kb||t==Mb)return new Bb(e,0,Rb);if(t==Ob&&e.type==zb)return e.parent;if(t==Pb){let t=/[1-9]/.exec(r.read(r.pos,n.pos));if(t)return new Bb(e,e.depth+ +t[0],zb)}return e},hash(e){return e.hash}});function qb(e,t,n=0){return e.peek(n)==t&&e.peek(n+1)==t&&e.peek(n+2)==t&&Gb(e.peek(n+3))}var Jb=new V_((e,t)=>{if(e.next==-1&&t.canShift(pb))return e.acceptToken(pb);let n=e.peek(-1);if((Ub(n)||n<0)&&t.context.type!=Rb){if(qb(e,45)){if(t.canShift(fb))e.acceptToken(fb);else return e.acceptToken(mb,3)}if(qb(e,46)){if(t.canShift(fb))e.acceptToken(fb);else return e.acceptToken(hb,3)}let n=0;for(;e.next==32;)n++,e.advance();(n<t.context.depth||n==t.context.depth&&t.context.type==Ib&&(e.next!=45||!Gb(e.peek(1))))&&e.next!=-1&&!Ub(e.next)&&e.next!=35&&e.acceptToken(fb,-n)}},{contextual:!0}),Yb=new V_((e,t)=>{if(t.context.type==Rb){e.next==63&&(e.advance(),Gb(e.next)&&e.acceptToken(bb));return}if(e.next==45)e.advance(),Gb(e.next)&&e.acceptToken(t.context.type==Ib&&t.context.depth==Vb(e,e.pos-1)?_b:gb);else if(e.next==63)e.advance(),Gb(e.next)&&e.acceptToken(t.context.type==Lb&&t.context.depth==Vb(e,e.pos-1)?yb:vb);else{let n=e.pos;for(;;)if(Hb(e.next)){if(e.pos==n)return;e.advance()}else if(e.next==33)$b(e);else if(e.next==38)ex(e);else if(e.next==42){ex(e);break}else if(e.next==39||e.next==34){if(tx(e,!0))break;return}else if(e.next==91||e.next==123){if(!nx(e))return;break}else{ox(e,!0,!1,0);break}for(;Hb(e.next);)e.advance();if(e.next==58){if(e.pos==n&&t.canShift(jb))return;Gb(e.peek(1))&&e.acceptTokenTo(t.context.type==Lb&&t.context.depth==Vb(e,n)?Sb:xb,n)}}},{contextual:!0});function Xb(e){return e>32&&e<127&&e!=34&&e!=37&&e!=44&&e!=60&&e!=62&&e!=92&&e!=94&&e!=96&&e!=123&&e!=124&&e!=125}function Zb(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Qb(e,t){return e.next==37?(e.advance(),Zb(e.next)&&e.advance(),Zb(e.next)&&e.advance(),!0):Xb(e.next)||t&&e.next==44?(e.advance(),!0):!1}function $b(e){if(e.advance(),e.next==60){for(e.advance();;)if(!Qb(e,!0)){e.next==62&&e.advance();break}}else for(;Qb(e,!1););}function ex(e){for(e.advance();!Gb(e.next)&&ix(e.next)!=`f`;)e.advance()}function tx(e,t){let n=e.next,r=!1,i=e.pos;for(e.advance();;){let a=e.next;if(a<0)break;if(e.advance(),a==n){if(a==39){if(e.next==39)e.advance();else break}else break}else if(a==92&&n==34)e.next>=0&&e.advance();else if(Ub(a)){if(t)return!1;r=!0}else if(t&&e.pos>=i+1024)return!1}return!r}function nx(e){for(let t=[],n=e.pos+1024;;)if(e.next==91||e.next==123)t.push(e.next),e.advance();else if(e.next==39||e.next==34){if(!tx(e,!0))return!1}else if(e.next==93||e.next==125){if(t[t.length-1]!=e.next-2)return!1;if(t.pop(),e.advance(),!t.length)return!0}else if(e.next<0||e.pos>n||Ub(e.next))return!1;else e.advance()}var rx=`iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif`;function ix(e){return e<33?`u`:e>125?`s`:rx[e-33]}function ax(e,t){let n=ix(e);return n!=`u`&&!(t&&n==`f`)}function ox(e,t,n,r){if(ix(e.next)==`s`||(e.next==63||e.next==58||e.next==45)&&ax(e.peek(1),n))e.advance();else return!1;let i=e.pos;for(;;){let a=e.next,o=0,s=r+1;for(;Wb(a);){if(Ub(a)){if(t)return!1;s=0}else s++;a=e.peek(++o)}if(!(a>=0&&(a==58?ax(e.peek(o+1),n):a==35?e.peek(o-1)!=32:ax(a,n)))||!n&&s<=r||s==0&&!n&&(qb(e,45,o)||qb(e,46,o)))break;if(t&&ix(a)==`f`)return!1;for(let t=o;t>=0;t--)e.advance();if(t&&e.pos>i+1024)return!1}return!0}var sx=new V_((e,t)=>{if(e.next==33)$b(e),e.acceptToken(Db);else if(e.next==38||e.next==42){let t=e.next==38?Tb:Eb;ex(e),e.acceptToken(t)}else e.next==39||e.next==34?(tx(e,!1),e.acceptToken(wb)):ox(e,!1,t.context.type==Rb,t.context.depth)&&e.acceptToken(Cb)}),cx=new V_((e,t)=>{let n=t.context.type==zb?t.context.depth:-1,r=e.pos;scan:for(;;){let i=0,a=e.next;for(;a==32;)a=e.peek(++i);if(!i&&(qb(e,45,i)||qb(e,46,i))||!Ub(a)&&(n<0&&(n=Math.max(t.context.depth+1,i)),i<n))break;for(;;){if(e.next<0)break scan;let t=Ub(e.next);if(e.advance(),t)continue scan;r=e.pos}}e.acceptTokenTo(Ob,r)}),lx=El({DirectiveName:Y.keyword,DirectiveContent:Y.attributeValue,"DirectiveEnd DocEnd":Y.meta,QuotedLiteral:Y.string,BlockLiteralHeader:Y.special(Y.string),BlockLiteralContent:Y.content,Literal:Y.content,"Key/Literal Key/QuotedLiteral":Y.definition(Y.propertyName),"Anchor Alias":Y.labelName,Tag:Y.typeName,Comment:Y.lineComment,": , -":Y.separator,"?":Y.punctuation,"[ ]":Y.squareBracket,"{ }":Y.brace}),ux=tv.deserialize({version:14,states:"5lQ!ZQgOOO#PQfO'#CpO#uQfO'#DOOOQR'#Dv'#DvO$qQgO'#DRO%gQdO'#DUO%nQgO'#DUO&ROaO'#D[OOQR'#Du'#DuO&{QgO'#D^O'rQgO'#D`OOQR'#Dt'#DtO(iOqO'#DbOOQP'#Dj'#DjO(zQaO'#CmO)YQgO'#CmOOQP'#Cm'#CmQ)jQaOOQ)uQgOOQ]QgOOO*PQdO'#CrO*nQdO'#CtOOQO'#Dw'#DwO+]Q`O'#CxO+hQdO'#CwO+rQ`O'#CwOOQO'#Cv'#CvO+wQdO'#CvOOQO'#Cq'#CqO,UQ`O,59[O,^QfO,59[OOQR,59[,59[OOQO'#Cx'#CxO,eQ`O'#DPO,pQdO'#DPOOQO'#Dx'#DxO,zQdO'#DxO-XQ`O,59jO-aQfO,59jOOQR,59j,59jOOQR'#DS'#DSO-hQcO,59mO-sQgO'#DVO.TQ`O'#DVO.YQcO,59pOOQR'#DX'#DXO#|QfO'#DWO.hQcO'#DWOOQR,59v,59vO.yOWO,59vO/OOaO,59vO/WOaO,59vO/cQgO'#D_OOQR,59x,59xO0VQgO'#DaOOQR,59z,59zOOQP,59|,59|O0yOaO,59|O1ROaO,59|O1aOqO,59|OOQP-E7h-E7hO1oQgO,59XOOQP,59X,59XO2PQaO'#DeO2_QgO'#DeO2oQgO'#DkOOQP'#Dk'#DkQ)jQaOOO3PQdO'#CsOOQO,59^,59^O3kQdO'#CuOOQO,59`,59`OOQO,59c,59cO4VQdO,59cO4aQdO'#CzO4kQ`O'#CzOOQO,59b,59bOOQU,5:Q,5:QOOQR1G.v1G.vO4pQ`O1G.vOOQU-E7d-E7dO4xQdO,59kOOQO,59k,59kO5SQdO'#DQO5^Q`O'#DQOOQO,5:d,5:dOOQU,5:R,5:ROOQR1G/U1G/UO5cQ`O1G/UOOQU-E7e-E7eO5kQgO'#DhO5xQcO1G/XOOQR1G/X1G/XOOQR,59q,59qO6TQgO,59qO6eQdO'#DiO6lQgO'#DiO7PQcO1G/[OOQR1G/[1G/[OOQR,59r,59rO#|QfO,59rOOQR1G/b1G/bO7_OWO1G/bO7dOaO1G/bOOQR,59y,59yOOQR,59{,59{OOQP1G/h1G/hO7lOaO1G/hO7tOaO1G/hO8POaO1G/hOOQP1G.s1G.sO8_QgO,5:POOQP,5:P,5:POOQP,5:V,5:VOOQP-E7i-E7iOOQO,59_,59_OOQO,59a,59aOOQO1G.}1G.}OOQO,59f,59fO8oQdO,59fOOQR7+$b7+$bP,XQ`O'#DfOOQO1G/V1G/VOOQO,59l,59lO8yQdO,59lOOQR7+$p7+$pP9TQ`O'#DgOOQR'#DT'#DTOOQR,5:S,5:SOOQR-E7f-E7fOOQR7+$s7+$sOOQR1G/]1G/]O9YQgO'#DYO9jQ`O'#DYOOQR,5:T,5:TO#|QfO'#DZO9oQcO'#DZOOQR-E7g-E7gOOQR7+$v7+$vOOQR1G/^1G/^OOQR7+$|7+$|O:QOWO7+$|OOQP7+%S7+%SO:VOaO7+%SO:_OaO7+%SOOQP1G/k1G/kOOQO1G/Q1G/QOOQO1G/W1G/WOOQR,59t,59tO:jQgO,59tOOQR,59u,59uO#|QfO,59uOOQR<<Hh<<HhOOQP<<Hn<<HnO:zOaO<<HnOOQR1G/`1G/`OOQR1G/a1G/aOOQPAN>YAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:`⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document`,maxTerm:74,context:Kb,nodeProps:[[`isolate`,-3,8,9,14,``],[`openedBy`,18,`[`,32,`{`],[`closedBy`,19,`]`,33,`}`]],propSources:[lx],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Jb,Yb,sx,cx,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),dx=$l.define({name:`yaml`,parser:ux.configure({props:[gu.add({Stream:e=>{for(let t=e.node.resolve(e.pos,-1);t&&t.to>=e.pos;t=t.parent){if(t.name==`BlockLiteralContent`&&t.from<t.to)return e.baseIndentFor(t);if(t.name==`BlockLiteral`)return e.baseIndentFor(t)+e.unit;if(t.name==`BlockSequence`||t.name==`BlockMapping`)return e.column(t.firstChild.from,1);if(t.name==`QuotedLiteral`)return null;if(t.name==`Literal`){let n=e.column(t.from,1);if(n==e.lineIndent(t.from,1))return n;if(t.to>e.pos)return null}}return null},FlowMapping:Tu({closing:`}`}),FlowSequence:Tu({closing:`]`})}),ju.add({"FlowMapping FlowSequence":Mu,"Item Pair BlockLiteral":(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}),languageData:{commentTokens:{line:`#`},indentOnInput:/^\s*[\]\}]$/}});function fx(){return new lu(dx)}Y.meta;var px=[[`plantuml`,`PlantUML`],[`mermaid`,`Mermaid`],[`graphviz`,`GraphViz`],[`d2`,`D2`],[`c4plantuml`,`C4 PlantUML`],[`blockdiag`,`BlockDiag`],[`seqdiag`,`SeqDiag`],[`actdiag`,`ActDiag`],[`nwdiag`,`NwDiag`],[`packetdiag`,`PacketDiag`],[`rackdiag`,`RackDiag`],[`bpmn`,`BPMN`],[`bytefield`,`Bytefield`],[`dbml`,`DBML`],[`diagramsnet`,`Diagrams.net`],[`ditaa`,`Ditaa`],[`erd`,`ERD`],[`excalidraw`,`Excalidraw`],[`goat`,`GoAT`],[`nomnoml`,`Nomnoml`],[`pikchr`,`Pikchr`],[`structurizr`,`Structurizr`],[`svgbob`,`Svgbob`],[`symbolator`,`Symbolator`],[`tikz`,`TikZ`],[`umlet`,`UMLet`],[`vega`,`Vega`],[`vegalite`,`Vega-Lite`],[`wavedrom`,`WaveDrom`],[`wireviz`,`WireViz`]].map(([e,t])=>({id:e,label:t})),mx=new Set(`actor.alt.and.as.class.component.database.direction.else.end.endnote.endif.endwhile.flowchart.graph.group.if.interface.loop.namespace.node.note.package.participant.rectangle.return.skinparam.start.state.stop.subgraph.then.title.while`.split(`.`)),hx=Pd.define({startState:()=>({blockComment:!1}),token(e,t){return t.blockComment?(e.skipTo(`*/`)?(e.match(`*/`),t.blockComment=!1):e.skipToEnd(),`blockComment`):e.match(`/*`)?(t.blockComment=!0,`blockComment`):e.match(/^\s*(?:%%|\/\/|'|#).*/)?`lineComment`:e.match(/^@(?:start|end)[a-z0-9_]*/i)?`keyword`:e.match(/^"(?:[^"\\]|\\.)*"/)?`string`:e.match(/^(?:--?>|<--?|==>|<==|\.\.>|<\.\.|->|<-|=>|<=|--|\.\.)/)?`operator`:e.match(/^#[0-9a-f]{3,8}\b/i)?`color`:e.match(/^\b\d+(?:\.\d+)?\b/)?`number`:e.match(/^\b[a-z_][\w-]*\b/i)?mx.has(e.current().toLowerCase())?`keyword`:`variableName`:(e.next(),null)}}),gx=new Set([`bytefield`,`excalidraw`,`vega`,`vegalite`,`wavedrom`]),_x=new Set([`bpmn`,`diagramsnet`,`umlet`]);function vx(e){return gx.has(e)?cv():_x.has(e)?lb():e===`wireviz`?fx():e===`dbml`?wy():hx}function yx(e){return px.some(t=>t.id===e)}var bx=`<?xml version="1.0" encoding="UTF-8"?>16+<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:qa="http://some-company/schema/bpmn/qa" id="_RdgBELNaEeSYkoSLDs6j-w" targetNamespace="http://activiti.org/bpmn">17+ <bpmn2:process id="Process_1">18+ <bpmn2:task id="Task_1" name="Examine Situation" qa:suitable="0.7">19+ <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>20+ <bpmn2:extensionElements>21+ <qa:analysisDetails lastChecked="2015-01-20" nextCheck="2015-07-15">22+ <qa:comment author="Klaus">23+ Our operators always have a hard time to figure out, what they need to do here.24+ </qa:comment>25+ <qa:comment author="Walter">26+ I believe this can be split up in a number of activities and partly automated.27+ </qa:comment>28+ </qa:analysisDetails>29+ </bpmn2:extensionElements>30+ </bpmn2:task>31+ <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="Task_1" targetRef="ExclusiveGateway_1"/>32+ <bpmn2:exclusiveGateway id="ExclusiveGateway_1" name="Things OK?">33+ <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>34+ <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>35+ <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing>36+ </bpmn2:exclusiveGateway>37+ <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_1"/>38+ <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ExclusiveGateway_1" targetRef="EndEvent_2"/>39+ <bpmn2:endEvent id="EndEvent_1" name="Notification Sent">40+ <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>41+ <bpmn2:messageEventDefinition id="MessageEventDefinition_1"/>42+ </bpmn2:endEvent>43+ <bpmn2:endEvent id="EndEvent_2" name="Error Propagated">44+ <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming>45+ <bpmn2:errorEventDefinition id="ErrorEventDefinition_1"/>46+ </bpmn2:endEvent>47+ </bpmn2:process>48+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">49+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">50+ <bpmndi:BPMNShape id="_BPMNShape_Task_2" bpmnElement="Task_1">51+ <dc:Bounds height="80.0" width="100.0" x="96.0" y="196.0"/>52+ </bpmndi:BPMNShape>53+ <bpmndi:BPMNShape id="_BPMNShape_EndEvent_2" bpmnElement="EndEvent_1">54+ <dc:Bounds height="36.0" width="36.0" x="396.0" y="300.0"/>55+ <bpmndi:BPMNLabel>56+ <dc:Bounds height="0.0" width="0.0" x="414.0" y="341.0"/>57+ </bpmndi:BPMNLabel>58+ </bpmndi:BPMNShape>59+ <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_2" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true">60+ <dc:Bounds height="50.0" width="50.0" x="276.0" y="210.0"/>61+ <bpmndi:BPMNLabel>62+ <dc:Bounds height="21.0" width="74.0" x="333.0" y="226.0"/>63+ </bpmndi:BPMNLabel>64+ </bpmndi:BPMNShape>65+ <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_Task_2" targetElement="_BPMNShape_ExclusiveGateway_2">66+ <di:waypoint xsi:type="dc:Point" x="196.0" y="236.0"/>67+ <di:waypoint xsi:type="dc:Point" x="276.0" y="235.0"/>68+ <bpmndi:BPMNLabel>69+ <dc:Bounds height="6.0" width="6.0" x="214.0" y="236.0"/>70+ </bpmndi:BPMNLabel>71+ </bpmndi:BPMNEdge>72+ <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ExclusiveGateway_2" targetElement="_BPMNShape_EndEvent_2">73+ <di:waypoint xsi:type="dc:Point" x="301.0" y="260.0"/>74+ <di:waypoint xsi:type="dc:Point" x="301.0" y="318.0"/>75+ <di:waypoint xsi:type="dc:Point" x="396.0" y="318.0"/>76+ <bpmndi:BPMNLabel>77+ <dc:Bounds height="6.0" width="6.0" x="298.0" y="301.0"/>78+ </bpmndi:BPMNLabel>79+ </bpmndi:BPMNEdge>80+ <bpmndi:BPMNShape id="_BPMNShape_EndEvent_3" bpmnElement="EndEvent_2">81+ <dc:Bounds height="36.0" width="36.0" x="396.0" y="132.0"/>82+ <bpmndi:BPMNLabel>83+ <dc:Bounds height="0.0" width="0.0" x="414.0" y="173.0"/>84+ </bpmndi:BPMNLabel>85+ </bpmndi:BPMNShape>86+ <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ExclusiveGateway_2" targetElement="_BPMNShape_EndEvent_3">87+ <di:waypoint xsi:type="dc:Point" x="301.0" y="210.0"/>88+ <di:waypoint xsi:type="dc:Point" x="301.0" y="150.0"/>89+ <di:waypoint xsi:type="dc:Point" x="396.0" y="150.0"/>90+ <bpmndi:BPMNLabel>91+ <dc:Bounds height="6.0" width="6.0" x="333.0" y="150.0"/>92+ </bpmndi:BPMNLabel>93+ </bpmndi:BPMNEdge>94+ </bpmndi:BPMNPlane>95+ </bpmndi:BPMNDiagram>96+</bpmn2:definitions>97+`,xx=`(draw-column-headers)98+(draw-box "Address" {:span 4})99+(draw-box "Size" {:span 2})100+(draw-box 0 {:span 2})101+(draw-gap "Payload")102+(draw-bottom)103+`,Sx=`dogs -> cats -> mice: chase104+replica 1 <-> replica 2105+a -> b: To err is human, to moo bovine {106+ style.animated: true107+ source-arrowhead: 1108+ target-arrowhead: * {109+ shape: diamond110+ }111+}112+`,Cx=`Table users {113+ id integer114+ username varchar115+ role varchar116+ created_at timestamp117+}118+119+Table posts {120+ id integer [primary key]121+ title varchar122+ body text [note: 'Content of the post']123+ user_id integer124+ status post_status125+ created_at timestamp126+}127+128+Enum post_status {129+ draft130+ published131+ private [note: 'visible via URL only']132+}133+134+Ref: posts.user_id > users.id // many-to-one135+`,wx=`<mxfile host="localhost" modified="2021-05-13T15:13:49.065Z" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36" etag="wSTZ0NLKJqQDPf-wjMNB" version="@DRAWIO-VERSION@" type="device"><diagram id="3228e29e-7158-1315-38df-8450db1d8a1d" name="Page-1">3VpdU+s4DP01PK5HtiTLfmwL3H3ZJ3Zmn0Mb2s4tTSeEBfbXr0LT2wbncvkI7WYDMzSy3CTnyEeSwxlObh+/ldlm8Ucxy1dnDmaPZ3h+5pwlCPqntjxtLUKNYV4uZ43T3nC1/CdvjNBY75ez/K7lWBXFqlpu2sZpsV7n06ply8qyeGi73RSr9lU32TxPDFfTbJVa/1rOqkVjtT7uB37Pl/NFc+ngZDtwnU2/z8vift1cb12s8+3Ibbb7muYZ7xbZrHg4MOHFGU7Koqi2n24fJ/mqhnWH2Hbe5U9Gf9xyma+rt0xwlqmZ9He2um+evLm36mkHhU5S1PVk/LBYVvnVJpvWIw9KvNrKosqqZbFWy28IarhZrlaTYlWUz7PxEoIAq73QecuqDgdfu91VZfE93zk+o4TjRXW70jOrH9OH2d1qXlb544GpebhveXGbV+WTujSj6MAgWYsueI8hNAw1EenYG+/QEgs7jLaJz4c92zrFQAAOzlvhgNFvXRYHvFv9FhSOFAOCOAqNT9bE3/zHXe2J0A8NFz/nxfXIi0VOebkI7PUqp+DFW2fIO6+/7NFjygt7G0J0IZLeJSbE2MgmgKOamaAnMeXFARknMQrqohUl0fbDC36Wlxc0uEsey+QkNDBYDd0YrUdG8YDU5gHZOOuDJ3ZgrfPp+hDoWBAE/SBNPSNt3Wg0fqsQHa4e7h15wmgsB+s9K7awg/ZpB6s1KkkcKIJlQKAEeRetcQREEFXYkEQ6iHA9EcF9pgjqSBGCfjIKJ1kDpBIfiFBCtFFUcNpMeDQYFGjkCACRO4hgQ6A5RKcCk0TqIALEuEBWPFJEiNH1w4tPeBklxCgMVY1kDex6/mexqTl4zgbFurpq/GB3vq3CLLVhrocOE/rz0RP84gy3IbdBARUBDwGDIHfITofq9BXrkmA6HhqmwvACUw1Qzaiq7xIFNBKjHBXTkGA6GRqmAYLRYkUlNWrVwbEt2FpenjJmY4Lv+dDw9ULtUqQdvwLGa65UB4xoO2T4C+FlSOC9GBq8TIkkxHaN4Y4qCZx2naPBaQIzGZF6wQNq+xjbpYPKrDlunKYd43hwmIrnpB44pbZy2u6Nhoeqd+EVdXXxpAinbd54MjiB1S75FYQRgxGwQThErjeLjgpw2r6N/2/4hlPWt5z2YePhFWBRO12P2gVLBPL2RbWApF2yDb7eM6r37Y6Kb0dPdj68CE67MutMjBEic0Br/XGrhbQpGw0uaElrLF37pFAK2wD+Remgw0E1g2zUoCXXscH/hQB3dGWDC1ptD14pcYlOKbs+7cvS7a8370t27ErefPDF1bzMZst8z0njccggfy1tCrFhODhebFcwGl06on21hQAdyyLWwrQ/OvY0lfrgg3gR0gN3+eKznKZ9Ybr99hlO8w++9Do2eW0dg1/wRR2rTEtOiFrb67L1tfpRPwSlTWbaDb3v/dcNX8t0aIywN6CwkmZuAXkrJWLIqVoGbbL0x0o/lKQtaprI3/miLMuuPyB8J6WEgA1GrVRBIvlgO7rYIy6TtKlNc/9ndEzQT7MPvDH77yQhYjIuIEBg9BARO8rfX6chdXFgRbkTFUfaFV3voE9P9/9w8zx28A9NePEv</diagram></mxfile>`,Tx=` +--------+136+ | |137+ | User |138+ | |139+ +--------+140+ ^141+ request |142+ v143+ +-------------+144+ | |145+ | Kroki |146+ | |---+147+ +-------------+ |148+ ^ ^ | inflate149+ | | |150+ v +---------+151+ +-------------+152+ | |153+ | Ditaa |154+ | |----+155+ +-------------+ |156+ ^ | process157+ | |158+ +-------+159+`,Ex=`[Person]160+*name161+height162+weight163++birth_location_id164+165+[Location]166+*id167+city168+state169+country170+171+Person *--1 Location172+`,Dx=`{173+ "type": "excalidraw",174+ "version": 2,175+ "source": "https://excalidraw.com",176+ "elements": [177+ {178+ "id": "vWrqOAfkind2qcm7LDAGZ",179+ "type": "ellipse",180+ "x": 414,181+ "y": 237,182+ "width": 214,183+ "height": 214,184+ "angle": 0,185+ "strokeColor": "#000000",186+ "backgroundColor": "#15aabf",187+ "fillStyle": "hachure",188+ "strokeWidth": 1,189+ "strokeStyle": "solid",190+ "roughness": 1,191+ "opacity": 100,192+ "groupIds": [],193+ "strokeSharpness": "sharp",194+ "seed": 1041657908,195+ "version": 120,196+ "versionNonce": 1188004276,197+ "isDeleted": false,198+ "boundElementIds": null199+ },200+ {201+ "id": "rC-02l026X3SWaucOxDw9",202+ "type": "ellipse",203+ "x": 563,204+ "y": 236,205+ "width": 214,206+ "height": 214,207+ "angle": 0,208+ "strokeColor": "#000000",209+ "backgroundColor": "#40c057",210+ "fillStyle": "hachure",211+ "strokeWidth": 1,212+ "strokeStyle": "solid",213+ "roughness": 1,214+ "opacity": 100,215+ "groupIds": [],216+ "strokeSharpness": "sharp",217+ "seed": 476355980,218+ "version": 169,219+ "versionNonce": 830055604,220+ "isDeleted": false,221+ "boundElementIds": null222+ },223+ {224+ "id": "DrhW4ZSEpniMojuzsiqvi",225+ "type": "ellipse",226+ "x": 476,227+ "y": 358,228+ "width": 214,229+ "height": 214,230+ "angle": 0,231+ "strokeColor": "#000000",232+ "backgroundColor": "#7950f2",233+ "fillStyle": "hachure",234+ "strokeWidth": 1,235+ "strokeStyle": "solid",236+ "roughness": 1,237+ "opacity": 100,238+ "groupIds": [],239+ "strokeSharpness": "sharp",240+ "seed": 1966042508,241+ "version": 119,242+ "versionNonce": 1553878324,243+ "isDeleted": false,244+ "boundElementIds": null245+ },246+ {247+ "id": "NMI4ix1W7sQ6z9EDdYwc7",248+ "type": "arrow",249+ "x": 384.12748830144295,250+ "y": 207.60779895196669,251+ "width": 119.87251169855705,252+ "height": 100.39220104803331,253+ "angle": 0,254+ "strokeColor": "#000000",255+ "backgroundColor": "#7950f2",256+ "fillStyle": "hachure",257+ "strokeWidth": 1,258+ "strokeStyle": "solid",259+ "roughness": 1,260+ "opacity": 100,261+ "groupIds": [],262+ "strokeSharpness": "round",263+ "seed": 1656470796,264+ "version": 69,265+ "versionNonce": 1460943500,266+ "isDeleted": false,267+ "boundElementIds": null,268+ "points": [269+ [270+ 0,271+ 0272+ ],273+ [274+ 119.87251169855705,275+ 100.39220104803331276+ ]277+ ],278+ "lastCommittedPoint": null,279+ "startBinding": {280+ "elementId": "3J8-URSbMsKSvZ2TvCc3K",281+ "focus": 0.2594107757283838,282+ "gap": 7.607798951966686283+ },284+ "endBinding": null285+ },286+ {287+ "id": "QixLrxvPLw7TbG6VJJ9dj",288+ "type": "arrow",289+ "x": 652.9917772874236,290+ "y": 609.5185939229559,291+ "width": 61.74239993095398,292+ "height": 105.02421977738851,293+ "angle": 0,294+ "strokeColor": "#000000",295+ "backgroundColor": "#40c057",296+ "fillStyle": "hachure",297+ "strokeWidth": 1,298+ "strokeStyle": "solid",299+ "roughness": 1,300+ "opacity": 100,301+ "groupIds": [],302+ "strokeSharpness": "round",303+ "seed": 738941452,304+ "version": 107,305+ "versionNonce": 1655140148,306+ "isDeleted": false,307+ "boundElementIds": null,308+ "points": [309+ [310+ 0,311+ 0312+ ],313+ [314+ -61.74239993095398,315+ -105.02421977738851316+ ]317+ ],318+ "lastCommittedPoint": null,319+ "startBinding": {320+ "elementId": "dhyExWoj7pia0unVwtXeL",321+ "focus": 0.1480924722475781,322+ "gap": 8.481406077044085323+ },324+ "endBinding": null325+ },326+ {327+ "id": "LBRnTRdXKmkt5IwhKJLDC",328+ "type": "arrow",329+ "x": 806.9784146802895,330+ "y": 212.38825479040858,331+ "width": 104.97841468028946,332+ "height": 96.61174520959142,333+ "angle": 0,334+ "strokeColor": "#000000",335+ "backgroundColor": "#40c057",336+ "fillStyle": "hachure",337+ "strokeWidth": 1,338+ "strokeStyle": "solid",339+ "roughness": 1,340+ "opacity": 100,341+ "groupIds": [],342+ "strokeSharpness": "round",343+ "seed": 751503500,344+ "version": 69,345+ "versionNonce": 1180701708,346+ "isDeleted": false,347+ "boundElementIds": null,348+ "points": [349+ [350+ 0,351+ 0352+ ],353+ [354+ -104.97841468028946,355+ 96.61174520959142356+ ]357+ ],358+ "lastCommittedPoint": null,359+ "startBinding": {360+ "elementId": "7fiPETvGUweaqK1VIn2zu",361+ "focus": -0.07338204068894764,362+ "gap": 9.388254790408553363+ },364+ "endBinding": null365+ },366+ {367+ "id": "VFSwfD_HsZyf5SBKdiFDz",368+ "type": "arrow",369+ "x": 599.140263160093,370+ "y": 191.4445904184276,371+ "width": 3.62529516014456,372+ "height": 206.31238589940077,373+ "angle": 0.13471642395161876,374+ "strokeColor": "#000000",375+ "backgroundColor": "#40c057",376+ "fillStyle": "hachure",377+ "strokeWidth": 1,378+ "strokeStyle": "solid",379+ "roughness": 1,380+ "opacity": 100,381+ "groupIds": [],382+ "strokeSharpness": "round",383+ "seed": 1721266612,384+ "version": 192,385+ "versionNonce": 1388066444,386+ "isDeleted": false,387+ "boundElementIds": null,388+ "points": [389+ [390+ 0,391+ 0392+ ],393+ [394+ 3.62529516014456,395+ 206.31238589940077396+ ]397+ ],398+ "lastCommittedPoint": null,399+ "startBinding": null,400+ "endBinding": null401+ },402+ {403+ "id": "3J8-URSbMsKSvZ2TvCc3K",404+ "type": "text",405+ "x": 314,406+ "y": 175,407+ "width": 135,408+ "height": 25,409+ "angle": 0,410+ "strokeColor": "#000000",411+ "backgroundColor": "#40c057",412+ "fillStyle": "hachure",413+ "strokeWidth": 1,414+ "strokeStyle": "solid",415+ "roughness": 1,416+ "opacity": 100,417+ "groupIds": [],418+ "strokeSharpness": "sharp",419+ "seed": 1793099060,420+ "version": 43,421+ "versionNonce": 2135655476,422+ "isDeleted": false,423+ "boundElementIds": [424+ "NMI4ix1W7sQ6z9EDdYwc7"425+ ],426+ "text": "want to draw",427+ "fontSize": 20,428+ "fontFamily": 1,429+ "textAlign": "left",430+ "verticalAlign": "top",431+ "baseline": 18432+ },433+ {434+ "id": "7fiPETvGUweaqK1VIn2zu",435+ "type": "text",436+ "x": 782,437+ "y": 178,438+ "width": 89,439+ "height": 25,440+ "angle": 0,441+ "strokeColor": "#000000",442+ "backgroundColor": "#40c057",443+ "fillStyle": "hachure",444+ "strokeWidth": 1,445+ "strokeStyle": "solid",446+ "roughness": 1,447+ "opacity": 100,448+ "groupIds": [],449+ "strokeSharpness": "sharp",450+ "seed": 1750780940,451+ "version": 38,452+ "versionNonce": 1584702860,453+ "isDeleted": false,454+ "boundElementIds": [455+ "LBRnTRdXKmkt5IwhKJLDC"456+ ],457+ "text": "can draw",458+ "fontSize": 20,459+ "fontFamily": 1,460+ "textAlign": "left",461+ "verticalAlign": "top",462+ "baseline": 18463+ },464+ {465+ "id": "dhyExWoj7pia0unVwtXeL",466+ "type": "text",467+ "x": 612,468+ "y": 618,469+ "width": 91,470+ "height": 25,471+ "angle": 0,472+ "strokeColor": "#000000",473+ "backgroundColor": "#40c057",474+ "fillStyle": "hachure",475+ "strokeWidth": 1,476+ "strokeStyle": "solid",477+ "roughness": 1,478+ "opacity": 100,479+ "groupIds": [],480+ "strokeSharpness": "sharp",481+ "seed": 1228201396,482+ "version": 105,483+ "versionNonce": 288443916,484+ "isDeleted": false,485+ "boundElementIds": [486+ "QixLrxvPLw7TbG6VJJ9dj"487+ ],488+ "text": "have time",489+ "fontSize": 20,490+ "fontFamily": 1,491+ "textAlign": "left",492+ "verticalAlign": "top",493+ "baseline": 18494+ },495+ {496+ "id": "PKjjaNpqiOpZQ7kml-d18",497+ "type": "text",498+ "x": 567,499+ "y": 148,500+ "width": 88,501+ "height": 25,502+ "angle": 0,503+ "strokeColor": "#000000",504+ "backgroundColor": "#40c057",505+ "fillStyle": "hachure",506+ "strokeWidth": 1,507+ "strokeStyle": "solid",508+ "roughness": 1,509+ "opacity": 100,510+ "groupIds": [],511+ "strokeSharpness": "sharp",512+ "seed": 152899636,513+ "version": 105,514+ "versionNonce": 1333089972,515+ "isDeleted": false,516+ "boundElementIds": [],517+ "text": "NOT ME!",518+ "fontSize": 20,519+ "fontFamily": 1,520+ "textAlign": "left",521+ "verticalAlign": "top",522+ "baseline": 18523+ }524+ ],525+ "appState": {526+ "viewBackgroundColor": "#ffffff",527+ "gridSize": null528+ }529+}530+`,Ox=`+-------------------+ ^ .---.531+| ‗A Box‗ |__.--.__ __.--> | .-. | |532+| | '--' v | * |<--- | |533++-------------------+ '-' | |534+ \`Round\` *---(-. |535+ .-----------------. .-------. .----------. .-------. | | |536+ | Mixed Rounded | | | / Diagonals \\ | | | | | |537+ | & Square Corners | '--. .--' / \\ |---+---| '-)-' .--------.538+ '--+------------+-' .--. | '-------+--------' | | | | / Search /539+ | | | | '---. | '-------' | '-+------'540+ |<---------->| | | | v Interior | ^541+ ' <---' '----' .-----------. ---. .--- v |542+ .------------------. Diag line | .-------. +---. \\ / . |543+ | if (a > b) +---. .--->| | | | |\`Curved line\` \\ / / \\ |544+ | obj->fcn() | \\ / | '-------' |<--' + / \\ |545+ '------------------' '--' '--+--------' .--. .--. | .-. +Done?+-'546+ .---+-----. | ^ |\\ | | /| .--+ | | \\ /547+ | | | Join \\|/ | | \`Curved\` | \\| |/ | | \\ | \\ /548+ | | +----> o --o-- '-' Vertical '--' '--' '-- '--' + .---.549+ <--+---+-----' | /|\\ | | 3 |550+ v not:line 'quotes' .-' '---'551+ .-. .---+--------. / A || B ·bold· | ^552+ | | | Not a dot | <---+---<-- A dash--is not a line v |553+ '-' '---------+--' / Nor/is this. ---554+`,kx=`[Pirate|eyeCount: Int|raid();pillage()|555+ [beard]--[parrot]556+ [beard]-:>[foul mouth]557+]558+559+[<abstract>Marauder]<:--[Pirate]560+[Pirate]- 0..7[mischief]561+[jollyness]->[Pirate]562+[jollyness]->[rum]563+[jollyness]->[singing]564+[Pirate]-> *[rum|tastiness: Int|swig()]565+[Pirate]->[singing]566+[singing]<->[rum]567+`,Ax=`nwdiag {568+ network dmz {569+ address = "210.x.x.x/24"570+571+ web01 [address = "210.x.x.1"];572+ web02 [address = "210.x.x.2"];573+ }574+ network internal {575+ address = "172.x.x.x/24";576+577+ web01 [address = "172.x.x.1"];578+ web02 [address = "172.x.x.2"];579+ db01;580+ db02;581+ }582+}583+`,jx=`packetdiag {584+ colwidth = 32;585+ node_height = 72;586+587+ 0-15: Source Port;588+ 16-31: Destination Port;589+ 32-63: Sequence Number;590+ 64-95: Acknowledgment Number;591+ 96-99: Data Offset;592+ 100-105: Reserved;593+ 106: URG [rotate = 270];594+ 107: ACK [rotate = 270];595+ 108: PSH [rotate = 270];596+ 109: RST [rotate = 270];597+ 110: SYN [rotate = 270];598+ 111: FIN [rotate = 270];599+ 112-127: Window;600+ 128-143: Checksum;601+ 144-159: Urgent Pointer;602+ 160-191: (Options and Padding);603+ 192-223: data [colheight = 3];604+}605+`,Mx=`D: diamond "Cardinal" "Points"606+ dot ".n" above at D.n607+ dot " .e" ljust at D.e608+ dot ".s" below at D.s609+ dot ".w " rjust at D.w610+`,Nx=`rackdiag {611+ 16U;612+ 1: UPS [2U];613+ 3: DB Server;614+ 4: Web Server;615+ 5: Web Server;616+ 6: Web Server;617+ 7: Load Balancer;618+ 8: L3 Switch;619+}620+`,Px=` .-,( ),-.621+ ___ _ .-( )-.622+ [___]|=| -->( ) __________623+ /::/ |_| '-( ).-' --->[_...__... ]624+ '-.( ).-'625+ \\ ____ __626+ '--->| | |==|627+ |____| | |628+ /::::/ |__|629+`,Fx=`module demo_device #(630+ //# {{}}631+ parameter SIZE = 8,632+ parameter RESET_ACTIVE_LEVEL = 1633+) (634+ //# {{clocks|Clocking}}635+ input wire clock,636+ //# {{control|Control signals}}637+ input wire reset,638+ input wire enable,639+ //# {{data|Data ports}}640+ input wire [SIZE-1:0] data_in,641+ output wire [SIZE-1:0] data_out642+);643+ // ...644+endmodule`,Ix=`% From: https://tikz.net/periodic-table/645+646+% Adapted from https://texample.net/tikz/examples/periodic-table-of-chemical-elements.647+% All Credit to Ivan Griffin.648+649+\\documentclass[tikz,border=5mm]{standalone}650+\\usetikzlibrary{shapes,calc}651+652+\\begin{document}653+654+\\newcommand{\\ElemLabel}[4]{655+ \\begin{minipage}{2.2cm}656+ \\centering657+ {\\textbf{#1} \\hfill #2}%658+ \\linebreak \\linebreak659+ {\\textbf{#3}}%660+ \\linebreak \\linebreak661+ {{#4}}662+ \\end{minipage}663+}664+665+\\newcommand{\\NaturalElem}[4]{\\ElemLabel{#1}{#2}{\\huge {#3}}{#4}}666+667+\\newcommand{\\SyntheticElem}[4]{\\ElemLabel{#1}{#2}{\\color{gray}{\\huge #3}}{#4}}668+669+\\begin{tikzpicture}[font=\\sffamily]670+671+ % Fill Color Styles672+ \\tikzstyle{ElementFill} = [fill=yellow!15]673+ \\tikzstyle{AlkaliMetalFill} = [fill=blue!55]674+ \\tikzstyle{AlkalineEarthMetalFill} = [fill=blue!40]675+ \\tikzstyle{MetalFill} = [fill=blue!25]676+ \\tikzstyle{MetalloidFill} = [fill=orange!40]677+ \\tikzstyle{NonmetalFill} = [fill=teal!40]678+ \\tikzstyle{HalogenFill} = [fill=yellow!40]679+ \\tikzstyle{NobleGasFill} = [fill=green!55]680+ \\tikzstyle{LanthanideActinideFill} = [fill=red!40]681+682+ % Element Styles683+ \\tikzstyle{Element} = [ElementFill,684+ minimum width=2.5cm, minimum height=2.5cm, node distance=2.75cm]685+ \\tikzstyle{AlkaliMetal} = [Element, AlkaliMetalFill]686+ \\tikzstyle{AlkalineEarthMetal} = [Element, AlkalineEarthMetalFill]687+ \\tikzstyle{Metal} = [Element, MetalFill]688+ \\tikzstyle{Metalloid} = [Element, MetalloidFill]689+ \\tikzstyle{Nonmetal} = [Element, NonmetalFill]690+ \\tikzstyle{Halogen} = [Element, HalogenFill]691+ \\tikzstyle{NobleGas} = [Element, NobleGasFill]692+ \\tikzstyle{LanthanideActinide} = [Element, LanthanideActinideFill]693+ \\tikzstyle{PeriodLabel} = [font={\\sffamily\\LARGE}, node distance=2.0cm]694+ \\tikzstyle{GroupLabel} = [font={\\sffamily\\LARGE}, minimum width=2.75cm, node distance=2.0cm]695+696+ % Group 1 - IA697+ \\node[Element] (H) {\\NaturalElem{1} {1.0079}{H}{Hydrogen}};698+ \\node[below of=H, AlkaliMetal] (Li) {\\NaturalElem{3}{6.941}{Li}{Lithium}};699+ \\node[below of=Li, AlkaliMetal] (Na) {\\NaturalElem{11}{22.990}{Na}{Sodium}};700+ \\node[below of=Na, AlkaliMetal] (K) {\\NaturalElem{19}{39.098}{K}{Potassium}};701+ \\node[below of=K, AlkaliMetal] (Rb) {\\NaturalElem{37}{85.468}{Rb}{Rubidium}};702+ \\node[below of=Rb, AlkaliMetal] (Cs) {\\NaturalElem{55}{132.91}{Cs}{Caesium}};703+ \\node[below of=Cs, AlkaliMetal] (Fr) {\\NaturalElem{87}{223}{Fr}{Francium}};704+705+ % Group 2 - IIA706+ \\node[right of=Li, AlkalineEarthMetal] (Be) {\\NaturalElem{4}{9.0122}{Be}{Beryllium}};707+ \\node[below of=Be, AlkalineEarthMetal] (Mg) {\\NaturalElem{12}{24.305}{Mg}{Magnesium}};708+ \\node[below of=Mg, AlkalineEarthMetal] (Ca) {\\NaturalElem{20}{40.078}{Ca}{Calcium}};709+ \\node[below of=Ca, AlkalineEarthMetal] (Sr) {\\NaturalElem{38}{87.62}{Sr}{Strontium}};710+ \\node[below of=Sr, AlkalineEarthMetal] (Ba) {\\NaturalElem{56}{137.33}{Ba}{Barium}};711+ \\node[below of=Ba, AlkalineEarthMetal] (Ra) {\\NaturalElem{88}{226}{Ra}{Radium}};712+713+ % Group 3 - IIIB714+ \\node[right of=Ca, Metal] (Sc) {\\NaturalElem{21}{44.956}{Sc}{Scandium}};715+ \\node[below of=Sc, Metal] (Y) {\\NaturalElem{39}{88.906}{Y}{Yttrium}};716+ \\node[below of=Y, LanthanideActinide] (LaLu) {\\NaturalElem{57-71}{}{La-Lu}{Lanthanide}};717+ \\node[below of=LaLu, LanthanideActinide] (AcLr) {\\NaturalElem{89-103}{}{Ac-Lr}{Actinide}};718+719+ % Group 4 - IVB720+ \\node[right of=Sc, Metal] (Ti) {\\NaturalElem{22}{47.867}{Ti}{Titanium}};721+ \\node[below of=Ti, Metal] (Zr) {\\NaturalElem{40}{91.224}{Zr}{Zirconium}};722+ \\node[below of=Zr, Metal] (Hf) {\\NaturalElem{72}{178.49}{Hf}{Hafnium}};723+ \\node[below of=Hf, Metal] (Rf) {\\SyntheticElem{104}{261}{Rf}{Rutherfordium}};724+725+ % Group 5 - VB726+ \\node[right of=Ti, Metal] (V) {\\NaturalElem{23}{50.942}{V}{Vanadium}};727+ \\node[below of=V, Metal] (Nb) {\\NaturalElem{41}{92.906}{Nb}{Niobium}};728+ \\node[below of=Nb, Metal] (Ta) {\\NaturalElem{73}{180.95}{Ta}{Tantalum}};729+ \\node[below of=Ta, Metal] (Db) {\\SyntheticElem{105}{262}{Db}{Dubnium}};730+731+ % Group 6 - VIB732+ \\node[right of=V, Metal] (Cr) {\\NaturalElem{24}{51.996}{Cr}{Chromium}};733+ \\node[below of=Cr, Metal] (Mo) {\\NaturalElem{42}{95.94}{Mo}{Molybdenum}};734+ \\node[below of=Mo, Metal] (W) {\\NaturalElem{74}{183.84}{W}{Tungsten}};735+ \\node[below of=W, Metal] (Sg) {\\SyntheticElem{106}{266}{Sg}{Seaborgium}};736+737+ % Group 7 - VIIB738+ \\node[right of=Cr, Metal] (Mn) {\\NaturalElem{25}{54.938}{Mn}{Manganese}};739+ \\node[below of=Mn, Metal] (Tc) {\\NaturalElem{43}{96}{Tc}{Technetium}};740+ \\node[below of=Tc, Metal] (Re) {\\NaturalElem{75}{186.21}{Re}{Rhenium}};741+ \\node[below of=Re, Metal] (Bh) {\\SyntheticElem{107}{264}{Bh}{Bohrium}};742+743+ % Group 8 - VIIIB744+ \\node[right of=Mn, Metal] (Fe) {\\NaturalElem{26}{55.845}{Fe}{Iron}};745+ \\node[below of=Fe, Metal] (Ru) {\\NaturalElem{44}{101.07}{Ru}{Ruthenium}};746+ \\node[below of=Ru, Metal] (Os) {\\NaturalElem{76}{190.23}{Os}{Osmium}};747+ \\node[below of=Os, Metal] (Hs) {\\SyntheticElem{108}{277}{Hs}{Hassium}};748+749+ % Group 9 - VIIIB750+ \\node[right of=Fe, Metal] (Co) {\\NaturalElem{27}{58.933}{Co}{Cobalt}};751+ \\node[below of=Co, Metal] (Rh) {\\NaturalElem{45}{102.91}{Rh}{Rhodium}};752+ \\node[below of=Rh, Metal] (Ir) {\\NaturalElem{77}{192.22}{Ir}{Iridium}};753+ \\node[below of=Ir, Metal] (Mt) {\\SyntheticElem{109}{268}{Mt}{Meitnerium}};754+755+ % Group 10 - VIIIB756+ \\node[right of=Co, Metal] (Ni) {\\NaturalElem{28}{58.693}{Ni}{Nickel}};757+ \\node[below of=Ni, Metal] (Pd) {\\NaturalElem{46}{106.42}{Pd}{Palladium}};758+ \\node[below of=Pd, Metal] (Pt) {\\NaturalElem{78}{195.08}{Pt}{Platinum}};759+ \\node[below of=Pt, Metal] (Ds) {\\SyntheticElem{110}{281}{Ds}{Darmstadtium}};760+761+ % Group 11 - IB762+ \\node[right of=Ni, Metal] (Cu) {\\NaturalElem{29}{63.546}{Cu}{Copper}};763+ \\node[below of=Cu, Metal] (Ag) {\\NaturalElem{47}{107.87}{Ag}{Silver}};764+ \\node[below of=Ag, Metal] (Au) {\\NaturalElem{79}{196.97}{Au}{Gold}};765+ \\node[below of=Au, Metal] (Rg) {\\SyntheticElem{111}{280}{Rg}{Roentgenium}};766+767+ % Group 12 - IIB768+ \\node[right of=Cu, Metal] (Zn) {\\NaturalElem{30}{65.39}{Zn}{Zinc}};769+ \\node[below of=Zn, Metal] (Cd) {\\NaturalElem{48}{112.41}{Cd}{Cadmium}};770+ \\node[below of=Cd, Metal] (Hg) {\\NaturalElem{80}{200.59}{Hg}{Mercury}};771+ \\node[below of=Hg, Metal] (Uub) {\\SyntheticElem{112}{285}{Uub}{Ununbium}};772+773+ % Group 13 - IIIA774+ \\node[right of=Zn, Metal] (Ga) {\\NaturalElem{31}{69.723}{Ga}{Gallium}};775+ \\node[above of=Ga, Metal] (Al) {\\NaturalElem{13}{26.982}{Al}{Aluminium}};776+ \\node[above of=Al, Metalloid] (B) {\\NaturalElem{5}{10.811}{B}{Boron}};777+ \\node[below of=Ga, Metal] (In) {\\NaturalElem{49}{114.82}{In}{Indium}};778+ \\node[below of=In, Metal] (Tl) {\\NaturalElem{81}{204.38}{Tl}{Thallium}};779+ \\node[below of=Tl, Metal] (Uut) {\\SyntheticElem{113}{284}{Uut}{Ununtrium}};780+781+ % Group 14 - IVA782+ \\node[right of=B, Nonmetal] (C) {\\NaturalElem{6}{12.011}{C}{Carbon}};783+ \\node[below of=C, Metalloid] (Si) {\\NaturalElem{14}{28.086}{Si}{Silicon}};784+ \\node[below of=Si, Metalloid] (Ge) {\\NaturalElem{32}{72.64}{Ge}{Germanium}};785+ \\node[below of=Ge, Metal] (Sn) {\\NaturalElem{50}{118.71}{Sn}{Tin}};786+ \\node[below of=Sn, Metal] (Pb) {\\NaturalElem{82}{207.2}{Pb}{Lead}};787+ \\node[below of=Pb, Metal] (Uuq) {\\SyntheticElem{114}{289}{Uuq}{Ununquadium}};788+789+ % Group 15 - VA790+ \\node[right of=C, Nonmetal] (N) {\\NaturalElem{7}{14.007}{N}{Nitrogen}};791+ \\node[below of=N, Nonmetal] (P) {\\NaturalElem{15}{30.974}{P}{Phosphorus}};792+ \\node[below of=P, Metalloid] (As) {\\NaturalElem{33}{74.922}{As}{Arsenic}};793+ \\node[below of=As, Metalloid] (Sb) {\\NaturalElem{51}{121.76}{Sb}{Antimony}};794+ \\node[below of=Sb, Metal] (Bi) {\\NaturalElem{83}{208.98}{Bi}{Bismuth}};795+ \\node[below of=Bi, Metal] (Uup) {\\SyntheticElem{115}{288}{Uup}{Ununpentium}};796+797+ % Group 16 - VIA798+ \\node[right of=N, Nonmetal] (O) {\\NaturalElem{8}{15.999}{O}{Oxygen}};799+ \\node[below of=O, Nonmetal] (S) {\\NaturalElem{16}{32.065}{S}{Sulphur}};800+ \\node[below of=S, Nonmetal] (Se) {\\NaturalElem{34}{78.96}{Se}{Selenium}};801+ \\node[below of=Se, Metalloid] (Te) {\\NaturalElem{52}{127.6}{Te}{Tellurium}};802+ \\node[below of=Te, Metalloid] (Po) {\\NaturalElem{84}{209}{Po}{Polonium}};803+ \\node[below of=Po, Metal] (Uuh) {\\SyntheticElem{116}{293}{Uuh}{Ununhexium}};804+805+ % Group 17 - VIIA806+ \\node[right of=O, Halogen] (F) {\\NaturalElem{9}{18.998}{F}{Fluorine}};807+ \\node[below of=F, Halogen] (Cl) {\\NaturalElem{17}{35.453}{Cl}{Chlorine}};808+ \\node[below of=Cl, Halogen] (Br) {\\NaturalElem{35}{79.904}{Br}{Bromine}};809+ \\node[below of=Br, Halogen] (I) {\\NaturalElem{53}{126.9}{I}{Iodine}};810+ \\node[below of=I, Halogen] (At) {\\NaturalElem{85}{210}{At}{Astatine}};811+ \\node[below of=At, Element] (Uus) {\\SyntheticElem{117}{292}{Uus}{Ununseptium}};812+813+ % Group 18 - VIIIA814+ \\node[right of=F, NobleGas] (Ne) {\\NaturalElem{10}{20.180}{Ne}{Neon}};815+ \\node[above of=Ne, NobleGas] (He) {\\NaturalElem{2}{4.0025}{He}{Helium}};816+ \\node[below of=Ne, NobleGas] (Ar) {\\NaturalElem{18}{39.948}{Ar}{Argon}};817+ \\node[below of=Ar, NobleGas] (Kr) {\\NaturalElem{36}{83.8}{Kr}{Krypton}};818+ \\node[below of=Kr, NobleGas] (Xe) {\\NaturalElem{54}{131.29}{Xe}{Xenon}};819+ \\node[below of=Xe, NobleGas] (Rn) {\\NaturalElem{86}{222}{Rn}{Radon}};820+ \\node[below of=Rn, Nonmetal] (Uuo) {\\SyntheticElem{118}{294}{Uuo}{Ununoctium}};821+822+ % Period823+ \\node[left of=H, PeriodLabel] (Period1) {1};824+ \\node[left of=Li, PeriodLabel] (Period2) {2};825+ \\node[left of=Na, PeriodLabel] (Period3) {3};826+ \\node[left of=K, PeriodLabel] (Period4) {4};827+ \\node[left of=Rb, PeriodLabel] (Period5) {5};828+ \\node[left of=Cs, PeriodLabel] (Period6) {6};829+ \\node[left of=Fr, PeriodLabel] (Period7) {7};830+831+ % Group832+ \\node[above of=H, GroupLabel] (Group1) {1 \\hfill IA};833+ \\node[above of=Be, GroupLabel] (Group2) {2 \\hfill IIA};834+ \\node[above of=Sc, GroupLabel] (Group3) {3 \\hfill IIIA};835+ \\node[above of=Ti, GroupLabel] (Group4) {4 \\hfill IVB};836+ \\node[above of=V, GroupLabel] (Group5) {5 \\hfill VB};837+ \\node[above of=Cr, GroupLabel] (Group6) {6 \\hfill VIB};838+ \\node[above of=Mn, GroupLabel] (Group7) {7 \\hfill VIIB};839+ \\node[above of=Fe, GroupLabel] (Group8) {8 \\hfill VIIIB};840+ \\node[above of=Co, GroupLabel] (Group9) {9 \\hfill VIIIB};841+ \\node[above of=Ni, GroupLabel] (Group10) {10 \\hfill VIIIB};842+ \\node[above of=Cu, GroupLabel] (Group11) {11 \\hfill IB};843+ \\node[above of=Zn, GroupLabel] (Group12) {12 \\hfill IIB};844+ \\node[above of=B, GroupLabel] (Group13) {13 \\hfill IIIA};845+ \\node[above of=C, GroupLabel] (Group14) {14 \\hfill IVA};846+ \\node[above of=N, GroupLabel] (Group15) {15 \\hfill VA};847+ \\node[above of=O, GroupLabel] (Group16) {16 \\hfill VIA};848+ \\node[above of=F, GroupLabel] (Group17) {17 \\hfill VIIA};849+ \\node[above of=He, GroupLabel] (Group18) {18 \\hfill VIIIA};850+851+ % Lanthanide852+ \\node[below of=Rf, LanthanideActinide, yshift=-1cm] (La) {\\NaturalElem{57}{138.91}{La}{Lanthanum}};853+ \\node[right of=La, LanthanideActinide] (Ce) {\\NaturalElem{58}{140.12}{Ce}{Cerium}};854+ \\node[right of=Ce, LanthanideActinide] (Pr) {\\NaturalElem{59}{140.91}{Pr}{Praseodymium}};855+ \\node[right of=Pr, LanthanideActinide] (Nd) {\\NaturalElem{60}{144.24}{Nd}{Neodymium}};856+ \\node[right of=Nd, LanthanideActinide] (Pm) {\\NaturalElem{61}{145}{Pm}{Promethium}};857+ \\node[right of=Pm, LanthanideActinide] (Sm) {\\NaturalElem{62}{150.36}{Sm}{Samarium}};858+ \\node[right of=Sm, LanthanideActinide] (Eu) {\\NaturalElem{63}{151.96}{Eu}{Europium}};859+ \\node[right of=Eu, LanthanideActinide] (Gd) {\\NaturalElem{64}{157.25}{Gd}{Gadolinium}};860+ \\node[right of=Gd, LanthanideActinide] (Tb) {\\NaturalElem{65}{158.93}{Tb}{Terbium}};861+ \\node[right of=Tb, LanthanideActinide] (Dy) {\\NaturalElem{66}{162.50}{Dy}{Dysprosium}};862+ \\node[right of=Dy, LanthanideActinide] (Ho) {\\NaturalElem{67}{164.93}{Ho}{Holmium}};863+ \\node[right of=Ho, LanthanideActinide] (Er) {\\NaturalElem{68}{167.26}{Er}{Erbium}};864+ \\node[right of=Er, LanthanideActinide] (Tm) {\\NaturalElem{69}{168.93}{Tm}{Thulium}};865+ \\node[right of=Tm, LanthanideActinide] (Yb) {\\NaturalElem{70}{173.04}{Yb}{Ytterbium}};866+ \\node[right of=Yb, LanthanideActinide] (Lu) {\\NaturalElem{71}{174.97}{Lu}{Lutetium}};867+868+ % Actinide869+ \\node[below of=La, LanthanideActinide, yshift=-1cm] (Ac) {\\NaturalElem{89}{227}{Ac}{Actinium}};870+ \\node[right of=Ac, LanthanideActinide] (Th) {\\NaturalElem{90}{232.04}{Th}{Thorium}};871+ \\node[right of=Th, LanthanideActinide] (Pa) {\\NaturalElem{91}{231.04}{Pa}{Protactinium}};872+ \\node[right of=Pa, LanthanideActinide] (U) {\\NaturalElem{92}{238.03}{U}{Uranium}};873+ \\node[right of=U, LanthanideActinide] (Np) {\\SyntheticElem{93}{237}{Np}{Neptunium}};874+ \\node[right of=Np, LanthanideActinide] (Pu) {\\SyntheticElem{94}{244}{Pu}{Plutonium}};875+ \\node[right of=Pu, LanthanideActinide] (Am) {\\SyntheticElem{95}{243}{Am}{Americium}};876+ \\node[right of=Am, LanthanideActinide] (Cm) {\\SyntheticElem{96}{247}{Cm}{Curium}};877+ \\node[right of=Cm, LanthanideActinide] (Bk) {\\SyntheticElem{97}{247}{Bk}{Berkelium}};878+ \\node[right of=Bk, LanthanideActinide] (Cf) {\\SyntheticElem{98}{251}{Cf}{Californium}};879+ \\node[right of=Cf, LanthanideActinide] (Es) {\\SyntheticElem{99}{252}{Es}{Einsteinium}};880+ \\node[right of=Es, LanthanideActinide] (Fm) {\\SyntheticElem{100}{257}{Fm}{Fermium}};881+ \\node[right of=Fm, LanthanideActinide] (Md) {\\SyntheticElem{101}{258}{Md}{Mendelevium}};882+ \\node[right of=Md, LanthanideActinide] (No) {\\SyntheticElem{102}{259}{No}{Nobelium}};883+ \\node[right of=No, LanthanideActinide] (Lr) {\\SyntheticElem{103}{262}{Lr}{Lawrencium}};884+885+ % Draw dotted lines connecting Lanthanide breakout to main table886+ \\draw[thick,dotted] (LaLu.north west) -- (La.north west)887+ (LaLu.south west) -- (La.south west);888+ % Draw dotted lines connecting Actinide breakout to main table889+ \\draw[thick,dotted] (AcLr.north west) -- (Ac.north west)890+ (AcLr.south west) -- (Ac.south west);891+892+ % Legend893+ \\fill[AlkaliMetalFill] ($(La.north -| Fr.west) + (0,1em)$)894+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (AlkaliMetal) {Alkali Metal};895+ \\fill[AlkalineEarthMetalFill] ($(AlkaliMetal.west) - (1em,2em)$)896+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (AlkalineEarthMetal) {Alkaline Earth Metal};897+ \\fill[MetalFill] ($(AlkalineEarthMetal.west) - (1em,2em)$)898+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (Metal) {Metal};899+ \\fill[MetalloidFill] ($(Metal.west) - (1em,2em)$)900+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (Metalloid) {Metalloid};901+ \\fill[NonmetalFill] ($(Metalloid.west) - (1em,2em)$)902+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (Non-metal) {Non-metal};903+ \\fill[HalogenFill] ($(Non-metal.west) - (1em,2em)$)904+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (Halogen) {Halogen};905+ \\fill[NobleGasFill] ($(Halogen.west) - (1em,2em)$)906+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (NobleGas) {Noble Gas};907+ \\fill[LanthanideActinideFill] ($(NobleGas.west) - (1em,2em)$)908+ rectangle +(1em, 1em) node[right, yshift=-1.2ex] (Lanthanide/Actinide) {Lanthanide/Actinide};909+910+ \\node at (Ac -| Fr) [draw, Element, fill=white] (legend) {\\NaturalElem{Z}{mass}{\\LARGE Symbol}{Name}};911+ \\node[align=left] at (Ac -| Ra) {black: natural\\\\\\color{gray}gray: man-made};912+913+ % Diagram Title914+ \\node at (H.west -| Fe.north) [scale=2, font={\\sffamily\\Huge\\bfseries}]915+ {Periodic Table of Elements};916+917+\\end{tikzpicture}918+919+\\end{document}920+`,Lx=`<?xml version="1.0" encoding="UTF-8"?>921+<umlet_diagram>922+ <element>923+ <type>com.umlet.element.base.Relation</type>924+ <coordinates>925+ <x>739</x>926+ <y>16</y>927+ <w>232</w>928+ <h>264</h>929+ </coordinates>930+ <panel_attributes>lt=<-931+ when(spidersensor="rotate")932+ /block spider933+ </panel_attributes>934+ <additional_attributes>161;244;161;34;71;34;71;74</additional_attributes>935+ </element>936+ <element>937+ <type>com.umlet.element.custom.FinalState</type>938+ <coordinates>939+ <x>890</x>940+ <y>260</y>941+ <w>20</w>942+ <h>20</h>943+ </coordinates>944+ <panel_attributes></panel_attributes>945+ <additional_attributes>transparentSelection=false</additional_attributes>946+ </element>947+ <element>948+ <type>com.umlet.element.base.Relation</type>949+ <coordinates>950+ <x>750</x>951+ <y>170</y>952+ <w>160</w>953+ <h>137</h>954+ </coordinates>955+ <panel_attributes>lt=<-956+ after (10s)957+ / block spider958+ </panel_attributes>959+ <additional_attributes>140;100;66;100;66;20</additional_attributes>960+ </element>961+ <element>962+ <type>com.umlet.element.custom.State</type>963+ <coordinates>964+ <x>340</x>965+ <y>420</y>966+ <w>100</w>967+ <h>40</h>968+ </coordinates>969+ <panel_attributes>wait</panel_attributes>970+ <additional_attributes>transparentSelection=false</additional_attributes>971+ </element>972+ <element>973+ <type>com.umlet.element.custom.HistoryState</type>974+ <coordinates>975+ <x>230</x>976+ <y>440</y>977+ <w>20</w>978+ <h>20</h>979+ </coordinates>980+ <panel_attributes></panel_attributes>981+ <additional_attributes>transparentSelection=false</additional_attributes>982+ </element>983+ <element>984+ <type>com.umlet.element.base.Relation</type>985+ <coordinates>986+ <x>230</x>987+ <y>416</y>988+ <w>130</w>989+ <h>54</h>990+ </coordinates>991+ <panel_attributes>lt=<-992+ restart993+ </panel_attributes>994+ <additional_attributes>20;34;110;34</additional_attributes>995+ </element>996+ <element>997+ <type>com.umlet.element.base.Relation</type>998+ <coordinates>999+ <x>270</x>1000+ <y>396</y>1001+ <w>90</w>1002+ <h>54</h>1003+ </coordinates>1004+ <panel_attributes>lt=<-1005+ pause1006+ </panel_attributes>1007+ <additional_attributes>70;34;20;34</additional_attributes>1008+ </element>1009+ <element>1010+ <type>com.umlet.element.custom.FinalState</type>1011+ <coordinates>1012+ <x>90</x>1013+ <y>400</y>1014+ <w>20</w>1015+ <h>20</h>1016+ </coordinates>1017+ <panel_attributes></panel_attributes>1018+ <additional_attributes>transparentSelection=false</additional_attributes>1019+ </element>1020+ <element>1021+ <type>com.umlet.element.base.Relation</type>1022+ <coordinates>1023+ <x>46</x>1024+ <y>256</y>1025+ <w>114</w>1026+ <h>164</h>1027+ </coordinates>1028+ <panel_attributes>lt=<-1029+ after (10s)1030+ /timeout1031+ </panel_attributes>1032+ <additional_attributes>54;144;54;34;94;34</additional_attributes>1033+ </element>1034+ <element>1035+ <type>com.umlet.element.base.Relation</type>1036+ <coordinates>1037+ <x>230</x>1038+ <y>110</y>1039+ <w>190</w>1040+ <h>170</h>1041+ </coordinates>1042+ <panel_attributes>lt=<-1043+ timeout1044+ </panel_attributes>1045+ <additional_attributes>20;150;110;150;110;20;170;20</additional_attributes>1046+ </element>1047+ <element>1048+ <type>com.umlet.element.custom.State</type>1049+ <coordinates>1050+ <x>700</x>1051+ <y>90</y>1052+ <w>180</w>1053+ <h>100</h>1054+ </coordinates>1055+ <panel_attributes>accept1056+ boarding pass1057+ --1058+ entry/ release card1059+ do/release spider1060+ </panel_attributes>1061+ <additional_attributes>transparentSelection=true</additional_attributes>1062+ </element>1063+ <element>1064+ <type>com.umlet.element.base.Relation</type>1065+ <coordinates>1066+ <x>540</x>1067+ <y>140</y>1068+ <w>205</w>1069+ <h>100</h>1070+ </coordinates>1071+ <panel_attributes>lt=<-1072+ [passenger booked]1073+ </panel_attributes>1074+ <additional_attributes>160;20;120;80;20;80</additional_attributes>1075+ </element>1076+ <element>1077+ <type>com.umlet.element.base.Relation</type>1078+ <coordinates>1079+ <x>450</x>1080+ <y>210</y>1081+ <w>239</w>1082+ <h>190</h>1083+ </coordinates>1084+ <panel_attributes>lt=<-1085+ [passenger not booked]1086+ </panel_attributes>1087+ <additional_attributes>219;170;99;170;99;20</additional_attributes>1088+ </element>1089+ <element>1090+ <type>com.umlet.element.custom.State</type>1091+ <coordinates>1092+ <x>670</x>1093+ <y>350</y>1094+ <w>120</w>1095+ <h>50</h>1096+ </coordinates>1097+ <panel_attributes>reject1098+ boarding pass1099+ </panel_attributes>1100+ <additional_attributes>transparentSelection=false</additional_attributes>1101+ </element>1102+ <element>1103+ <type>com.umlet.element.base.Relation</type>1104+ <coordinates>1105+ <x>480</x>1106+ <y>130</y>1107+ <w>142</w>1108+ <h>100</h>1109+ </coordinates>1110+ <panel_attributes>lt=<-1111+ result of search1112+ </panel_attributes>1113+ <additional_attributes>71;80;71;20</additional_attributes>1114+ </element>1115+ <element>1116+ <type>com.umlet.element.base.Relation</type>1117+ <coordinates>1118+ <x>270</x>1119+ <y>70</y>1120+ <w>150</w>1121+ <h>40</h>1122+ </coordinates>1123+ <panel_attributes>lt=<-</panel_attributes>1124+ <additional_attributes>130;20;20;20</additional_attributes>1125+ </element>1126+ <element>1127+ <type>com.umlet.element.custom.ThreeWayRelation</type>1128+ <coordinates>1129+ <x>540</x>1130+ <y>210</y>1131+ <w>20</w>1132+ <h>20</h>1133+ </coordinates>1134+ <panel_attributes></panel_attributes>1135+ <additional_attributes>transparentSelection=false</additional_attributes>1136+ </element>1137+ <element>1138+ <type>com.umlet.element.custom.State</type>1139+ <coordinates>1140+ <x>140</x>1141+ <y>60</y>1142+ <w>150</w>1143+ <h>420</h>1144+ </coordinates>1145+ <panel_attributes>read boarding pass1146+ --1147+ </panel_attributes>1148+ <additional_attributes>transparentSelection=true</additional_attributes>1149+ </element>1150+ <element>1151+ <type>com.umlet.element.custom.State</type>1152+ <coordinates>1153+ <x>400</x>1154+ <y>60</y>1155+ <w>180</w>1156+ <h>90</h>1157+ </coordinates>1158+ <panel_attributes>check passenger1159+ --1160+ entry/start search1161+ do/blink lamp1162+ </panel_attributes>1163+ <additional_attributes>transparentSelection=true</additional_attributes>1164+ </element>1165+ <element>1166+ <type>com.umlet.element.custom.FinalState</type>1167+ <coordinates>1168+ <x>170</x>1169+ <y>410</y>1170+ <w>20</w>1171+ <h>20</h>1172+ </coordinates>1173+ <panel_attributes></panel_attributes>1174+ <additional_attributes>transparentSelection=false</additional_attributes>1175+ </element>1176+ <element>1177+ <type>com.umlet.element.custom.State</type>1178+ <coordinates>1179+ <x>150</x>1180+ <y>240</y>1181+ <w>100</w>1182+ <h>40</h>1183+ </coordinates>1184+ <panel_attributes>read1185+ passenger ID1186+ </panel_attributes>1187+ <additional_attributes>transparentSelection=false</additional_attributes>1188+ </element>1189+ <element>1190+ <type>com.umlet.element.custom.State</type>1191+ <coordinates>1192+ <x>150</x>1193+ <y>330</y>1194+ <w>100</w>1195+ <h>40</h>1196+ </coordinates>1197+ <panel_attributes>identify1198+ passenger1199+ </panel_attributes>1200+ <additional_attributes>transparentSelection=false</additional_attributes>1201+ </element>1202+ <element>1203+ <type>com.umlet.element.base.Relation</type>1204+ <coordinates>1205+ <x>160</x>1206+ <y>260</y>1207+ <w>40</w>1208+ <h>90</h>1209+ </coordinates>1210+ <panel_attributes>lt=<-</panel_attributes>1211+ <additional_attributes>20;70;20;20</additional_attributes>1212+ </element>1213+ <element>1214+ <type>com.umlet.element.base.Relation</type>1215+ <coordinates>1216+ <x>160</x>1217+ <y>100</y>1218+ <w>40</w>1219+ <h>70</h>1220+ </coordinates>1221+ <panel_attributes>lt=<-</panel_attributes>1222+ <additional_attributes>20;50;20;20</additional_attributes>1223+ </element>1224+ <element>1225+ <type>com.umlet.element.base.Relation</type>1226+ <coordinates>1227+ <x>160</x>1228+ <y>350</y>1229+ <w>40</w>1230+ <h>80</h>1231+ </coordinates>1232+ <panel_attributes>lt=<-</panel_attributes>1233+ <additional_attributes>20;60;20;20</additional_attributes>1234+ </element>1235+ <element>1236+ <type>com.umlet.element.base.Relation</type>1237+ <coordinates>1238+ <x>140</x>1239+ <y>170</y>1240+ <w>78</w>1241+ <h>90</h>1242+ </coordinates>1243+ <panel_attributes>lt=<-1244+ [valid]1245+ </panel_attributes>1246+ <additional_attributes>39;70;39;20</additional_attributes>1247+ </element>1248+ <element>1249+ <type>com.umlet.element.custom.State</type>1250+ <coordinates>1251+ <x>150</x>1252+ <y>150</y>1253+ <w>100</w>1254+ <h>40</h>1255+ </coordinates>1256+ <panel_attributes>check1257+ validity1258+ </panel_attributes>1259+ <additional_attributes>transparentSelection=false</additional_attributes>1260+ </element>1261+ <element>1262+ <type>com.umlet.element.custom.InitialState</type>1263+ <coordinates>1264+ <x>170</x>1265+ <y>100</y>1266+ <w>20</w>1267+ <h>20</h>1268+ </coordinates>1269+ <panel_attributes></panel_attributes>1270+ <additional_attributes>transparentSelection=false</additional_attributes>1271+ </element>1272+</umlet_diagram>1273+`,Rx=`{1274+ "$schema": "https://vega.github.io/schema/vega/v5.json",1275+ "width": 400,1276+ "height": 200,1277+ "padding": 5,1278+1279+ "data": [1280+ {1281+ "name": "table",1282+ "values": [1283+ {"category": "A", "amount": 28},1284+ {"category": "B", "amount": 55},1285+ {"category": "C", "amount": 43},1286+ {"category": "D", "amount": 91},1287+ {"category": "E", "amount": 81},1288+ {"category": "F", "amount": 53},1289+ {"category": "G", "amount": 19},1290+ {"category": "H", "amount": 87}1291+ ]1292+ }1293+ ],1294+1295+ "signals": [1296+ {1297+ "name": "tooltip",1298+ "value": {},1299+ "on": [1300+ {"events": "rect:mouseover", "update": "datum"},1301+ {"events": "rect:mouseout", "update": "{}"}1302+ ]1303+ }1304+ ],1305+1306+ "scales": [1307+ {1308+ "name": "xscale",1309+ "type": "band",1310+ "domain": {"data": "table", "field": "category"},1311+ "range": "width",1312+ "padding": 0.05,1313+ "round": true1314+ },1315+ {1316+ "name": "yscale",1317+ "domain": {"data": "table", "field": "amount"},1318+ "nice": true,1319+ "range": "height"1320+ }1321+ ],1322+1323+ "axes": [1324+ { "orient": "bottom", "scale": "xscale" },1325+ { "orient": "left", "scale": "yscale" }1326+ ],1327+1328+ "marks": [1329+ {1330+ "type": "rect",1331+ "from": {"data":"table"},1332+ "encode": {1333+ "enter": {1334+ "x": {"scale": "xscale", "field": "category"},1335+ "width": {"scale": "xscale", "band": 1},1336+ "y": {"scale": "yscale", "field": "amount"},1337+ "y2": {"scale": "yscale", "value": 0}1338+ },1339+ "update": {1340+ "fill": {"value": "steelblue"}1341+ },1342+ "hover": {1343+ "fill": {"value": "red"}1344+ }1345+ }1346+ },1347+ {1348+ "type": "text",1349+ "encode": {1350+ "enter": {1351+ "align": {"value": "center"},1352+ "baseline": {"value": "bottom"},1353+ "fill": {"value": "#333"}1354+ },1355+ "update": {1356+ "x": {"scale": "xscale", "signal": "tooltip.category", "band": 0.5},1357+ "y": {"scale": "yscale", "signal": "tooltip.amount", "offset": -2},1358+ "text": {"signal": "tooltip.amount"},1359+ "fillOpacity": [1360+ {"test": "datum === tooltip", "value": 0},1361+ {"value": 1}1362+ ]1363+ }1364+ }1365+ }1366+ ]1367+}1368+`,zx=`{1369+ "$schema": "https://vega.github.io/schema/vega-lite/v4.json",1370+ "description": "Horizontally concatenated charts that show different types of discretizing scales.",1371+ "data": {1372+ "values": [1373+ {"a": "A", "b": 28},1374+ {"a": "B", "b": 55},1375+ {"a": "C", "b": 43},1376+ {"a": "D", "b": 91},1377+ {"a": "E", "b": 81},1378+ {"a": "F", "b": 53},1379+ {"a": "G", "b": 19},1380+ {"a": "H", "b": 87},1381+ {"a": "I", "b": 52}1382+ ]1383+ },1384+ "hconcat": [1385+ {1386+ "mark": "circle",1387+ "encoding": {1388+ "y": {1389+ "field": "b",1390+ "type": "nominal",1391+ "sort": null,1392+ "axis": {1393+ "ticks": false,1394+ "domain": false,1395+ "title": null1396+ }1397+ },1398+ "size": {1399+ "field": "b",1400+ "type": "quantitative",1401+ "scale": {1402+ "type": "quantize"1403+ }1404+ },1405+ "color": {1406+ "field": "b",1407+ "type": "quantitative",1408+ "scale": {1409+ "type": "quantize",1410+ "zero": true1411+ },1412+ "legend": {1413+ "title": "Quantize"1414+ }1415+ }1416+ }1417+ },1418+ {1419+ "mark": "circle",1420+ "encoding": {1421+ "y": {1422+ "field": "b",1423+ "type": "nominal",1424+ "sort": null,1425+ "axis": {1426+ "ticks": false,1427+ "domain": false,1428+ "title": null1429+ }1430+ },1431+ "size": {1432+ "field": "b",1433+ "type": "quantitative",1434+ "scale": {1435+ "type": "quantile",1436+ "range": [80, 160, 240, 320, 400]1437+ }1438+ },1439+ "color": {1440+ "field": "b",1441+ "type": "quantitative",1442+ "scale": {1443+ "type": "quantile",1444+ "scheme": "magma"1445+ },1446+ "legend": {1447+ "format": "d",1448+ "title": "Quantile"1449+ }1450+ }1451+ }1452+ },1453+ {1454+ "mark": "circle",1455+ "encoding": {1456+ "y": {1457+ "field": "b",1458+ "type": "nominal",1459+ "sort": null,1460+ "axis": {1461+ "ticks": false,1462+ "domain": false,1463+ "title": null1464+ }1465+ },1466+ "size": {1467+ "field": "b",1468+ "type": "quantitative",1469+ "scale": {1470+ "type": "threshold",1471+ "domain": [30, 70],1472+ "range": [80, 200, 320]1473+ }1474+ },1475+ "color": {1476+ "field": "b",1477+ "type": "quantitative",1478+ "scale": {1479+ "type": "threshold",1480+ "domain": [30, 70],1481+ "scheme": "viridis"1482+ },1483+ "legend": {1484+ "title": "Threshold"1485+ }1486+ }1487+ }1488+ }1489+ ],1490+ "resolve": {1491+ "scale": {1492+ "color": "independent",1493+ "size": "independent"1494+ }1495+ }1496+}1497+`,Bx=`{ signal: [1498+ { name: "clk", wave: "p.....|..." },1499+ { name: "Data", wave: "x.345x|=.x", data: ["head", "body", "tail", "data"] },1500+ { name: "Request", wave: "0.1..0|1.0" },1501+ {},1502+ { name: "Acknowledge", wave: "1.....|01." }1503+]}1504+`,Vx=`connectors:1505+ X1:1506+ type: D-Sub1507+ subtype: female1508+ pinlabels: [DCD, RX, TX, DTR, GND, DSR, RTS, CTS, RI]1509+ X2:1510+ type: Molex KK 2541511+ subtype: female1512+ pinlabels: [GND, RX, TX]1513+1514+cables:1515+ W1:1516+ gauge: 0.25 mm21517+ length: 0.21518+ color_code: DIN1519+ wirecount: 31520+ shield: true1521+1522+connections:1523+ -1524+ - X1: [5,2,3]1525+ - W1: [1,2,3]1526+ - X2: [1,3,2]1527+ -1528+ - X1: 51529+ - W1: s1530+`,Hx=4,Ux=0,Wx=1,Gx=2;function Kx(e){let t=e.length;for(;--t>=0;)e[t]=0}var qx=29,Jx=256,Yx=286,Xx=30,Zx=19,Qx=573,$x=15,eS=16,tS=7,nS=256,rS=16,iS=17,aS=18,oS=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),sS=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),cS=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),lS=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),uS=512,dS=Array(576);Kx(dS);var fS=Array(Xx*2);Kx(fS);var pS=Array(uS);Kx(pS);var mS=Array(256);Kx(mS);var hS=Array(qx);Kx(hS);var gS=Array(Xx);Kx(gS);var _S=class{constructor(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}},vS,yS,bS,xS=class{constructor(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}},SS=e=>e<256?pS[e]:pS[256+(e>>>7)],CS=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},wS=(e,t,n)=>{e.bi_valid>eS-n?(e.bi_buf|=t<<e.bi_valid&65535,CS(e,e.bi_buf),e.bi_buf=t>>eS-e.bi_valid,e.bi_valid+=n-eS):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},TS=(e,t,n)=>{wS(e,n[t*2],n[t*2+1])},ES=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},DS=e=>{e.bi_valid===16?(CS(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},OS=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,m,h=0;for(f=0;f<=$x;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<Qx;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,h++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),m=n[u*2],e.opt_len+=m*(f+p),a&&(e.static_len+=m*(i[u*2+1]+p)));if(h!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,h-=2}while(h>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},kS=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=$x;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=ES(r[t]++,t))}},AS=()=>{let e,t,n,r,i,a=Array(16);for(n=0,r=0;r<qx-1;r++)for(hS[r]=n,e=0;e<1<<oS[r];e++)mS[n++]=r;for(mS[n-1]=r,i=0,r=0;r<16;r++)for(gS[r]=i,e=0;e<1<<sS[r];e++)pS[i++]=r;for(i>>=7;r<Xx;r++)for(gS[r]=i<<7,e=0;e<1<<sS[r]-7;e++)pS[256+i++]=r;for(t=0;t<=$x;t++)a[t]=0;for(e=0;e<=143;)dS[e*2+1]=8,e++,a[8]++;for(;e<=255;)dS[e*2+1]=9,e++,a[9]++;for(;e<=279;)dS[e*2+1]=7,e++,a[7]++;for(;e<=287;)dS[e*2+1]=8,e++,a[8]++;for(kS(dS,287,a),e=0;e<Xx;e++)fS[e*2+1]=5,fS[e*2]=ES(e,5);vS=new _S(dS,oS,257,Yx,$x),yS=new _S(fS,sS,0,Xx,$x),bS=new _S([],cS,0,Zx,tS)},jS=e=>{let t;for(t=0;t<Yx;t++)e.dyn_ltree[t*2]=0;for(t=0;t<Xx;t++)e.dyn_dtree[t*2]=0;for(t=0;t<Zx;t++)e.bl_tree[t*2]=0;e.dyn_ltree[nS*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},MS=e=>{e.bi_valid>8?CS(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},NS=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},PS=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&NS(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!NS(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},FS=(e,t,n)=>{let r,i,a=0,o,s;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+a++]&255,r+=(e.pending_buf[e.sym_buf+a++]&255)<<8,i=e.pending_buf[e.sym_buf+a++],r===0?TS(e,i,t):(o=mS[i],TS(e,o+Jx+1,t),s=oS[o],s!==0&&(i-=hS[o],wS(e,i,s)),r--,o=SS(r),TS(e,o,n),s=sS[o],s!==0&&(r-=gS[o],wS(e,r,s)));while(a<e.sym_next);TS(e,nS,t)},IS=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=Qx,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)PS(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],PS(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,PS(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],OS(e,t),kS(n,c,e.bl_count)},LS=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[34]++:e.bl_tree[36]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[32]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},RS=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do TS(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(TS(e,iS,e.bl_tree),wS(e,s-3,3)):(TS(e,aS,e.bl_tree),wS(e,s-11,7)):(a!==i&&(TS(e,a,e.bl_tree),s--),TS(e,rS,e.bl_tree),wS(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},zS=e=>{let t;for(LS(e,e.dyn_ltree,e.l_desc.max_code),LS(e,e.dyn_dtree,e.d_desc.max_code),IS(e,e.bl_desc),t=18;t>=3&&e.bl_tree[lS[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},BS=(e,t,n,r)=>{let i;for(wS(e,t-257,5),wS(e,n-1,5),wS(e,r-4,4),i=0;i<r;i++)wS(e,e.bl_tree[lS[i]*2+1],3);RS(e,e.dyn_ltree,t-1),RS(e,e.dyn_dtree,n-1)},VS=e=>{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return Ux;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return Wx;for(n=32;n<Jx;n++)if(e.dyn_ltree[n*2]!==0)return Wx;return Ux},HS=!1,US=e=>{HS||=(AS(),!0),e.l_desc=new xS(e.dyn_ltree,vS),e.d_desc=new xS(e.dyn_dtree,yS),e.bl_desc=new xS(e.bl_tree,bS),e.bi_buf=0,e.bi_valid=0,jS(e)},WS=(e,t,n,r)=>{wS(e,0+ +!!r,3),MS(e),CS(e,n),CS(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},GS=e=>{wS(e,2,3),TS(e,nS,dS),DS(e)},KS=(e,t,n,r)=>{let i,a,o=0;e.level>0?(e.strm.data_type===Gx&&(e.strm.data_type=VS(e)),IS(e,e.l_desc),IS(e,e.d_desc),o=zS(e),i=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=i&&(i=a)):i=a=n+5,n+4<=i&&t!==-1?WS(e,t,n,r):e.strategy===Hx||a===i?(wS(e,2+ +!!r,3),FS(e,dS,fS)):(wS(e,4+ +!!r,3),BS(e,e.l_desc.max_code+1,e.d_desc.max_code+1,o+1),FS(e,e.dyn_ltree,e.dyn_dtree)),jS(e),r&&MS(e)},qS=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(mS[n]+Jx+1)*2]++,e.dyn_dtree[SS(t)*2]++),e.sym_next===e.sym_end),JS=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},YS=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),XS=(e,t,n,r)=>{let i=YS,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},ZS={2:`need dictionary`,1:`stream end`,0:``,"-1":`file error`,"-2":`stream error`,"-3":`data error`,"-4":`insufficient memory`,"-5":`buffer error`,"-6":`incompatible version`},QS=9,$S=573,Z=3,eC=258,tC=262,nC=32,rC=42,iC=57,aC=69,oC=73,sC=91,cC=103,lC=113,uC=666,dC=1,fC=2,pC=3,mC=4,hC=3,gC=(e,t)=>(e.msg=ZS[t],t),_C=e=>e*2-(e>4?9:0),vC=e=>{let t=e.length;for(;--t>=0;)e[t]=0},yC=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)},bC=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,xC=(e,t)=>{let n;if(e.legacy_hash)n=e.ins_h=bC(e,e.ins_h,e.window[t+Z-1]);else{let r=e.window,i=r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24;n=e.ins_h=Math.imul(i,66521)+66521>>>16&e.hash_mask}let r=e.prev[t&e.w_mask]=e.head[n];return e.head[n]=t,r},SC=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},CC=(e,t)=>{KS(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,SC(e.strm)},Q=(e,t)=>{e.pending_buf[e.pending++]=t},wC=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},TC=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=JS(e.adler,t,i,n):e.state.wrap===2&&(e.adler=XS(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},EC=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-tC?e.strstart-(e.w_size-tC):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+eC,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(i=t,l[i+o]===m&&l[i+o-1]===p&&l[i]===l[r]&&l[++i]===l[r+1]){r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=eC-(f-r),r=f-eC,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},DC=e=>{let t=e.w_size,n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-tC)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),yC(e),r+=t),e.strm.avail_in===0)break;if(n=TC(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,!e.legacy_hash){if(e.lookahead+e.insert>Z)for(i=e.strstart-e.insert;e.insert&&(xC(e,i),i++,e.insert--,!(e.lookahead+e.insert<=Z)););}else if(e.lookahead+e.insert>=Z)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=bC(e,e.ins_h,e.window[i+1]);e.insert&&(xC(e,i),i++,e.insert--,!(e.lookahead+e.insert<Z)););}while(e.lookahead<tC&&e.strm.avail_in!==0)},OC=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,a,o=0,s=e.strm.avail_in;do{if(r=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&t!==4||t===0||r!==i+e.strm.avail_in)))break;o=+(t===4&&r===i+e.strm.avail_in),WS(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,SC(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(TC(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(o===0);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),o?mC:t!==0&&t!==4&&e.strm.avail_in===0&&e.strstart===e.block_start?fC:(a=e.window_size-e.strstart,e.strm.avail_in>a&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(TC(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,n=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=n||(i||t===4)&&t!==0&&e.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=+(t===4&&e.strm.avail_in===0&&r===i),WS(e,e.block_start,r,o),e.block_start+=r,SC(e.strm)),o?pC:dC)},kC=(e,t)=>{let n,r;for(;;){if(e.lookahead<tC){if(DC(e),e.lookahead<tC&&t===0)return dC;if(e.lookahead===0)break}if(n=0,e.lookahead>=Z&&(n=xC(e,e.strstart)),n!==0&&e.strstart-n<=e.w_size-tC&&(e.match_length=EC(e,n)),e.match_length>=Z){if(r=qS(e,e.strstart-e.match_start,e.match_length-Z),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=Z){e.match_length--;do e.strstart++,n=xC(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=bC(e,e.ins_h,e.window[e.strstart+1]))}else r=qS(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(CC(e,!1),e.strm.avail_out===0))return dC}return e.insert=e.strstart<Z-1?e.strstart:Z-1,t===4?(CC(e,!0),e.strm.avail_out===0?pC:mC):e.sym_next&&(CC(e,!1),e.strm.avail_out===0)?dC:fC},AC=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<tC){if(DC(e),e.lookahead<tC&&t===0)return dC;if(e.lookahead===0)break}if(n=0,e.lookahead>=Z&&(n=xC(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=Z-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-tC&&(e.match_length=EC(e,n),e.match_length<=5&&(e.strategy===1||e.match_length===Z&&e.strstart-e.match_start>4096)&&(e.match_length=Z-1)),e.prev_length>=Z&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-Z,r=qS(e,e.strstart-1-e.prev_match,e.prev_length-Z),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(n=xC(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=Z-1,e.strstart++,r&&(CC(e,!1),e.strm.avail_out===0))return dC}else if(e.match_available){if(r=qS(e,0,e.window[e.strstart-1]),r&&CC(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return dC}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&=(r=qS(e,0,e.window[e.strstart-1]),0),e.insert=e.strstart<Z-1?e.strstart:Z-1,t===4?(CC(e,!0),e.strm.avail_out===0?pC:mC):e.sym_next&&(CC(e,!1),e.strm.avail_out===0)?dC:fC},jC=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=eC){if(DC(e),e.lookahead<=eC&&t===0)return dC;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=Z&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+eC;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=eC-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=Z?(n=qS(e,1,e.match_length-Z),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=qS(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(CC(e,!1),e.strm.avail_out===0))return dC}return e.insert=0,t===4?(CC(e,!0),e.strm.avail_out===0?pC:mC):e.sym_next&&(CC(e,!1),e.strm.avail_out===0)?dC:fC},MC=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(DC(e),e.lookahead===0)){if(t===0)return dC;break}if(e.match_length=0,n=qS(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(CC(e,!1),e.strm.avail_out===0))return dC}return e.insert=0,t===4?(CC(e,!0),e.strm.avail_out===0?pC:mC):e.sym_next&&(CC(e,!1),e.strm.avail_out===0)?dC:fC},NC=class{constructor(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}},PC=[new NC(0,0,0,0,OC),new NC(4,4,8,4,kC),new NC(4,5,16,8,kC),new NC(4,6,32,32,kC),new NC(4,4,16,16,AC),new NC(8,16,32,32,AC),new NC(8,16,128,128,AC),new NC(8,32,128,256,AC),new NC(32,128,258,1024,AC),new NC(32,258,258,4096,AC)],FC=e=>{e.window_size=2*e.w_size,vC(e.head),e.max_lazy_match=PC[e.level].max_lazy,e.good_match=PC[e.level].good_length,e.nice_match=PC[e.level].nice_length,e.max_chain_length=PC[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=Z-1,e.match_available=0,e.ins_h=0},IC=class{constructor(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.legacy_hash=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array($S*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),vC(this.dyn_ltree),vC(this.dyn_dtree),vC(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),vC(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),vC(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}},LC=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.status!==rC&&t.status!==iC&&t.status!==aC&&t.status!==oC&&t.status!==sC&&t.status!==cC&&t.status!==lC&&t.status!==uC)},RC=e=>{if(LC(e))return gC(e,-2);e.total_in=e.total_out=0,e.data_type=2;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?iC:t.wrap?rC:lC,e.adler=t.wrap===2?0:1,t.last_flush=-2,US(t),0},zC=e=>{let t=RC(e);return t===0&&FC(e.state),t},BC=(e,t,n,r,i,a,o)=>{if(!e)return-2;let s=1;if(t===-1&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>QS||n!==8||r<8||r>15||t<0||t>9||a<0||a>4||r===8&&s!==1)return gC(e,-2);r===8&&(r=9);let c=new IC;return e.state=c,c.strm=e,c.status=rC,c.wrap=s,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.legacy_hash=+!!o,c.hash_bits=i+7,!c.legacy_hash&&c.hash_bits<15&&(c.hash_bits=15),c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+Z-1)/Z),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=t,c.strategy=a,c.method=n,zC(e)},VC=(e,t)=>{if(LC(e)||t>5||t<0)return e?gC(e,-2):-2;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===uC&&t!==4)return gC(e,e.avail_out===0?-5:-2);let r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(SC(e),e.avail_out===0)return n.last_flush=-1,0}else if(e.avail_in===0&&_C(t)<=_C(r)&&t!==4)return gC(e,-5);if(n.status===uC&&e.avail_in!==0)return gC(e,-5);if(n.status===rC&&n.wrap===0&&(n.status=lC),n.status===rC){let t=8+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=2||n.level<2?0:n.level<6?1:n.level===6?2:3,t|=r<<6,n.strstart!==0&&(t|=nC),t+=31-t%31,wC(n,t),n.strstart!==0&&(wC(n,e.adler>>>16),wC(n,e.adler&65535)),e.adler=1,n.status=lC,SC(e),n.pending!==0)return n.last_flush=-1,0}if(n.status===iC){if(e.adler=0,Q(n,31),Q(n,139),Q(n,8),n.gzhead)Q(n,+!!n.gzhead.text+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Q(n,n.gzhead.time&255),Q(n,n.gzhead.time>>8&255),Q(n,n.gzhead.time>>16&255),Q(n,n.gzhead.time>>24&255),Q(n,n.level===9?2:n.strategy>=2||n.level<2?4:0),Q(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(Q(n,n.gzhead.extra.length&255),Q(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=XS(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=aC;else if(Q(n,0),Q(n,0),Q(n,0),Q(n,0),Q(n,0),Q(n,n.level===9?2:n.strategy>=2||n.level<2?4:0),Q(n,hC),n.status=lC,SC(e),n.pending!==0)return n.last_flush=-1,0}if(n.status===aC){if(n.gzhead.extra){let t=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=XS(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,SC(e),n.pending!==0)return n.last_flush=-1,0;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=XS(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=oC}if(n.status===oC){if(n.gzhead.name){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=XS(e.adler,n.pending_buf,n.pending-t,t)),SC(e),n.pending!==0)return n.last_flush=-1,0;t=0}r=n.gzindex<n.gzhead.name.length?n.gzhead.name.charCodeAt(n.gzindex++)&255:0,Q(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=XS(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=sC}if(n.status===sC){if(n.gzhead.comment){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=XS(e.adler,n.pending_buf,n.pending-t,t)),SC(e),n.pending!==0)return n.last_flush=-1,0;t=0}r=n.gzindex<n.gzhead.comment.length?n.gzhead.comment.charCodeAt(n.gzindex++)&255:0,Q(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=XS(e.adler,n.pending_buf,n.pending-t,t))}n.status=cC}if(n.status===cC){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(SC(e),n.pending!==0))return n.last_flush=-1,0;Q(n,e.adler&255),Q(n,e.adler>>8&255),e.adler=0}if(n.status=lC,SC(e),n.pending!==0)return n.last_flush=-1,0}if(e.avail_in!==0||n.lookahead!==0||t!==0&&n.status!==uC){let r=n.level===0?OC(n,t):n.strategy===2?MC(n,t):n.strategy===3?jC(n,t):PC[n.level].func(n,t);if((r===pC||r===mC)&&(n.status=uC),r===dC||r===pC)return e.avail_out===0&&(n.last_flush=-1),0;if(r===fC&&(t===1?GS(n):t!==5&&(WS(n,0,0,!1),t===3&&(vC(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),SC(e),e.avail_out===0))return n.last_flush=-1,0}return t===4?n.wrap<=0?1:(n.wrap===2?(Q(n,e.adler&255),Q(n,e.adler>>8&255),Q(n,e.adler>>16&255),Q(n,e.adler>>24&255),Q(n,e.total_in&255),Q(n,e.total_in>>8&255),Q(n,e.total_in>>16&255),Q(n,e.total_in>>24&255)):(wC(n,e.adler>>>16),wC(n,e.adler&65535)),SC(e),n.wrap>0&&(n.wrap=-n.wrap),+(n.pending===0)):0},HC=e=>{if(LC(e))return-2;let t=e.state.status;return e.state=null,t===lC?gC(e,-3):0},UC=(e,t)=>{let n=t.length;if(LC(e))return-2;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==rC||r.lookahead)return-2;if(i===1&&(e.adler=JS(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(vC(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,DC(r);r.lookahead>=Z;){let e=r.strstart,t=r.lookahead-(Z-1);do xC(r,e),e++;while(--t);r.strstart=e,r.lookahead=Z-1,DC(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=Z-1,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,0},WC=16209,GC=16191;function KC(e,t){let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E=e.state;n=e.next_in,w=e.input,r=n+(e.avail_in-5),i=e.next_out,T=e.output,a=i-(t-e.avail_out),o=i+(e.avail_out-257),s=E.dmax,c=E.wsize,l=E.whave,u=E.wnext,d=E.window,f=E.hold,p=E.bits,m=E.lencode,h=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;top:do{p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=m[f&g];dolen:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y===0)T[i++]=v&65535;else if(y&16){b=v&65535,y&=15,y&&(p<y&&(f+=w[n++]<<p,p+=8),b+=f&(1<<y)-1,f>>>=y,p-=y),p<15&&(f+=w[n++]<<p,p+=8,f+=w[n++]<<p,p+=8),v=h[f&_];dodist:for(;;){if(y=v>>>24,f>>>=y,p-=y,y=v>>>16&255,y&16){if(x=v&65535,y&=15,p<y&&(f+=w[n++]<<p,p+=8,p<y&&(f+=w[n++]<<p,p+=8)),x+=f&(1<<y)-1,x>s){e.msg=`invalid distance too far back`,E.mode=WC;break top}if(f>>>=y,p-=y,y=i-a,x>y){if(y=x-y,y>l&&E.sane){e.msg=`invalid distance too far back`,E.mode=WC;break top}if(S=0,C=d,u===0){if(S+=c-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}else if(u<y){if(S+=c+u-y,y-=u,y<b){b-=y;do T[i++]=d[S++];while(--y);if(S=0,u<b){y=u,b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}}}else if(S+=u-y,y<b){b-=y;do T[i++]=d[S++];while(--y);S=i-x,C=T}for(;b>2;)T[i++]=C[S++],T[i++]=C[S++],T[i++]=C[S++],b-=3;b&&(T[i++]=C[S++],b>1&&(T[i++]=C[S++]))}else{S=i-x;do T[i++]=T[S++],T[i++]=T[S++],T[i++]=T[S++],b-=3;while(b>2);b&&(T[i++]=T[S++],b>1&&(T[i++]=T[S++]))}}else if(y&64){e.msg=`invalid distance code`,E.mode=WC;break top}else{v=h[(v&65535)+(f&(1<<y)-1)];continue dodist}break}}else if(!(y&64)){v=m[(v&65535)+(f&(1<<y)-1)];continue dolen}else if(y&32){E.mode=GC;break top}else{e.msg=`invalid literal/length code`,E.mode=WC;break top}break}}while(n<r&&i<o);b=p>>3,n-=b,p-=b<<3,f&=(1<<p)-1,e.next_in=n,e.next_out=i,e.avail_in=n<r?5+(r-n):5-(n-r),e.avail_out=i<o?257+(o-i):257-(i-o),E.hold=f,E.bits=p}var qC=15,JC=852,YC=592,XC=0,ZC=1,QC=2,$C=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ew=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,199,75]),tw=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),nw=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),rw=(e,t,n,r,i,a,o,s)=>{let c=s.bits,l=0,u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y,b,x,S,C,w=null,T,E=new Uint16Array(16),D=new Uint16Array(16),O=null,ee,k,te;for(l=0;l<=qC;l++)E[l]=0;for(u=0;u<r;u++)E[t[n+u]]++;for(p=c,f=qC;f>=1&&E[f]===0;f--);if(p>f&&(p=f),f===0)return i[a++]=20971520,i[a++]=20971520,s.bits=1,0;for(d=1;d<f&&E[d]===0;d++);for(p<d&&(p=d),g=1,l=1;l<=qC;l++)if(g<<=1,g-=E[l],g<0)return-1;if(g>0&&(e===XC||f!==1))return-1;for(D[1]=0,l=1;l<qC;l++)D[l+1]=D[l]+E[l];for(u=0;u<r;u++)t[n+u]!==0&&(o[D[t[n+u]]++]=u);if(e===XC?(w=O=o,T=20):e===ZC?(w=$C,O=ew,T=257):(w=tw,O=nw,T=0),v=0,u=0,l=d,C=a,m=p,h=0,x=-1,_=1<<p,S=_-1,e===ZC&&_>JC||e===QC&&_>YC)return 1;for(;;){ee=l-h,o[u]+1<T?(k=0,te=o[u]):o[u]>=T?(k=O[o[u]-T],te=w[o[u]-T]):(k=96,te=0),y=1<<l-h,b=1<<m,d=b;do b-=y,i[C+(v>>h)+b]=ee<<24|k<<16|te|0;while(b!==0);for(y=1<<l-1;v&y;)y>>=1;if(y===0?v=0:(v&=y-1,v+=y),u++,--E[l]===0){if(l===f)break;l=t[n+o[u]]}if(l>p&&(v&S)!==x){for(h===0&&(h=p),C+=d,m=l-h,g=1<<m;m+h<f&&(g-=E[m+h],!(g<=0));)m++,g<<=1;if(_+=1<<m,e===ZC&&_>JC||e===QC&&_>YC)return 1;x=v&S,i[x]=p<<24|m<<16|C-a|0}}return v!==0&&(i[C+v]=l-h<<24|4194304),s.bits=p,0},iw=0,aw=1,ow=2,sw=16180,cw=16181,lw=16182,uw=16183,dw=16184,fw=16185,pw=16186,mw=16187,hw=16188,gw=16189,_w=16190,vw=16191,yw=16192,bw=16193,xw=16194,Sw=16195,Cw=16196,ww=16197,Tw=16198,Ew=16199,Dw=16200,Ow=16201,kw=16202,Aw=16203,jw=16204,Mw=16205,Nw=16206,Pw=16207,Fw=16208,$=16209,Iw=16210,Lw=16211,Rw=852,zw=592,Bw=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24),Vw=class{constructor(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}},Hw=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.mode<sw||t.mode>Lw)},Uw=e=>{if(Hw(e))return-2;let t=e.state;return e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=t.wrap&1),t.mode=sw,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Rw),t.distcode=t.distdyn=new Int32Array(zw),t.sane=1,t.back=-1,0},Ww=e=>{if(Hw(e))return-2;let t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Uw(e)},Gw=(e,t)=>{let n;if(Hw(e))return-2;let r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+5,t<48&&(t&=15)),t&&(t<8||t>15)?-2:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Ww(e))},Kw=(e,t)=>{if(!e)return-2;let n=new Vw;e.state=n,n.strm=e,n.window=null,n.mode=sw;let r=Gw(e,t);return r!==0&&(e.state=null),r},qw=!0,Jw,Yw,Xw=e=>{if(qw){Jw=new Int32Array(512),Yw=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(rw(aw,e.lens,0,288,Jw,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;rw(ow,e.lens,0,32,Yw,0,e.work,{bits:5}),qw=!1}e.lencode=Jw,e.lenbits=9,e.distcode=Yw,e.distbits=5},Zw=(e,t,n,r)=>{let i,a=e.state;return a.window===null&&(a.window=new Uint8Array(1<<a.wbits)),a.wsize===0&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0),r>=a.wsize?(a.window.set(t.subarray(n-a.wsize,n),0),a.wnext=0,a.whave=a.wsize):(i=a.wsize-a.wnext,i>r&&(i=r),a.window.set(t.subarray(n-r,n-r+i),a.wnext),r-=i,r?(a.window.set(t.subarray(n-r,n),0),a.wnext=r,a.whave=a.wsize):(a.wnext+=i,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=i))),0},Qw=(e,t)=>{let n,r,i,a,o,s,c,l,u,d,f,p,m,h,g=0,_,v,y,b,x,S,C,w,T=new Uint8Array(4),E,D,O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Hw(e)||!e.output||!e.input&&e.avail_in!==0)return-2;n=e.state,n.mode===vw&&(n.mode=yw),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,d=s,f=c,w=0;inf_leave:for(;;)switch(n.mode){case sw:if(n.wrap===0){n.mode=yw;break}for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&2&&l===35615){n.wbits===0&&(n.wbits=15),n.check=0,T[0]=l&255,T[1]=l>>>8&255,n.check=XS(n.check,T,2,0),l=0,u=0,n.mode=cw;break}if(n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg=`incorrect header check`,n.mode=$;break}if((l&15)!=8){e.msg=`unknown compression method`,n.mode=$;break}if(l>>>=4,u-=4,C=(l&15)+8,n.wbits===0&&(n.wbits=C),C>15||C>n.wbits){e.msg=`invalid window size`,n.mode=$;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=l&512?gw:vw,l=0,u=0;break;case cw:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.flags=l,(n.flags&255)!=8){e.msg=`unknown compression method`,n.mode=$;break}if(n.flags&57344){e.msg=`unknown header flags set`,n.mode=$;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=XS(n.check,T,2,0)),l=0,u=0,n.mode=lw;case lw:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,T[2]=l>>>16&255,T[3]=l>>>24&255,n.check=XS(n.check,T,4,0)),l=0,u=0,n.mode=uw;case uw:for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=XS(n.check,T,2,0)),l=0,u=0,n.mode=dw;case dw:if(n.flags&1024){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&n.wrap&4&&(T[0]=l&255,T[1]=l>>>8&255,n.check=XS(n.check,T,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=fw;case fw:if(n.flags&1024&&(p=n.length,p>s&&(p=s),p&&(n.head&&(C=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(a,a+p),C)),n.flags&512&&n.wrap&4&&(n.check=XS(n.check,r,p,a)),s-=p,a+=p,n.length-=p),n.length))break inf_leave;n.length=0,n.mode=pw;case pw:if(n.flags&2048){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.name+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=XS(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.name=null);n.length=0,n.mode=mw;case mw:if(n.flags&4096){if(s===0)break inf_leave;p=0;do C=r[a+p++],n.head&&C&&n.length<65536&&(n.head.comment+=String.fromCharCode(C));while(C&&p<s);if(n.flags&512&&n.wrap&4&&(n.check=XS(n.check,r,p,a)),s-=p,a+=p,C)break inf_leave}else n.head&&(n.head.comment=null);n.mode=hw;case hw:if(n.flags&512){for(;u<16;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.check&65535)){e.msg=`header crc mismatch`,n.mode=$;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=vw;break;case gw:for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}e.adler=n.check=Bw(l),l=0,u=0,n.mode=_w;case _w:if(n.havedict===0)return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,2;e.adler=n.check=1,n.mode=vw;case vw:if(t===5||t===6)break inf_leave;case yw:if(n.last){l>>>=u&7,u-=u&7,n.mode=Nw;break}for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}switch(n.last=l&1,l>>>=1,--u,l&3){case 0:n.mode=bw;break;case 1:if(Xw(n),n.mode=Ew,t===6){l>>>=2,u-=2;break inf_leave}break;case 2:n.mode=Cw;break;case 3:e.msg=`invalid block type`,n.mode=$}l>>>=2,u-=2;break;case bw:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if((l&65535)!=(l>>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=$;break}if(n.length=l&65535,l=0,u=0,n.mode=xw,t===6)break inf_leave;case xw:n.mode=Sw;case Sw:if(p=n.length,p){if(p>s&&(p=s),p>c&&(p=c),p===0)break inf_leave;i.set(r.subarray(a,a+p),o),s-=p,a+=p,c-=p,o+=p,n.length-=p;break}n.mode=vw;break;case Cw:for(;u<14;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg=`too many length or distance symbols`,n.mode=$;break}n.have=0,n.mode=ww;case ww:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.lens[O[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[O[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,E={bits:n.lenbits},w=rw(iw,n.lens,0,19,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid code lengths set`,n.mode=$;break}n.have=0,n.mode=Tw;case Tw:for(;n.have<n.nlen+n.ndist;){for(;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(y<16)l>>>=_,u-=_,n.lens[n.have++]=y;else{if(y===16){for(D=_+2;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(l>>>=_,u-=_,n.have===0){e.msg=`invalid bit length repeat`,n.mode=$;break}C=n.lens[n.have-1],p=3+(l&3),l>>>=2,u-=2}else if(y===17){for(D=_+3;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=3+(l&7),l>>>=3,u-=3}else{for(D=_+7;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=_,u-=_,C=0,p=11+(l&127),l>>>=7,u-=7}if(n.have+p>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=$;break}for(;p--;)n.lens[n.have++]=C}}if(n.mode===$)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=$;break}if(n.lenbits=9,E={bits:n.lenbits},w=rw(aw,n.lens,0,n.nlen,n.lencode,0,n.work,E),n.lenbits=E.bits,w){e.msg=`invalid literal/lengths set`,n.mode=$;break}if(n.distbits=6,n.distcode=n.distdyn,E={bits:n.distbits},w=rw(ow,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,E),n.distbits=E.bits,w){e.msg=`invalid distances set`,n.mode=$;break}if(n.mode=Ew,t===6)break inf_leave;case Ew:n.mode=Dw;case Dw:if(s>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,KC(e,f),o=e.next_out,i=e.output,c=e.avail_out,a=e.next_in,r=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===vw&&(n.back=-1);break}for(n.back=0;g=n.lencode[l&(1<<n.lenbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(v&&!(v&240)){for(b=_,x=v,S=y;g=n.lencode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,n.length=y,v===0){n.mode=Mw;break}if(v&32){n.back=-1,n.mode=vw;break}if(v&64){e.msg=`invalid literal/length code`,n.mode=$;break}n.extra=v&15,n.mode=Ow;case Ow:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=kw;case kw:for(;g=n.distcode[l&(1<<n.distbits)-1],_=g>>>24,v=g>>>16&255,y=g&65535,!(_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(!(v&240)){for(b=_,x=v,S=y;g=n.distcode[S+((l&(1<<b+x)-1)>>b)],_=g>>>24,v=g>>>16&255,y=g&65535,!(b+_<=u);){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}l>>>=b,u-=b,n.back+=b}if(l>>>=_,u-=_,n.back+=_,v&64){e.msg=`invalid distance code`,n.mode=$;break}n.offset=y,n.extra=v&15,n.mode=Aw;case Aw:if(n.extra){for(D=n.extra;u<D;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=$;break}n.mode=jw;case jw:if(c===0)break inf_leave;if(p=f-c,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=$;break}p>n.wnext?(p-=n.wnext,m=n.wsize-p):m=n.wnext-p,p>n.length&&(p=n.length),h=n.window}else h=i,m=o-n.offset,p=n.length;p>c&&(p=c),c-=p,n.length-=p;do i[o++]=h[m++];while(--p);n.length===0&&(n.mode=Dw);break;case Mw:if(c===0)break inf_leave;i[o++]=n.length,c--,n.mode=Dw;break;case Nw:if(n.wrap){for(;u<32;){if(s===0)break inf_leave;s--,l|=r[a++]<<u,u+=8}if(f-=c,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?XS(n.check,i,f,o-f):JS(n.check,i,f,o-f)),f=c,n.wrap&4&&(n.flags?l:Bw(l))!==n.check){e.msg=`incorrect data check`,n.mode=$;break}l=0,u=0}n.mode=Pw;case Pw:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break inf_leave;s--,l+=r[a++]<<u,u+=8}if(n.wrap&4&&l!==(n.total&4294967295)){e.msg=`incorrect length check`,n.mode=$;break}l=0,u=0}n.mode=Fw;case Fw:w=1;break inf_leave;case $:w=-3;break inf_leave;case Iw:return-4;case Lw:default:return-2}return e.next_out=o,e.avail_out=c,e.next_in=a,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||f!==e.avail_out&&n.mode<$&&(n.mode<Nw||t!==4))&&Zw(e,e.output,e.next_out,f-e.avail_out)?(n.mode=Iw,-4):(d-=e.avail_in,f-=e.avail_out,e.total_in+=d,e.total_out+=f,n.total+=f,n.wrap&4&&f&&(e.adler=n.check=n.flags?XS(n.check,i,f,e.next_out-f):JS(n.check,i,f,e.next_out-f)),e.data_type=n.bits+(n.last?64:0)+(n.mode===vw?128:0)+(n.mode===Ew||n.mode===xw?256:0),(d===0&&f===0||t===4)&&w===0&&(w=-5),w)},$w=e=>{if(Hw(e))return-2;let t=e.state;return t.window&&=null,e.state=null,0},eT=(e,t)=>{let n=t.length,r,i,a;return Hw(e)||(r=e.state,r.wrap!==0&&r.mode!==_w)?-2:r.mode===_w&&(i=1,i=JS(i,t,n,0),i!==r.check)?-3:(a=Zw(e,t,n,n),a?(r.mode=Iw,-4):(r.havedict=1,0))},tT=class{constructor(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}},nT=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t},rT=Object.prototype.toString,iT={level:-1,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,raw:!1,gzip:!1,legacyHash:!1,dictionary:new Uint8Array},aT=class{options;err;msg;ended;started;chunks;strm;result;constructor(e={}){this.options=Object.assign({},iT,e);let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.started=!1,this.chunks=[],this.result=new Uint8Array,this.strm=new tT,this.strm.avail_out=0;let n=BC(this.strm,t.level,8,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(n!==0)throw Error(ZS[n]);rT.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary));let r=t.dictionary;if(r.length){if(t.gzip)throw Error(`dictionary is not supported with gzip`);if(n=UC(this.strm,r),n!==0)throw Error(ZS[n])}}push(e,t=!1){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=typeof t==`number`?t:t===!0?4:0,n.input=typeof e==`string`?new TextEncoder().encode(e):rT.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):e,n.next_in=0,n.avail_in=n.input.length,this.started||(this.started=!0,this.onStart(n));;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===2||a===3)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=VC(n,a),i===-2)break;if(i===1){n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=HC(this.strm);break}if(n.avail_out===0){this.onData(n.output);continue}if(a>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)return!0}return this.err=i,this.msg=n.msg||ZS[i],this.ended=!0,this.onEnd(i),i===0}onStart(e){}onData(e){this.chunks.push(e)}onEnd(e){e===0&&(this.result=nT(this.chunks)),this.chunks=[]}};function oT(e,t={}){let n=new aT(t);if(n.push(e,!0),n.err)throw Error(n.msg);return n.result}var sT=Object.prototype.toString,cT={chunkSize:65536,windowBits:15,raw:!1,dictionary:new Uint8Array},lT=class{options;err;msg;ended;started;chunks;strm;result;constructor(e={}){this.options=Object.assign({},cT,e);let t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!e.windowBits&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15||(t.windowBits|=15)),this.err=0,this.msg=``,this.ended=!1,this.started=!1,this.chunks=[],this.result=new Uint8Array,this.strm=new tT,this.strm.avail_out=0;let n=Kw(this.strm,t.windowBits);if(n!==0)throw Error(ZS[n]);sT.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary));let r=t.dictionary;if(t.raw&&r.length&&(n=eT(this.strm,r),n!==0))throw Error(ZS[n])}push(e,t=!1){let n=this.strm,r=this.options.chunkSize,i,a,o;if(this.ended)return this.err===0;for(a=typeof t==`number`?t:t===!0?4:0,n.input=sT.call(e)===`[object ArrayBuffer]`?new Uint8Array(e):e,n.next_in=0,n.avail_in=n.input.length,this.started||(this.started=!0,this.onStart(n));;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),i=Qw(n,a),i===2){let e=this.options.dictionary;e.length&&(i=eT(n,e),i===0?i=Qw(n,a):i===-3&&(i=2))}for(;n.avail_in>0&&i===1&&n.state.wrap&2&&n.state.flags!==0&&n.input[n.next_in]!==0;)Ww(n),i=Qw(n,a);if(i===-2||i===-3||i===2||i===-4)break;if(o=n.avail_out,n.next_out&&(n.avail_out===0||i===1||a>0)&&(this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out)),n.avail_out=0,n.next_out=0),i!==0&&i!==-5||o!==0){if(i===1){i=$w(this.strm);break}if(n.avail_in===0){if(a===4){i=$w(this.strm),i===0&&(i=-5);break}return!0}}}return this.err=i,this.msg=n.msg||ZS[i],this.ended=!0,this.onEnd(i),i===0}onStart(e){}onData(e){this.chunks.push(e)}onEnd(e){e===0&&(this.result=nT(this.chunks)),this.chunks=[]}};function uT(e,t={}){let n=new lT(t);if(n.push(e,!0),n.err)throw Error(n.msg);let r=n.result;return t.toText?new TextDecoder().decode(r):r}var dT=15e3,fT=`plantuml`,pT=`@startuml1531+skinparam monochrome true1532+skinparam shadowing false1533+1534+actor Alice1535+participant "Alice Agent" as AliceAgent1536+participant "Tandem App" as Tandem1537+participant "Bob Agent" as BobAgent1538+actor Bob1539+1540+Alice -> AliceAgent: Describe a shared to-do app1541+AliceAgent -> Tandem: Draft the task flow1542+Bob -> BobAgent: Build and test the API1543+BobAgent -> Tandem: Ship task sync1544+Alice -> Tandem: Add "Buy paint"1545+Tandem -> Bob: Share the new task1546+Bob -> Tandem: Mark it done1547+Tandem --> Alice: Everyone is in sync1548+@enduml`,mT=new TextEncoder,hT=new TextDecoder;function gT(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t).replaceAll(`+`,`-`).replaceAll(`/`,`_`).replace(/=+$/,``)}function _T(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n);return Uint8Array.from(r,e=>e.charCodeAt(0))}function vT(e){return gT(oT(mT.encode(e),{level:9}))}function yT(e){return hT.decode(uT(_T(e)))}function bT({type:e,source:t,options:n={}}){let r=JSON.stringify({source:t,options:n});return`#v1/${encodeURIComponent(e)}/${vT(r)}`}function xT(e){let[t,n,r]=e.replace(/^#/,``).split(`/`);if(t!==`v1`||!n||!r)throw Error(`Unsupported diagram.zip link.`);let i=JSON.parse(yT(r));if(typeof i.source!=`string`||typeof i.options!=`object`||i.options===null||Array.isArray(i.options))throw Error(`Invalid diagram.zip link.`);return{type:decodeURIComponent(n),source:i.source,options:i.options}}function ST(e,{type:t,source:n,options:r={}}){let i=new URL(`/${encodeURIComponent(t)}/svg/${vT(n)}`,e);for(let[e,t]of Object.entries(r))i.searchParams.set(e,String(t));return i.toString()}var CT={plantuml:pT,mermaid:`flowchart LR1549+ Alice([Alice]) -->|describes the shared list| AliceAgent["Alice Agent"]1550+ AliceAgent -->|drafts the experience| Tandem["Tandem App"]1551+ Bob([Bob]) -->|reviews the plan| BobAgent["Bob Agent"]1552+ BobAgent -->|builds and tests the API| Tandem1553+ Tandem -->|keeps tasks in sync| Alice1554+ Tandem -->|keeps tasks in sync| Bob`,graphviz:`digraph Tandem {1555+ rankdir=LR1556+ node [shape=box, style="rounded,filled", fillcolor="#eef2ff"]1557+ Alice [shape=oval, fillcolor="#fef3c7"]1558+ Bob [shape=oval, fillcolor="#dcfce7"]1559+ AliceAgent [label="Alice Agent"]1560+ BobAgent [label="Bob Agent"]1561+ Tandem [label="Tandem App", fillcolor="#ddd6fe"]1562+ Alice -> AliceAgent [label="shares an idea"]1563+ AliceAgent -> Tandem [label="proposes the flow"]1564+ Bob -> BobAgent [label="asks for an API"]1565+ BobAgent -> Tandem [label="ships + tests"]1566+ Tandem -> { Alice Bob } [label="syncs tasks"]1567+}`,c4plantuml:`@startuml1568+!include <C4/C4_Context>1569+1570+Person(alice, "Alice", "Plans the product and creates shared tasks")1571+Person(bob, "Bob", "Builds the app and completes shared tasks")1572+System(aliceAgent, "Alice Agent", "Turns Alice's ideas into product flows")1573+System(bobAgent, "Bob Agent", "Implements and tests Bob's changes")1574+System(tandem, "Tandem App", "A tiny shared to-do list")1575+1576+Rel(alice, aliceAgent, "Explains what friends need")1577+Rel(aliceAgent, tandem, "Proposes task flows")1578+Rel(bob, bobAgent, "Requests implementation help")1579+Rel(bobAgent, tandem, "Builds and verifies")1580+Rel(alice, tandem, "Creates tasks")1581+Rel(bob, tandem, "Completes tasks")1582+@enduml`,blockdiag:`blockdiag {1583+ orientation = portrait1584+ Alice -> "Alice Agent" -> "Tandem App";1585+ Bob -> "Bob Agent" -> "Tandem App";1586+ "Tandem App" -> "Shared task list";1587+1588+ Alice [color = "#fde68a"];1589+ Bob [color = "#bbf7d0"];1590+ "Alice Agent" [color = "#bfdbfe"];1591+ "Bob Agent" [color = "#bfdbfe"];1592+ "Tandem App" [color = "#ddd6fe"];1593+ "Shared task list" [color = "#fecdd3"];1594+}`,seqdiag:`seqdiag {1595+ Alice; "Alice Agent"; "Tandem App"; "Bob Agent"; Bob;1596+ Alice -> "Alice Agent" [label = "Sketch our shared errands"];1597+ "Alice Agent" -> "Tandem App" [label = "Create task: Buy paint"];1598+ "Tandem App" -> "Bob Agent" [label = "Task assigned to Bob"];1599+ "Bob Agent" -> Bob [label = "Offer a reminder"];1600+ Bob -> "Tandem App" [label = "Mark task complete"];1601+ "Tandem App" -> Alice [label = "List synced"];1602+}`,actdiag:`actdiag {1603+ describe -> shape -> implement -> verify -> share1604+1605+ lane Alice {1606+ label = "Alice"1607+ describe [label = "Describe shared tasks"];1608+ share [label = "Try Tandem with Bob"];1609+ }1610+ lane "Alice Agent" {1611+ shape [label = "Shape the task flow"];1612+ }1613+ lane "Bob Agent" {1614+ implement [label = "Build Tandem"];1615+ verify [label = "Test task sync"];1616+ }1617+}`,structurizr:`workspace "Tandem" "Alice and Bob build a shared to-do app with their agents" {1618+ model {1619+ alice = person "Alice" "Plans Tandem and creates tasks"1620+ bob = person "Bob" "Builds Tandem and completes tasks"1621+ aliceAgent = softwareSystem "Alice Agent" "Shapes Alice's ideas into product flows"1622+ bobAgent = softwareSystem "Bob Agent" "Implements and tests Bob's changes"1623+ tandem = softwareSystem "Tandem App" "Keeps Alice and Bob's tasks in sync"1624+1625+ alice -> aliceAgent "Describes the experience"1626+ aliceAgent -> tandem "Proposes task flows"1627+ bob -> bobAgent "Requests implementation help"1628+ bobAgent -> tandem "Builds and tests"1629+ alice -> tandem "Creates tasks"1630+ bob -> tandem "Completes tasks"1631+ }1632+ views {1633+ systemLandscape "TandemLandscape" {1634+ include *1635+ autolayout lr1636+ }1637+ theme default1638+ }1639+}`,d2:Sx,nwdiag:Ax,packetdiag:jx,rackdiag:Nx,bpmn:bx.replaceAll(`Examine Situation`,`Bob Agent tests Tandem`).replaceAll(`Things OK?`,`Tests pass?`).replaceAll(`Notification Sent`,`Alice and Bob share tasks`).replaceAll(`Error Propagated`,`Alice Agent revises flow`).replaceAll(`Klaus`,`Alice`).replaceAll(`Walter`,`Bob`),bytefield:xx,dbml:Cx,diagramsnet:wx,ditaa:Tx,erd:Ex,excalidraw:Dx,goat:Ox,nomnoml:kx,pikchr:Mx,svgbob:Px,symbolator:Fx,tikz:Ix,umlet:Lx,vega:Rx,vegalite:zx,wavedrom:Bx,wireviz:Vx};function wT(e){return CT[e]??pT}function TT(e,t,n){return Math.min(Math.max(e,t),n)}var ET=class{constructor({stage:e,image:t,status:n,minimap:r,minimapImage:i,minimapViewport:a}){this.stage=e,this.image=t,this.status=n,this.minimap=r,this.minimapImage=i,this.minimapViewport=a,this.scale=1,this.x=0,this.y=0,this.objectUrl=null,this.abortController=null,this.requestNumber=0,this.pendingRender=null,this.renderLoop=null,this.drag=null,this.image.addEventListener(`load`,()=>this.fit()),this.stage.addEventListener(`pointerdown`,e=>this.startPan(e)),this.stage.addEventListener(`pointermove`,e=>this.pan(e)),this.stage.addEventListener(`pointerup`,e=>this.endPan(e)),this.stage.addEventListener(`pointercancel`,e=>this.endPan(e)),this.stage.addEventListener(`wheel`,e=>this.wheelZoom(e),{passive:!1}),this.minimap.addEventListener(`pointerdown`,e=>this.moveFromMinimap(e)),new ResizeObserver(()=>this.updateTransform()).observe(this.stage)}render({type:e,source:t,options:n={}}){if(!t.trim()){this.requestNumber++,this.pendingRender=null,this.abortController?.abort(),this.setStatus(`Write something to render.`,`idle`);return}return this.pendingRender={type:e,source:t,options:n,requestNumber:++this.requestNumber},this.abortController?.abort(),this.renderLoop||=this.drainRenderQueue(),this.renderLoop}async drainRenderQueue(){try{for(;this.pendingRender;){let e=this.pendingRender;this.pendingRender=null,await this.performRender(e)}}finally{this.renderLoop=null,this.pendingRender&&(this.renderLoop=this.drainRenderQueue())}}async performRender({type:e,source:t,options:n,requestNumber:r}){let i=new AbortController;this.abortController=i,this.setStatus(`Rendering…`,`loading`),this.stage.style.setProperty(`--render-background`,`var(--preview-bg)`);let a=ST(window.location.origin,{type:e,source:t,options:n}),o=a.length<=dT,s=o?a:new URL(`/${encodeURIComponent(e)}/svg`,window.location.origin);if(!o)for(let[e,t]of Object.entries(n))s.searchParams.set(e,String(t));try{let e=await fetch(s,{method:o?`GET`:`POST`,headers:o?{Accept:`image/svg+xml`}:{Accept:`image/svg+xml`,"Content-Type":`text/plain; charset=utf-8`},body:o?void 0:t,signal:i.signal});if(r!==this.requestNumber)return;if(!e.ok)throw Error(await this.errorMessage(e));this.status.dataset.cache=e.headers.get(`X-Diagram-Cache`)?.toLowerCase()??`browser`;let{blob:n,background:a}=this.normalizedSvgBlob(await e.text());this.stage.style.setProperty(`--render-background`,a);let c=URL.createObjectURL(n),l=this.objectUrl;this.objectUrl=c,this.image.src=c,this.minimapImage.src=c,this.image.hidden=!1,this.setStatus(`Rendered`,`ready`),l&&URL.revokeObjectURL(l)}catch(e){if(e.name===`AbortError`)return;this.setStatus(e.message||`Could not render this diagram.`,`error`)}finally{this.abortController===i&&(this.abortController=null)}}async errorMessage(e){let t=await e.text();return new DOMParser().parseFromString(t,`text/html`).body.textContent.trim().replace(/\s+/g,` `)||`Render failed with HTTP ${e.status}.`}normalizedSvgBlob(e){let t=new DOMParser().parseFromString(e,`image/svg+xml`).documentElement,n=t.getAttribute(`viewBox`)?.trim().split(/[\s,]+/).map(Number);t.nodeName===`svg`&&n?.length===4&&n.every(Number.isFinite)&&(t.hasAttribute(`width`)||t.setAttribute(`width`,String(n[2])),t.hasAttribute(`height`)||t.setAttribute(`height`,String(n[3])),e=new XMLSerializer().serializeToString(t));let r=t.style.backgroundColor||t.style.background,i=r&&r!==`transparent`?r:`#ffffff`;return{blob:new Blob([e],{type:`image/svg+xml`}),background:i}}setStatus(e,t){this.status.textContent=e,this.status.dataset.state=t}zoom(e){if(this.image.hidden)return;let t=this.stage.getBoundingClientRect();this.zoomAt(e,t.width/2,t.height/2)}zoomAt(e,t,n){let r=TT(this.scale*e,.1,8),i=(t-this.x)/this.scale,a=(n-this.y)/this.scale;this.x=t-i*r,this.y=n-a*r,this.scale=r,this.updateTransform()}wheelZoom(e){if(this.image.hidden||e.target.closest(`.preview-toolbar, .minimap`))return;e.preventDefault();let t=this.stage.getBoundingClientRect(),n=e.deltaY*(e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?t.height:1);this.zoomAt(Math.exp(-TT(n,-240,240)*.002),e.clientX-t.left,e.clientY-t.top)}oneToOne(){if(this.image.hidden)return;let e=this.stage.getBoundingClientRect();this.scale=1,this.x=(e.width-this.image.naturalWidth)/2,this.y=(e.height-this.image.naturalHeight)/2,this.updateTransform()}fit(){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let e=this.stage.getBoundingClientRect(),t=Math.min(64,e.width*.12);this.scale=TT(Math.min((e.width-t*2)/this.image.naturalWidth,(e.height-t*2)/this.image.naturalHeight),.1,2),this.x=(e.width-this.image.naturalWidth*this.scale)/2,this.y=(e.height-this.image.naturalHeight*this.scale)/2,this.updateTransform()}updateTransform(){this.image.style.transform=`translate(${this.x}px, ${this.y}px) scale(${this.scale})`,this.updateMinimap()}startPan(e){this.image.hidden||e.button!==0||e.target.closest(`.preview-toolbar, .minimap`)||(this.drag={pointerId:e.pointerId,x:e.clientX,y:e.clientY,originX:this.x,originY:this.y},this.stage.setPointerCapture(e.pointerId),this.stage.dataset.dragging=`true`)}pan(e){!this.drag||e.pointerId!==this.drag.pointerId||(this.x=this.drag.originX+e.clientX-this.drag.x,this.y=this.drag.originY+e.clientY-this.drag.y,this.updateTransform())}endPan(e){!this.drag||e.pointerId!==this.drag.pointerId||(this.drag=null,delete this.stage.dataset.dragging)}moveFromMinimap(e){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let t=this.minimap.getBoundingClientRect(),n=Math.min(t.width/this.image.naturalWidth,t.height/this.image.naturalHeight),r=(t.width-this.image.naturalWidth*n)/2,i=(t.height-this.image.naturalHeight*n)/2,a=(e.clientX-t.left-r)/n,o=(e.clientY-t.top-i)/n,s=this.stage.getBoundingClientRect();this.x=s.width/2-a*this.scale,this.y=s.height/2-o*this.scale,this.updateTransform()}updateMinimap(){if(!this.image.naturalWidth||!this.image.naturalHeight)return;let e=this.stage.getBoundingClientRect(),t=this.image.naturalWidth*this.scale,n=this.image.naturalHeight*this.scale,r=this.x>=0&&this.y>=0&&this.x+t<=e.width&&this.y+n<=e.height;if(this.minimap.hidden=r,r)return;let i=this.minimap.getBoundingClientRect(),a=Math.min(i.width/this.image.naturalWidth,i.height/this.image.naturalHeight),o=(i.width-this.image.naturalWidth*a)/2,s=(i.height-this.image.naturalHeight*a)/2,c=TT(-this.x/this.scale,0,this.image.naturalWidth),l=TT(-this.y/this.scale,0,this.image.naturalHeight),u=TT((e.width-this.x)/this.scale,0,this.image.naturalWidth),d=TT((e.height-this.y)/this.scale,0,this.image.naturalHeight);this.minimapViewport.style.left=`${o+c*a}px`,this.minimapViewport.style.top=`${s+l*a}px`,this.minimapViewport.style.width=`${Math.max(4,(u-c)*a)}px`,this.minimapViewport.style.height=`${Math.max(4,(d-l)*a)}px`}},DT=`diagram.zip:draft:v1`,OT=new Ce,kT,AT=!1,jT,MT=new Map;document.querySelector(`#app`).innerHTML=`1640+ <main class="app-shell">1641+ <header class="app-header">1642+ <a class="brand" href="#" aria-label="New diagram"><img class="brand-mark" src="/diagram.zip/icon.svg" alt=""><span>diagram.zip</span></a>1643+ <div class="header-meta">1644+ <span class="render-status" data-state="idle" role="status">Ready</span>1645+ <label class="type-picker">1646+ <span class="sr-only">Diagram type</span>1647+ <select id="diagram-type"></select>1648+ </label>1649+ <button class="primary-action" id="share" type="button">Share</button>1650+ </div>1651+ </header>1652+1653+ <div class="mobile-tabs" role="tablist" aria-label="Workspace panel">1654+ <button type="button" role="tab" aria-selected="true" data-panel="editor">Edit</button>1655+ <button type="button" role="tab" aria-selected="false" data-panel="preview">Preview</button>1656+ </div>1657+1658+ <div class="workspace" data-mobile-panel="editor">1659+ <section class="editor-panel" aria-label="Diagram source">1660+ <div id="editor"></div>1661+ </section>1662+ <section class="preview-panel" aria-label="Diagram preview">1663+ <div class="preview-stage" id="preview-stage">1664+ <img id="preview-image" alt="Rendered diagram" draggable="false" hidden>1665+ <p class="preview-empty">Your diagram will appear here.</p>1666+ <div class="preview-toolbar" aria-label="Preview controls">1667+ <button type="button" data-preview-action="zoom-out" aria-label="Zoom out">−</button>1668+ <button type="button" data-preview-action="zoom-in" aria-label="Zoom in">+</button>1669+ <button type="button" data-preview-action="fit">Fit</button>1670+ <button type="button" data-preview-action="one-to-one">1:1</button>1671+ </div>1672+ <div class="minimap" id="minimap" aria-label="Preview minimap" hidden>1673+ <img id="minimap-image" alt="" draggable="false">1674+ <span id="minimap-viewport" aria-hidden="true"></span>1675+ </div>1676+ </div>1677+ </section>1678+ </div>1679+ </main>1680+1681+ <dialog id="share-dialog" aria-labelledby="share-title">1682+ <form method="dialog" class="dialog-card">1683+ <div class="dialog-header">1684+ <div><p class="dialog-eyebrow">Share</p><h1 id="share-title">Take the diagram with you.</h1></div>1685+ <button class="icon-button" value="cancel" aria-label="Close">×</button>1686+ </div>1687+ <div class="share-options">1688+ <label><span>Editable diagram</span><div><input id="editable-link" readonly><button type="button" data-copy="editable-link">Copy</button></div></label>1689+ <label><span>SVG image</span><div><input id="image-link" readonly><button type="button" data-copy="image-link">Copy</button></div><small id="image-link-note"></small></label>1690+ <label><span>Markdown</span><div><input id="markdown-link" readonly><button type="button" data-copy="markdown-link">Copy</button></div></label>1691+ </div>1692+ </form>1693+ </dialog>1694+1695+ <div class="toast" id="toast" role="status" aria-live="polite"></div>1696+`;var NT=document.querySelector(`#diagram-type`);for(let{id:e,label:t}of px)NT.add(new Option(t,e));var PT=VT();NT.value=PT.type,jT=PT.type,MT.set(PT.type,PT.source);var FT=ad.define([{tag:Y.keyword,color:`var(--syntax-keyword)`,fontWeight:`650`},{tag:Y.string,color:`var(--syntax-string)`},{tag:[Y.comment,Y.lineComment,Y.blockComment],color:`var(--syntax-comment)`,fontStyle:`italic`},{tag:[Y.number,Y.bool],color:`var(--syntax-number)`},{tag:[Y.operator,Y.punctuation],color:`var(--syntax-operator)`},{tag:[Y.variableName,Y.typeName],color:`var(--syntax-variable)`}]),IT=new W({state:P.create({doc:PT.source,extensions:[A_,OT.of(vx(PT.type)),ld(FT),W.theme({"&":{height:`100%`,backgroundColor:`transparent`},".cm-scroller":{fontFamily:`var(--font-mono)`,lineHeight:`1.65`},".cm-content":{padding:`28px 10px 80px`},".cm-gutters":{backgroundColor:`transparent`,border:`0`,paddingLeft:`12px`},".cm-activeLine, .cm-activeLineGutter":{backgroundColor:`var(--editor-active-line)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--ink)`},"&.cm-focused":{outline:`none`}}),W.updateListener.of(e=>{e.docChanged&&!AT&&zT()})]}),parent:document.querySelector(`#editor`)}),LT=new ET({stage:document.querySelector(`#preview-stage`),image:document.querySelector(`#preview-image`),status:document.querySelector(`.render-status`),minimap:document.querySelector(`#minimap`),minimapImage:document.querySelector(`#minimap-image`),minimapViewport:document.querySelector(`#minimap-viewport`)});NT.addEventListener(`change`,()=>{MT.set(jT,IT.state.doc.toString());let e=NT.value;HT({type:e,source:MT.get(e)??wT(e),options:{}})}),document.querySelector(`#share`).addEventListener(`click`,UT),document.querySelector(`.brand`).addEventListener(`click`,e=>{e.preventDefault(),confirm(`Start a new diagram?`)&&HT({type:fT,source:pT,options:{}})}),document.querySelectorAll(`[data-preview-action]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.dataset.previewAction;t===`zoom-out`&<.zoom(.8),t===`zoom-in`&<.zoom(1.25),t===`fit`&<.fit(),t===`one-to-one`&<.oneToOne()})}),document.querySelectorAll(`.mobile-tabs button`).forEach(e=>{e.addEventListener(`click`,()=>{document.querySelector(`.workspace`).dataset.mobilePanel=e.dataset.panel,document.querySelectorAll(`.mobile-tabs button`).forEach(t=>{t.setAttribute(`aria-selected`,String(t===e))}),e.dataset.panel===`preview`&<.fit()})}),document.querySelectorAll(`[data-copy]`).forEach(e=>{e.addEventListener(`click`,async()=>{await WT(document.querySelector(`#${e.dataset.copy}`).value),GT(`Copied`)})}),window.addEventListener(`hashchange`,()=>{try{HT(xT(location.hash),!1)}catch{GT(`This diagram link could not be opened.`)}}),window.addEventListener(`keydown`,e=>{(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),UT())});function RT(){return{type:NT.value,source:IT.state.doc.toString(),options:{}}}function zT(e=1200){clearTimeout(kT),kT=setTimeout(BT,e)}function BT(){let e=RT(),t=bT(e);location.hash!==t&&history.replaceState(null,``,t),localStorage.setItem(DT,JSON.stringify(e)),LT.render(e)}function VT(){if(location.hash.startsWith(`#v1/`))try{let e=xT(location.hash);if(yx(e.type))return e}catch{}try{let e=JSON.parse(localStorage.getItem(DT));if(e&&yx(e.type)&&typeof e.source==`string`)return{...e,options:e.options??{}}}catch{}return{type:fT,source:pT,options:{}}}function HT(e,t=!0){if(!yx(e.type))throw Error(`Unsupported diagram type.`);AT=!0,jT=e.type,MT.set(e.type,e.source),NT.value=e.type,IT.dispatch({changes:{from:0,to:IT.state.doc.length,insert:e.source},effects:OT.reconfigure(vx(e.type))}),AT=!1,t?BT():LT.render(RT())}function UT(){BT();let e=RT(),t=`${location.origin}${location.pathname}${bT(e)}`,n=ST(location.origin,e),r=n.length>dT,i=document.querySelector(`#image-link`),a=document.querySelector(`#markdown-link`),o=document.querySelector(`[data-copy="image-link"]`),s=document.querySelector(`[data-copy="markdown-link"]`);document.querySelector(`#editable-link`).value=t,i.value=r?``:n,i.placeholder=r?`Unavailable for this diagram`:``,a.value=r?``:``,a.placeholder=r?`Unavailable for this diagram`:``,o.disabled=r,s.disabled=r,document.querySelector(`#image-link-note`).textContent=r?`This diagram exceeds the safe image URL limit. Share the editable link instead.`:``,document.querySelector(`#share-dialog`).showModal()}async function WT(e){if(navigator.clipboard)return navigator.clipboard.writeText(e);let t=document.createElement(`textarea`);t.value=e,document.body.append(t),t.select(),document.execCommand(`copy`),t.remove()}function GT(e){let t=document.querySelector(`#toast`);t.textContent=e,t.dataset.visible=`true`,clearTimeout(GT.timeout),GT.timeout=setTimeout(()=>delete t.dataset.visible,1800)}BT();\ No newline at end of file@@ -0,0 +1,16 @@
1+2+<html lang="en">3+ <head>4+ <meta charset="UTF-8">5+ <meta name="viewport" content="width=device-width, initial-scale=1.0">6+ <meta name="theme-color" content="#ffffff">7+ <meta name="description" content="Create diagrams from text and share them as a link.">8+ <link rel="icon" href="/diagram.zip/icon.svg" type="image/svg+xml">9+ <title>diagram.zip</title>10+ <script type="module" crossorigin src="/diagram.zip/assets/index-DdXUFryB.js"></script>11+ <link rel="stylesheet" crossorigin href="/diagram.zip/assets/index-Cvv5Q-Ty.css">12+ </head>13+ <body>14+ <div id="app"></div>15+ </body>16+</html>@@ -107,7 +107,7 @@ class ServerListenTest {
107107 .as(BodyCodec.string())108108 .send()109109 .await(2, TimeUnit.SECONDS);110- assertThat(response.body()).contains("https://kroki.io");110+ assertThat(response.body()).contains("<title>diagram.zip</title>");111111 }112112 113113 private int getAvailablePort() throws IOException {@@ -45,7 +45,7 @@ class ServerSSLTest {
4545 .as(BodyCodec.string())4646 .send()4747 .await(5, TimeUnit.SECONDS);48- assertThat(response.body()).contains("https://kroki.io");48+ assertThat(response.body()).contains("<title>diagram.zip</title>");4949 }5050 5151 @@ -61,7 +61,7 @@ class ServerSSLTest {
6161 .as(BodyCodec.string())6262 .send()6363 .await(5, TimeUnit.SECONDS);64- assertThat(response.body()).contains("https://kroki.io");64+ assertThat(response.body()).contains("<title>diagram.zip</title>");6565 }6666 6767 @@ -77,7 +77,7 @@ class ServerSSLTest {
7777 .as(BodyCodec.string())7878 .send()7979 .await(5, TimeUnit.SECONDS);80- assertThat(response.body()).contains("https://kroki.io");80+ assertThat(response.body()).contains("<title>diagram.zip</title>");8181 }8282 8383 @@ -51,7 +51,7 @@ class ServerTest {
5151 if (response.failed()) {5252 throw new RuntimeException("Failed to get response", response.cause());5353 } else {54- assertThat(response.result().bodyAsString()).contains("https://kroki.io");54+ assertThat(response.result().bodyAsString()).contains("<title>diagram.zip</title>");5555 }5656 });5757 }@@ -52,6 +52,6 @@ public class ServerUriResponseTest {
5252 .await(5, TimeUnit.SECONDS);5353 assertThat(response.statusCode()).isEqualTo(414);5454 assertThat(response.statusMessage()).isEqualTo("Request-URI Too Long");55- assertThat(response.body()).isEqualTo("Error 414: The request URI's length exceeds 8192. You can update this value by setting KROKI_MAX_URI_LENGTH environment variable. Please read: https://docs.kroki.io/kroki/setup/configuration/#_max_uri_length for more information.");55+ assertThat(response.body()).isEqualTo("Error 414: This image link is too large to open. Use a shorter diagram or share the editable diagram.zip link instead.");5656 }5757 }@@ -19,6 +19,10 @@ import java.nio.file.Files;
1919 import java.nio.file.Paths;2020 import java.util.HashMap;2121 import java.util.concurrent.TimeUnit;22+import java.util.concurrent.CancellationException;23+import java.util.concurrent.ExecutionException;24+import java.util.concurrent.ExecutorService;25+import java.util.concurrent.Executors;2226 import java.util.regex.Matcher;2327 import java.util.regex.Pattern;2428 import java.util.stream.Collectors;@@ -37,6 +41,23 @@ class CommanderTest {
3741 .hasMessageStartingWith("Cannot run program \"/path/not/found/dot\"");3842 }3943 44+ 45+ void should_terminate_a_cancelled_command() throws Exception {46+ RenderCancellation cancellation = new RenderCancellation();47+ ExecutorService executor = Executors.newSingleThreadExecutor();48+ try {49+ java.util.concurrent.Future<byte[]> result = executor.submit(() ->50+ new Commander(new JsonObject().put("KROKI_COMMAND_TIMEOUT", "30s"))51+ .execute(cancellation, new byte[0], "sh", "-c", "sleep 30"));52+ cancellation.cancel();53+ assertThatThrownBy(() -> result.get(5, TimeUnit.SECONDS))54+ .isInstanceOf(ExecutionException.class)55+ .hasCauseInstanceOf(CancellationException.class);56+ } finally {57+ executor.shutdownNow();58+ }59+ }60+4061 // Server code injection4162 4263 @@ -326,6 +326,8 @@ class DiagramHandlerTest {
326326 when(diagramService.getSupportedFormats()).thenReturn(supportedFormats);327327 when(diagramService.getSourceDecoder()).thenReturn(sourceDecoder);328328 when(diagramService.convert(any(), any(), any(), any())).thenReturn(Future.succeededFuture(Buffer.buffer("")));329+ when(diagramService.convert(any(), any(), any(), any(), any())).thenAnswer(invocation ->330+ diagramService.convert(invocation.getArgument(0), invocation.getArgument(1), invocation.getArgument(2), invocation.getArgument(3)));329331 return diagramService;330332 }331333 }@@ -0,0 +1,42 @@
1+package io.kroki.server.service;2+3+import io.vertx.core.Handler;4+import io.vertx.core.Vertx;5+import io.vertx.core.http.HttpHeaders;6+import io.vertx.core.http.HttpServerResponse;7+import io.vertx.ext.web.RoutingContext;8+import org.junit.jupiter.api.Test;9+import org.mockito.ArgumentMatcher;10+import org.mockito.Mockito;11+12+import static org.mockito.ArgumentMatchers.any;13+import static org.mockito.ArgumentMatchers.argThat;14+import static org.mockito.ArgumentMatchers.contains;15+import static org.mockito.ArgumentMatchers.eq;16+import static org.mockito.Mockito.mock;17+import static org.mockito.Mockito.when;18+19+class DiagramZipHandlerTest {20+21+ 22+ void shouldReturnTheApplicationShellWithSecurityHeaders() {23+ Vertx vertx = Vertx.vertx();24+ RoutingContext routingContext = mock(RoutingContext.class);25+ HttpServerResponse response = mock(HttpServerResponse.class);26+ when(routingContext.response()).thenReturn(response);27+ when(response.putHeader(any(CharSequence.class), any(CharSequence.class))).thenReturn(response);28+29+ Handler<RoutingContext> handler = new DiagramZipHandler(vertx).create();30+ handler.handle(routingContext);31+32+ Mockito.verify(response).putHeader(HttpHeaders.CONTENT_TYPE, "text/html; charset=utf-8");33+ Mockito.verify(response).putHeader(HttpHeaders.CACHE_CONTROL, "no-cache");34+ Mockito.verify(response).putHeader(35+ eq("Content-Security-Policy"),36+ contains("connect-src 'self'")37+ );38+ Mockito.verify(response).end(argThat((ArgumentMatcher<String>) page ->39+ page.contains("<title>diagram.zip</title>") && page.contains("/diagram.zip/assets/")40+ ));41+ }42+}@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.format.FileFormat;56 import io.vertx.core.Vertx;67 import io.vertx.core.buffer.Buffer;@@ -22,7 +23,7 @@ public class GraphVizServiceTest {
2223 public void should_call_graphviz_with_correct_arguments() throws Throwable {2324 Vertx vertx = Vertx.vertx();2425 Commander commanderMock = mock(Commander.class);25- when(commanderMock.execute(any(), any(String[].class))).thenReturn("<svg>graphviz</svg>".getBytes());26+ when(commanderMock.execute(any(RenderCancellation.class), any(), any(String[].class))).thenReturn("<svg>graphviz</svg>".getBytes());2627 HashMap<String, Object> config = new HashMap<>();2728 config.put("KROKI_SAFE_MODE", "unsafe");2829 config.put("KROKI_DOT_BIN_PATH", "/path/to/dot");@@ -37,6 +38,6 @@ public class GraphVizServiceTest {
3738 options.put("edge-attribute-arrowhead", "diamond");3839 Buffer buffer = graphvizService.convert("{}", "graphviz", FileFormat.SVG, options).await(2, TimeUnit.SECONDS);3940 assertThat(buffer.toString()).isEqualTo("<svg>graphviz</svg>");40- Mockito.verify(commanderMock).execute("{}".getBytes(), "/path/to/dot", "-Tsvg", "-Kneato", "-Nfontcolor=Crimson", "-Nshape=rect", "-Gfontcolor=SteelBlue", "-Glabel=Hello World", "-Ecolor=NavajoWhite", "-Earrowhead=diamond");41+ Mockito.verify(commanderMock).execute(any(RenderCancellation.class), Mockito.eq("{}".getBytes()), Mockito.eq("/path/to/dot"), Mockito.eq("-Tsvg"), Mockito.eq("-Kneato"), Mockito.eq("-Nfontcolor=Crimson"), Mockito.eq("-Nshape=rect"), Mockito.eq("-Gfontcolor=SteelBlue"), Mockito.eq("-Glabel=Hello World"), Mockito.eq("-Ecolor=NavajoWhite"), Mockito.eq("-Earrowhead=diamond"));4142 }4243 }@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.format.FileFormat;56 import io.vertx.core.Vertx;67 import io.vertx.core.buffer.Buffer;@@ -22,13 +23,13 @@ public class PikchrServiceTest {
2223 public void should_call_pikchr_with_correct_arguments() throws Throwable {2324 Vertx vertx = Vertx.vertx();2425 Commander commanderMock = mock(Commander.class);25- when(commanderMock.execute(any(), any(String[].class))).thenReturn("<svg>pikchr</svg>".getBytes());26+ when(commanderMock.execute(any(RenderCancellation.class), any(), any(String[].class))).thenReturn("<svg>pikchr</svg>".getBytes());2627 HashMap<String, Object> config = new HashMap<>();2728 config.put("KROKI_SAFE_MODE", "unsafe");2829 config.put("KROKI_PIKCHR_BIN_PATH", "/path/to/pikchr");2930 Pikchr pikchrService = new Pikchr(vertx, new JsonObject(config), commanderMock);3031 Buffer buffer = pikchrService.convert("{}", "pikchr", FileFormat.SVG, new JsonObject()).await(2, TimeUnit.SECONDS);3132 assertThat(buffer.toString()).isEqualTo("<svg>pikchr</svg>");32- Mockito.verify(commanderMock).execute("{}".getBytes(), "/path/to/pikchr", "--svg-only", "-");33+ Mockito.verify(commanderMock).execute(any(RenderCancellation.class), Mockito.eq("{}".getBytes()), Mockito.eq("/path/to/pikchr"), Mockito.eq("--svg-only"), Mockito.eq("-"));3334 }3435 }@@ -0,0 +1,65 @@
1+package io.kroki.server.service;2+3+import io.kroki.server.action.RenderCancellation;4+import io.kroki.server.format.FileFormat;5+import io.vertx.core.Promise;6+import io.vertx.core.buffer.Buffer;7+import io.vertx.core.json.JsonObject;8+import org.junit.jupiter.api.Test;9+10+import java.util.concurrent.atomic.AtomicInteger;11+import java.util.concurrent.atomic.AtomicReference;12+13+import static org.assertj.core.api.Assertions.assertThat;14+15+class RenderCacheTest {16+17+ 18+ void should_coalesce_in_flight_renders_and_cache_successes() {19+ RenderCache cache = new RenderCache(new JsonObject());20+ Promise<Buffer> render = Promise.promise();21+ AtomicInteger calls = new AtomicInteger();22+23+ RenderCache.RenderRequest first = cache.render("packetdiag", FileFormat.SVG, "source", new JsonObject(), cancellation -> {24+ calls.incrementAndGet();25+ return render.future();26+ });27+ RenderCache.RenderRequest second = cache.render("packetdiag", FileFormat.SVG, "source", new JsonObject(), cancellation -> {28+ calls.incrementAndGet();29+ return render.future();30+ });31+32+ assertThat(first.status()).isEqualTo(RenderCache.CacheStatus.MISS);33+ assertThat(second.status()).isEqualTo(RenderCache.CacheStatus.COALESCED);34+ assertThat(calls).hasValue(1);35+36+ render.complete(Buffer.buffer("svg"));37+ assertThat(first.future().result().toString()).isEqualTo("svg");38+39+ RenderCache.RenderRequest third = cache.render("packetdiag", FileFormat.SVG, "source", new JsonObject(), cancellation -> {40+ calls.incrementAndGet();41+ return render.future();42+ });43+ assertThat(third.status()).isEqualTo(RenderCache.CacheStatus.HIT);44+ assertThat(third.future().result().toString()).isEqualTo("svg");45+ assertThat(calls).hasValue(1);46+ }47+48+ 49+ void should_cancel_when_the_last_subscriber_leaves() {50+ RenderCache cache = new RenderCache(new JsonObject());51+ Promise<Buffer> render = Promise.promise();52+ AtomicReference<RenderCancellation> cancellation = new AtomicReference<>();53+54+ RenderCache.RenderRequest first = cache.render("packetdiag", FileFormat.SVG, "source", new JsonObject(), token -> {55+ cancellation.set(token);56+ return render.future();57+ });58+ RenderCache.RenderRequest second = cache.render("packetdiag", FileFormat.SVG, "source", new JsonObject(), token -> render.future());59+60+ first.release();61+ assertThat(cancellation.get().isCancelled()).isFalse();62+ second.release();63+ assertThat(cancellation.get().isCancelled()).isTrue();64+ }65+}@@ -1,6 +1,7 @@
11 package io.kroki.server.service;22 33 import io.kroki.server.action.Commander;4+import io.kroki.server.action.RenderCancellation;45 import io.kroki.server.format.FileFormat;56 import io.vertx.core.Vertx;67 import io.vertx.core.buffer.Buffer;@@ -22,27 +23,27 @@ public class VegaServiceTest {
2223 public void should_call_vega_with_correct_arguments() throws Throwable {2324 Vertx vertx = Vertx.vertx();2425 Commander commanderMock = mock(Commander.class);25- when(commanderMock.execute(any(), any(String[].class))).thenReturn("<svg>vega</svg>".getBytes());26+ when(commanderMock.execute(any(RenderCancellation.class), any(), any(String[].class))).thenReturn("<svg>vega</svg>".getBytes());2627 HashMap<String, Object> config = new HashMap<>();2728 config.put("KROKI_SAFE_MODE", "unsafe");2829 config.put("KROKI_VEGA_BIN_PATH", "/path/to/vega");2930 Vega vegaService = new Vega(vertx, new JsonObject(config), Vega.SpecFormat.DEFAULT, commanderMock);3031 Buffer buffer = vegaService.convert("{}", "vega", FileFormat.SVG, new JsonObject()).await(4, TimeUnit.SECONDS);3132 assertThat(buffer.toString()).isEqualTo("<svg>vega</svg>");32- Mockito.verify(commanderMock).execute("{}".getBytes(), "/path/to/vega", "--output-format=svg", "--safe-mode=unsafe", "--spec-format=default");33+ Mockito.verify(commanderMock).execute(any(RenderCancellation.class), Mockito.eq("{}".getBytes()), Mockito.eq("/path/to/vega"), Mockito.eq("--output-format=svg"), Mockito.eq("--safe-mode=unsafe"), Mockito.eq("--spec-format=default"));3334 }3435 3536 3637 public void should_call_vega_lite_with_correct_arguments() throws Throwable {3738 Vertx vertx = Vertx.vertx();3839 Commander commanderMock = mock(Commander.class);39- when(commanderMock.execute(any(), any(String[].class))).thenReturn("<svg>vega-lite</svg>".getBytes());40+ when(commanderMock.execute(any(RenderCancellation.class), any(), any(String[].class))).thenReturn("<svg>vega-lite</svg>".getBytes());4041 HashMap<String, Object> config = new HashMap<>();4142 config.put("KROKI_SAFE_MODE", "unsafe");4243 config.put("KROKI_VEGA_BIN_PATH", "/path/to/vega");4344 Vega vegaService = new Vega(vertx, new JsonObject(config), Vega.SpecFormat.LITE, commanderMock);4445 Buffer buffer = vegaService.convert("{}", "vegalite", FileFormat.SVG, new JsonObject()).await(4, TimeUnit.SECONDS);4546 assertThat(buffer.toString()).isEqualTo("<svg>vega-lite</svg>");46- Mockito.verify(commanderMock).execute("{}".getBytes(), "/path/to/vega", "--output-format=svg", "--safe-mode=unsafe", "--spec-format=lite");47+ Mockito.verify(commanderMock).execute(any(RenderCancellation.class), Mockito.eq("{}".getBytes()), Mockito.eq("/path/to/vega"), Mockito.eq("--output-format=svg"), Mockito.eq("--safe-mode=unsafe"), Mockito.eq("--spec-format=lite"));4748 }4849 }Not shown: this page already shows 6000 lines of diff.