diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9daeb0..26232e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,10 @@ repos: - id: check-toml - id: check-added-large-files args: ['--maxkb=1024'] + # The tracked web build output (src/profiles/web/dist/) is a + # bundled artifact regenerated by `npm run build`; its minified + # JS bundle crossed the 1 MB source-size line (issue #192 PR). + exclude: ^src/profiles/web/dist/ # Ruff - Linter et formatter - repo: https://github.com/astral-sh/ruff-pre-commit diff --git a/AGENTS.md b/AGENTS.md index 2f7ce2f..2a2d4d6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,6 +47,7 @@ Ce document définit les standards d'architecture, les principes de conception e src/profiles/ ├── core/ # Logique métier — indépendante de toute UI │ ├── actions.py # Actions domaine (lancement, ouverture, ActionResult) +│ ├── paths.py # Politique de chemins utilisateur (~/.profiles, CWD non informatifs, #191) │ ├── config/ # Sous-système configuration │ │ ├── models.py # AppConfig, MachineConfiguration, ColumnConfiguration │ │ ├── loader.py # load_config, propose_config_creation diff --git a/CHANGELOG.md b/CHANGELOG.md index de5848e..68bdaab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **Per-user configuration path policy** (issue #191): launcher-style + launches (Start Menu, pinned taskbar, `.desktop` entries — any process + whose CWD is System32, the home folder, or an install/runtime directory) + no longer propose creating `.profiles` in a system directory. The + proposal targets `~/.profiles/.profiles` (next to `profiles.log`), every + later launch loads that per-user default automatically, terminal/project + launches keep their current behavior, and no code path ever proposes an + existing directory as the configuration file. New + `profiles.core.paths` module is the single source of truth for these + user-level locations. - **Windows installer polish**: the MSI now creates a desktop shortcut, asks per-user vs per-machine at install time, and shows a proper finish page ("Launch ProFiles" checkbox plus Documentation / What's new links). @@ -20,6 +30,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Branded installer**: the welcome dialog and page banners now use the ProFiles brand art (indigo-violet gradient) instead of the stock WiX look. +### Fixed + +- **Config picker mode follows the entry point** (issue #192): with no + active configuration, the editor's **Load config file…** and the file + list's **Choose configuration** buttons now open the picker in Load + mode; only the first-run auto-prompt still opens Create mode. + ### Changed - **Loopback-only by default**: the web server now binds `127.0.0.1` on launch diff --git a/README.fr.md b/README.fr.md index 6b5db7f..e57087b 100644 --- a/README.fr.md +++ b/README.fr.md @@ -220,7 +220,7 @@ ProFiles --config "/path/to/.profiles" ## 🛠 Configuration -ProFiles est piloté par un fichier **YAML** `.profiles`, recherché en remontant l'arborescence du système de fichiers. +ProFiles est piloté par un fichier **YAML** `.profiles`, recherché en remontant l'arborescence du système de fichiers. Les lancements par lanceur (menu Démarrer, dock, entrées `.desktop`) ignorent la recherche dans l'arborescence et chargent le défaut par utilisateur `~/.profiles/.profiles` s'il existe ; sans fichier trouvé, la proposition de création cible le dossier du projet — ou `~/.profiles` pour un lancement par lanceur — afin de ne jamais écrire dans un répertoire système. ```yaml # ProFiles Configuration — Format YAML diff --git a/README.md b/README.md index 4db9e1b..c658c96 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ ProFiles --config "/path/to/.profiles" ## 🛠 Configuration -ProFiles is driven by a `.profiles` **YAML** file, walking up the filesystem tree to locate it. +ProFiles is driven by a `.profiles` **YAML** file, walking up the filesystem tree to locate it. Launcher-style starts (Start Menu, dock, `.desktop` entries) skip the tree search and load the per-user default `~/.profiles/.profiles` when it exists; when nothing is found, the creation proposal targets the project folder — or `~/.profiles` for launcher starts — so nothing is ever written into a system directory. ```yaml # ProFiles Configuration — YAML Format diff --git a/docs/configuration-profile.en.md b/docs/configuration-profile.en.md index 6975f9e..27ecec2 100644 --- a/docs/configuration-profile.en.md +++ b/docs/configuration-profile.en.md @@ -12,18 +12,18 @@ ## Overview -The `.profiles` file is a **YAML-format** configuration file that customizes ProFiles's behavior. This file is searched for starting from the current working directory (CWD) and descending into subdirectories. The first match found is used. +The `.profiles` file is a **YAML-format** configuration file that customizes ProFiles's behavior. This file is searched for starting from the current working directory (CWD) and descending into subdirectories. The first match found is used. The CWD tree is skipped when the CWD carries no launch information — a Start-Menu/launcher start inherits `System32`, the home folder, or the interpreter/app install directory — and the per-user default `~/.profiles/.profiles` is loaded when it exists instead. If no `.profiles` file is found: -- In interactive mode (web UI, desktop or browser): ProFiles proposes to create a default configuration file +- In interactive mode (web UI, desktop or browser): ProFiles proposes to create a default configuration file — in the project folder for a terminal launch, in `~/.profiles` for a launcher-style launch - In headless mode: ProFiles uses default values identical to those presented in this document ## Creating the Configuration File ### Method 1: Automatic Proposal (Interactive Mode) -On first launch in interactive mode (web UI in the PyWebView shell or browser), if no `.profiles` file is found, ProFiles proposes to create a default configuration file in the current working directory. +On first launch in interactive mode (web UI in the PyWebView shell or browser), if no `.profiles` file is found, ProFiles proposes to create a default configuration file in the current working directory. When that directory carries no launch information (a Start-Menu shortcut, a launcher with an empty "Start in" field, a Finder/dock launch), the proposal targets `~/.profiles/.profiles` instead — the same folder as `profiles.log` — so nothing is ever written into a system directory, and every later launch loads that per-user default automatically. ### Method 2: Command Line diff --git a/docs/configuration-profile.fr.md b/docs/configuration-profile.fr.md index 9cc7c90..7bbdaf0 100644 --- a/docs/configuration-profile.fr.md +++ b/docs/configuration-profile.fr.md @@ -12,17 +12,17 @@ ## Vue d'ensemble -Le fichier `.profiles` est un fichier de configuration au format **YAML** qui personnalise le comportement de ProFiles. Ce fichier est recherché en commençant depuis le répertoire courant (CWD) et en descendant dans les sous-répertoires. Le premier fichier trouvé est utilisé. +Le fichier `.profiles` est un fichier de configuration au format **YAML** qui personnalise le comportement de ProFiles. Ce fichier est recherché en commençant depuis le répertoire courant (CWD) et en descendant dans les sous-répertoires. Le premier fichier trouvé est utilisé. La recherche dans l'arborescence du CWD est ignorée lorsque le CWD ne porte aucune information de lancement — un démarrage via le menu Démarrer/ lanceur hérite de `System32`, du dossier personnel ou du répertoire d'installation de l'interpréteur/application — et le défaut par utilisateur `~/.profiles/.profiles` est chargé s'il existe. Si aucun fichier `.profiles` n'est trouvé : -- En mode interactif (interface web, bureau ou navigateur) : ProFiles propose de créer un fichier de configuration par défaut +- En mode interactif (interface web, bureau ou navigateur) : ProFiles propose de créer un fichier de configuration par défaut — dans le dossier du projet pour un lancement en terminal, dans `~/.profiles` pour un lancement par lanceur - En mode headless : ProFiles utilise des valeurs par défaut identiques à celles présentées dans ce document ## Création du fichier de configuration ### Méthode 1 : Proposition automatique (mode interactif) -Au premier lancement en mode interactif (interface web dans la fenêtre PyWebView ou dans le navigateur), si aucun fichier `.profiles` n'est trouvé, ProFiles propose de créer un fichier de configuration par défaut dans le répertoire courant. +Au premier lancement en mode interactif (interface web dans la fenêtre PyWebView ou dans le navigateur), si aucun fichier `.profiles` n'est trouvé, ProFiles propose de créer un fichier de configuration par défaut dans le répertoire courant. Lorsque ce répertoire ne porte aucune information de lancement (raccourci du menu Démarrer, lanceur avec un champ « Démarrer dans » vide, lancement depuis le Finder/dock), la proposition cible `~/.profiles/.profiles` — le même dossier que `profiles.log` — afin de ne jamais écrire dans un répertoire système ; chaque lancement suivant charge automatiquement ce défaut par utilisateur. ### Méthode 2 : Commande ligne de commande diff --git a/docs/installation-guide.en.md b/docs/installation-guide.en.md index fe4babd..7e3937f 100644 --- a/docs/installation-guide.en.md +++ b/docs/installation-guide.en.md @@ -256,6 +256,13 @@ python -m profiles --init This creates a `.profiles` file in the current directory with default settings. +You can also skip this step: on the **first launch from the Start Menu** (or +any launcher that runs without a project folder), ProFiles proposes to create +the configuration at `~/.profiles/.profiles` — the same folder as +`profiles.log` — and every later launch loads that per-user default +automatically. Launches from a terminal inside a project keep proposing the +project-local `.profiles`. + ### 2. Customize configuration Edit the `.profiles` file to adapt: diff --git a/src/profiles/app.py b/src/profiles/app.py index f09ac9e..53bbc4c 100644 --- a/src/profiles/app.py +++ b/src/profiles/app.py @@ -17,6 +17,7 @@ from profiles.core import AppConfig, actions, load_config from profiles.core.config.io.yaml_io import PRIMARY_CONFIG_NAME from profiles.core.environment.system import format_user_host +from profiles.core.paths import default_config_path from profiles.core.processing.scanner import scan_and_process from profiles.core.telemetry import events from profiles.core.telemetry.diagnostics import ( @@ -172,8 +173,8 @@ def _setup_logging(self, level: int | str = logging.INFO) -> logging.Logger: def _resolve_startup_config( self, explicit: Path | None, - ) -> tuple[Path | None, bool]: - """Return (config_path, config_is_missing). + ) -> tuple[Path | None, bool, Path]: + """Return (config_path, config_is_missing, launch_default). Uses the launch resolution logic to determine which config file should be used for this launch. On macOS a double-clicked @@ -182,11 +183,20 @@ def _resolve_startup_config( context (issue #188). The context source is remembered for the busy-port handoff decision. + The third element is the launch-default target from + :func:`profiles.core.paths.default_config_path` — where a + missing configuration would be proposed (``~/.profiles/.profiles`` + for launcher-style launches, the project folder for terminal + launches; issue #191). The defaults AppConfig carries it when + nothing was resolved, so the server and UI pre-fill the right + path without any server-specific override. + Args: explicit: Value of --config flag, if any. Returns: - Tuple of (resolved config path or None, whether it's missing). + Tuple of (resolved config path or None, whether it's missing, + default proposal target). """ documents: tuple[Path, ...] = () if not self._headless: @@ -198,12 +208,15 @@ def _resolve_startup_config( self._launch_source = ctx.source resolved = resolve_config_path(ctx) is_missing = resolved is not None and not resolved.exists() - return resolved, is_missing + launch_default = default_config_path(ctx.working_directory) + return resolved, is_missing, launch_default def _load_configuration(self, logger: logging.Logger) -> AppConfig: """Load the application configuration. Uses launch-time resolution to determine which config file to use. + When nothing resolves, the defaults are bound to the launch-default + target (``~/.profiles/.profiles`` for launcher starts, issue #191). If no config is found and not in server-only mode, offers to create a starter configuration. @@ -217,22 +230,23 @@ def _load_configuration(self, logger: logging.Logger) -> AppConfig: SystemExit(1) if configuration is invalid. """ # Use launch resolution instead of bare self._config_path - resolved, is_missing = self._resolve_startup_config(self._config_path) + resolved, is_missing, launch_default = self._resolve_startup_config(self._config_path) if is_missing: events.config_invalid(logger, error=f"Config file not found: {resolved}") print(f"ERROR: Configuration file not found: {resolved}", file=sys.stderr) sys.exit(1) + effective_path = resolved if resolved is not None else launch_default try: - config = load_config(resolved) + config = load_config(effective_path) events.config_loaded( logger, path=str(resolved) if resolved else "auto", mode="launch resolution" if resolved else "auto", release=config.release, ) - self._config_path = resolved # Update for later use + self._config_path = effective_path # Update for later use return config except (OSError, ValueError) as exc: events.config_invalid(logger, error=str(exc)) diff --git a/src/profiles/core/AGENTS.md b/src/profiles/core/AGENTS.md index ebf8076..5a45097 100644 --- a/src/profiles/core/AGENTS.md +++ b/src/profiles/core/AGENTS.md @@ -15,6 +15,7 @@ owns a single responsibility: | Sub-package / file | Responsibility (SRP) | | ------------------------ | ------------------------------------------------------------------------------------ | +| `paths.py` | Per-user path policy: `~/.profiles` data dir, config default, uninformative-directory tests (issue #191) | | `config/__init__.py` | Single point of egress for the configuration subsystem (high-level API) | | `config/models.py` | Pure dataclasses (`AppConfig`, `MachineConfiguration`, `ColumnConfiguration`, `HookSpec`, `WorkflowStep`) | | `config/service.py` | Domain operations over `AppConfig` — find, merge, auto-select directories | diff --git a/src/profiles/core/__init__.py b/src/profiles/core/__init__.py index 808e1d6..e6d83ea 100644 --- a/src/profiles/core/__init__.py +++ b/src/profiles/core/__init__.py @@ -46,6 +46,14 @@ parse_hook_entries, run_hooks_for_file, ) +from profiles.core.paths import ( + default_config_path, + default_search_directory, + find_user_config, + is_uninformative_directory, + user_config_path, + user_data_dir, +) from profiles.core.processing import ( ScannedFile, ScannedFileDynamic, @@ -90,6 +98,13 @@ "scan_and_process", # Template "STARTER_CONFIG_TEMPLATE", + # Per-user path policy (issue #191) + "default_config_path", + "default_search_directory", + "find_user_config", + "is_uninformative_directory", + "user_config_path", + "user_data_dir", # System "SystemInfo", "collect_system_info", diff --git a/src/profiles/core/config/io/yaml_io.py b/src/profiles/core/config/io/yaml_io.py index ac1734c..6c6239c 100644 --- a/src/profiles/core/config/io/yaml_io.py +++ b/src/profiles/core/config/io/yaml_io.py @@ -23,6 +23,18 @@ #: Every accepted configuration file name, primary first. CONFIG_FILE_NAMES: tuple[str, ...] = (PRIMARY_CONFIG_NAME, *FALLBACK_CONFIG_NAMES) + +def is_config_file_name(name: str) -> bool: + """True when a file *name* matches the accepted config whitelist. + + Case-insensitive on purpose: the save-as endpoint accepts + ``BACKUP.PROFILES`` (issue #95 wave), so every apply-path gate must + re-accept what it wrote. Shared by the server's config-name check and + the desktop odoc applier's skip guard (issue #193). + """ + return name.lower().endswith(CONFIG_FILE_NAMES) + + _yaml = YAML() _yaml.preserve_quotes = True @@ -268,6 +280,7 @@ def find_config_file( "PRIMARY_CONFIG_NAME", "content_hash", "find_config_file", + "is_config_file_name", "read_yaml", "write_text_atomic", "write_value", diff --git a/src/profiles/core/config/loader.py b/src/profiles/core/config/loader.py index 2fc29b3..c065069 100644 --- a/src/profiles/core/config/loader.py +++ b/src/profiles/core/config/loader.py @@ -11,21 +11,32 @@ from pathlib import Path from profiles.core.config.io.yaml_io import ( - PRIMARY_CONFIG_NAME, find_config_file, ) from profiles.core.config.models import AppConfig from profiles.core.config.reader import ConfigReader +from profiles.core.paths import ( + default_config_path, + default_search_directory, + find_user_config, + is_uninformative_directory, + user_data_dir, +) def load_config(config_path: Path | str | None = None) -> AppConfig: """Load the application configuration. - Searches the folder tree for a configuration file starting from - the working directory (canonical ``.profiles`` names first, then any - ``*.profiles``-style file, ascending). If *config_path* is provided, - uses that directly. Falls back to ``.profiles.yaml`` (backward - compatibility) when no ``.profiles`` file is found, then to defaults. + With *config_path*, uses that directly. Otherwise searches the folder + tree for a configuration file starting from the working directory + (canonical ``.profiles`` names first, then any ``*.profiles``-style + file, ascending) — skipping the search when the working directory is + uninformative (``System32``, home, interpreter/app install roots; + issue #191). When no project config is found, the per-user default + ``~/.profiles/.profiles`` is loaded when it exists; failing that, + defaults are returned bound to :func:`default_config_path` (the + per-user path for launcher-style launches, the project folder for + terminal launches). Args: config_path: Optional explicit path to the configuration file. @@ -36,19 +47,32 @@ def load_config(config_path: Path | str | None = None) -> AppConfig: if config_path is not None: return ConfigReader(config_path).load() - found = find_config_file() - if found is not None: - return ConfigReader(found).load() + try: + start = Path.cwd() + except OSError: + start = None + + if not is_uninformative_directory(start): + found = find_config_file() + if found is not None: + return ConfigReader(found).load() - # No .profiles found anywhere — use defaults from the primary path - return ConfigReader(Path.cwd() / PRIMARY_CONFIG_NAME).load() + user_config = find_user_config() + if user_config is not None: + return ConfigReader(user_config).load() + + # No .profiles found anywhere — use defaults bound to the policy-chosen + # default path (~/.profiles/.profiles for launcher starts). + return ConfigReader(default_config_path(start)).load() def propose_config_creation() -> bool: """Propose to create a default ``.profiles`` configuration file. Prompts the user in CLI mode to create a default configuration - file in the current working directory. + file at :func:`default_config_path` (the project folder for a + terminal launch, ``~/.profiles/.profiles`` for launcher-style + launches; issue #191). Returns: ``True`` if user accepts and the file is created, ``False`` otherwise. @@ -68,14 +92,28 @@ def propose_config_creation() -> bool: return False if response in ("y", "yes"): - target = Path.cwd() / PRIMARY_CONFIG_NAME + target = default_config_path() if target.exists(): print(f"Warning: {target} already exists. Creation skipped.") return False + try: + # The per-user data directory may not exist yet on a fresh + # install; write_starter_config requires an existing parent. + target.parent.mkdir(parents=True, exist_ok=True) + except OSError as exc: + print(f"\n✗ Error creating configuration directory: {exc}", file=sys.stderr) + return False + from profiles.core.actions import ActionStatus, write_starter_config - result = write_starter_config(target) + # Same rule as profiles.launch.creation (#191): a normal project + # target scans itself; the per-user data directory only holds logs + # and configs, so the template falls back to the policy default. + search_dir = ( + default_search_directory() if target.parent == user_data_dir() else target.parent + ) + result = write_starter_config(target, cwd=search_dir) if result.status is ActionStatus.SUCCESS: print(f"\n✓ Default configuration created: {target}") print("\nYou can now customize this file to suit your needs.") diff --git a/src/profiles/core/config/template.py b/src/profiles/core/config/template.py index cb99744..a9ad446 100644 --- a/src/profiles/core/config/template.py +++ b/src/profiles/core/config/template.py @@ -32,9 +32,15 @@ # names win first (".profiles", then ".profiles.yaml"/".profiles.yml"); # when none of them exists anywhere, any "*.profiles"-style file (e.g. # "a.profiles", "b.profiles") is accepted — several matches are sorted -# ascending and the first one is launched. If nothing is found at all, -# defaults are used (identical to this starter). An explicit file can -# be passed with --config (see CLI FLAGS). +# ascending and the first one is launched. The CWD tree is skipped when +# the CWD carries no launch information (System32, the home folder or +# the interpreter/app install root — Start-Menu and launcher starts); +# in that case, and whenever the tree search finds nothing, the +# per-user default "~/.profiles/.profiles" is loaded when it exists +# (issue #191). If nothing is found at all, defaults are used and a +# starter is proposed at the project folder, or at +# "~/.profiles/.profiles" for launcher-style starts. An explicit file +# can be passed with --config (see CLI FLAGS). # # SYNTAX # * YAML format; all keys are case-insensitive. diff --git a/src/profiles/core/paths.py b/src/profiles/core/paths.py new file mode 100644 index 0000000..0b0b51c --- /dev/null +++ b/src/profiles/core/paths.py @@ -0,0 +1,222 @@ +"""Per-user path policy — one source of truth for user-level locations. + +Single Responsibility: decide where ProFiles keeps per-user data (the +``~/.profiles`` folder shared by logs and the default configuration) and +which directories carry no information about the user's launch location. + +Pure functions only: nothing here touches the filesystem beyond +existence/metadata checks, and nothing mutates state. + +Why this module exists (issue #191): a Start-Menu shortcut with an empty +"Start in" field runs the process with ``CWD = %SystemRoot%\\System32``, +and a launcher whose CWD is the home folder collides with the +``~/.profiles`` **log directory**. Both facts are path-policy concerns, +so every consumer (launch resolution, config loader, server state, +logger defaults) asks here instead of re-deriving them. +""" + +from __future__ import annotations + +import os +import sys +from pathlib import Path + +from profiles.core.config.io.yaml_io import CONFIG_FILE_NAMES + +#: Name of the per-user data directory (logs + default config). +USER_DATA_DIRNAME = ".profiles" + + +def user_data_dir() -> Path: + """Return the per-user data directory: ``~/.profiles``. + + Holds ``profiles.log`` and the per-user default configuration, so + both can never drift apart. + + Returns: + Absolute path under the user's home folder. + + Raises: + RuntimeError: When the home directory cannot be determined + (same failure mode as :meth:`pathlib.Path.home`, which the + logger already accepted before this module existed). + """ + return Path.home() / USER_DATA_DIRNAME + + +def user_config_path() -> Path: + """Return the per-user default configuration path: ``~/.profiles/.profiles``. + + Returns: + Absolute path to the canonical primary config name inside + :func:`user_data_dir`. + """ + return user_data_dir() / CONFIG_FILE_NAMES[0] + + +def find_user_config() -> Path | None: + """Return the per-user default configuration file, when one exists. + + Only the canonical names are checked, in priority order, directly + inside :func:`user_data_dir` (depth 0, no wildcard search) — the + per-user folder is not a project tree to walk. + + Returns: + The first existing config **file**, or ``None``. + """ + data_dir = user_data_dir() + for name in CONFIG_FILE_NAMES: + candidate = data_dir / name + try: + if candidate.is_file(): + return candidate + except OSError: + continue + return None + + +def is_uninformative_directory(path: Path | None) -> bool: + """True when *path* says nothing about the user's launch location. + + A directory is uninformative when it was chosen by the OS or the + runtime rather than by the user: + + * ``None`` or an unresolvable path; + * a filesystem/drive root (``/``, ``C:\\``); + * the home folder itself (a launcher CWD, and colliding with the + ``~/.profiles`` data directory); + * anything inside the Python runtime prefix (idle interpreter + launches); + * anything inside the running executable's directory (packaged-app + install root); + * on Windows-style environments: anything inside + ``%SystemRoot%``/``%windir%`` (covers ``System32``, ``SysWOW64``) + or ``%ProgramFiles%``/``%ProgramFiles(x86)%``. The variables are + consulted whenever they are set, so tests can monkeypatch them on + any platform and real non-Windows environments (where they are + unset) are unaffected. + + Args: + path: Candidate directory (``None`` allowed). + + Returns: + ``True`` when the directory must not be used to infer a project + location or to host a proposed configuration file. + """ + if path is None: + return True + + try: + resolved = path.resolve() + except OSError: + return True + + # Filesystem / drive root. + if resolved.parent == resolved: + return True + + # Home folder itself (launchers often start there; it also hosts the + # ~/.profiles data directory, so it can never host a config file). + try: + if resolved == Path.home().resolve(): + return True + except (OSError, RuntimeError): + pass + + # Python runtime prefix (venv / system interpreter locations). + try: + if resolved.is_relative_to(Path(sys.prefix).resolve()): + return True + except OSError: + return True + + # Running executable's directory (packaged-app install root). + try: + exe_dir = Path(sys.executable).resolve().parent + if resolved.is_relative_to(exe_dir): + return True + except OSError: + pass + + # Windows system / program locations, via env vars (see docstring). + for var in ("SystemRoot", "windir", "ProgramFiles", "ProgramFiles(x86)"): + value = os.environ.get(var) + if not value: + continue + try: + base = Path(value).resolve() + except OSError: + continue + if resolved.is_relative_to(base): + return True + + return False + + +def _effective_start(start: Path | None) -> Path | None: + """Resolve the effective start directory: *start*, or the process CWD. + + Returns ``None`` when both are unavailable (exotic service + environments where even ``Path.cwd()`` raises). + """ + if start is not None: + return start + try: + return Path.cwd() + except OSError: + return None + + +def default_config_path(start: Path | None = None) -> Path: + """Return the path a missing configuration should be proposed at. + + Args: + start: Directory the launch happened in (default: the process + CWD). May be ``None`` when the CWD is unreadable. + + Returns: + ``start / ".profiles"`` for an informative *start*, otherwise the + per-user :func:`user_config_path`. When the project candidate + exists and is a **directory** (the ``CWD == home`` collision with + the ``~/.profiles`` data folder), the per-user path is returned + instead: the app never proposes a directory as its config file. + """ + start = _effective_start(start) + if start is None or is_uninformative_directory(start): + return user_config_path() + + candidate = start / CONFIG_FILE_NAMES[0] + try: + if candidate.exists() and candidate.is_dir(): + return user_config_path() + except OSError: + pass + return candidate + + +def default_search_directory(start: Path | None = None) -> Path: + """Return the directory a starter configuration should scan. + + Args: + start: Directory the launch happened in (default: the process + CWD). May be ``None`` when the CWD is unreadable. + + Returns: + *start* when informative; the home folder otherwise (a launcher + start must never scan ``System32`` or the interpreter's folder). + """ + start = _effective_start(start) + if start is None or is_uninformative_directory(start): + return Path.home() + return start + + +__all__ = [ + "USER_DATA_DIRNAME", + "default_config_path", + "default_search_directory", + "find_user_config", + "is_uninformative_directory", + "user_config_path", + "user_data_dir", +] diff --git a/src/profiles/core/telemetry/diagnostics.py b/src/profiles/core/telemetry/diagnostics.py index e2638ce..358039b 100644 --- a/src/profiles/core/telemetry/diagnostics.py +++ b/src/profiles/core/telemetry/diagnostics.py @@ -270,11 +270,17 @@ def default_log_path() -> Path: ``CWD=/`` (read-only on macOS), so a CWD-relative log path crashes with ``OSError: [Errno 30]`` at the first log write. + Delegates to :func:`profiles.core.paths.user_data_dir` so the log + location and the per-user default configuration (issue #191) share + one source of truth and cannot drift apart. + Returns: Absolute path under the user folder in a dedicated ``.profiles`` directory (matching the ``.profiles`` config-file convention). """ - return Path.home() / ".profiles" / "profiles.log" + from profiles.core.paths import user_data_dir + + return user_data_dir() / "profiles.log" def configure_logger( diff --git a/src/profiles/desktop/launcher.py b/src/profiles/desktop/launcher.py index ea65b4c..d2bec11 100644 --- a/src/profiles/desktop/launcher.py +++ b/src/profiles/desktop/launcher.py @@ -70,14 +70,24 @@ def _make_document_applier(state: ServerState) -> Callable[[Sequence[str]], None Shares :func:`apply_config_from_disk` with ``POST /api/instance/handoff`` so a double-click landing on the running window is launch-equivalent, and buffers the same UI event the frontend toast poll renders - (issue #188). A rejected file degrades to a failure notification — - the callback must never raise into the GUI event loop. + (issue #188). Documents whose name is not a config name are skipped + exactly like launch resolution skips them (issue #193): macOS also + delivers the opened *folder* — or any non-config document — as an + odoc path, and reporting it as a failed config apply produced a + spurious failure toast while the launch had already resolved the + folder's ``a.profiles``-style config. A rejected config-named file + still degrades to a failure notification — the callback must never + raise into the GUI event loop. """ + from profiles.core.config.io.yaml_io import is_config_file_name from profiles.server.routes.config import apply_config_from_disk def apply_documents(paths: Sequence[str]) -> None: for raw in paths: config_path = Path(raw).expanduser().resolve() + if not is_config_file_name(config_path.name): + logger.debug("Skipping non-config odoc document: %s", config_path) + continue try: apply_config_from_disk(state, config_path) except HTTPException as exc: diff --git a/src/profiles/launch/context.py b/src/profiles/launch/context.py index 5d40e46..c535b69 100644 --- a/src/profiles/launch/context.py +++ b/src/profiles/launch/context.py @@ -34,6 +34,7 @@ FALLBACK_CONFIG_NAMES, PRIMARY_CONFIG_NAME, ) +from profiles.core.paths import is_uninformative_directory #: Canonical primary configuration file name (``.profiles``). CONFIG_SUFFIX = PRIMARY_CONFIG_NAME @@ -57,18 +58,18 @@ def cwd_is_uninformative(cwd: Path | None) -> bool: """True when *cwd* says nothing about the user's launch location. + Delegates to + :func:`profiles.core.paths.is_uninformative_directory` so launch + detection and the per-user path policy cannot drift (issue #191): GUI-style launches (double-click / Finder) typically inherit - ``CWD == "/"`` or an idle Python-runtime directory; only then is the - Finder probe worth consulting for the real launch folder, and only - then is the macOS odoc capture (:mod:`profiles.desktop.appkit_events`) + ``CWD == "/"`` or an idle Python-runtime directory, and launcher + shortcuts (Start Menu, ``.desktop``) inherit ``System32`` or the + home folder — in all those cases the CWD is discarded, the Finder + probe (macOS) is worth consulting for the real launch folder, and + the macOS odoc capture (:mod:`profiles.desktop.appkit_events`) is worth its bounded wait. """ - if cwd is None or cwd == Path("/"): - return True - try: - return cwd.resolve().is_relative_to(Path(sys.prefix).resolve()) - except OSError: - return True + return is_uninformative_directory(cwd) @dataclass(frozen=True) diff --git a/src/profiles/launch/creation.py b/src/profiles/launch/creation.py index fbdc984..e50ecf4 100644 --- a/src/profiles/launch/creation.py +++ b/src/profiles/launch/creation.py @@ -17,6 +17,7 @@ from profiles.core.actions import ActionStatus from profiles.core.actions import write_starter_config as _write_starter +from profiles.core.paths import default_search_directory, user_data_dir @dataclass(frozen=True) @@ -28,12 +29,38 @@ class CreationResult: message: str -def propose_creation(target: Path) -> CreationResult: +def _resolve_search_dir(target: Path, search_dir: Path | str | None) -> Path: + """Return the directory the starter's ``search_dir`` should point at. + + Explicit *search_dir* wins. Otherwise a normal project directory + scans itself, while the per-user data directory falls back to + :func:`default_search_directory` — that folder only holds logs and + configs, so scanning it is useless (issue #191). + """ + if search_dir is not None: + return Path(search_dir) + try: + if target.resolve() == user_data_dir().resolve(): + return default_search_directory() + except OSError: + return target + return target + + +def propose_creation( + target: Path, + *, + search_dir: Path | str | None = None, +) -> CreationResult: """Offer to write a starter ``.profiles`` at *target*. Args: target: Directory where the starter should be written. The file will be created as ``target / ".profiles"``. + search_dir: Directory the starter's ``search_dir`` template + placeholder points at. Defaults to *target* itself, except + when *target* is the per-user data directory (``~/.profiles``), + which scans :func:`default_search_directory` instead. Returns: A :class:`CreationResult` with the outcome. Never raises: every @@ -64,8 +91,9 @@ def propose_creation(target: Path) -> CreationResult: message=f"Could not create directory {config_path.parent}: {exc}", ) - # Delegate to the existing domain action. - result = _write_starter(config_path) + # Delegate to the existing domain action, carrying the resolved + # search_dir so a launcher-created starter never scans System32. + result = _write_starter(config_path, cwd=_resolve_search_dir(target, search_dir)) if result.status == ActionStatus.SUCCESS: return CreationResult( diff --git a/src/profiles/launch/resolution.py b/src/profiles/launch/resolution.py index a54a39b..561862f 100644 --- a/src/profiles/launch/resolution.py +++ b/src/profiles/launch/resolution.py @@ -7,11 +7,15 @@ returns a path (or ``None``). It never reads a file, never prompts, and never writes — those are :mod:`profiles.launch.creation`'s jobs. -Resolution order (spec §1): +Resolution order (spec §1, issue #191): 1. ``--config`` when supplied — explicit always wins 2. a ``*.profiles`` document opened by the user - 3. a ``.profiles`` found by searching the working directory, 5 deep - 4. ``None`` — the caller decides whether to propose creating one + 3. a ``.profiles`` found by searching the working directory, 5 deep — + only when the working directory is informative (System32, the + home folder, the interpreter/app install root are skipped: they + say nothing about the user's project) + 4. the per-user default ``~/.profiles/.profiles`` when it exists + 5. ``None`` — the caller decides whether to propose creating one """ from __future__ import annotations @@ -19,6 +23,7 @@ from pathlib import Path from profiles.core.config.io.yaml_io import CONFIG_FILE_NAMES, find_config_file +from profiles.core.paths import find_user_config, is_uninformative_directory from profiles.launch.context import LaunchContext #: How many directory levels to search. Matches ``find_config_file``'s @@ -46,6 +51,13 @@ def resolve_config_path(ctx: LaunchContext) -> Path | None: an existence check: reporting a typo'd path is the reader's job, and silently substituting a different file would be worse than the error the user is about to see. + + The working-directory tree search is skipped for uninformative + directories (issue #191): a Start-Menu launch must not walk + ``System32`` looking for a config, and a home-CWD launch must not + walk the whole user profile. The per-user default + (``~/.profiles/.profiles``) is the final fallback, so a launcher + start picks up the config created by an earlier session. """ if ctx.explicit_config is not None: return ctx.explicit_config @@ -55,10 +67,15 @@ def resolve_config_path(ctx: LaunchContext) -> Path | None: return document start = ctx.working_directory or Path.cwd() - try: - return find_config_file(start, max_depth=_CONFIG_SEARCH_DEPTH) - except OSError: - return None + if not is_uninformative_directory(start): + try: + found = find_config_file(start, max_depth=_CONFIG_SEARCH_DEPTH) + except OSError: + found = None + if found is not None: + return found + + return find_user_config() __all__ = ["resolve_config_path"] diff --git a/src/profiles/server/routes/config.py b/src/profiles/server/routes/config.py index ee92749..421a9c4 100644 --- a/src/profiles/server/routes/config.py +++ b/src/profiles/server/routes/config.py @@ -8,10 +8,11 @@ from pydantic import BaseModel from profiles.core.config.diagnostics import collect_config_issues -from profiles.core.config.io.yaml_io import CONFIG_FILE_NAMES, content_hash, write_text_atomic +from profiles.core.config.io.yaml_io import content_hash, is_config_file_name, write_text_atomic from profiles.core.config.models import AppConfig from profiles.core.config.reader import ConfigReader from profiles.core.config.template import STARTER_CONFIG_TEMPLATE +from profiles.core.paths import default_search_directory from profiles.launch.creation import propose_creation from profiles.server.state import ServerState from profiles.utils.path_utils import normalize_user_path @@ -68,9 +69,11 @@ def _is_config_path(path: Path) -> bool: ``BACKUP.PROFILES`` (its whitelist checks ``filename.lower()``), so the apply step that re-reads what was just written must accept it too — a case-sensitive comparison here turned a successful save-as into a 400 - with the file already on disk (branch review, issue #95 wave). + with the file already on disk (branch review, issue #95 wave). The + predicate lives in the core so the desktop odoc applier's skip guard + (issue #193) stays in lockstep with what this apply step accepts. """ - return path.name.lower().endswith(CONFIG_FILE_NAMES) + return is_config_file_name(path.name) def _is_safe_filename(filename: str) -> bool: @@ -105,7 +108,10 @@ def _config_response(state: ServerState) -> dict: elif available_dirs: state.active_directory = Path(available_dirs[0]) else: - state.active_directory = Path.cwd() + # Empty-config fallback (issue #191): a launcher-style start + # must pre-fill the picker with the home folder, never + # System32 or the interpreter directory the CWD happens to be. + state.active_directory = default_search_directory() if not available_dirs: available_dirs = [str(state.active_directory)] @@ -290,7 +296,13 @@ async def create_config_endpoint(payload: CreateConfigRequest, request: Request) status_code=400, detail=f"Configuration already exists at {target_config}" ) - result = propose_creation(target_dir) + result = propose_creation( + target_dir, + # The starter's search_dir: the session's active directory, or the + # policy default (home for launcher-style starts) — never the + # process CWD, which a Start-Menu launch puts in System32 (#191). + search_dir=state.active_directory or default_search_directory(), + ) if result.status in {"SKIPPED", "FAILED"}: raise HTTPException(status_code=400, detail=result.message) @@ -313,7 +325,10 @@ async def template_config_endpoint(request: Request) -> dict: directory so the rendered draft scans where the session points. """ state: ServerState = request.app.state.server_state - cwd = str(state.active_directory) if state.active_directory else str(Path.cwd()) + # default_search_directory over a bare CWD (issue #191): an unset + # active directory under a launcher start resolves to the home folder + # instead of System32 / the interpreter directory. + cwd = str(default_search_directory(state.active_directory)) return { "content": STARTER_CONFIG_TEMPLATE.format(cwd=cwd), "filename": ".profiles", diff --git a/src/profiles/server/state.py b/src/profiles/server/state.py index efc4e32..d8581db 100644 --- a/src/profiles/server/state.py +++ b/src/profiles/server/state.py @@ -6,8 +6,9 @@ from pathlib import Path from typing import Any, Protocol -from profiles.core.config.io.yaml_io import PRIMARY_CONFIG_NAME, find_config_file +from profiles.core.config.io.yaml_io import find_config_file from profiles.core.config.models import AppConfig +from profiles.core.paths import default_config_path _MAX_EXTERNAL_EVENTS = 50 @@ -62,12 +63,23 @@ def active_config_path(self) -> Path: Resolution order mirrors launch-time resolution: any explicit ``config_path`` recorded after loading, then the path carried by the loaded :class:`AppConfig`, then a core search of the CWD - subtree, and finally the canonical primary name in the CWD. + subtree, and finally :func:`default_config_path` (the per-user + ``~/.profiles/.profiles`` for launcher-style launches, the + project folder otherwise; issue #191). An existing **directory** + is never returned as the config file — the ``CWD == home`` + collision with the ``~/.profiles`` log directory falls through to + :func:`default_config_path` instead. """ config_path = self.config_path or getattr(self.config, "config_path", None) if config_path is None: - config_path = find_config_file() or Path.cwd() / PRIMARY_CONFIG_NAME - return Path(config_path) + config_path = find_config_file() or default_config_path() + resolved = Path(config_path) + try: + if resolved.is_dir(): + return default_config_path() + except OSError: + pass + return resolved def record_external_event( self, kind: str, message: str, *, config_applied: bool = False diff --git a/src/profiles/web/dist/assets/index-C_WnxvAZ.js b/src/profiles/web/dist/assets/index-C_WnxvAZ.js deleted file mode 100644 index aafad1c..0000000 --- a/src/profiles/web/dist/assets/index-C_WnxvAZ.js +++ /dev/null @@ -1,448 +0,0 @@ -var sM=Object.defineProperty;var oM=(n,e,t)=>e in n?sM(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var yh=(n,e,t)=>oM(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(l){if(l.ep)return;l.ep=!0;const o=t(l);fetch(l.href,o)}})();function gy(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Xg={exports:{}},Ic={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Tk;function aM(){if(Tk)return Ic;Tk=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,l,o){var a=null;if(o!==void 0&&(a=""+o),l.key!==void 0&&(a=""+l.key),"key"in l){o={};for(var u in l)u!=="key"&&(o[u]=l[u])}else o=l;return l=o.ref,{$$typeof:n,type:i,key:a,ref:l!==void 0?l:null,props:o}}return Ic.Fragment=e,Ic.jsx=t,Ic.jsxs=t,Ic}var Ak;function cM(){return Ak||(Ak=1,Xg.exports=aM()),Xg.exports}var y=cM(),$g={exports:{}},Ve={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Ek;function uM(){if(Ek)return Ve;Ek=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),b=Symbol.for("react.view_transition"),v=Symbol.iterator;function w(R){return R===null||typeof R!="object"?null:(R=v&&R[v]||R["@@iterator"],typeof R=="function"?R:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,N={};function j(R,X,he){this.props=R,this.context=X,this.refs=N,this.updater=he||S}j.prototype.isReactComponent={},j.prototype.setState=function(R,X){if(typeof R!="object"&&typeof R!="function"&&R!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,R,X,"setState")},j.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function M(){}M.prototype=j.prototype;function U(R,X,he){this.props=R,this.context=X,this.refs=N,this.updater=he||S}var H=U.prototype=new M;H.constructor=U,C(H,j.prototype),H.isPureReactComponent=!0;var E=Array.isArray;function D(){}var I={H:null,A:null,T:null,S:null},ne=Object.prototype.hasOwnProperty;function F(R,X,he){var ge=he.ref;return{$$typeof:n,type:R,key:X,ref:ge!==void 0?ge:null,props:he}}function V(R,X){return F(R.type,X,R.props)}function _(R){return typeof R=="object"&&R!==null&&R.$$typeof===n}function ie(R){var X={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(he){return X[he]})}var pe=/\/+/g;function ce(R,X){return typeof R=="object"&&R!==null&&R.key!=null?ie(""+R.key):X.toString(36)}function Z(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(D,D):(R.status="pending",R.then(function(X){R.status==="pending"&&(R.status="fulfilled",R.value=X)},function(X){R.status==="pending"&&(R.status="rejected",R.reason=X)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function oe(R,X,he,ge,ze){var Te=typeof R;(Te==="undefined"||Te==="boolean")&&(R=null);var He=!1;if(R===null)He=!0;else switch(Te){case"bigint":case"string":case"number":He=!0;break;case"object":switch(R.$$typeof){case n:case e:He=!0;break;case m:return He=R._init,oe(He(R._payload),X,he,ge,ze)}}if(He)return ze=ze(R),He=ge===""?"."+ce(R,0):ge,E(ze)?(he="",He!=null&&(he=He.replace(pe,"$&/")+"/"),oe(ze,X,he,"",function(Qt){return Qt})):ze!=null&&(_(ze)&&(ze=V(ze,he+(ze.key==null||R&&R.key===ze.key?"":(""+ze.key).replace(pe,"$&/")+"/")+He)),X.push(ze)),1;He=0;var ke=ge===""?".":ge+":";if(E(R))for(var Ae=0;Ae>>1,T=Z[W];if(0>>1;Wl(z,G))Rl(X,z)?(Z[W]=X,Z[R]=G,W=R):(Z[W]=z,Z[be]=G,W=be);else if(Rl(X,G))Z[W]=X,Z[R]=G,W=R;else break e}}return oe}function l(Z,oe){var G=Z.sortIndex-oe.sortIndex;return G!==0?G:Z.id-oe.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();n.unstable_now=function(){return a.now()-u}}var f=[],d=[],m=1,g=null,b=3,v=!1,w=!1,S=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function U(Z){for(var oe=t(d);oe!==null;){if(oe.callback===null)i(d);else if(oe.startTime<=Z)i(d),oe.sortIndex=oe.expirationTime,e(f,oe);else break;oe=t(d)}}function H(Z){if(S=!1,U(Z),!w)if(t(f)!==null)w=!0,E||(E=!0,_());else{var oe=t(d);oe!==null&&ce(H,oe.startTime-Z)}}var E=!1,D=-1,I=5,ne=-1;function F(){return C?!0:!(n.unstable_now()-neZ&&F());){var W=g.callback;if(typeof W=="function"){g.callback=null,b=g.priorityLevel;var T=W(g.expirationTime<=Z);if(Z=n.unstable_now(),typeof T=="function"){g.callback=T,U(Z),oe=!0;break t}g===t(f)&&i(f),U(Z)}else i(f);g=t(f)}if(g!==null)oe=!0;else{var de=t(d);de!==null&&ce(H,de.startTime-Z),oe=!1}}break e}finally{g=null,b=G,v=!1}oe=void 0}}finally{oe?_():E=!1}}}var _;if(typeof M=="function")_=function(){M(V)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,pe=ie.port2;ie.port1.onmessage=V,_=function(){pe.postMessage(null)}}else _=function(){N(V,0)};function ce(Z,oe){D=N(function(){Z(n.unstable_now())},oe)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(Z){Z.callback=null},n.unstable_forceFrameRate=function(Z){0>Z||125W?(Z.sortIndex=G,e(d,Z),t(f)===null&&Z===t(d)&&(S?(j(D),D=-1):S=!0,ce(H,G-W))):(Z.sortIndex=T,e(f,Z),w||v||(w=!0,E||(E=!0,_()))),Z},n.unstable_shouldYield=F,n.unstable_wrapCallback=function(Z){var oe=b;return function(){var G=b;b=oe;try{return Z.apply(this,arguments)}finally{b=G}}}})(Kg)),Kg}var Rk;function dM(){return Rk||(Rk=1,Gg.exports=hM()),Gg.exports}var Wg={exports:{}},Rn={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var jk;function mM(){if(jk)return Rn;jk=1;var n=xy();function e(m){var g="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Wg.exports=mM(),Wg.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Lk;function pM(){if(Lk)return Uc;Lk=1;var n=dM(),e=xy(),t=GC();function i(r){var s="https://react.dev/errors/"+r;if(1gn||(r.current=Ft[gn],Ft[gn]=null,gn--)}function st(r,s){gn++,Ft[gn]=r.current,r.current=s}var tn=Ht(null),Pn=Ht(null),qt=Ht(null),Kt=Ht(null);function Oe(r,s){switch(st(qt,s),st(Pn,r),st(tn,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?zw(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=zw(s),r=Bw(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}Ot(tn),st(tn,r)}function qe(){Ot(tn),Ot(Pn),Ot(qt)}function $e(r){var s=r.memoizedState;s!==null&&(na._currentValue=s.memoizedState,st(Kt,r)),s=tn.current;var c=Bw(s,r.type);s!==c&&(st(Pn,r),st(tn,c))}function mt(r){Pn.current===r&&(Ot(tn),Ot(Pn)),Kt.current===r&&(Ot(Kt),na._currentValue=Qt)}var te,fe;function Le(r){if(te===void 0)try{throw Error()}catch(c){var s=c.stack.trim().match(/\n( *(at )?)/);te=s&&s[1]||"",fe=-1)":-1p||L[h]!==Y[p]){var ee=` -`+L[h].replace(" at new "," at ");return r.displayName&&ee.includes("")&&(ee=ee.replace("",r.displayName)),ee}while(1<=h&&0<=p);break}}}finally{Be=!1,Error.prepareStackTrace=c}return(c=r?r.displayName||r.name:"")?Le(c):""}function ue(r,s){switch(r.tag){case 26:case 27:case 5:return Le(r.type);case 16:return Le("Lazy");case 13:return r.child!==s&&s!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return bt(r.type,!1);case 11:return bt(r.type.render,!1);case 1:return bt(r.type,!0);case 31:return Le("Activity");case 30:return Le("ViewTransition");default:return""}}function ye(r){try{var s="",c=null;do s+=ue(r,c),c=r,r=r.return;while(r);return s}catch(h){return` -Error generating stack: `+h.message+` -`+h.stack}}var Re=Object.prototype.hasOwnProperty,ct=n.unstable_scheduleCallback,vt=n.unstable_cancelCallback,Sn=n.unstable_shouldYield,Cn=n.unstable_requestPaint,Et=n.unstable_now,Wt=n.unstable_getCurrentPriorityLevel,Yn=n.unstable_ImmediatePriority,Hn=n.unstable_UserBlockingPriority,ys=n.unstable_NormalPriority,Fu=n.unstable_LowPriority,bs=n.unstable_IdlePriority,vs=n.log,Fa=n.unstable_setDisableYieldValue,Ki=null,Gn=null;function vi(r){if(typeof vs=="function"&&Fa(r),Gn&&typeof Gn.setStrictMode=="function")try{Gn.setStrictMode(Ki,r)}catch{}}var fn=Math.clz32?Math.clz32:Sm,ve=Math.log,km=Math.LN2;function Sm(r){return r>>>=0,r===0?32:31-(ve(r)/km|0)|0}var In=256,Mt=262144,On=4194304;function nn(r){var s=r&42;if(s!==0)return s;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&-r;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function Dt(r,s,c){var h=r.pendingLanes;if(h===0)return 0;var p=0,x=r.suspendedLanes,k=r.pingedLanes;r=r.warmLanes;var O=h&134217727;return O!==0?(h=O&~x,h!==0?p=nn(h):(k&=O,k!==0?p=nn(k):c||(c=O&~r,c!==0&&(p=nn(c))))):(O=h&~x,O!==0?p=nn(O):k!==0?p=nn(k):c||(c=h&~r,c!==0&&(p=nn(c)))),p===0?0:s!==0&&s!==p&&(s&x)===0&&(x=p&-p,c=s&-s,x>=c||x===32&&(c&4194048)!==0)?s:p}function ws(r,s){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&s)===0}function qa(r,s){(s&8)!==0&&(s|=s&32);var c=r.entangledLanes;if(c!==0)for(r=r.entanglements,c&=s;0c;c++)s.push(r);return s}function mr(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function Cm(r,s,c,h,p,x){var k=r.pendingLanes;r.pendingLanes=c,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=c,r.entangledLanes&=c,r.errorRecoveryDisabledLanes&=c,r.shellSuspendCounter=0;var O=r.entanglements,L=r.expirationTimes,Y=r.hiddenUpdates;for(c=k&~c;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Em=!1;if(Yr)try{var Ja={};Object.defineProperty(Ja,"passive",{get:function(){Em=!0}}),window.addEventListener("test",Ja,Ja),window.removeEventListener("test",Ja,Ja)}catch{Em=!1}var Cl=null,Mm=null,ef=null;function Rb(){if(ef)return ef;var r,s=Mm,c=s.length,h,p="value"in Cl?Cl.value:Cl.textContent,x=p.length;for(r=0;r=nc),Pb=" ",Hb=!1;function Ib(r,s){switch(r){case"keyup":return i5.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ub(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Co=!1;function l5(r,s){switch(r){case"compositionend":return Ub(s);case"keypress":return s.which!==32?null:(Hb=!0,Pb);case"textInput":return r=s.data,r===Pb&&Hb?null:r;default:return null}}function s5(r,s){if(Co)return r==="compositionend"||!Lm&&Ib(r,s)?(r=Rb(),ef=Mm=Cl=null,Co=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Gb(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Kb(r,s){var c=Gb(r);r=0;for(var h;c;){if(c.nodeType===3){if(h=r+c.textContent.length,r<=s&&h>=s)return{node:c,offset:s-r};r=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Gb(c)}}function Wb(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?Wb(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function Zb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=Pm(r.document);s instanceof r.HTMLIFrameElement;){try{var c=typeof s.contentWindow.location.href=="string"}catch{c=!1}if(c)r=s.contentWindow;else break;s=Pm(r.document)}return s}function Hm(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}var m5=Yr&&"documentMode"in document&&11>=document.documentMode,Oo=null,Im=null,sc=null,Um=!1;function Jb(r,s,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Um||Oo==null||Oo!==Pm(h)||(h=Oo,"selectionStart"in h&&Hm(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),sc&&lc(sc,h)||(sc=h,h=sh(Im,"onSelect"),0>=k,p-=k,pr=1<<32-fn(s)+p|c<Ue?(an=Pe,Pe=null):an=Pe.sibling;var dt=Q($,Pe,K[Ue],se);if(dt===null){Pe===null&&(Pe=an);break}r&&Pe&&dt.alternate===null&&s($,Pe),q=x(dt,q,Ue),at===null?Me=dt:at.sibling=dt,at=dt,Pe=an}if(Ue===K.length)return c($,Pe),Ze&&Zr($,Ue),Me;if(Pe===null){for(;UeUe?(an=Pe,Pe=null):an=Pe.sibling;var Gl=Q($,Pe,dt.value,se);if(Gl===null){Pe===null&&(Pe=an);break}r&&Pe&&Gl.alternate===null&&s($,Pe),q=x(Gl,q,Ue),at===null?Me=Gl:at.sibling=Gl,at=Gl,Pe=an}if(dt.done)return c($,Pe),Ze&&Zr($,Ue),Me;if(Pe===null){for(;!dt.done;Ue++,dt=K.next())dt=ae($,dt.value,se),dt!==null&&(q=x(dt,q,Ue),at===null?Me=dt:at.sibling=dt,at=dt);return Ze&&Zr($,Ue),Me}for(Pe=h(Pe);!dt.done;Ue++,dt=K.next())dt=J(Pe,$,Ue,dt.value,se),dt!==null&&(r&&(an=dt.alternate,an!==null&&Pe.delete(an.key===null?Ue:an.key)),q=x(dt,q,Ue),at===null?Me=dt:at.sibling=dt,at=dt);return r&&Pe.forEach(function(lM){return s($,lM)}),Ze&&Zr($,Ue),Me}function Ge($,q,K,se){if(typeof K=="object"&&K!==null&&K.type===V&&K.key===null&&K.props.ref===void 0&&(K=K.props.children),typeof K=="object"&&K!==null){switch(K.$$typeof){case ne:e:{for(var Me=K.key;q!==null;){if(q.key===Me){if(Me=K.type,Me===V){if(q.tag===7){c($,q.sibling),se=p(q,K.props.children),Ml(se,K),se.return=$,$=se;break e}}else if(q.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===T&&Bs(Me)===q.type){c($,q.sibling),se=p(q,K.props),Ml(se,K),se.return=$,$=se;break e}c($,q);break}else s($,q);q=q.sibling}K.type===V?(se=Ms(K.props.children,$.mode,se,K.key),Ml(se,K),se.return=$,$=se):(se=ff(K.type,K.key,K.props,null,$.mode,se),Ml(se,K),se.return=$,$=se)}return k($);case F:e:{for(Me=K.key;q!==null;){if(q.key===Me)if(q.tag===4&&q.stateNode.containerInfo===K.containerInfo&&q.stateNode.implementation===K.implementation){c($,q.sibling),se=p(q,K.children||[]),se.return=$,$=se;break e}else{c($,q);break}else s($,q);q=q.sibling}se=Ym(K,$.mode,se),se.return=$,$=se}return k($);case T:return K=Bs(K),Ge($,q,K,se)}if(He(K))return we($,q,K,se);if(ge(K)){if(Me=ge(K),typeof Me!="function")throw Error(i(150));return K=Me.call(K),je($,q,K,se)}if(typeof K.then=="function")return Ge($,q,wf(K),se);if(K.$$typeof===ce)return Ge($,q,xf($,K),se);kf($,K)}return typeof K=="string"&&K!==""||typeof K=="number"||typeof K=="bigint"?(K=""+K,q!==null&&q.tag===6?(c($,q.sibling),se=p(q,K),se.return=$,$=se):(c($,q),se=$m(K,$.mode,se),se.return=$,$=se),k($)):c($,q)}return function($,q,K,se){try{hc=0;var Me=Ge($,q,K,se);return _o=null,Me}catch(Pe){if(Pe===jo||Pe===bf)throw Pe;var at=si(29,Pe,null,$.mode);return at.lanes=se,at.return=$,at}finally{}}}var Hs=S1(!0),C1=S1(!1),Dl=!1;function rp(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lp(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function Rl(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function jl(r,s,c){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,(yt&2)!==0){var p=h.pending;return p===null?s.next=s:(s.next=p.next,p.next=s),h.pending=s,s=uf(r),o1(r,null,c),s}return cf(r,h,s,c),uf(r)}function dc(r,s,c){if(s=s.updateQueue,s!==null&&(s=s.shared,(c&4194048)!==0)){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,xo(r,c)}}function sp(r,s){var c=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var p=null,x=null;if(c=c.firstBaseUpdate,c!==null){do{var k={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};x===null?p=x=k:x=x.next=k,c=c.next}while(c!==null);x===null?p=x=s:x=x.next=s}else p=x=s;c={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:x,shared:h.shared,callbacks:h.callbacks},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=s:r.next=s,c.lastBaseUpdate=s}var op=!1;function mc(){if(op){var r=Ro;if(r!==null)throw r}}function pc(r,s,c,h){op=!1;var p=r.updateQueue;Dl=!1;var x=p.firstBaseUpdate,k=p.lastBaseUpdate,O=p.shared.pending;if(O!==null){p.shared.pending=null;var L=O,Y=L.next;L.next=null,k===null?x=Y:k.next=Y,k=L;var ee=r.alternate;ee!==null&&(ee=ee.updateQueue,O=ee.lastBaseUpdate,O!==k&&(O===null?ee.firstBaseUpdate=Y:O.next=Y,ee.lastBaseUpdate=L))}if(x!==null){var ae=p.baseState;k=0,ee=Y=L=null,O=x;do{var Q=O.lane&-536870913,J=Q!==O.lane;if(J?(ot&Q)===Q:(h&Q)===Q){Q!==0&&Q===Ls&&(op=!0),ee!==null&&(ee=ee.next={lane:0,tag:O.tag,payload:O.payload,callback:null,next:null});e:{var we=r,je=O;Q=s;var Ge=c;switch(je.tag){case 1:if(we=je.payload,typeof we=="function"){ae=we.call(Ge,ae,Q);break e}ae=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=je.payload,Q=typeof we=="function"?we.call(Ge,ae,Q):we,Q==null)break e;ae=D({},ae,Q);break e;case 2:Dl=!0}}Q=O.callback,Q!==null&&(r.flags|=64,J&&(r.flags|=8192),J=p.callbacks,J===null?p.callbacks=[Q]:J.push(Q))}else J={lane:Q,tag:O.tag,payload:O.payload,callback:O.callback,next:null},ee===null?(Y=ee=J,L=ae):ee=ee.next=J,k|=Q;if(O=O.next,O===null){if(O=p.shared.pending,O===null)break;J=O,O=J.next,J.next=null,p.lastBaseUpdate=J,p.shared.pending=null}}while(!0);ee===null&&(L=ae),p.baseState=L,p.firstBaseUpdate=Y,p.lastBaseUpdate=ee,x===null&&(p.shared.lanes=0),Il|=k,r.lanes=k,r.memoizedState=ae}}function O1(r,s){if(typeof r!="function")throw Error(i(191,r));r.call(s)}function N1(r,s){var c=r.callbacks;if(c!==null)for(r.callbacks=null,r=0;rx?x:8;var k=ke.T,O={};O.types=k!==null?k.types:null,ke.T=O,Tp(r,!1,s,c);try{var L=p(),Y=ke.S;if(Y!==null&&Y(O,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var ee=O5(L,h);bc(r,s,ee,Ti(r))}else bc(r,s,h,Ti(r))}catch(ae){bc(r,s,{then:function(){},status:"rejected",reason:ae},Ti())}finally{Ae.p=x,k!==null&&O.types!==null&&(k.types=O.types),ke.T=k}}function D5(){}function Op(r,s,c,h){if(r.tag!==5)throw Error(i(476));var p=rv(r).queue;iv(r,p,s,Qt,c===null?D5:function(){return lv(r),c(h)})}function rv(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:Qt,baseState:Qt,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:Qt},next:null};var c={};return s.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:nl,lastRenderedState:c},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function lv(r){var s=rv(r);s.next===null&&(s=r.alternate.memoizedState),bc(r,s.next.queue,{},Ti())}function Np(){return Tn(na)}function sv(){return Zt().memoizedState}function ov(){return Zt().memoizedState}function R5(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var c=Ti();r=Rl(c);var h=jl(s,r,c);h!==null&&(ui(h,s,c),dc(h,s,c)),s={cache:ep()},r.payload=s;return}s=s.return}}function j5(r,s,c){var h=Ti();c={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},Rf(r)?cv(s,c):(c=Qm(r,s,c,h),c!==null&&(ui(c,r,h),uv(c,s,h)))}function av(r,s,c){var h=Ti();bc(r,s,c,h)}function bc(r,s,c,h){var p={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(Rf(r))cv(s,p);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=s.lastRenderedReducer,x!==null))try{var k=s.lastRenderedState,O=x(k,c);if(p.hasEagerState=!0,p.eagerState=O,ki(O,k))return cf(r,s,p,0),Rt===null&&af(),!1}catch{}finally{}if(c=Qm(r,s,p,h),c!==null)return ui(c,r,h),uv(c,s,h),!0}return!1}function Tp(r,s,c,h){if(h={lane:2,revertLane:xg(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},Rf(r)){if(s)throw Error(i(479))}else s=Qm(r,c,h,2),s!==null&&ui(s,r,2)}function Rf(r){var s=r.alternate;return r===Ye||s!==null&&s===Ye}function cv(r,s){Lo=Of=!0;var c=r.pending;c===null?s.next=s:(s.next=c.next,c.next=s),r.pending=s}function uv(r,s,c){if((c&4194048)!==0){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,xo(r,c)}}var jf={readContext:Tn,use:Af,useCallback:Xt,useContext:Xt,useEffect:Xt,useImperativeHandle:Xt,useLayoutEffect:Xt,useInsertionEffect:Xt,useMemo:Xt,useReducer:Xt,useRef:Xt,useState:Xt,useDebugValue:Xt,useDeferredValue:Xt,useTransition:Xt,useSyncExternalStore:Xt,useId:Xt,useHostTransitionStatus:Xt,useFormState:Xt,useActionState:Xt,useOptimistic:Xt,useMemoCache:Xt,useCacheRefresh:Xt,useEffectEvent:Xt},fv={readContext:Tn,use:Af,useCallback:function(r,s){return Zn().memoizedState=[r,s===void 0?null:s],r},useContext:Tn,useEffect:Y1,useImperativeHandle:function(r,s,c){c=c!=null?c.concat([r]):null,Mf(4194308,4,Z1.bind(null,s,r),c)},useLayoutEffect:function(r,s){return Mf(4194308,4,r,s)},useInsertionEffect:function(r,s){Mf(4,2,r,s)},useMemo:function(r,s){var c=Zn();s=s===void 0?null:s;var h=r();if(Is){vi(!0);try{r()}finally{vi(!1)}}return c.memoizedState=[h,s],h},useReducer:function(r,s,c){var h=Zn();if(c!==void 0){var p=c(s);if(Is){vi(!0);try{c(s)}finally{vi(!1)}}}else p=s;return h.memoizedState=h.baseState=p,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:p},h.queue=r,r=r.dispatch=j5.bind(null,Ye,r),[h.memoizedState,r]},useRef:function(r){var s=Zn();return r={current:r},s.memoizedState=r},useState:function(r){r=vp(r);var s=r.queue,c=av.bind(null,Ye,s);return s.dispatch=c,[r.memoizedState,c]},useDebugValue:Sp,useDeferredValue:function(r,s){var c=Zn();return Cp(c,r,s)},useTransition:function(){var r=vp(!1);return r=iv.bind(null,Ye,r.queue,!0,!1),Zn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,c){var h=Ye,p=Zn();if(Ze){if(c===void 0)throw Error(i(407));c=c()}else{if(c=s(),Rt===null)throw Error(i(349));(ot&127)!==0||R1(h,s,c)}p.memoizedState=c;var x={value:c,getSnapshot:s};return p.queue=x,Y1(_1.bind(null,h,x,r),[r]),h.flags|=2048,Bo(9,{destroy:void 0},j1.bind(null,h,x,c,s),null),c},useId:function(){var r=Zn(),s=Rt.identifierPrefix;if(Ze){var c=gr,h=pr;c=(h&~(1<<32-fn(h)-1)).toString(32)+c,s="_"+s+"R_"+c,c=Nf++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof h.is=="string"?k.createElement("select",{is:h.is}):k.createElement("select"),h.multiple?x.multiple=!0:h.size&&(x.size=h.size);break;default:x=typeof h.is=="string"?k.createElement(p,{is:h.is}):k.createElement(p)}}x[hn]=s,x[Un]=h;e:for(k=s.child;k!==null;){if(k.tag===5||k.tag===6)x.appendChild(k.stateNode);else if(k.tag!==4&&k.tag!==27&&k.child!==null){k.child.return=k,k=k.child;continue}if(k===s)break e;for(;k.sibling===null;){if(k.return===null||k.return===s)break e;k=k.return}k.sibling.return=k.return,k=k.sibling}s.stateNode=x;e:switch(Dn(x,p,h),p){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&rl(s)}}return Bt(s),s.subtreeFlags&=-33554433,Ip(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,c),null;case 6:if(r&&s.stateNode!=null)r.memoizedProps!==h&&rl(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(r=qt.current,Do(s)){if(r=s.stateNode,c=s.memoizedProps,h=null,p=xn,p!==null)switch(p.tag){case 27:case 5:h=p.memoizedProps}r[hn]=s,r=!!(r.nodeValue===c||h!==null&&h.suppressHydrationWarning===!0||_w(r.nodeValue,c)),r||Al(s,!0)}else r=Rc(r).createTextNode(h),r[hn]=s,s.stateNode=r}return Bt(s),null;case 31:if(c=s.memoizedState,r===null||r.memoizedState!==null){if(h=Do(s),c!==null){if(r===null){if(!h)throw Error(i(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[hn]=s}else Ds(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Bt(s),r=!1}else c=Wm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=c),r=!0;if(!r)return s.flags&256?(Si(s),s):(Si(s),null);if((s.flags&128)!==0)throw Error(i(558))}return Bt(s),null;case 13:if(h=s.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(p=Do(s),h!==null&&h.dehydrated!==null){if(r===null){if(!p)throw Error(i(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[hn]=s}else Ds(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Bt(s),p=!1}else p=Wm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return s.flags&256?(Si(s),s):(Si(s),null)}return Si(s),(s.flags&128)!==0?(s.lanes=c,s):(c=h!==null,r=r!==null&&r.memoizedState!==null,c&&(h=s.child,p=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(p=h.alternate.memoizedState.cachePool.pool),x=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(x=h.memoizedState.cachePool.pool),x!==p&&(h.flags|=2048)),c!==r&&c&&(s.child.flags|=8192),Hf(s,s.updateQueue),Bt(s),null);case 4:return qe(),r===null&&wg(s.stateNode.containerInfo),s.flags|=67108864,Bt(s),null;case 10:return el(s.type),Bt(s),null;case 19:if(fp(s),h=s.memoizedState,h===null)return Bt(s),null;if(p=(s.flags&128)!==0,x=h.rendering,x===null)if(p)wc(h,!1);else{if($t!==0||r!==null&&(r.flags&128)!==0)for(r=s.child;r!==null;){if(x=Cf(r),x!==null){for(s.flags|=128,wc(h,!1),r=x.updateQueue,s.updateQueue=r,Hf(s,r),s.subtreeFlags=0,r=c,c=s.child;c!==null;)a1(c,r),c=c.sibling;return gc(s,En.current&1|2),Ze&&Zr(s,h.treeForkCount),s.child}r=r.sibling}h.tail!==null&&Et()>Wf&&(s.flags|=128,p=!0,wc(h,!1),s.lanes=4194304)}else{if(!p)if(r=Cf(x),r!==null){if(s.flags|=128,p=!0,r=r.updateQueue,s.updateQueue=r,Hf(s,r),wc(h,!0),h.tail===null&&h.tailMode!=="collapsed"&&h.tailMode!=="visible"&&!x.alternate&&!Ze)return Bt(s),null}else 2*Et()-h.renderingStartTime>Wf&&c!==536870912&&(s.flags|=128,p=!0,wc(h,!1),s.lanes=4194304);h.isBackwards?(x.sibling=s.child,s.child=x):(r=h.last,r!==null?r.sibling=x:s.child=x,h.last=x)}if(h.tail!==null){r=h.tail;e:{for(c=r;c!==null;){if(c.alternate!==null){c=!1;break e}c=c.sibling}c=!0}return h.rendering=r,h.tail=r.sibling,h.renderingStartTime=Et(),r.sibling=null,x=En.current,x=p?x&1|2:x&1,h.tailMode==="visible"||h.tailMode==="collapsed"||!c||Ze?gc(s,x):(c=x,st(An,s),st(En,c),Fn===null&&(Fn=s)),Ze&&Zr(s,h.treeForkCount),r}return Bt(s),null;case 22:case 23:return Si(s),cp(),h=s.memoizedState!==null,r!==null?r.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(c&536870912)!==0&&(s.flags&128)===0&&(Bt(s),s.subtreeFlags&6&&(s.flags|=8192)):Bt(s),c=s.updateQueue,c!==null&&Hf(s,c.retryQueue),c=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==c&&(s.flags|=2048),r!==null&&Ot(zs),null;case 24:return c=null,r!==null&&(c=r.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),el(ln),Bt(s),null;case 25:return null;case 30:return s.flags|=33554432,Bt(s),null}throw Error(i(156,s.tag))}function I5(r,s){switch(Gm(s),s.tag){case 1:return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return el(ln),qe(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 26:case 27:case 5:return mt(s),null;case 31:if(s.memoizedState!==null){if(Si(s),s.alternate===null)throw Error(i(340));Ds()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 13:if(Si(s),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(i(340));Ds()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return fp(s),r=s.flags,r&65536?(s.flags=r&-65537|128,r=s.memoizedState,r!==null&&(r.rendering=null,r.tail=null),s.flags|=4,s):null;case 4:return qe(),null;case 10:return el(s.type),null;case 22:case 23:return Si(s),cp(),r!==null&&Ot(zs),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 24:return el(ln),null;case 25:return null;default:return null}}function zv(r,s){switch(Gm(s),s.tag){case 3:el(ln),qe();break;case 26:case 27:case 5:mt(s);break;case 4:qe();break;case 31:s.memoizedState!==null&&Si(s);break;case 13:Si(s);break;case 19:fp(s);break;case 10:el(s.type);break;case 22:case 23:Si(s),cp(),r!==null&&Ot(zs);break;case 24:el(ln)}}function kc(r,s){try{var c=s.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var p=h.next;c=p;do{if((c.tag&r)===r){h=void 0;var x=c.create,k=c.inst;h=x(),k.destroy=h}c=c.next}while(c!==p)}}catch(O){St(s,s.return,O)}}function Bl(r,s,c){try{var h=s.updateQueue,p=h!==null?h.lastEffect:null;if(p!==null){var x=p.next;h=x;do{if((h.tag&r)===r){var k=h.inst,O=k.destroy;if(O!==void 0){k.destroy=void 0,p=s;var L=c,Y=O;try{Y()}catch(ee){St(p,L,ee)}}}h=h.next}while(h!==x)}}catch(ee){St(s,s.return,ee)}}function Bv(r){var s=r.updateQueue;if(s!==null){var c=r.stateNode;try{N1(s,c)}catch(h){St(r,r.return,h)}}}function Pv(r,s,c){c.props=Us(r.type,r.memoizedProps),c.state=r.memoizedState;try{c.componentWillUnmount()}catch(h){St(r,s,h)}}function xr(r,s){try{var c=r.ref;if(c!==null){switch(r.tag){case 26:case 27:case 5:var h=r.stateNode;break;case 30:var p=r.stateNode,x=Gr(r.memoizedProps,p);(p.ref===null||p.ref.name!==x)&&(p.ref=Qw(x)),h=p.ref;break;case 7:if(r.stateNode===null){var k=new Ai(r);g(r.child,!1,M3,k,void 0,void 0),r.stateNode=k}h=r.stateNode;break;default:h=r.stateNode}typeof c=="function"?r.refCleanup=c(h):c.current=h}}catch(O){St(r,s,O)}}function Mn(r,s){var c=r.ref,h=r.refCleanup;if(c!==null)if(typeof h=="function")try{h()}catch(p){St(r,s,p)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(p){St(r,s,p)}else c.current=null}function If(r,s){if((r.tag===5||r.tag===27||r.tag===6)&&r.alternate===null&&s!==null)for(var c=0;c title"))),Dn(h,s,c),h[hn]=r,rn(h),s=h;break e;case"link":if(x=ak("link","href",p).get(s+(c.href||""))){for(k=0;kGe&&(k=Ge,Ge=je,je=k);var $=Kb(O,je),q=Kb(O,Ge);if($&&q&&(J.rangeCount!==1||J.anchorNode!==$.node||J.anchorOffset!==$.offset||J.focusNode!==q.node||J.focusOffset!==q.offset)){var K=ae.createRange();K.setStart($.node,$.offset),J.removeAllRanges(),je>Ge?(J.addRange(K),J.extend(q.node,q.offset)):(K.setEnd(q.node,q.offset),J.addRange(K))}}}}for(ae=[],J=O;J=J.parentNode;)J.nodeType===1&&ae.push({element:J,left:J.scrollLeft,top:J.scrollTop});for(typeof O.focus=="function"&&O.focus(),O=0;Oc?32:c,ke.T=null,c=og,og=null;var x=ir,k=Sr;if(Vt=0,Qs=ir=null,Sr=0,(yt&6)!==0)throw Error(i(331));var O=yt;if(yt|=4,ow(x.current),rw(x,x.current,k,c),yt=O,Ec(0,!1),Gn&&typeof Gn.onPostCommitFiberRoot=="function")try{Gn.onPostCommitFiberRoot(Ki,x)}catch{}return!0}finally{Ae.p=p,ke.T=h,kw(r,s)}}function Sw(r,s,c){s=Bi(c,s),s=Mp(r.stateNode,s,2),r=jl(r,s,2),r!==null&&(mr(r,2),Cr(r))}function St(r,s,c){if(r.tag===3)Sw(r,r,c);else for(;s!==null;){if(s.tag===3){Sw(s,r,c);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Ul===null||!Ul.has(h))){r=Bi(c,r),c=bv(2),h=jl(s,c,2),h!==null&&(vv(c,h,s,r),mr(h,2),Cr(h));break}}s=s.return}}function mg(r,s,c){var h=r.pingCache;if(h===null){h=r.pingCache=new V5;var p=new Set;h.set(s,p)}else p=h.get(s),p===void 0&&(p=new Set,h.set(s,p));p.has(c)||(rg=!0,p.add(c),r=Z5.bind(null,r,s,c),s.then(r,r))}function Z5(r,s,c){var h=r.pingCache;h!==null&&h.delete(s),r.pingedLanes|=r.suspendedLanes&c,r.warmLanes&=~c,Rt===r&&(ot&c)===c&&(($t===4||$t===3&&(ot&62914560)===ot&&300>Et()-Kf)&&(yt&2)===0?Yo(r,0):Gf|=c,qo===ot&&(qo=0)),Cr(r)}function Cw(r,s){s===0&&(s=qu()),r=Es(r,s),r!==null&&(mr(r,s),Cr(r))}function J5(r){var s=r.memoizedState,c=0;s!==null&&(c=s.retryLane),Cw(r,c)}function e3(r,s){var c=0;switch(r.tag){case 31:case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(c=p.retryLane);break;case 19:h=r.stateNode;break;case 22:h=r.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),Cw(r,c)}function t3(r,s){return ct(r,s)}var Ko=null,Wo=null,pg=!1,rh=!1,gg=!1,ql=0;function Cr(r){r!==Wo&&r.next===null&&(Wo===null?Ko=Wo=r:Wo=Wo.next=r),rh=!0,pg||(pg=!0,i3())}function Ec(r,s){if(!gg&&rh){gg=!0;do for(var c=!1,h=Ko;h!==null;){if(r!==0){var p=h.pendingLanes;if(p===0)var x=0;else{var k=h.suspendedLanes,O=h.pingedLanes;x=(1<<31-fn(42|r)+1)-1,x&=p&~(k&~O),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(c=!0,Aw(h,x))}else x=ot,x=Dt(h,h===Rt?x:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(x&3)===0||ws(h,x)||(c=!0,Aw(h,x));h=h.next}while(c);gg=!1}}function n3(){Ow()}function Ow(){rh=pg=!1;var r=0;ql!==0&&m3()&&(r=ql);for(var s=Et(),c=null,h=Ko;h!==null;){var p=h.next,x=Nw(h,s);x===0?(h.next=null,c===null?Ko=p:c.next=p,p===null&&(Wo=c)):(c=h,(r!==0||(x&3)!==0)&&(rh=!0)),h=p}Vt!==0&&Vt!==5||Ec(r),ql!==0&&(ql=0)}function Nw(r,s){for(var c=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,x=r.pendingLanes&-62914561;0O)break;var ee=L.transferSize,ae=L.initiatorType;ee&&Lw(ae)&&(L=L.responseEnd,k+=ee*(Lch){je.length=we;break}K=new Promise(v3.bind(K)),je.push(K)}}}if(0"u"?null:document;function rk(r,s,c){var h=Jo;if(h&&typeof s=="string"&&s){var p=li(s);p='link[rel="'+r+'"][href="'+p+'"]',typeof c=="string"&&(p+='[crossorigin="'+c+'"]'),ik.has(p)||(ik.add(p),r={rel:r,crossOrigin:c,href:s},h.querySelector(p)===null&&(s=h.createElement("link"),Dn(s,"link",r),rn(s),h.head.appendChild(s)))}}function H3(r){sl.D(r),rk("dns-prefetch",r,null)}function I3(r,s){sl.C(r,s),rk("preconnect",r,s)}function U3(r,s,c){sl.L(r,s,c);var h=Jo;if(h&&r&&s){var p='link[rel="preload"][as="'+li(s)+'"]';s==="image"&&c&&c.imageSrcSet?(p+='[imagesrcset="'+li(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(p+='[imagesizes="'+li(c.imageSizes)+'"]')):p+='[href="'+li(r)+'"]';var x=p;switch(s){case"style":x=ea(r);break;case"script":x=ta(r)}if(!(qi.has(x)||(r=D({rel:"preload",href:s==="image"&&c&&c.imageSrcSet?void 0:r,as:s},c),qi.set(x,r),h.querySelector(p)!==null||s==="style"&&h.querySelector(_c(x))||s==="script"&&h.querySelector(Lc(x))))){var k=h.createElement("link");Dn(k,"link",r),s==="style"&&(k[bo]=!0,k.onload=k.onerror=function(){Xu(k)}),rn(k),h.head.appendChild(k)}}}function F3(r,s){sl.m(r,s);var c=Jo;if(c&&r){var h=s&&typeof s.as=="string"?s.as:"script",p='link[rel="modulepreload"][as="'+li(h)+'"][href="'+li(r)+'"]',x=p;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=ta(r)}if(!qi.has(x)&&(r=D({rel:"modulepreload",href:r},s),qi.set(x,r),c.querySelector(p)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(Lc(x)))return}h=c.createElement("link"),Dn(h,"link",r),rn(h),c.head.appendChild(h)}}}function q3(r,s,c){sl.S(r,s,c);var h=Jo;if(h&&r){var p=vl(h).hoistableStyles,x=ea(r);s=s||"default";var k=p.get(x);if(!k){var O={loading:0,preload:null};if(k=h.querySelector(_c(x)))O.loading=5;else{r=D({rel:"stylesheet",href:r,"data-precedence":s},c),(c=qi.get(x))&&Bg(r,c);var L=k=h.createElement("link");rn(L),Dn(L,"link",r),L._p=new Promise(function(Y,ee){L.onload=Y,L.onerror=ee}),L.addEventListener("load",function(){O.loading|=1}),L.addEventListener("error",function(){O.loading|=2}),O.loading|=4,oh(k,s,h)}k={type:"stylesheet",instance:k,count:1,state:O},p.set(x,k)}}}function V3(r,s){sl.X(r,s);var c=Jo;if(c&&r){var h=vl(c).hoistableScripts,p=ta(r),x=h.get(p);x||(x=c.querySelector(Lc(p)),x||(r=D({src:r,async:!0},s),(s=qi.get(p))&&Pg(r,s),x=c.createElement("script"),rn(x),Dn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function Q3(r,s){sl.M(r,s);var c=Jo;if(c&&r){var h=vl(c).hoistableScripts,p=ta(r),x=h.get(p);x||(x=c.querySelector(Lc(p)),x||(r=D({src:r,async:!0,type:"module"},s),(s=qi.get(p))&&Pg(r,s),x=c.createElement("script"),rn(x),Dn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function lk(r,s,c,h){var p=(p=qt.current)?jc(p):null;if(!p)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(c=ea(c.href),s=vl(p).hoistableStyles,h=s.get(c),h||(h={type:"style",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){r=ea(c.href);var x=vl(p).hoistableStyles,k=x.get(r);if(k||(p=p.ownerDocument||p,k={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(r,k),(x=p.querySelector(_c(r)))?x._p||(k.instance=x,k.state.loading=5):(x=qi.get(r),x||(x={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},qi.set(r,x)),X3(p,r,x,k.state))),s&&h===null)throw Error(i(528,""));return k}if(s&&h!==null)throw Error(i(529,""));return null;case"script":return s=c.async,c=c.src,typeof c=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(c=ta(c),s=vl(p).hoistableScripts,h=s.get(c),h||(h={type:"script",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function ea(r){return'href="'+li(r)+'"'}function _c(r){return'link[rel="stylesheet"]['+r+"]"}function sk(r){return D({},r,{"data-precedence":r.precedence,precedence:null})}function X3(r,s,c,h){if(s=r.querySelector('link[rel="preload"][as="style"]['+s+"]")){if(s[bo]!==!0){h.loading=1;return}}else s=r.createElement("link"),s[bo]=!0,s.onload=s.onerror=Xu.bind(null,s),Dn(s,"link",c),rn(s),r.head.appendChild(s);h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2})}function ta(r){return'[src="'+li(r)+'"]'}function Lc(r){return"script[async]"+r}function ok(r,s,c){if(s.count++,s.instance===null)switch(s.type){case"style":var h=r.querySelector('style[data-href~="'+li(c.href)+'"]');if(h)return s.instance=h,rn(h),h;var p=D({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return h=(r.ownerDocument||r).createElement("style"),rn(h),Dn(h,"style",p),oh(h,c.precedence,r),s.instance=h;case"stylesheet":p=ea(c.href);var x=r.querySelector(_c(p));if(x)return s.state.loading|=4,s.instance=x,rn(x),x;h=sk(c),(p=qi.get(p))&&Bg(h,p),x=(r.ownerDocument||r).createElement("link"),rn(x);var k=x;return k._p=new Promise(function(O,L){k.onload=O,k.onerror=L}),Dn(x,"link",h),s.state.loading|=4,oh(x,c.precedence,r),s.instance=x;case"script":return x=ta(c.src),(p=r.querySelector(Lc(x)))?(s.instance=p,rn(p),p):(h=c,(p=qi.get(x))&&(h=D({},c),Pg(h,p)),r=r.ownerDocument||r,p=r.createElement("script"),rn(p),Dn(p,"link",h),r.head.appendChild(p),s.instance=p);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(h=s.instance,s.state.loading|=4,oh(h,c.precedence,r));return s.instance}function oh(r,s,c){for(var h=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=h.length?h[h.length-1]:null,x=p,k=0;k title"):null)}function $3(r,s,c){if(c===1||s.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return r=s.disabled,typeof s.precedence=="string"&&r==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function ck(r,s){return r==="img"&&s.src!=null&&s.src!==""&&s.onLoad==null&&s.loading!=="lazy"}function uk(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function fk(r){return(r.width||100)*(r.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function hk(r,s){typeof s.decode=="function"&&(r.imgCount++,s.complete||(r.imgBytes+=fk(s),r.suspenseyImages.push(s)),r=K3.bind(r),s.decode().then(r,r))}function Y3(r,s,c,h){if(c.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var p=ea(h.href),x=s.querySelector(_c(p));if(x){s=x._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(r.count++,r=zc.bind(r),s.then(r,r)),c.state.loading|=4,c.instance=x,rn(x);return}x=s.ownerDocument||s,h=sk(h),(p=qi.get(p))&&Bg(h,p),x=x.createElement("link"),rn(x);var k=x;k._p=new Promise(function(O,L){k.onload=O,k.onerror=L}),Dn(x,"link",h),c.instance=x}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(c,s),(s=c.state.preload)&&(c.state.loading&3)===0&&(r.count++,c=zc.bind(r),s.addEventListener("load",c),s.addEventListener("error",c))}}var ch=0;function G3(r,s){return r.stylesheets&&r.count===0&&fh(r,r.stylesheets),0ch?50:800)+s);return r.unsuspend=c,function(){r.unsuspend=null,clearTimeout(h),clearTimeout(p)}}:null}function dk(r){if(r.count===0&&(r.imgCount===0||!r.waitingForImages)){if(r.stylesheets)fh(r,r.stylesheets);else if(r.unsuspend){var s=r.unsuspend;r.unsuspend=null,s()}}}function zc(){this.count--,dk(this)}function K3(){this.imgCount--,dk(this)}var uh=null;function fh(r,s){r.stylesheets=null,r.unsuspend!==null&&(r.count++,uh=new Map,s.forEach(W3,r),uh=null,zc.call(r))}function W3(r,s){if(!(s.state.loading&4)){var c=uh.get(r);if(c)var h=c.get(null);else{c=new Map,uh.set(r,c);for(var p=r.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Yg.exports=pM(),Yg.exports}var xM=gM();const yM=gy(xM);class yy extends Error{constructor(t,i,l){super(t);yh(this,"status");yh(this,"detail");this.name="ApiError",this.status=i,this.detail=l}}async function Ir(n,e){let t=e,i;try{const l=await n.json();typeof(l==null?void 0:l.detail)=="string"&&l.detail?(t=l.detail,i=l.detail):Array.isArray(l==null?void 0:l.detail)&&(i=l.detail)}catch{}return new yy(t,n.status,i)}async function bM(n){const e=await fetch(`/api/notifications?after=${n}`);if(!e.ok)throw new Error("Failed to fetch notifications");return e.json()}async function vM(){const n=await fetch("/api/actions/open-log",{method:"POST"});if(!n.ok)throw new Error("Failed to open log file");return n.json()}async function wM(n){const e=new URLSearchParams;e.set("limit",String(n.limit)),n!=null&&n.level&&e.set("level",n.level),n!=null&&n.search&&e.set("search",n.search);const t=await fetch(`/api/logs?${e.toString()}`);if(!t.ok)throw new Error("Failed to fetch log entries");return t.json()}async function ed(){const n=await fetch("/api/system");if(!n.ok)throw new Error("Failed to fetch system info");return n.json()}async function kM(n){const e=await fetch("/api/system/bind",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:n})});if(!e.ok){let t="Failed to update LAN binding";try{const i=await e.json();i!=null&&i.detail&&(t=i.detail)}catch{}throw new Error(t)}return e.json()}async function SM(n,e=1e4){const t=Date.now()+e;let i=null;for(;Date.now()setTimeout(l,500))}return i}async function Bk(){const n=await fetch("/api/config");if(!n.ok)throw new Error("Failed to fetch app configuration");return n.json()}async function Pk(n){const e=await fetch("/api/config/select-directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw await Ir(e,"Failed to select directory");return e.json()}async function CM(n){const e=await fetch("/api/config/load",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_path:n})});if(!e.ok)throw new Error("Failed to load config file");return e.json()}async function KC(n,e){const t=await fetch("/api/config/load-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok){let i=`Failed to apply dropped config (${n})`;try{const l=await t.json();l!=null&&l.detail&&(i=l.detail)}catch{}throw new Error(i)}return t.json()}async function OM(){const n=await fetch("/api/config/reload",{method:"POST"});if(!n.ok){let e="Failed to reload configuration";try{const t=await n.json();t!=null&&t.detail&&(e=t.detail)}catch{}throw new Error(e)}return n.json()}async function NM(n){const e=await fetch("/api/config/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw new Error("Failed to create config file");return e.json()}async function Hk(){const n=await fetch("/api/config/content");if(!n.ok)throw await Ir(n,"Failed to fetch config content");return n.json()}async function Ik(n,e){const t=await fetch("/api/config/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok)throw await Ir(t,"Failed to validate config content");return t.json()}async function TM(){const n=await fetch("/api/config/template",{method:"POST"});if(!n.ok)throw await Ir(n,"Failed to fetch config template");return n.json()}async function Uk(n,e,t={}){const i=await fetch("/api/config/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,force:e,baseline_hash:t.baselineHash??null,overwrite_changes:t.overwriteChanges??!1})});if(!i.ok)throw await Ir(i,"Failed to save configuration");const l=await i.json();return{config:l.config,contentHash:l.content_hash??null}}async function AM(n){const e=await fetch("/api/config/save-as",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await Ir(e,"Failed to save configuration as");const t=await e.json();return{config:t.config,contentHash:t.content_hash??null}}async function EM(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}&include_hidden=true`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse config files");return t.json()}async function WC(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse directory");return t.json()}async function Fk(n,e){const t=await fetch("/api/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:e});if(!t.ok)throw await Ir(t,"Failed to execute scan");return t.json()}async function Zg(n){const e=new URLSearchParams;(n==null?void 0:n.offset)!=null&&e.set("offset",String(n.offset)),(n==null?void 0:n.limit)!=null&&e.set("limit",String(n.limit)),n!=null&&n.sort_by&&e.set("sort_by",n.sort_by),n!=null&&n.sort_dir&&e.set("sort_dir",n.sort_dir);const t=e.toString(),i=`/api/scan/results${t?`?${t}`:""}`,l=await fetch(i,{signal:n==null?void 0:n.signal});if(!l.ok)throw new Error("Failed to fetch scan results");return l.json()}async function MM(n){const e=await fetch("/api/actions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw new Error("Failed to launch file");return e.json()}async function ZC(n){const e=await fetch("/api/actions/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to reveal file");return e.json()}async function W0(n){const e=await fetch("/api/actions/open-folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open folder");return e.json()}async function qk(n){const e=await fetch("/api/actions/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open terminal");return e.json()}async function Vk(n,e){const t=await fetch("/api/actions/hash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n,algorithm:e})});if(!t.ok)throw new Error("Failed to compute hash");return t.json()}async function DM(){const n=await fetch("/api/actions/open-config",{method:"POST"});if(!n.ok)throw new Error("Failed to open config file");return n.json()}async function Qk(n){const e={file_path:n.file_path||n.filePath,content:n.content},t=await fetch("/api/actions/barcode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error("Failed to generate barcode");return t.json()}async function RM(n){const e=await fetch("/api/actions/barcode/decode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n.imageBase64,formats:n.formats})});if(!e.ok)throw e.status===503?new Error("Server-side barcode decoding is unavailable"):new Error(`Failed to decode frame (HTTP ${e.status})`);return e.json()}async function jM(n,e){const t=await fetch("/api/actions/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n}),signal:e});if(!t.ok)throw new Error("Failed to fetch metadata");return t.json()}async function _M(n,e){const t=await fetch("/api/actions/export-csv",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,filename:e})});if(!t.ok)throw new Error("Failed to export CSV");return t.json()}async function LM(n,e){const t=await fetch("/api/actions/save-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n,filename:e})});if(!t.ok)throw new Error("Failed to save image");return t.json()}async function zM(n){const e=await fetch("/api/workflow/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await Ir(e,"Failed to start workflow session");return e.json()}async function BM(n,e){const t=await fetch(`/api/workflow/${n}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})});if(!t.ok)throw await Ir(t,"Failed to respond to workflow prompt");return t.json()}async function PM(n){const e=await fetch(`/api/workflow/${n}/abort`,{method:"POST"});if(!e.ok)throw await Ir(e,"Failed to abort workflow session");return e.json()}const HM=[".profiles",".profiles.yaml",".profiles.yml",".yaml",".yml"];function IM(n){const e=n.toLowerCase();return HM.some(t=>e.endsWith(t))}function UM(n){for(const e of n)if(IM(e.name))return e;return null}function td(){return{depth:0,overlayVisible:!1}}function Xk(n,e,t){switch(e){case"enter":return t?{depth:n.depth+1,overlayVisible:!0}:n;case"leave":{const i=Math.max(0,n.depth-1);return{depth:i,overlayVisible:n.depth>0&&i>0}}case"drop":return td()}}function $k(n){return n==="light"?"light":"dark"}/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const FM=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),JC=(...n)=>n.filter((e,t,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===t).join(" ").trim();/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var qM={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const VM=A.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:l="",children:o,iconNode:a,...u},f)=>A.createElement("svg",{ref:f,...qM,width:e,height:e,stroke:n,strokeWidth:i?Number(t)*24/Number(e):t,className:JC("lucide",l),...u},[...a.map(([d,m])=>A.createElement(d,m)),...Array.isArray(o)?o:[o]]));/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _e=(n,e)=>{const t=A.forwardRef(({className:i,...l},o)=>A.createElement(VM,{ref:o,iconNode:e,className:JC(`lucide-${FM(n)}`,i),...l}));return t.displayName=`${n}`,t};/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QM=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],XM=_e("Activity",QM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $M=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],eO=_e("ArrowDown",$M);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const YM=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],GM=_e("ArrowLeftRight",YM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KM=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],WM=_e("ArrowRight",KM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZM=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Yk=_e("ArrowUpDown",ZM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JM=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],e4=_e("ArrowUp",JM);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const t4=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],n4=_e("Bug",t4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const i4=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],r4=_e("Calendar",i4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const l4=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],tO=_e("Camera",l4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const s4=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Br=_e("Check",s4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const o4=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],a4=_e("ChevronDown",o4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const c4=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Wd=_e("ChevronRight",c4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const u4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],tu=_e("CircleAlert",u4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const f4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Gk=_e("CircleCheck",f4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const h4=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],d4=_e("CircleDashed",h4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const m4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],p4=_e("CircleDot",m4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const g4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],x4=_e("CirclePause",g4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const y4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],b4=_e("CirclePlay",y4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const v4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],du=_e("CircleX",v4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const w4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],k4=_e("Clock",w4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const S4=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],hi=_e("Copy",S4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const C4=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],nO=_e("Download",C4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const O4=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],iO=_e("ExternalLink",O4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const N4=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],T4=_e("EyeOff",N4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const A4=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Z0=_e("Eye",A4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const E4=[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]],M4=_e("FastForward",E4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const D4=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],R4=_e("FileCode2",D4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const j4=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],J0=_e("FileCode",j4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _4=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]],fa=_e("FileCog",_4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const L4=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],z4=_e("FilePlus2",L4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const B4=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Na=_e("FileText",B4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const P4=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],Jg=_e("File",P4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const H4=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],I4=_e("FlaskConical",H4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const U4=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],rs=_e("FolderOpen",U4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const F4=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Du=_e("Folder",F4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const q4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],V4=_e("Globe",q4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Q4=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],ha=_e("Hash",Q4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const X4=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],Zd=_e("House",X4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $4=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],by=_e("Info",$4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Y4=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],rO=_e("Keyboard",Y4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const G4=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],K4=_e("Link2",G4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const W4=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],fl=_e("LoaderCircle",W4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Z4=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],J4=_e("Lock",Z4);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eD=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],tD=_e("Moon",eD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nD=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],iD=_e("Network",nD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rD=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],ss=_e("Play",rD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lD=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],sD=_e("Plus",lD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oD=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],vy=_e("QrCode",oD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aD=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Jd=_e("RefreshCw",aD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cD=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],uD=_e("Rocket",cD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fD=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],hD=_e("RotateCcw",fD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dD=[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]],mD=_e("SaveAll",dD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pD=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],lO=_e("Save",pD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],sO=_e("Search",gD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xD=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],yD=_e("Settings",xD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bD=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],vD=_e("Sun",bD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wD=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],oO=_e("Terminal",wD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kD=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],aO=_e("Timer",kD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const SD=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],cO=_e("Trash2",SD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const CD=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],wy=_e("TriangleAlert",CD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const OD=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],ND=_e("User",OD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const TD=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],uO=_e("Webhook",TD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const AD=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],ED=_e("Workflow",AD);/** - * @license lucide-react v0.477.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const MD=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],_i=_e("X",MD);function DD(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m${t.toString().padStart(2,"0")}s`}function RD(n){if(!n)return{label:"",cut:!1};const e=n.replace(/\\/g,"/").split("/").filter(Boolean);return e.length===0?{label:n,cut:!1}:{label:e[e.length-1],cut:e.length>1}}function jD({directory:n}){const[e,t]=A.useState(0);A.useEffect(()=>{t(0);const o=window.setInterval(()=>{t(a=>a+1)},1e3);return()=>window.clearInterval(o)},[]);const{label:i,cut:l}=RD(n);return y.jsxs("div",{"data-testid":"scan-status-strip",className:"flex min-w-0 items-center gap-1.5 text-[11px] text-ink-muted",children:[y.jsx(fl,{className:"h-3 w-3 shrink-0 animate-spin text-chip-indigo-text motion-reduce:animate-none","aria-hidden":"true"}),y.jsxs("span",{className:"min-w-0 truncate",children:["Scanning",n&&y.jsxs(y.Fragment,{children:[" ",y.jsxs("span",{className:"font-mono text-ink-secondary",title:n,children:[l?"…/":"",i]})]})," — ",y.jsx("span",{className:"font-mono tabular-nums text-ink-secondary",children:DD(e)})]})]})}function _D({onExecute:n,scanning:e,hasSelection:t,fileCount:i,totalCount:l,scanningDirectory:o="",toastMessage:a,onToastDismiss:u}){const f=(a==null?void 0:a.kind)==="error";return y.jsxs("div",{className:"relative flex items-center justify-between border-t border-line bg-surface-glass px-4 py-2.5 text-xs transition-colors duration-200",children:[a&&y.jsx("div",{role:"status","aria-live":f?"assertive":"polite","aria-atomic":"true",className:`animate-toast-in absolute left-1/2 top-1/2 z-[var(--z-toast)] max-w-[min(80vw,640px)] -translate-x-1/2 -translate-y-1/2 rounded-xl border px-4 py-2 text-xs font-medium glass-panel-strong ${f?"pointer-events-auto flex max-w-[min(70vw,560px)] items-center gap-2.5 border-status-danger-border text-left text-ink":"pointer-events-none max-w-[min(70vw,560px)] text-center text-ink"}`,children:f?y.jsxs(y.Fragment,{children:[y.jsx(du,{className:"h-3.5 w-3.5 shrink-0 text-status-danger-text/80","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 flex-1",children:a.message}),u&&y.jsx("button",{type:"button",onClick:u,"aria-label":"Dismiss error",className:"shrink-0 rounded-md p-0.5 text-status-danger-text/60 hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-status-danger-border transition-colors",children:y.jsx(_i,{className:"h-3.5 w-3.5"})})]}):a.message}),y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e&&y.jsx(jD,{directory:o}),l!==void 0&&l!==i&&y.jsxs("span",{"data-testid":"action-bar-count",className:"text-ink-muted",children:["Showing ",i," of ",l]})]}),y.jsxs("button",{onClick:n,disabled:!t||e,className:"flex shrink-0 items-center gap-2 rounded-xl border border-emerald-300/50 bg-gradient-to-b from-emerald-400/90 to-emerald-600/90 px-5 py-2 font-semibold text-white shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] transition-[filter,box-shadow,transform] hover:-translate-y-px hover:brightness-110 hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_12px_30px_-6px_rgb(16_185_129/0.7)] disabled:opacity-40 disabled:hover:translate-y-0 disabled:hover:brightness-100 disabled:hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400",children:[y.jsx(ss,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:"Execute"}),y.jsx("kbd",{className:"rounded bg-emerald-800/60 px-1.5 py-0.5 text-[10px] text-emerald-200 shadow-[inset_0_1px_0_rgb(255_255_255/0.12)]",children:"↵"})]})]})}let ex=[],fO=[];(()=>{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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=fO[i])e=i+1;else return!0;if(e==t)return!1}}function Kk(n){return n>=127462&&n<=127487}const Wk=8205;function zD(n,e,t=!0,i=!0){return(t?hO:BD)(n,e,i)}function hO(n,e,t){if(e==n.length)return e;e&&dO(n.charCodeAt(e))&&mO(n.charCodeAt(e-1))&&e--;let i=e0(n,e);for(e+=Zk(i);e=0&&Kk(e0(n,a));)o++,a-=2;if(o%2==0)break;e+=2}else break}return e}function BD(n,e,t){for(;e>1;){let i=hO(n,e-2,t);if(i=56320&&n<57344}function mO(n){return n>=55296&&n<56320}function Zk(n){return n<65536?1:2}class pt{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=Ta(this,e,t);let l=[];return this.decompose(0,e,l,2),i.length&&i.decompose(0,i.length,l,3),this.decompose(t,this.length,l,1),Dr.from(l,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=Ta(this,e,t);let i=[];return this.decompose(e,t,i,0),Dr.from(i,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),i=this.length-this.scanIdentical(e,-1),l=new nu(this),o=new nu(e);for(let a=t,u=t;;){if(l.next(a),o.next(a),a=0,l.lineBreak!=o.lineBreak||l.done!=o.done||l.value!=o.value)return!1;if(u+=l.value.length,l.done||u>=i)return!0}}iter(e=1){return new nu(this,e)}iterRange(e,t=this.length){return new pO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let l=this.line(e).from;i=this.iterRange(l,Math.max(l,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new gO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?pt.empty:e.length<=32?new Jt(e):Dr.from(Jt.split(e,[]))}}class Jt extends pt{constructor(e,t=PD(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.text[o],u=l+a.length;if((t?i:u)>=e)return new HD(l,u,i,a);l=u+1,i++}}decompose(e,t,i,l){let o=e<=0&&t>=this.length?this:new Jt(Jk(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let a=i.pop(),u=nd(o.text,a.text.slice(),0,o.length);if(u.length<=32)i.push(new Jt(u,a.length+o.length));else{let f=u.length>>1;i.push(new Jt(u.slice(0,f)),new Jt(u.slice(f)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof Jt))return super.replace(e,t,i);[e,t]=Ta(this,e,t);let l=nd(this.text,nd(i.text,Jk(this.text,0,e)),t),o=this.length+i.length-(t-e);return l.length<=32?new Jt(l,o):Dr.from(Jt.split(l,[]),o)}sliceString(e,t=this.length,i=` -`){[e,t]=Ta(this,e,t);let l="";for(let o=0,a=0;o<=t&&ae&&a&&(l+=i),eo&&(l+=u.slice(Math.max(0,e-o),t-o)),o=f+1}return l}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],l=-1;for(let o of e)i.push(o),l+=o.length+1,i.length==32&&(t.push(new Jt(i,l)),i=[],l=-1);return l>-1&&t.push(new Jt(i,l)),t}}class Dr extends pt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.children[o],u=l+a.length,f=i+a.lines-1;if((t?f:u)>=e)return a.lineInner(e,t,i,l);l=u+1,i=f+1}}decompose(e,t,i,l){for(let o=0,a=0;a<=t&&o=a){let d=l&((a<=e?1:0)|(f>=t?2:0));a>=e&&f<=t&&!d?i.push(u):u.decompose(e-a,t-a,i,d)}a=f+1}}replace(e,t,i){if([e,t]=Ta(this,e,t),i.lines=o&&t<=u){let f=a.replace(e-o,t-o,i),d=this.lines-a.lines+f.lines;if(f.lines>4&&f.lines>d>>6){let m=this.children.slice();return m[l]=f,new Dr(m,this.length-(t-e)+i.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` -`){[e,t]=Ta(this,e,t);let l="";for(let o=0,a=0;oe&&o&&(l+=i),ea&&(l+=u.sliceString(e-a,t-a,i)),a=f+1}return l}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Dr))return 0;let i=0,[l,o,a,u]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;l+=t,o+=t){if(l==a||o==u)return i;let f=this.children[l],d=e.children[o];if(f!=d)return i+f.scanIdentical(d,t);i+=f.length+1}}static from(e,t=e.reduce((i,l)=>i+l.length+1,-1)){let i=0;for(let v of e)i+=v.lines;if(i<32){let v=[];for(let w of e)w.flatten(v);return new Jt(v,t)}let l=Math.max(32,i>>5),o=l<<1,a=l>>1,u=[],f=0,d=-1,m=[];function g(v){let w;if(v.lines>o&&v instanceof Dr)for(let S of v.children)g(S);else v.lines>a&&(f>a||!f)?(b(),u.push(v)):v instanceof Jt&&f&&(w=m[m.length-1])instanceof Jt&&v.lines+w.lines<=32?(f+=v.lines,d+=v.length+1,m[m.length-1]=new Jt(w.text.concat(v.text),w.length+1+v.length)):(f+v.lines>l&&b(),f+=v.lines,d+=v.length+1,m.push(v))}function b(){f!=0&&(u.push(m.length==1?m[0]:Dr.from(m,d)),d=-1,f=m.length=0)}for(let v of e)g(v);return b(),u.length==1?u[0]:new Dr(u,t)}}pt.empty=new Jt([""],0);function PD(n){let e=-1;for(let t of n)e+=t.length+1;return e}function nd(n,e,t=0,i=1e9){for(let l=0,o=0,a=!0;o=t&&(f>i&&(u=u.slice(0,i-l)),l0?1:(e instanceof Jt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,l=this.nodes[i],o=this.offsets[i],a=o>>1,u=l instanceof Jt?l.text.length:l.children.length;if(a==(t>0?u:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(l instanceof Jt){let f=l.text[a+(t<0?-1:0)];if(this.offsets[i]+=t,f.length>Math.max(0,e))return this.value=e==0?f:t>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=l.children[a+(t<0?-1:0)];e>f.length?(e-=f.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(f),this.offsets.push(t>0?1:(f instanceof Jt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class pO{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new nu(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}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 i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:l}=this.cursor.next(e);return this.pos+=(l.length+e)*t,this.value=l.length<=i?l:t<0?l.slice(l.length-i):l.slice(0,i),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!=""}}class gO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:l}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=l,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(pt.prototype[Symbol.iterator]=function(){return this.iter()},nu.prototype[Symbol.iterator]=pO.prototype[Symbol.iterator]=gO.prototype[Symbol.iterator]=function(){return this});class HD{constructor(e,t,i,l){this.from=e,this.to=t,this.number=i,this.text=l}get length(){return this.to-this.from}}function Ta(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function wn(n,e,t=!0,i=!0){return zD(n,e,t,i)}function ID(n){return n>=56320&&n<57344}function UD(n){return n>=55296&&n<56320}function di(n,e){let t=n.charCodeAt(e);if(!UD(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return ID(i)?(t-55296<<10)+(i-56320)+65536:t}function ky(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function Rr(n){return n<65536?1:2}const tx=/\r\n?|\n/;var ni=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(ni||(ni={}));class Pr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return o+(e-l);o+=u}else{if(i!=ni.Simple&&d>=e&&(i==ni.TrackDel&&le||i==ni.TrackBefore&&le))return null;if(d>e||d==e&&t<0&&!u)return e==l||t<0?o:o+f;o+=f}l=d}if(e>l)throw new RangeError(`Position ${e} is out of range for changeset of length ${l}`);return o}touchesRange(e,t=e){for(let i=0,l=0;i=0&&l<=t&&u>=e)return lt?"cover":!0;l=u}return!1}toString(){let e="";for(let t=0;t=0?":"+l:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Pr(e)}static create(e){return new Pr(e)}}class mn extends Pr{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return nx(this,(t,i,l,o,a)=>e=e.replace(l,l+(i-t),a),!1),e}mapDesc(e,t=!1){return ix(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let l=0,o=0;l=0){t[l]=u,t[l+1]=a;let f=l>>1;for(;i.length0&&ts(i,t,o.text),o.forward(m),u+=m}let d=e[a++];for(;u>1].toJSON()))}return e}static of(e,t,i){let l=[],o=[],a=0,u=null;function f(m=!1){if(!m&&!l.length)return;ab||g<0||b>t)throw new RangeError(`Invalid change range ${g} to ${b} (in doc of length ${t})`);let w=v?typeof v=="string"?pt.of(v.split(i||tx)):v:pt.empty,S=w.length;if(g==b&&S==0)return;ga&&qn(l,g-a,-1),qn(l,b-g,S),ts(o,l,w),a=b}}return d(e),f(!u),u}static empty(e){return new mn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let l=0;lu&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)t.push(o[0],0);else{for(;i.length=0&&t<=0&&t==n[l+1]?n[l]+=e:l>=0&&e==0&&n[l]==0?n[l+1]+=t:i?(n[l]+=e,n[l+1]+=t):n.push(e,t)}function ts(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||a==n.sections.length||n.sections[a+1]<0);)u=n.sections[a++],f=n.sections[a++];e(l,d,o,m,g),l=d,o=m}}}function ix(n,e,t,i=!1){let l=[],o=i?[]:null,a=new mu(n),u=new mu(e);for(let f=-1;;){if(a.done&&u.len||u.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&u.ins==-1){let d=Math.min(a.len,u.len);qn(l,d,-1),a.forward(d),u.forward(d)}else if(u.ins>=0&&(a.ins<0||f==a.i||a.off==0&&(u.len=0&&f=0){let d=0,m=a.len;for(;m;)if(u.ins==-1){let g=Math.min(m,u.len);d+=g,m-=g,u.forward(g)}else if(u.ins==0&&u.lenf||a.ins>=0&&a.len>f)&&(u||i.length>d),o.forward2(f),a.forward(f)}}}}class mu{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?pt.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?pt.empty:t[i].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)}}class Jl{constructor(e,t,i,l){this.from=e,this.to=t,this.flags=i,this.goalColumn=l}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(e,t=-1){let i,l;return this.empty?i=l=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),l=e.mapPos(this.to,-1)),i==this.from&&l==this.to?this:new Jl(i,l,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return le.range(e,t,void 0,void 0,i);let l=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return le.range(this.anchor,l,void 0,void 0,i)}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 new RangeError("Invalid JSON representation for SelectionRange");return le.range(e.anchor,e.head)}static create(e,t,i,l){return new Jl(e,t,i,l)}}class le{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:le.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new le(e.ranges.map(t=>Jl.fromJSON(t)),e.main)}static single(e,t=e){return new le([le.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,l=0;ll.from-o.from),t=e.indexOf(i);for(let l=1;lo.head?le.range(f,u):le.range(u,f))}}return new le(e,t)}}function yO(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Sy=0;class Ne{constructor(e,t,i,l,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=l,this.id=Sy++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ne(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Cy),!!e.static,e.enables)}of(e){return new id([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new id(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new id(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Cy(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class id{constructor(e,t,i,l){this.dependencies=e,this.facet=t,this.type=i,this.value=l,this.id=Sy++}dynamicSlot(e){var t;let i=this.value,l=this.facet.compareInput,o=this.id,a=e[o]>>1,u=this.type==2,f=!1,d=!1,m=[];for(let g of this.dependencies)g=="doc"?f=!0:g=="selection"?d=!0:(((t=e[g.id])!==null&&t!==void 0?t:1)&1)==0&&m.push(e[g.id]);return{create(g){return g.values[a]=i(g),1},update(g,b){if(f&&b.docChanged||d&&(b.docChanged||b.selection)||rx(g,m)){let v=i(g);if(u?!eS(v,g.values[a],l):!l(v,g.values[a]))return g.values[a]=v,1}return 0},reconfigure:(g,b)=>{let v,w=b.config.address[o];if(w!=null){let S=gd(b,w);if(this.dependencies.every(C=>C instanceof Ne?b.facet(C)===g.facet(C):C instanceof Qn?b.field(C,!1)==g.field(C,!1):!0)||(u?eS(v=i(g),S,l):l(v=i(g),S)))return g.values[a]=S,0}else v=i(g);return g.values[a]=v,1}}}get extension(){return this}}function eS(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[f.id]),l=t.map(f=>f.type),o=i.filter(f=>!(f&1)),a=n[e.id]>>1;function u(f){let d=[];for(let m=0;mi===l),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(bh).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,l)=>{let o=i.values[t],a=this.updateF(o,l);return this.compareF(o,a)?0:(i.values[t]=a,1)},reconfigure:(i,l)=>{let o=i.facet(bh),a=l.facet(bh),u;return(u=o.find(f=>f.field==this))&&u!=a.find(f=>f.field==this)?(i.values[t]=u.create(i),1):l.config.address[this.id]!=null?(i.values[t]=l.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,bh.of({field:this,create:e})]}get extension(){return this}}const Zs={lowest:4,low:3,default:2,high:1,highest:0};function Fc(n){return e=>new bO(e,n)}const mo={highest:Fc(Zs.highest),high:Fc(Zs.high),default:Fc(Zs.default),low:Fc(Zs.low),lowest:Fc(Zs.lowest)};class bO{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class em{of(e){return new lx(this,e)}reconfigure(e){return em.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class lx{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class pd{constructor(e,t,i,l,o,a){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=l,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let l=[],o=Object.create(null),a=new Map;for(let b of qD(e,t,a))b instanceof Qn?l.push(b):(o[b.facet.id]||(o[b.facet.id]=[])).push(b);let u=Object.create(null),f=[],d=[];for(let b of l)u[b.id]=d.length<<1,d.push(v=>b.slot(v));let m=i==null?void 0:i.config.facets;for(let b in o){let v=o[b],w=v[0].facet,S=m&&m[b]||[];if(v.every(C=>C.type==0))if(u[w.id]=f.length<<1|1,Cy(S,v))f.push(i.facet(w));else{let C=w.combine(v.map(N=>N.value));f.push(i&&w.compare(C,i.facet(w))?i.facet(w):C)}else{for(let C of v)C.type==0?(u[C.id]=f.length<<1|1,f.push(C.value)):(u[C.id]=d.length<<1,d.push(N=>C.dynamicSlot(N)));u[w.id]=d.length<<1,d.push(C=>FD(C,w,v))}}let g=d.map(b=>b(u));return new pd(e,a,g,u,f,o)}}function qD(n,e,t){let i=[[],[],[],[],[]],l=new Map;function o(a,u){let f=l.get(a);if(f!=null){if(f<=u)return;let d=i[f].indexOf(a);d>-1&&i[f].splice(d,1),a instanceof lx&&t.delete(a.compartment)}if(l.set(a,u),Array.isArray(a))for(let d of a)o(d,u);else if(a instanceof lx){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let d=e.get(a.compartment)||a.inner;t.set(a.compartment,d),o(d,u)}else if(a instanceof bO)o(a.inner,a.prec);else if(a instanceof Qn)i[u].push(a),a.provides&&o(a.provides,u);else if(a instanceof id)i[u].push(a),a.facet.extensions&&o(a.facet.extensions,Zs.default);else{let d=a.extension;if(!d)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(d==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(d,u)}}return o(n,Zs.default),i.reduce((a,u)=>a.concat(u))}function iu(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let l=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|l}function gd(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const vO=Ne.define(),sx=Ne.define({combine:n=>n.some(e=>e),static:!0}),wO=Ne.define({combine:n=>n.length?n[0]:void 0,static:!0}),kO=Ne.define(),SO=Ne.define(),CO=Ne.define(),OO=Ne.define({combine:n=>n.length?n[0]:!1});class pl{constructor(e,t){this.type=e,this.value=t}static define(){return new VD}}class VD{of(e){return new pl(this,e)}}class QD{constructor(e){this.map=e}of(e){return new Ke(this,e)}}class Ke{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new Ke(this.type,t)}is(e){return this.type==e}static define(e={}){return new QD(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let l of e){let o=l.map(t);o&&i.push(o)}return i}}Ke.reconfigure=Ke.define();Ke.appendConfig=Ke.define();class pn{constructor(e,t,i,l,o,a){this.startState=e,this.changes=t,this.selection=i,this.effects=l,this.annotations=o,this.scrollIntoView=a,this._doc=null,this._state=null,i&&yO(i,t.newLength),o.some(u=>u.type==pn.time)||(this.annotations=o.concat(pn.time.of(Date.now())))}static create(e,t,i,l,o,a){return new pn(e,t,i,l,o,a)}get newDoc(){return this._doc||(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(e){let t=this.annotation(pn.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}pn.time=pl.define();pn.userEvent=pl.define();pn.addToHistory=pl.define();pn.remote=pl.define();function XD(n,e){let t=[];for(let i=0,l=0;;){let o,a;if(i=n[i]))o=n[i++],a=n[i++];else if(l=0;l--){let o=i[l](n);o instanceof pn?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof pn?n=o[0]:n=TO(e,ya(o),!1)}return n}function YD(n){let e=n.startState,t=e.facet(CO),i=n;for(let l=t.length-1;l>=0;l--){let o=t[l](n);o&&Object.keys(o).length&&(i=NO(i,ox(e,o,n.changes.newLength),!0))}return i==n?n:pn.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const GD=[];function ya(n){return n==null?GD:Array.isArray(n)?n:[n]}var Ut=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(Ut||(Ut={}));const KD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ax;try{ax=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function WD(n){if(ax)return ax.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||KD.test(t)))return!0}return!1}function ZD(n){return e=>{if(!/\S/.test(e))return Ut.Space;if(WD(e))return Ut.Word;for(let t=0;t-1)return Ut.Word;return Ut.Other}}class gt{constructor(e,t,i,l,o,a){this.config=e,this.doc=t,this.selection=i,this.values=l,this.status=e.statusTemplate.slice(),this.computeSlot=o,a&&(a._state=this);for(let u=0;ul.set(d,f)),t=null),l.set(u.value.compartment,u.value.extension)):u.is(Ke.reconfigure)?(t=null,i=u.value):u.is(Ke.appendConfig)&&(t=null,i=ya(i).concat(u.value));let o;t?o=e.startState.values.slice():(t=pd.resolve(i,l,this),o=new gt(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(f,d)=>d.reconfigure(f,this),null).values);let a=e.startState.facet(sx)?e.newSelection:e.newSelection.asSingle();new gt(t,e.newDoc,a,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:le.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),l=this.changes(i.changes),o=[i.range],a=ya(i.effects);for(let u=1;ua.spec.fromJSON(u,f)))}}return gt.create({doc:e.doc,selection:le.fromJSON(e.selection),extensions:t.extensions?l.concat([t.extensions]):l})}static create(e={}){let t=pd.resolve(e.extensions||[],new Map),i=e.doc instanceof pt?e.doc:pt.of((e.doc||"").split(t.staticFacet(gt.lineSeparator)||tx)),l=e.selection?e.selection instanceof le?e.selection:le.single(e.selection.anchor,e.selection.head):le.single(0);return yO(l,i.length),t.staticFacet(sx)||(l=l.asSingle()),new gt(t,i,l,t.dynamicSlots.map(()=>null),(o,a)=>a.create(o),null)}get tabSize(){return this.facet(gt.tabSize)}get lineBreak(){return this.facet(gt.lineSeparator)||` -`}get readOnly(){return this.facet(OO)}phrase(e,...t){for(let i of this.facet(gt.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,l)=>{if(l=="$")return"$";let o=+(l||1);return!o||o>t.length?i:t[o-1]})),e}languageDataAt(e,t,i=-1){let l=[];for(let o of this.facet(vO))for(let a of o(this,t,i))Object.prototype.hasOwnProperty.call(a,e)&&l.push(a[e]);return l}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return ZD(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:l}=this.doc.lineAt(e),o=this.charCategorizer(e),a=e-i,u=e-i;for(;a>0;){let f=wn(t,a,!1);if(o(t.slice(f,a))!=Ut.Word)break;a=f}for(;un.length?n[0]:4});gt.lineSeparator=wO;gt.readOnly=OO;gt.phrases=Ne.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(l=>n[l]==e[l])}});gt.languageData=vO;gt.changeFilter=kO;gt.transactionFilter=SO;gt.transactionExtender=CO;em.reconfigure=Ke.define();function Ur(n,e,t={}){let i={};for(let l of n)for(let o of Object.keys(l)){let a=l[o],u=i[o];if(u===void 0)i[o]=a;else if(!(u===a||a===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](u,a);else throw new Error("Config merge conflict for field "+o)}for(let l in e)i[l]===void 0&&(i[l]=e[l]);return i}class os{eq(e){return this==e}range(e,t=e){return cx.create(e,t,this)}}os.prototype.startSide=os.prototype.endSide=0;os.prototype.point=!1;os.prototype.mapMode=ni.TrackDel;function Oy(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let cx=class AO{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new AO(e,t,i)}};function ux(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Ny{constructor(e,t,i,l){this.from=e,this.to=t,this.value=i,this.maxPoint=l}get length(){return la(this.to)}findIndex(e,t,i,l=0){let o=i?this.to:this.from;for(let a=l,u=o.length;;){if(a==u)return a;let f=a+u>>1,d=o[f]-e||(i?this.value[f].endSide:this.value[f].startSide)-t;if(f==a)return d>=0?a:u;d>=0?u=f:a=f+1}}between(e,t,i,l){for(let o=this.findIndex(t,-1e9,!0),a=this.findIndex(i,1e9,!1,o);oC||S==C&&b.startSide>0&&b.endSide<=0)continue;if(!((C-S||b.endSide-b.startSide)<0))if(d<0&&(d=S),b.point&&(m=Math.max(m,C-S)),(S-i||b.startSide-l)>=0)a.push(b),u.push(S-d),f.push(C-d),i=C,l=b.endSide;else{if(S==C)for(let N=a.length;N>0;N--){if((S-(f[N-1]+d)||b.startSide-a[N-1].endSide)>=0){a.splice(N,0,b),u.splice(N,0,S-d),f.splice(N,0,C-d);continue e}if((S-(u[N-1]+d)||b.endSide-a[N-1].startSide)>0)break}o(S,C,b)}}return{mapped:a.length?new Ny(u,f,a,m):null,pos:d}}}class lt{constructor(e,t,i,l){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=l}static create(e,t,i,l){return new lt(e,t,i,l)}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(e){let{add:t=[],sort:i=!1,filterFrom:l=0,filterTo:o=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(i&&(t=t.slice().sort(ux)),this.isEmpty)return t.length?lt.of(t):this;let u=new EO(this,null,-1).goto(0),f=0,d=[],m=new Hr;for(;u.value||f=0){let g=t[f++];m.addInner(g.from,g.to,g.value,!1)||d.push(g)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new Hr),o.addRange(f,d,m,!1)};for(let f=0;f=o&&e<=o+a.length&&a.between(o,e-o,t-o,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return pu.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return pu.from(e).goto(t)}static compare(e,t,i,l,o=-1){let a=e.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),u=t.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),f=tS(a,u,i),d=new qc(a,f,o),m=new qc(u,f,o);i.iterGaps((g,b,v)=>nS(d,g,m,b,v,l)),i.empty&&i.length==0&&nS(d,0,m,0,0,l)}static eq(e,t,i=0,l){l==null&&(l=999999999);let o=e.filter(m=>!m.isEmpty&&t.indexOf(m)<0),a=t.filter(m=>!m.isEmpty&&e.indexOf(m)<0);if(o.length!=a.length)return!1;if(!o.length)return!0;let u=tS(o,a),f=new qc(o,u,0).goto(i),d=new qc(a,u,0).goto(i);for(;;){if(f.to!=d.to||!fx(f.active,d.active)||f.point&&(!d.point||!Oy(f.point,d.point)))return!1;if(f.to>l)return!0;f.next(),d.next()}}static spans(e,t,i,l,o=-1){let a=new qc(e,null,o).goto(t),u=t,f=a.openStart;for(;;){let d=Math.min(a.to,i);if(a.point){let m=a.activeForPoint(a.to),g=a.pointFromu&&(l.span(u,d,a.active,f),f=a.openEnd(d));if(a.to>i)return f+(a.point&&a.to>i?1:0);u=a.to,a.next()}}static of(e,t=!1){let i=new Hr;for(let l of e instanceof cx?[e]:t?JD(e):e)i.add(l.from,l.to,l.value);return i.finish()}static join(e){if(!e.length)return lt.empty;let t=la(e);for(let i=e.length-2;i>=0;i--)for(let l=e[i];l!=lt.empty;l=l.nextLayer)t=new lt(l.chunkPos,l.chunk,t,Math.max(l.maxPoint,t.maxPoint));return t}}lt.empty=new lt([],[],null,-1);function la(n){return n[n.length-1]}function JD(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(ux);e=i}return n}lt.empty.nextLayer=lt.empty;class Hr{finishChunk(e){this.chunks.push(new Ny(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(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,l){this.addInner(e,t,i,l)||(this.nextLayer||(this.nextLayer=new Hr)).addRange(e,t,i,l)}addInner(e,t,i,l){let o=e-this.lastTo||i.startSide-this.last.endSide;if(l&&o<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<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=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.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 i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(lt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=lt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function tS(n,e,t){let i=new Map;for(let o of n)for(let a=0;a=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&l.push(new EO(a,t,i,o));return l.length==1?l[0]:new pu(l)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)t0(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)t0(this.heap,i);(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(),t0(this.heap,0)}}}function t0(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let l=n[i];if(i+1=0&&(l=n[i+1],i++),t.compare(l)<0)break;n[i]=t,n[e]=l,e=i}}class qc{constructor(e,t,i){this.minPoint=i,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=pu.from(e,t,i)}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){vh(this.active,e),vh(this.activeTo,e),vh(this.activeRank,e),this.minActive=iS(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:l,rank:o}=this.cursor;for(;t0;)t++;wh(this.active,t,i),wh(this.activeTo,t,l),wh(this.activeRank,t,o),e&&wh(e,t,this.cursor.from),this.minActive=iS(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let l=this.minActive;if(l>-1&&(this.activeTo[l]-this.cursor.from||this.active[l].endSide-this.cursor.startSide)<0){if(this.activeTo[l]>e){this.to=this.activeTo[l],this.endSide=this.active[l].endSide;break}this.removeActive(l),i&&vh(i,l)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[l]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function nS(n,e,t,i,l,o){n.goto(e),t.goto(i);let a=i+l,u=i,f=i-e,d=!!o.boundChange;for(let m=!1;;){let g=n.to+f-t.to,b=g||n.endSide-t.endSide,v=b<0?n.to+f:t.to,w=Math.min(v,a);if(n.point||t.point?(n.point&&t.point&&Oy(n.point,t.point)&&fx(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(u,w,n.point,t.point),m=!1):(m&&(o.boundChange(u),m=!1),w>u&&!fx(n.active,t.active)&&o.compareRange(u,w,n.active,t.active),d&&wa)break;u=v,b<=0&&n.next(),b>=0&&t.next()}}function fx(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function iS(n,e){let t=-1,i=1e9;for(let l=0;l=e)return l;if(l==n.length)break;o+=n.charCodeAt(l)==9?t-o%t:1,l=wn(n,l)}return i===!0?-1:n.length}const dx="ͼ",rS=typeof Symbol>"u"?"__"+dx:Symbol.for(dx),mx=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),lS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class as{constructor(e,t){this.rules=[];let{finish:i}=t||{};function l(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function o(a,u,f,d){let m=[],g=/^@(\w+)\b/.exec(a[0]),b=g&&g[1]=="keyframes";if(g&&u==null)return f.push(a[0]+";");for(let v in u){let w=u[v];if(/&/.test(v))o(v.split(/,\s*/).map(S=>a.map(C=>S.replace(/&/,C))).reduce((S,C)=>S.concat(C)),w,f);else if(w&&typeof w=="object"){if(!g)throw new RangeError("The value of a property ("+v+") should be a primitive value.");o(l(v),w,m,b)}else w!=null&&m.push(v.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+w+";")}(m.length||b)&&f.push((i&&!g&&!d?a.map(i):a).join(", ")+" {"+m.join(" ")+"}")}for(let a in e)o(l(a),e[a],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=lS[rS]||1;return lS[rS]=e+1,dx+e.toString(36)}static mount(e,t,i){let l=e[mx],o=i&&i.nonce;l?o&&l.setNonce(o):l=new eR(e,o),l.mount(Array.isArray(t)?t:[t],e)}}let sS=new Map;class eR{constructor(e,t){let i=e.ownerDocument||e,l=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let o=sS.get(i);if(o)return e[mx]=o;this.sheet=new l.CSSStyleSheet,sS.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[mx]=this}mount(e,t){let i=this.sheet,l=0,o=0,a=!1;for(let u=0;u-1&&(this.modules.splice(d,1),a=!0,o--,d=-1),d==-1){if(this.modules.splice(o++,0,f),a=!0,i)for(let m=0;m",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},tR=typeof navigator<"u"&&/Mac/.test(navigator.platform),nR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _n=0;_n<10;_n++)cs[48+_n]=cs[96+_n]=String(_n);for(var _n=1;_n<=24;_n++)cs[_n+111]="F"+_n;for(var _n=65;_n<=90;_n++)cs[_n]=String.fromCharCode(_n+32),gu[_n]=String.fromCharCode(_n);for(var n0 in cs)gu.hasOwnProperty(n0)||(gu[n0]=cs[n0]);function iR(n){var e=tR&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||nR&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?gu:cs)[n.keyCode]||n.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 Tt(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var l=t[i];typeof l=="string"?n.setAttribute(i,l):l!=null&&(n[i]=l)}e++}for(;e2);var Ce={mac:cS||/Mac/.test(ti.platform),windows:/Win/.test(ti.platform),linux:/Linux|X11/.test(ti.platform),ie:tm,ie_version:DO?px.documentMode||6:xx?+xx[1]:gx?+gx[1]:0,gecko:oS,gecko_version:oS?+(/Firefox\/(\d+)/.exec(ti.userAgent)||[0,0])[1]:0,chrome:!!i0,chrome_version:i0?+i0[1]:0,ios:cS,android:/Android\b/.test(ti.userAgent),webkit:aS,webkit_version:aS?+(/\bAppleWebKit\/(\d+)/.exec(ti.userAgent)||[0,0])[1]:0,safari:yx,safari_version:yx?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ti.userAgent)||[0,0])[1]:0,tabSize:px.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Ty(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const xd=Object.create(null);function Ay(n,e,t){if(n==e)return!0;n||(n=xd),e||(e=xd);let i=Object.keys(n),l=Object.keys(e);if(i.length-0!=l.length-0)return!1;for(let o of i)if(o!=t&&(l.indexOf(o)==-1||n[o]!==e[o]))return!1;return!0}function rR(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function uS(n,e,t){let i=!1;if(e)for(let l in e)t&&l in t||(i=!0,l=="style"?n.style.cssText="":n.removeAttribute(l));if(t)for(let l in t)e&&e[l]==t[l]||(i=!0,l=="style"?n.style.cssText=t[l]:n.setAttribute(l,t[l]));return i}function lR(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new co(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,l;if(e.isBlockGap)i=-5e8,l=4e8;else{let{start:o,end:a}=RO(e,t);i=(o?t?-3e8:-1:5e8)-1,l=(a?t?2e8:1:-6e8)+1}return new co(e,i,l,t,e.widget||null,!0)}static line(e){return new ju(e)}static set(e,t=!1){return lt.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Fe.none=lt.empty;class Ru extends Fe{constructor(e){let{start:t,end:i}=RO(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Ty(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||xd}eq(e){return this==e||e instanceof Ru&&this.tagName==e.tagName&&Ay(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}Ru.prototype.point=!1;class ju extends Fe{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ju&&this.spec.class==e.spec.class&&Ay(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ju.prototype.mapMode=ni.TrackBefore;ju.prototype.point=!0;class co extends Fe{constructor(e,t,i,l,o,a){super(t,i,o,e),this.block=l,this.isReplace=a,this.mapMode=l?t<=0?ni.TrackBefore:ni.TrackAfter:ni.TrackDel}get type(){return this.startSide!=this.endSide?Bn.WidgetRange:this.startSide<=0?Bn.WidgetBefore:Bn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof co&&sR(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}co.prototype.point=!0;function RO(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function sR(n,e){return n==e||!!(n&&e&&n.compare(e))}function ba(n,e,t,i=0){let l=t.length-1;l>=0&&t[l]+i>=n?t[l]=Math.max(t[l],e):t.push(n,e)}class xu extends os{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof xu&&this.tagName==e.tagName&&Ay(this.attributes,e.attributes)}static create(e){return new xu(e.tagName,e.attributes||xd,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return lt.of(e,t)}}xu.prototype.startSide=xu.prototype.endSide=-1;const kn=n=>n.nodeType==1,Aa=n=>n.nodeType==3;function yu(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function bx(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function ru(n,e){if(!e.anchorNode)return!1;try{return bx(n,e.anchorNode)}catch{return!1}}function rd(n){return Aa(n)?bu(n,0,n.nodeValue.length).getClientRects():kn(n)?n.getClientRects():[]}function lu(n,e,t,i){return t?fS(n,e,t,i,-1)||fS(n,e,t,i,1):!1}function us(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function yd(n){return kn(n)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function fS(n,e,t,i,l){for(;;){if(n==t&&e==i)return!0;if(e==(l<0?0:hl(n))){if(n.nodeName=="DIV")return!1;let o=n.parentNode;if(!o||!kn(o))return!1;e=us(n)+(l<0?0:1),n=o}else if(kn(n)){if(n=n.childNodes[e+(l<0?-1:0)],kn(n)&&(n.nodeName=="IMG"||n.nodeName=="BR"||n.contentEditable=="false"))return!1;e=l<0?hl(n):0}else return!1}}function hl(n){return Aa(n)?n.nodeValue.length:n.childNodes.length}function bd(n,e){let{left:t,right:i}=n;if(t==i)return n;let l=e?t:i;return{left:l,right:l,top:n.top,bottom:n.bottom}}function oR(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function jO(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function aR(n,e,t,i,l,o,a,u){let f=n.ownerDocument,d=f.defaultView||window;for(let m=n,g=!1;m&&!g;)if(kn(m)){let b,v=m==f.body,w=1,S=1,C=!0,N=!0;if(v)b=oR(d);else{let U=getComputedStyle(m);if(/^(fixed|sticky)$/.test(U.position)&&(g=!0),(m.scrollHeight<=m.clientHeight||!/auto|scroll/.test(U.overflowY))&&(N=!1),(m.scrollWidth<=m.clientWidth||!/auto|scroll/.test(U.overflowX))&&(C=!1),!C&&!N){m=m.assignedSlot||m.parentNode;continue}let H=m.getBoundingClientRect();({scaleX:w,scaleY:S}=jO(m,H)),b={left:H.left,right:H.left+m.clientWidth*w,top:H.top,bottom:H.top+m.clientHeight*S}}let j=0,M=0;if(N)if(l=="nearest")e.top0&&e.bottom>b.bottom+M&&(M=e.bottom-b.bottom+a)):e.bottom>b.bottom-a&&(M=e.bottom-b.bottom+a,t<0&&e.top-M0&&e.right>b.right+j&&(j=e.right-b.right+o)):e.right>b.right-o&&(j=e.right-b.right+o,t<0&&e.leftb.bottom||e.leftb.right)&&(e={left:Math.max(e.left,b.left),right:Math.min(e.right,b.right),top:Math.max(e.top,b.top),bottom:Math.min(e.bottom,b.bottom)}),m=m.assignedSlot||m.parentNode}else if(m.nodeType==11)m=m.host;else break}function _O(n,e=!0){let t=n.ownerDocument,i=null,l=null;for(let o=n.parentNode;o&&!(o==t.body||(!e||i)&&l);)if(kn(o))!l&&o.scrollHeight>o.clientHeight&&/scroll|auto/.test(getComputedStyle(o).overflowY)&&(l=o),e&&!i&&o.scrollWidth>o.clientWidth&&/scroll|auto/.test(getComputedStyle(o).overflowX)&&(i=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:i,y:l}}class cR{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:i}=e;this.set(t,Math.min(e.anchorOffset,t?hl(t):0),i,Math.min(e.focusOffset,i?hl(i):0))}set(e,t,i,l){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=l}}function LO(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)kn(t)&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function zO(n,e=!0){for(let{node:t,left:i,top:l}of n)e&&t.scrollTop!=l&&(t.scrollTop=l),t.scrollLeft!=i&&(t.scrollLeft=i)}let Ks=null;Ce.safari&&Ce.safari_version>=26&&(Ks=!1);function BO(n){if(n.setActive)return n.setActive();if(Ks)return n.focus(Ks);let e=LO(n);n.focus(Ks==null?{get preventScroll(){return Ks={preventScroll:!0},!0}}:void 0),Ks||(Ks=!1,zO(e))}let hS;function bu(n,e,t=e){let i=hS||(hS=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function va(n,e,t,i){let l={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:l.altKey,ctrlKey:l.ctrlKey,shiftKey:l.shiftKey,metaKey:l.metaKey}=i);let o=new KeyboardEvent("keydown",l);o.synthetic=!0,n.dispatchEvent(o);let a=new KeyboardEvent("keyup",l);return a.synthetic=!0,n.dispatchEvent(a),o.defaultPrevented||a.defaultPrevented}function uR(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function fR(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,hl(t));;)if(i){if(!kn(t))return!1;let l=t.childNodes[i-1];l.contentEditable=="false"?i--:(t=l,i=hl(t))}else{if(t==n)return!0;i=us(t),t=t.parentNode}}function PO(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function HO(n,e){for(let t=n,i=e;;){if(Aa(t)&&i>0)return{node:t,offset:i};if(kn(t)&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=hl(t)}else if(t.parentNode&&!yd(t))i=us(t),t=t.parentNode;else return null}}function IO(n,e){for(let t=n,i=e;;){if(Aa(t)&&i=t){if(u.level==i)return a;(o<0||(l!=0?l<0?u.fromt:e[o].level>u.level))&&(o=a)}}if(o<0)throw new RangeError("Index out of range");return o}}function qO(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;S-=3)if(Or[S+1]==-v){let C=Or[S+2],N=C&2?l:C&4?C&1?o:l:0;N&&(_t[g]=_t[Or[S]]=N),u=S;break}}else{if(Or.length==189)break;Or[u++]=g,Or[u++]=b,Or[u++]=f}else if((w=_t[g])==2||w==1){let S=w==l;f=S?0:1;for(let C=u-3;C>=0;C-=3){let N=Or[C+2];if(N&2)break;if(S)Or[C+2]|=2;else{if(N&4)break;Or[C+2]|=4}}}}}function xR(n,e,t,i){for(let l=0,o=i;l<=t.length;l++){let a=l?t[l-1].to:n,u=lf;)w==C&&(w=t[--S].from,C=S?t[S-1].to:n),_t[--w]=v;f=m}else o=d,f++}}}function wx(n,e,t,i,l,o,a){let u=i%2?2:1;if(i%2==l%2)for(let f=e,d=0;ff&&a.push(new _r(f,S.from,v));let C=S.direction==Ea!=!(v%2);kx(n,C?i+1:i,l,S.inner,S.from,S.to,a),f=S.to}w=S.to}else{if(w==t||(m?_t[w]!=u:_t[w]==u))break;w++}b?wx(n,f,w,i+1,l,b,a):fe;){let m=!0,g=!1;if(!d||f>o[d-1].to){let S=_t[f-1];S!=u&&(m=!1,g=S==16)}let b=!m&&u==1?[]:null,v=m?i:i+1,w=f;e:for(;;)if(d&&w==o[d-1].to){if(g)break e;let S=o[--d];if(!m)for(let C=S.from,N=d;;){if(C==e)break e;if(N&&o[N-1].to==C)C=o[--N].from;else{if(_t[C-1]==u)break e;break}}if(b)b.push(S);else{S.to_t.length;)_t[_t.length]=256;let i=[],l=e==Ea?0:1;return kx(n,l,l,t,0,n.length,i),i}function VO(n){return[new _r(0,n,0)]}let QO="";function bR(n,e,t,i,l){var o;if(!n.length)return null;let a=i.head-n.from,u;if(i.head==n.from&&i.assoc<0){if(!l)return null;a=e[u=0].side(!1,t)}else if(i.head==n.to&&i.assoc>0){if(l)return null;a=e[u=e.length-1].side(!0,t)}else u=_r.find(e,a,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc);let f=e[u],d=f.side(l,t);if(a==d){let b=u+=l?1:-1;if(b<0||b>=e.length)return null;f=e[u=b],a=f.side(!l,t),d=f.side(l,t)}let m=wn(n.text,a,f.forward(l,t));(mf.to)&&(m=d),QO=n.text.slice(Math.min(a,m),Math.max(a,m));let g=u==(l?e.length-1:0)?null:e[u+(l?1:-1)];if(m==d){if(!g)return l?le.cursor(n.to,1):le.cursor(n.from,-1);if(g.level+(l?0:1)n.some(e=>e)}),JO=Ne.define({combine:n=>n.some(e=>e)}),eN=Ne.define();class wa{constructor(e,t,i,l,o,a=!1){this.range=e,this.y=t,this.x=i,this.yMargin=l,this.xMargin=o,this.isSnapshot=a}map(e){return e.empty?this:new wa(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new wa(le.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const kh=Ke.define({map:(n,e)=>n.map(e)}),tN=Ke.define();function gi(n,e,t){let i=n.facet(GO);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const cl=Ne.define({combine:n=>n.length?n[0]:!0});let wR=0;const da=Ne.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let f=[];return a&&f.push(nm.of(d=>{let m=d.plugin(u);return m?a(m):Fe.none})),o&&f.push(o(u)),f})}static fromClass(e,t){return en.define((i,l)=>new e(i,l),t)}}class r0{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.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(gi(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){gi(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){gi(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const nN=Ne.define(),Ry=Ne.define(),nm=Ne.define(),iN=Ne.define(),jy=Ne.define(),_u=Ne.define(),rN=Ne.define();function dS(n,e){let t=n.state.facet(rN);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),l=[];return lt.spans(i,e.from,e.to,{point(){},span(o,a,u,f){let d=o-e.from,m=a-e.from,g=l;for(let b=u.length-1;b>=0;b--,f--){let v=u[b].spec.bidiIsolate,w;if(f>0&&g.length&&(w=g[g.length-1]).to==d&&w.direction==v)w.to=m,g=w.inner;else{let S={from:d,to:m,direction:v,inner:[]};g.push(S),g=S.inner}}}}),lN(e.text,l)}function lN(n,e){for(let t of e){if(t.direction==null){for(let i=t.from,l=0;i0;t--){let l=e[t-1];if(!(l.fromA>i.toA)){if(l.toAl.push(new Qi(o,a,u,f))),this.changedRanges=l}static create(e,t,i){return new vd(e,t,i)}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}}const kR=[];class Gt{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return kR}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 t=this.domAttrs;t&&rR(this.dom,t)}}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 i=t;for(let l of this.children){if(l==e)return i;i+=l.length+l.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=us(this.dom),l=this.length?e>0:t>0;return new or(this.parent.dom,i+(l?1:0),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 rm)return e;return null}static get(e){return e.cmTile}}class im extends Gt{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,i=null,l,o=(e==null?void 0:e.node)==t?e:null,a=0;for(let u of this.children){if(u.sync(e),a+=u.length+u.breakAfter,l=i?i.nextSibling:t.firstChild,o&&l!=u.dom&&(o.written=!0),u.dom.parentNode==t)for(;l&&l!=u.dom;)l=mS(l);else t.insertBefore(u.dom,l);i=u.dom}for(l=i?i.nextSibling:t.firstChild,o&&l&&(o.written=!0);l;)l=mS(l);this.length=a}}function mS(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class rm extends im{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=Gt.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,l=0,o=0;;)if(l==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&o++,l=t.pop()}else{let a=i.children[l++];if(a instanceof ul)t.push(l),i=a,l=0;else{let u=o+a.length,f=e(a,o);if(f!==void 0)return f;o=u+a.breakAfter}}}resolveBlock(e,t){let i,l=-1,o,a=-1;if(this.blockTiles((u,f)=>{let d=f+u.length;if(e>=f&&e<=d){if(u.isWidget()&&t>=-1&&t<=1){if(u.flags&32)return!0;u.flags&16&&(i=void 0)}(fe||e==f&&(t>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,a=e-f)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:l}:{tile:o,offset:a}}}class ul extends im{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(e,t){let i=new ul(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class Ma extends im{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let l=new Ma(t||document.createElement("div"),e);return(!t||!i)&&(l.flags|=4),l}get domAttrs(){return this.attrs}resolveInline(e,t,i=!1){let l=null,o=-1,a=null,u=-1;function f(m,g){for(let b=0,v=0;b=g&&(w.isComposite()?f(w,g-v):(!a||i&&a.isHidden&&(t>0&&!(a.flags&32)||i&&CR(a,w)))&&(S>g||w.flags&32&&t<=1)?(a=w,u=g-v):(v=-1)&&(l=w,o=g-v)),v=S}}f(this,e);let d=(t<0?l:a)||l||a;return d?{tile:d,offset:d==l?o:u}:null}coordsIn(e,t,i){let l=this.resolveInline(e,t,!0);return l?l.tile.coordsIn(Math.max(0,l.offset),t,i):SR(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:l,offset:o}=i;if(this.dom.contains(l.dom))return l.isText()?new or(l.dom,Math.min(l.dom.nodeValue.length,o)):l.domPosFor(o,l.flags&16?1:l.flags&32?-1:t);let a=i.tile.parent,u=!1;for(let f of a.children){if(u)return new or(f.dom,0);f==i.tile&&(u=!0)}}return new or(this.dom,0)}}function SR(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=rd(e);return t[t.length-1]||null}function CR(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.topl&&(e=l);let o=e,a=e,u=0;e==0&&t<0||e==l&&t>=0?Ce.chrome||Ce.gecko||(e?(o--,u=1):a=0)?0:f.length-1];return Ce.safari&&!u&&d.width==0&&(d=Array.prototype.find.call(f,m=>m.width)||d),i==null?d:bd(d,(u?u>0:t<0)==i)}static of(e,t){let i=new to(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class uo extends Gt{constructor(e,t,i,l){super(e,t,l),this.widget=i}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,i){let l=this.widget.coordsAt(this.dom,e,t);if(l)return l;if(i)return bd(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let o=this.dom.getClientRects(),a=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;a=o[f],!(e>0?f==0:f==o.length-1||a.top0==i)}}class OR{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:l,index:o,beforeBreak:a,parents:u}=this;for(;e||t>0;)if(l.isComposite())if(a){if(!e)break;i&&i.break(),e--,a=!1}else if(o==l.children.length){if(!e&&!u.length)break;i&&i.leave(l),a=!!l.breakAfter,{tile:l,index:o}=u.pop(),o++}else{let f=l.children[o],d=f.breakAfter;(t>0?f.length<=e:f.length=0;u--){let f=t.marks[u],d=l.lastChild;if(d instanceof pi&&d.mark.eq(f.mark))d.dom!=f.dom&&d.setDOM(l0(f.dom)),l=d;else{let{dom:m}=f;this.cache.reused.get(f)&&Gt.get(f.dom)&&(m=l0(f.dom));let g=pi.of(f.mark,m);l.append(g),l=g}this.cache.reused.set(f,2)}let o=Gt.get(e.text);o&&this.cache.reused.set(o,2);let a=new to(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,l.append(a)}addInlineWidget(e,t,i){let l=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);l||this.flushBuffer();let o=this.ensureMarks(t,i);!l&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).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){var i;e||(e=oN);let l=Ma.start(e,t||((i=this.cache.find(Ma))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=l)}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){var i;let l=this.curLine;for(let o=e.length-1;o>=0;o--){let a=e[o],u;if(t>0&&(u=l.lastChild)&&u instanceof pi&&u.mark.eq(a))l=u,t--;else{let f=pi.of(a,(i=this.cache.find(pi,d=>d.mark.eq(a)))===null||i===void 0?void 0:i.dom);l.append(f),l=f,t=0}}return l}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!pS(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ce.ios&&pS(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(s0,0,32)||new uo(s0.toDOM(),0,s0,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){let t=e.rank*102+e.value.rank,i=new NR(e.from,e.to,e.value,t),l=this.wrappers.length;for(;l>0&&(this.wrappers[l-1].rank-i.rank||this.wrappers[l-1].to-i.to)<0;)l--;this.wrappers.splice(l,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let l=t.lastChild;if(i.froma.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(o),t=o}}return t}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),i=this.cache.find(wd,void 0,1);return i&&(i.flags=t),i||new wd(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class AR{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:l,lineBreak:o,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=l;let u=this.textOff=Math.min(e,l.length);return o?null:l.slice(0,u)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const kd=[uo,Ma,to,pi,wd,ul,rm];for(let n=0;n[]),this.index=kd.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let l=e.bucket,o=this.buckets[l],a=this.index[l];for(let u=0;u{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let l=0,o=0,a=0;;){let u=al){let d=f-l;this.preserve(d,!a,!u),l=f,o+=d}if(!u)break;t&&u.fromA<=t.range.fromA&&u.toA>=t.range.toA?(this.forward(u.fromA,t.range.fromA,t.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let d=f>0||u{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof pi&&l.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?l.length&&(l.length=o=0):a instanceof pi&&(l.shift(),o=Math.min(o,l.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,l=this.builder,o=-1,a=lt.spans(this.decorations,e,t,{point:(u,f,d,m,g,b)=>{if(d instanceof co){if(this.disallowBlockEffectsFor[b]){if(d.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=m.length,g>m.length)l.continueWidget(f-u);else{let v=d.widget||(d.block?Da.block:Da.inline),w=DR(d),S=this.cache.findWidget(v,f-u,w)||uo.of(v,this.view,f-u,w);d.block?(d.startSide>0&&l.addLineStartIfNotCovered(i),l.addBlockWidget(S)):(l.ensureLine(i),l.addInlineWidget(S,m,g))}i=null}else i=RR(i,d);f>u&&this.text.skip(f-u)},span:(u,f,d,m)=>{for(let g=u;g-1&&(this.openWidget=a>o),this.openWidget||l.addLineStartIfNotCovered(i),this.openMarks=a}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let l=e.parentNode;;l=l.parentNode){let o=Gt.get(l);if(l==this.view.contentDOM)break;o instanceof pi?t.push(o):o!=null&&o.isLine()?i=o:o instanceof ul||(l.nodeName=="DIV"&&!i?i=new Ma(l,oN):i||t.push(pi.of(new Ru({tagName:l.nodeName.toLowerCase(),attributes:lR(l)}),l)))}return i?{line:i,marks:t}:null}}function pS(n,e){let t=i=>{for(let l of i.children)if((e?l.isText():l.length)||t(l))return!0;return!1};return t(n)}function DR(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const oN={class:"cm-line"};function RR(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&Ty(t,n),i&&(n.class+=" "+i)),n}function jR(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof pi&&e.push(i.mark)}return e}function l0(n){let e=Gt.get(n);return e&&e.setDOM(n.cloneNode()),n}class Da extends gl{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}}Da.inline=new Da("span");Da.block=new Da("div");const s0=new class extends gl{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class gS{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Fe.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 rm(e,e.contentDOM),this.updateInner([new Qi(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:m,toA:g})=>gthis.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 l=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?l=this.domChanged.newSel.head:!FR(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let o=l>-1?LR(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){let{from:m,to:g}=this.hasComposition;i=new Qi(m,g,e.changes.mapPos(m,-1),e.changes.mapPos(g,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Ce.ie||Ce.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,u=this.blockWrappers;this.updateDeco();let f=PR(a,this.decorations,e.changes);f.length&&(i=Qi.extendWithRanges(i,f));let d=IR(u,this.blockWrappers,e.changes);return d.length&&(i=Qi.extendWithRanges(i,d)),o&&!i.some(m=>m.fromA<=o.range.fromA&&m.toA>=o.range.toA)&&(i=o.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let a=this.tile,u=new MR(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Gt.get(t.text)&&u.cache.reused.set(Gt.get(t.text),2),this.tile=u.run(e,t),Cx(a,u.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 o=Ce.chrome||Ce.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||i.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let l=[];if(this.view.viewport.from||this.view.viewport.to-1)&&ru(i,this.view.observer.selectionRange)&&!(l&&i.contains(l));if(!(o||t||a))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,d,m;if(f.empty?m=d=this.inlineDOMNearPos(f.anchor,f.assoc||1):(m=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),d=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Ce.gecko&&f.empty&&!this.hasComposition&&_R(d)){let b=document.createTextNode("");this.view.observer.ignore(()=>d.node.insertBefore(b,d.node.childNodes[d.offset]||null)),d=m=new or(b,0),u=!0}let g=this.view.observer.selectionRange;(u||!g.focusNode||(!lu(d.node,d.offset,g.anchorNode,g.anchorOffset)||!lu(m.node,m.offset,g.focusNode,g.focusOffset))&&!this.suppressWidgetCursorChange(g,f))&&(this.view.observer.ignore(()=>{Ce.android&&Ce.chrome&&i.contains(g.focusNode)&&UR(g.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let b=yu(this.view.root);if(b)if(f.empty){if(Ce.gecko){let v=zR(d.node,d.offset);if(v&&v!=3){let w=(v==1?HO:IO)(d.node,d.offset);w&&(d=new or(w.node,w.offset))}}b.collapse(d.node,d.offset),f.bidiLevel!=null&&b.caretBidiLevel!==void 0&&(b.caretBidiLevel=f.bidiLevel)}else if(b.extend){b.collapse(d.node,d.offset);try{b.extend(m.node,m.offset)}catch{}}else{let v=document.createRange();f.anchor>f.head&&([d,m]=[m,d]),v.setEnd(m.node,m.offset),v.setStart(d.node,d.offset),b.removeAllRanges(),b.addRange(v)}a&&this.view.root.activeElement==i&&(i.blur(),l&&l.focus())}),this.view.observer.setSelectionRange(d,m)),this.impreciseAnchor=d.precise?null:new or(g.anchorNode,g.anchorOffset),this.impreciseHead=m.precise?null:new or(g.focusNode,g.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&lu(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,i=yu(e.root),{anchorNode:l,anchorOffset:o}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let u=a.posAtStart;if(t.head==u||t.head==u+a.length)return;let f=this.coordsAt(t.head,-1),d=this.coordsAt(t.head,1);if(!f||!d||f.bottom>d.top)return;let m=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(m.node,m.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let g=e.observer.selectionRange;e.docView.posFromDOM(g.anchorNode,g.anchorOffset)!=t.from&&i.collapse(l,o)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let l=i.posAtStart;if(i.isComposite()){let o;if(e==i.dom)o=i.dom.childNodes[t];else{let a=hl(e)==0?0:t==0?-1:1;for(;;){let u=e.parentNode;if(u==i.dom)break;a==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?a=-1:a=1),e=u}a<0?o=e:o=e.nextSibling}if(o==i.dom.firstChild)return l;for(;o&&!Gt.get(o);)o=o.nextSibling;if(!o)return l+i.length;for(let a=0,u=l;;a++){let f=i.children[a];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return i.isText()?e==i.dom?l+t:l+(t?i.length:0):l}domAtPos(e,t){let{tile:i,offset:l}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(l,t):i.domIn(l,t)}inlineDOMNearPos(e,t){let i,l=-1,o=!1,a,u=-1,f=!1;return this.tile.blockTiles((d,m)=>{if(d.isWidget()){if(d.flags&32&&m>=e)return!0;d.flags&16&&(o=!0)}else{let g=m+d.length;if(m<=e&&(i=d,l=e-m,o=g=e&&!a&&(a=d,u=e-m,f=m>e),m>e&&a)return!0}}),!i&&!a?this.domAtPos(e,t):(o&&a?i=null:f&&i&&(a=null),i&&t<0||!a?i.domIn(l,t):a.domIn(u,t))}coordsAt(e,t,i){let{tile:l,offset:o}=this.tile.resolveBlock(e,t);return l.isWidget()?l.widget instanceof o0?null:l.coordsInWidget(o,t,!0):l.coordsIn(o,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function l(o,a){if(o.isComposite())for(let u of o.children){if(u.length>=a){let f=l(u,a);if(f)return f}if(a-=u.length,a<0)break}else if(o.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==At.LTR,d=0,m=(g,b,v)=>{for(let w=0;wl);w++){let S=g.children[w],C=b+S.length,N=S.dom.getBoundingClientRect(),{height:j}=N;if(v&&!w&&(d+=N.top-v.top),S instanceof ul)C>i&&m(S,b,N);else if(b>=i&&(d>0&&t.push(-d),t.push(j+d),d=0,a)){let M=S.dom.lastChild,U=M?rd(M):[];if(U.length){let H=U[U.length-1],E=f?H.right-N.left:N.right-H.left;E>u&&(u=E,this.minWidth=o,this.minWidthFrom=b,this.minWidthTo=C)}}v&&w==g.children.length-1&&(d+=v.bottom-N.bottom),b=C+S.breakAfter}};return m(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?At.RTL:At.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let u=0,f;for(let d of a.children){if(!d.isText()||/[^ -~]/.test(d.text))return;let m=rd(d.dom);if(m.length!=1)return;u+=m[0].width,f=m[0].height}if(u)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:u/a.length,textHeight:f}}});if(e)return e;let t=document.createElement("div"),i,l,o;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 a=rd(t.firstChild)[0];i=t.getBoundingClientRect().height,l=a&&a.width?a.width/27:7,o=a&&a.height?a.height:i,t.remove()}),{lineHeight:i,charWidth:l,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,l=0;;l++){let o=l==t.viewports.length?null:t.viewports[l],a=o?o.from-1:this.view.state.doc.length;if(a>i){let u=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Fe.replace({widget:new o0(u),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!o)break;i=o.to+1}return Fe.set(e)}updateDeco(){let e=1,t=this.view.state.facet(nm).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,l=this.view.state.facet(jy).map((o,a)=>{let u=typeof o=="function";return u&&(i=!0),u?o(this.view):o});for(l.length&&(this.dynamicDecorationMap[e++]=i,t.push(lt.join(l))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let d=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=d.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let d of this.view.state.facet(eN))try{if(d(this.view,e.range,e))return!0}catch(m){gi(this.view.state,m,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),l;if(!i)return;!t.empty&&(l=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,l.left),top:Math.min(i.top,l.top),right:Math.max(i.right,l.right),bottom:Math.max(i.bottom,l.bottom)});let o=_y(this.view),a={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(aR(this.view.scrollDOM,a,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Cx(this.tile)}}function Cx(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)Cx(i,e)}}function _R(n){return kn(n.node)&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function aN(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=HO(t.focusNode,t.focusOffset),l=IO(t.focusNode,t.focusOffset),o=i||l;if(l&&i&&l.node!=i.node){let u=Gt.get(l.node);if(!u||u.isText()&&u.text!=l.node.nodeValue)o=l;else if(n.docView.lastCompositionAfterCursor){let f=Gt.get(i.node);!f||f.isText()&&f.text!=i.node.nodeValue||(o=l)}}if(n.docView.lastCompositionAfterCursor=o!=i,!o)return null;let a=e-o.offset;return{from:a,to:a+o.node.nodeValue.length,node:o.node}}function LR(n,e,t){let i=aN(n,t);if(!i)return null;let{node:l,from:o,to:a}=i,u=l.nodeValue;if(/[\n\r]/.test(u)||n.state.doc.sliceString(i.from,i.to)!=u)return null;let f=e.invertedDesc;return{range:new Qi(f.mapPos(o),f.mapPos(a),o,a),text:l}}function zR(n,e){return kn(n)?(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class o0 extends gl{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 qR(n,e,t=1){let i=n.charCategorizer(e),l=n.doc.lineAt(e),o=e-l.from;if(l.length==0)return le.cursor(e);o==0?t=1:o==l.length&&(t=-1);let a=o,u=o;t<0?a=wn(l.text,o,!1):u=wn(l.text,o);let f=i(l.text.slice(a,u));for(;a>0;){let d=wn(l.text,a,!1);if(i(l.text.slice(d,a))!=f)break;a=d}for(;un.defaultLineHeight*1.5){let u=n.viewState.heightOracle.textHeight,f=Math.floor((l-t.top-(n.defaultLineHeight-u)*.5)/u);o+=f*n.viewState.heightOracle.lineLength}let a=n.state.sliceDoc(t.from,t.to);return t.from+hx(a,o,n.state.tabSize)}function Ox(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let l;for(let o of i.type){if(o.from>e)break;if(!(o.toe)return o;(!l||o.type==Bn.Text&&(l.type!=o.type||(t<0?o.frome)))&&(l=o)}}return l||i}return i}function QR(n,e,t,i){let l=Ox(n,e.head,e.assoc||-1),o=!i||l.type!=Bn.Text||!(n.lineWrapping||l.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>l.from?e.head-1:e.head);if(o){let a=n.dom.getBoundingClientRect(),u=n.textDirectionAt(l.from),f=n.posAndSideAtCoords({x:t==(u==At.LTR)?a.right-1:a.left+1,y:(o.top+o.bottom)/2});if(f)return le.cursor(f.pos,f.assoc)}return le.cursor(t?l.to:l.from,t?1:-1)}function xS(n,e,t,i){let l=n.state.doc.lineAt(e.head),o=n.bidiSpans(l),a=n.textDirectionAt(l.from);for(let u=e,f=null;;){let d=bR(l,o,a,u,t),m=QO;if(!d){if(l.number==(t?n.state.doc.lines:1))return u;m=` -`,l=n.state.doc.line(l.number+(t?1:-1)),o=n.bidiSpans(l),d=t?le.cursor(l.from,-1):le.cursor(l.to,1)}if(f){if(!f(m))return u}else{if(!i)return d;f=i(m)}u=d}}function XR(n,e,t){let i=n.state.charCategorizer(e),l=i(t);return o=>{let a=i(o);return l==Ut.Space&&(l=a),l==a}}function $R(n,e,t,i){let l=e.head,o=t?1:-1;if(l==(t?n.state.doc.length:0))return le.cursor(l,e.assoc);let a=e.goalColumn,u,f=n.contentDOM.getBoundingClientRect(),d=n.coordsAtPos(l,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),m=n.documentTop;if(d)a==null&&(a=d.left-f.left),u=o<0?d.top:d.bottom;else{let w=n.viewState.lineBlockAt(l);a==null&&(a=Math.min(f.right-f.left,n.defaultCharacterWidth*(l-w.from))),u=(o<0?w.top:w.bottom)+m}let g=f.left+a,b=n.viewState.heightOracle.textHeight>>1,v=i??b;for(let w=0;;w+=b){let S=u+(v+w)*o,C=Nx(n,{x:g,y:S},!1,o);if(t?S>f.bottom:Su:j{if(e>o&&el(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:le.cursor(i,in.viewState.docHeight)return new jr(n.state.doc.length,-1);if(d=n.elementAtHeight(f),i==null)break;if(d.type==Bn.Text){if(i<0?d.ton.viewport.to)break;let b=n.docView.coordsAt(i<0?d.from:d.to,i>0?-1:1);if(b&&(i<0?b.top<=f+o:b.bottom>=f+o))break}let g=n.viewState.heightOracle.textHeight/2;f=i>0?d.bottom+g:d.top-g}if(n.viewport.from>=d.to||n.viewport.to<=d.from){if(t)return null;if(d.type==Bn.Text){let g=VR(n,l,d,a,u);return new jr(g,g==d.from?1:-1)}}if(d.type!=Bn.Text)return f<(d.top+d.bottom)/2?new jr(d.from,1):new jr(d.to,-1);let m=n.docView.lineAt(d.from,2);return(!m||m.length!=d.length)&&(m=n.docView.lineAt(d.from,-2)),new YR(n,a,u,n.textDirectionAt(d.from)).scanTile(m,d.from)}class YR{constructor(e,t,i,l){this.view=e,this.x=t,this.y=i,this.baseDir=l,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+l.from>1;t:if(a.has(S)){for(let j=1;j=o&&(M-=w),!a.has(M)){S=M;break t}}break e}a.add(S);let C=t(S),N=0;if(C)for(let j=0;j1))if(M.bottomthis.y)(!d||d.top>M.top)&&(d=M),N=-1;else{let U=M.left>this.x?this.x-M.left:M.right(w+w+S)/3)return this.y=f.bottom-1,this.scan(e,t,!0);if(d&&d.top<(w+S+S)/3)return this.y=d.top+1,this.scan(e,t,!0)}let v=(u?this.dirAt(e[m],1):this.baseDir)==At.LTR;return{i:m,after:this.x>(b.left+b.right)/2==v}}scanText(e,t){let i=[];for(let o=0;o{let a=i[o]-t,u=i[o+1]-t;return bu(e.dom,a,u).getClientRects()});return l.after?new jr(i[l.i+1],-1):new jr(i[l.i],1)}scanTile(e,t){if(!e.length)return new jr(t,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,t);if(u.isComposite())return this.scanTile(u,t)}let i=[t];for(let u=0,f=t;u{let f=e.children[u];return f.flags&48?null:(kn(f.dom)?f.dom:bu(f.dom,0,f.length)).getClientRects()}),o=e.children[l.i],a=i[l.i];return o.isText()?this.scanText(o,a):o.isComposite()?this.scanTile(o,a):l.after?new jr(i[l.i+1],-1):new jr(a,1)}}const sa="￿";class GR{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(gt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=sa}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let l=e;;){this.findPointBefore(i,l);let o=this.text.length;this.readNode(l);let a=Gt.get(l),u=l.nextSibling;if(u==t){a!=null&&a.breakAfter&&!u&&i!=this.view.contentDOM&&this.lineBreak();break}let f=Gt.get(u);(a&&f?a.breakAfter:(a?a.breakAfter:yd(l))||yd(u)&&(l.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>o)&&!WR(u,t)&&this.lineBreak(),l=u}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,l=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,a=1,u;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(u=l.exec(t))&&(o=u.index,a=u[0].length),this.append(t.slice(i,o<0?t.length:o)),o<0)break;if(this.lineBreak(),a>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=a-1);i=o+a}}readNode(e){let t=Gt.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let l=i.iter();!l.next().done;)l.lineBreak?this.lineBreak():this.append(l.value)}else Aa(e)?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():kn(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(Aa(e)?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(KR(e,i.node,i.offset)?t:0))}}function KR(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:o,impreciseAnchor:a}=e.docView,u=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=uN(e.docView.tile,t,i,0))){let f=o||a?[]:ej(e),d=new GR(f,e);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=tj(f,this.bounds.from)}else{let f=e.observer.selectionRange,d=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!bx(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),m=a&&a.node==f.anchorNode&&a.offset==f.anchorOffset||!bx(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),g=e.viewport;if((Ce.ios||Ce.chrome)&&d!=m&&Math.min(d,m)<=u.main.from&&Math.max(d,m)>=u.main.to&&(g.from>0||g.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(le.range(m,d));else if(e.lineWrapping&&m==d&&!(u.main.empty&&u.main.head==d)&&e.inputState.lastTouchTime>Date.now()-100){let b=e.coordsAtPos(d,-1),v=0;b&&(v=e.inputState.lastTouchY<=b.bottom?-1:1),this.newSel=le.create([le.cursor(d,v)])}else this.newSel=le.single(m,d)}}}function uN(n,e,t,i){if(n.isComposite()){let l=-1,o=-1,a=-1,u=-1;for(let f=0,d=i,m=i;ft)return uN(g,e,t,d);if(b>=e&&l==-1&&(l=f,o=d),d>t&&g.dom.parentNode==n.dom){a=f,u=m;break}m=b,d=b+g.breakAfter}return{from:o,to:u<0?i+n.length:u,startDOM:(l?n.children[l-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:a=0?n.children[a].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function fN(n,e){let t,{newSel:i}=e,{state:l}=n,o=l.selection.main,a=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,d=o.from,m=null;(a===8||Ce.android&&e.text.length=u&&o.to<=f&&(e.typeOver||g!=e.text)&&g.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&g.slice(o.to-u)==e.text.slice(b=e.text.length-(g.length-(o.to-u)))?t={from:o.from,to:o.to,insert:pt.of(e.text.slice(o.from-u,b).split(sa))}:(v=hN(g,e.text,d-u,m))&&(Ce.chrome&&a==13&&v.toB==v.from+2&&e.text.slice(v.from,v.toB)==sa+sa&&v.toB--,t={from:u+v.from,to:u+v.toA,insert:pt.of(e.text.slice(v.from,v.toB).split(sa))})}else i&&(!n.hasFocus&&l.facet(cl)||Tx(i,o))&&(i=null);if(!t&&!i)return!1;if((Ce.mac||Ce.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=le.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:pt.of([t.insert.toString().replace("."," ")])}):l.doc.lineAt(o.from).toDate.now()-50?t={from:o.from,to:o.to,insert:l.toText(n.inputState.insertingText)}:Ce.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==` - `&&n.lineWrapping&&(i&&(i=le.single(i.main.anchor-1,i.main.head-1)),t={from:o.from,to:o.to,insert:pt.of([" "])}),t)return Ly(n,t,i,a);if(i&&!Tx(i,o)){let u=!1,f="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(u=!0),f=n.inputState.lastSelectionOrigin,f=="select.pointer"&&(i=cN(l.facet(_u).map(d=>d(n)),i))),n.dispatch({selection:i,scrollIntoView:u,userEvent:f}),!0}else return!1}function Ly(n,e,t,i=-1){if(Ce.ios&&n.inputState.flushIOSKey(e))return!0;let l=n.state.selection.main;if(Ce.android&&(e.to==l.to&&(e.from==l.from||e.from==l.from-1&&n.state.sliceDoc(e.from,l.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&va(n.contentDOM,"Enter",13)||(e.from==l.from-1&&e.to==l.to&&e.insert.length==0||i==8&&e.insert.lengthl.head)&&va(n.contentDOM,"Backspace",8)||e.from==l.from&&e.to==l.to+1&&e.insert.length==0&&va(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let a,u=()=>a||(a=JR(n,e,t));return n.state.facet(KO).some(f=>f(n,e.from,e.to,o,u))||n.dispatch(u()),!0}function JR(n,e,t){let i,l=n.state,o=l.selection.main,a=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromg(n)),d,f);e.from==m&&(a=m)}if(a>-1)i={changes:e,selection:le.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let f=o.frome.to?l.sliceDoc(e.to,o.to):"";i=l.replaceSelection(n.state.toText(f+e.insert.sliceString(0,void 0,n.state.lineBreak)+d))}else{let f=l.changes(e),d=t&&t.main.to<=f.newLength?t.main:void 0;if(l.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let m=n.state.sliceDoc(e.from,e.to),g,b=t&&aN(n,t.main.head);if(b){let w=e.insert.length-(e.to-e.from);g={from:b.from,to:b.to-w}}else g=n.state.doc.lineAt(o.head);let v=o.to-e.to;i=l.changeByRange(w=>{if(w.from==o.from&&w.to==o.to)return{changes:f,range:d||w.map(f)};let S=w.to-v,C=S-m.length;if(n.state.sliceDoc(C,S)!=m||S>=g.from&&C<=g.to)return{range:w};let N=l.changes({from:C,to:S,insert:e.insert}),j=w.to-o.to;return{changes:N,range:d?le.range(Math.max(0,d.anchor+j),Math.max(0,d.head+j)):w.map(N)}})}else i={changes:f,selection:d&&l.selection.replaceRange(d)}}let u="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,u+=".compose",n.inputState.compositionFirstChange&&(u+=".start",n.inputState.compositionFirstChange=!1)),l.update(i,{userEvent:u,scrollIntoView:!0})}function hN(n,e,t,i){let l=Math.min(n.length,e.length),o=0;for(;o0&&u>0&&n.charCodeAt(a-1)==e.charCodeAt(u-1);)a--,u--;if(i=="end"){let f=Math.max(0,o-Math.min(a,u));t-=a+f-o}if(a=a?o-t:0;o-=f,u=o+(u-a),a=o}else if(u=u?o-t:0;o-=f,a=o+(a-u),u=o}return{from:o,toA:a,toB:u}}function ej(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new yS(t,i)),(l!=t||o!=i)&&e.push(new yS(l,o))),e}function tj(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t<0||i<0?null:t==i?le.create([le.cursor(i+e,-1)]):le.single(t+e,i+e)}function Tx(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class nj{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,Ce.safari&&e.contentDOM.addEventListener("input",()=>null),Ce.gecko&&yj(e.contentDOM.ownerDocument)}handleEvent(e){!fj(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let l of i.observers)l(this.view,t);for(let l of i.handlers){if(t.defaultPrevented)break;if(l(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=rj(e),i=this.handlers,l=this.view.contentDOM;for(let o in t)if(o!="scroll"){let a=!t[o].handlers.length,u=i[o];u&&a!=!u.handlers.length&&(l.removeEventListener(o,this.handleEvent),u=null),u||l.addEventListener(o,this.handleEvent,{passive:a})}for(let o in i)o!="scroll"&&!t[o]&&l.removeEventListener(o,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&&mN.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ce.android&&Ce.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Ce.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(dN.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||lj.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&Ce.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&ij(this.view.win)&&(t.shiftKey=!1);let i=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==i&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from0?!0:Ce.safari&&!Ce.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 ij(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function bS(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(l){gi(t.state,l)}}}function rj(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let l=i.spec,o=l&&l.plugin.domEventHandlers,a=l&&l.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&t(u).handlers.push(bS(i.value,f))}if(a)for(let u in a){let f=a[u];f&&t(u).observers.push(bS(i.value,f))}}for(let i in fr)t(i).handlers.push(fr[i]);for(let i in ri)t(i).observers.push(ri[i]);return e}const dN=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lj="dthko",mN=[16,17,18,20,91,92,224,225],Sh=6;function Ch(n){return Math.max(0,n)*.7+8}function sj(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class oj{constructor(e,t,i,l){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=l,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=_O(e.contentDOM),this.atoms=e.state.facet(_u).map(a=>a(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(gt.allowMultipleSelections)&&aj(e,t),this.dragging=uj(e,t)&&xN(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&&sj(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,l=0,o=0,a=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=_y(this.view);e.clientX-f.left<=l+Sh?t=-Ch(l-e.clientX):e.clientX+f.right>=a-Sh&&(t=Ch(e.clientX-a)),e.clientY-f.top<=o+Sh?i=-Ch(o-e.clientY):e.clientY+f.bottom>=u-Sh&&(i=Ch(e.clientY-u)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&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,i=cN(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function aj(n,e){let t=n.state.facet(XO);return t.length?t[0](e):Ce.mac?e.metaKey:e.ctrlKey}function cj(n,e){let t=n.state.facet($O);return t.length?t[0](e):Ce.mac?!e.altKey:!e.ctrlKey}function uj(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=yu(n.root);if(!i||i.rangeCount==0)return!0;let l=i.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function fj(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Gt.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const fr=Object.create(null),ri=Object.create(null),pN=Ce.ie&&Ce.ie_version<15||Ce.ios&&Ce.webkit_version<604;function hj(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),gN(n,t.value)},50)}function lm(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function gN(n,e){e=lm(n.state,My,e);let{state:t}=n,i,l=1,o=t.toText(e),a=o.lines==t.selection.ranges.length;if(Ax!=null&&t.selection.ranges.every(f=>f.empty)&&Ax==o.toString()){let f=-1;i=t.changeByRange(d=>{let m=t.doc.lineAt(d.from);if(m.from==f)return{range:d};f=m.from;let g=t.toText((a?o.line(l++).text:e)+t.lineBreak);return{changes:{from:m.from,insert:g},range:le.cursor(d.from+g.length,-1)}})}else a?i=t.changeByRange(f=>{let d=o.line(l++);return{changes:{from:f.from,to:f.to,insert:d.text},range:le.cursor(f.from+d.length,-1)}}):i=t.replaceSelection(o);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ri.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,Ce.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};ri.wheel=ri.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};fr.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);ri.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};ri.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};ri.touchend=(n,e)=>{n.inputState.touchActive=!1};fr.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(YO))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=mj(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new oj(n,e,t,i)),i&&n.observer.ignore(()=>{BO(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let l=n.inputState.mouseSelection;if(l)return l.start(e),l.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function vS(n,e,t,i){if(i==1)return le.cursor(e,t);if(i==2)return qR(n.state,e,t);{let l=n.docView.lineAt(e,t),o=n.state.doc.lineAt(l?l.posAtEnd:e),a=l?l.posAtStart:o.from,u=l?l.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(kS+1)%3:1}function mj(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=xN(e),l=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),l=l.map(o.changes))},get(o,a,u){let f=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),d,m=vS(n,f.pos,f.assoc,i);if(t.pos!=f.pos&&!a){let g=vS(n,t.pos,t.assoc,i),b=Math.min(g.from,m.from),v=Math.max(g.to,m.to);m=b1&&(d=pj(l,f.pos))?d:u?l.addRange(m):le.create([m])}}}function pj(n,e){for(let t=0;t=e)return le.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}fr.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let l=n.docView.tile.nearest(e.target);if(l&&l.isWidget()){let o=l.posAtStart,a=o+l.length;(o>=t.to||a<=t.from)&&(t=le.undirectionalRange(o,a))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",lm(n.state,Dy,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};fr.dragend=n=>(n.inputState.draggedContent=null,!1);function CS(n,e,t,i){if(t=lm(n.state,My,t),!t)return;let l=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,a=i&&o&&cj(n,e)?{from:o.from,to:o.to}:null,u={from:l,insert:t},f=n.state.changes(a?[a,u]:u);n.focus(),n.dispatch({changes:f,selection:{anchor:f.mapPos(l,-1),head:f.mapPos(l,1)},userEvent:a?"move.drop":"input.drop"}),n.inputState.draggedContent=null}fr.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),l=0,o=()=>{++l==t.length&&CS(n,e,i.filter(a=>a!=null).join(n.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(i[a]=u.result),o()},u.readAsText(t[a])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return CS(n,e,i,!0),!0}return!1};fr.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=pN?null:e.clipboardData;return t?(gN(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(hj(n),!1)};function gj(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function xj(n){let e=[],t=[],i=!1;for(let l of n.selection.ranges)l.empty||(e.push(n.sliceDoc(l.from,l.to)),t.push(l));if(!e.length){let l=-1;for(let{from:o}of n.selection.ranges){let a=n.doc.lineAt(o);a.number>l&&(e.push(a.text),t.push({from:a.from,to:Math.min(n.doc.length,a.to+1)})),l=a.number}i=!0}return{text:lm(n,Dy,e.join(n.lineBreak)),ranges:t,linewise:i}}let Ax=null;fr.copy=fr.cut=(n,e)=>{if(!ru(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:l}=xj(n.state);if(!t&&!l)return!1;Ax=l?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=pN?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(gj(n,t),!1)};const yN=pl.define();function bN(n,e){let t=[];for(let i of n.facet(WO)){let l=i(n,e);l&&t.push(l)}return t.length?n.update({effects:t,annotations:yN.of(!0)}):null}function vN(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=bN(n.state,e);t?n.dispatch(t):n.update([])}},10)}ri.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),vN(n)};ri.blur=n=>{n.observer.clearSelectionRange(),vN(n)};ri.compositionstart=ri.compositionupdate=(n,e)=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:t}=n.state.selection;!t.empty&&n.lineBlockAt(t.from).from!=n.lineBlockAt(t.to).from&&!n.state.readOnly&&n.dispatch({changes:n.state.selection.ranges.filter(i=>!i.empty).map(i=>({from:i.from,to:i.to})),userEvent:"input"}),n.inputState.composing=0}};ri.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,Ce.chrome&&Ce.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};ri.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};fr.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(o&&a.length){let u=a[0],f=n.posAtDOM(u.startContainer,u.startOffset),d=n.posAtDOM(u.endContainer,u.endOffset);return Ly(n,{from:f,to:d,insert:n.state.toText(o)},null),!0}}let l;if(Ce.chrome&&Ce.android&&(l=dN.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(l.key,l.keyCode),l.key=="Backspace"||l.key=="Delete")){let o=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return Ce.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),Ce.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>ri.compositionend(n,e),20),!1};const OS=new Set;function yj(n){OS.has(n)||(OS.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const NS=["pre-wrap","normal","pre-line","break-spaces"];let Ra=!1;function TS(){Ra=!1}class bj{constructor(e){this.lineWrapping=e,this.doc=pt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}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 NS.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,f=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=t,this.charWidth=i,this.textHeight=l,this.lineLength=o,f){this.heightSamples={};for(let d=0;d0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ld&&(Ra=!0),this.height=e)}replace(e,t,i){return ii.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,l){let o=this,a=i.doc;for(let u=l.length-1;u>=0;u--){let{fromA:f,toA:d,fromB:m,toB:g}=l[u],b=o.lineAt(f,Pt.ByPosNoHeight,i.setDoc(t),0,0),v=b.to>=d?b:o.lineAt(d,Pt.ByPosNoHeight,i,0,0);for(g+=v.to-d,d=v.to;u>0&&b.from<=l[u-1].toA;)f=l[u-1].fromA,m=l[u-1].fromB,u--,fo*2){let u=e[t-1];u.break?e.splice(--t,1,u.left,null,u.right):e.splice(--t,1,u.left,u.right),i+=1+u.break,l-=u.size}else if(o>l*2){let u=e[i];u.break?e.splice(i,1,u.left,null,u.right):e.splice(i,1,u.left,u.right),i+=2+u.break,o-=u.size}else break;else if(l=o&&a(this.lineAt(0,Pt.ByPos,i,l,o))}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,i=!1,l){return l&&l.from<=t&&l.more&&this.setMeasuredHeight(l),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Ri extends wN{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new sr(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let l=i[0];return i.length==1&&(l instanceof Ri||l instanceof jn&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof jn?l=new Ri(l.length,this.height,this.spaceAbove):l.height=this.height,this.outdated||(l.outdated=!1),l):ii.of(i)}updateHeight(e,t=0,i=!1,l){return l&&l.from<=t&&l.more?this.setMeasuredHeight(l):(i||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:""})`}}class jn extends ii{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,l=e.doc.lineAt(t+this.length).number,o=l-i+1,a,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);a=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else a=this.height/o;return{firstLine:i,lastLine:l,perLine:a,perChar:u}}blockAt(e,t,i,l){let{firstLine:o,lastLine:a,perLine:u,perChar:f}=this.heightMetrics(t,l);if(t.lineWrapping){let d=l+(e0){let o=i[i.length-1];o instanceof jn?i[i.length-1]=new jn(o.length+l):i.push(null,new jn(l-1))}if(e>0){let o=i[0];o instanceof jn?i[0]=new jn(e+o.length):i.unshift(new jn(e-1),null)}return ii.of(i)}decomposeLeft(e,t){t.push(new jn(e-1),null)}decomposeRight(e,t){t.push(null,new jn(this.length-e-1))}updateHeight(e,t=0,i=!1,l){let o=t+this.length;if(l&&l.from<=t+this.length&&l.more){let a=[],u=Math.max(t,l.from),f=-1;for(l.from>t&&a.push(new jn(l.from-t-1).updateHeight(e,t));u<=o&&l.more;){let m=e.doc.lineAt(u).length;a.length&&a.push(null);let g=l.heights[l.index++],b=0;g<0&&(b=-g,g=l.heights[l.index++]),f==-1?f=g:Math.abs(g-f)>=ld&&(f=-2);let v=new Ri(m,g,b);v.outdated=!1,a.push(v),u+=m+1}u<=o&&a.push(null,new jn(o-u).updateHeight(e,u));let d=ii.of(a);return(f<0||Math.abs(d.height-this.height)>=ld||Math.abs(f-this.heightMetrics(e,t).perLine)>=ld)&&(Ra=!0),Sd(this,d)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class kj extends ii{constructor(e,t,i){super(e.length+(t?1:0)+i.length,e.height+i.height,(t?1:0)|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,l){let o=i+this.left.height;return eu))return d;let m=t==Pt.ByPosNoHeight?Pt.ByPosNoHeight:Pt.ByPos;return f?d.join(this.right.lineAt(u,m,i,a,u)):this.left.lineAt(u,m,i,l,o).join(d)}forEachLine(e,t,i,l,o,a){let u=l+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,t,i,u,f,a);else{let d=this.lineAt(f,Pt.ByPos,i,l,o);e=e&&d.from<=t&&a(d),t>d.to&&this.right.forEachLine(Math.max(e,d.to+1),t,i,u,f,a)}}replace(e,t,i){let l=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-l,t-l,i));let o=[];e>0&&this.decomposeLeft(e,o);let a=o.length;for(let u of i)o.push(u);if(e>0&&AS(o,a-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,l=i+this.break;if(e>=l)return this.right.decomposeRight(e-l,t);e2*t.size||t.size>2*e.size?ii.of(this.break?[e,null,t]:[e,t]):(this.left=Sd(this.left,e),this.right=Sd(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,i=!1,l){let{left:o,right:a}=this,u=t+o.length+this.break,f=null;return l&&l.from<=t+o.length&&l.more?f=o=o.updateHeight(e,t,i,l):o.updateHeight(e,t,i),l&&l.from<=u+a.length&&l.more?f=a=a.updateHeight(e,u,i,l):a.updateHeight(e,u,i),f?this.balanced(o,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function AS(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof jn&&(i=n[e+1])instanceof jn&&n.splice(e-1,3,new jn(t.length+1+i.length))}const Sj=5;class zy{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 i=Math.min(t,this.lineEnd),l=this.nodes[this.nodes.length-1];l instanceof Ri?l.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new Ri(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Sj)&&this.addLineDeco(l,o,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Ri(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new jn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Ri)return e;let t=new Ri(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=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let l=this.ensureLine();l.length+=i,l.collapsed+=i,l.widgetHeight=Math.max(l.widgetHeight,e),l.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Ri)&&!this.isCovered?this.nodes.push(new Ri(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&m.overflow!="visible"){let g=d.getBoundingClientRect();o=Math.max(o,g.left),a=Math.min(a,g.right),u=Math.max(u,g.top),f=Math.min(d==n.parentNode?l.innerHeight:f,g.bottom)}d=m.position=="absolute"||m.position=="fixed"?d.offsetParent:d.parentNode}else if(d.nodeType==11)d=d.host;else break;return{left:o-t.left,right:Math.max(o,a)-t.left,top:u-(t.top+e),bottom:Math.max(u,f)-(t.top+e)}}function Tj(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function Aj(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class c0{constructor(e,t,i,l){this.from=e,this.to=t,this.size=i,this.displaySize=l}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof l!="function"&&l.class=="cm-lineWrapping");this.heightOracle=new bj(i),this.stateDeco=MS(t),this.heightMap=ii.empty().applyChanges(this.stateDeco,pt.empty,this.heightOracle.setDoc(t.doc),[new Qi(0,0,0,t.doc.length)]);for(let l=0;l<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());l++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Fe.set(this.lineGaps.map(l=>l.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let l=i?t.head:t.anchor;if(!e.some(({from:o,to:a})=>l>=o&&l<=a)){let{from:o,to:a}=this.lineBlockAt(l);e.push(new Oh(o,a))}}return this.viewports=e.sort((i,l)=>i.from-l.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ex:Cd.get(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(Jc(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=MS(this.state);let l=e.changedRanges,o=Qi.extendWithRanges(l,Cj(i,this.stateDeco,e?e.changes:mn.empty(this.state.doc.length))),a=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);TS(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=a||Ra)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,t));let d=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(d||!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(JO)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),l=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?At.RTL:At.LTR;let a=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=t.getBoundingClientRect(),f=a||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let d=0,m=0;if(u.width&&u.height){let{scaleX:H,scaleY:E}=jO(t,u);(H>.005&&Math.abs(this.scaleX-H)>.005||E>.005&&Math.abs(this.scaleY-E)>.005)&&(this.scaleX=H,this.scaleY=E,d|=16,a=f=!0)}let g=(parseInt(i.paddingTop)||0)*this.scaleY,b=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=g||this.paddingBottom!=b)&&(this.paddingTop=g,this.paddingBottom=b,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(l.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let v=_O(this.view.contentDOM,!1).y;v!=this.scrollParent&&(this.scrollParent=v,this.scrollAnchorHeight=-1,this.scrollOffset=0);let w=this.getScrollOffset();this.scrollOffset!=w&&(this.scrollAnchorHeight=-1,this.scrollOffset=w),this.scrolledToBottom=PO(this.scrollParent||e.win);let S=(this.printing?Aj:Nj)(t,this.paddingTop),C=S.top-this.pixelViewport.top,N=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let j=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(j!=this.inView&&(this.inView=j,j&&(f=!0)),!this.inView&&!this.scrollTarget&&!Tj(e.dom))return 0;let M=u.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),f){let H=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(H)&&(a=!0),a||l.lineWrapping&&Math.abs(M-this.contentDOMWidth)>l.charWidth){let{lineHeight:E,charWidth:D,textHeight:I}=e.docView.measureTextSize();a=E>0&&l.refresh(o,E,D,I,Math.max(5,M/D),H),a&&(e.docView.minWidth=0,d|=16)}C>0&&N>0?m=Math.max(C,N):C<0&&N<0&&(m=Math.min(C,N)),TS();for(let E of this.viewports){let D=E.from==this.viewport.from?H:e.docView.measureVisibleLineHeights(E);this.heightMap=(a?ii.empty().applyChanges(this.stateDeco,pt.empty,this.heightOracle,[new Qi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,a,new vj(E.from,D))}Ra&&(d|=2)}let U=!this.viewportIsAppropriate(this.viewport,m)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return U&&(d&2&&(d|=this.updateScaler()),this.viewport=this.getViewport(m,this.scrollTarget),d|=this.updateForViewport()),(d&2||U)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),l=this.heightMap,o=this.heightOracle,{visibleTop:a,visibleBottom:u}=this,f=new Oh(l.lineAt(a-i*1e3,Pt.ByHeight,o,0,0).from,l.lineAt(u+(1-i)*1e3,Pt.ByHeight,o,0,0).to);if(t){let{head:d}=t.range;if(df.to){let m=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),g=l.lineAt(d,Pt.ByPos,o,0,0),b;t.y=="center"?b=(g.top+g.bottom)/2-m/2:t.y=="start"||t.y=="nearest"&&d=u+Math.max(10,Math.min(i,250)))&&l>a-2*1e3&&o>1,a=l<<1;if(this.defaultTextDirection!=At.LTR&&!i)return[];let u=[],f=(m,g,b,v)=>{if(g-mm&&NN.from>=b.from&&N.to<=b.to&&Math.abs(N.from-m)N.fromj));if(!C){if(gM.from<=g&&M.to>=g)){let M=t.moveToLineBoundary(le.cursor(g),!1,!0).head;M>m&&(g=M)}let N=this.gapSize(b,m,g,v),j=i||N<2e6?N:2e6;C=new c0(m,g,N,j)}u.push(C)},d=m=>{if(m.length2e6)for(let E of e)E.from>=m.from&&E.fromm.from&&f(m.from,v,m,g),wt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];lt.spans(t,this.viewport.from,this.viewport.to,{span(o,a){i.push({from:o,to:a})},point(){}},20);let l=0;if(i.length!=this.visibleRanges.length)l=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Jc(this.heightMap.lineAt(e,Pt.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)||Jc(this.heightMap.lineAt(this.scaler.fromDOM(e),Pt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Jc(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}}class Oh{constructor(e,t){this.from=e,this.to=t}}function Mj(n,e,t){let i=[],l=n,o=0;return lt.spans(t,n,e,{span(){},point(a,u){a>l&&(i.push({from:l,to:a}),o+=a-l),l=u}},20),l=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let l=0;;l++){let{from:o,to:a}=e[l],u=a-o;if(i<=u)return o+i;i-=u}}function Th(n,e){let t=0;for(let{from:i,to:l}of n.ranges){if(e<=l){t+=e-i;break}t+=l-i}return t/n.total}function Dj(n,e){for(let t of n)if(e(t))return t}const Ex={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function MS(n){let e=n.facet(nm).filter(i=>typeof i!="function"),t=n.facet(jy).filter(i=>typeof i!="function");return t.length&&e.push(lt.join(t)),e}class Cd{constructor(e,t){this.scale=e,this.viewports=t}static get(e,t,i){let l=0,o=0,a=0,u=i.map(({from:d,to:m})=>{let g=t.lineAt(d,Pt.ByPos,e,0,0).top,b=t.lineAt(m,Pt.ByPos,e,0,0).bottom;return l+=b-g,{from:d,to:m,top:g,bottom:b,domTop:0,domBottom:0}});if(t.height-l<10)return Ex;let f=(7e6-l)/(t.height-l);for(let d of u)d.domTop=a+(d.top-o)*f,a=d.domBottom=d.domTop+(d.bottom-d.top),o=d.bottom;return new Cd(f,u)}toDOM(e){for(let t=0,i=0,l=0;;t++){let o=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function Jc(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new sr(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(l=>Jc(l,e)):n._content)}const Ah=Ne.define({combine:n=>n.join(" ")}),Mx=Ne.define({combine:n=>n.indexOf(!0)>-1}),Dx=as.newName(),kN=as.newName(),SN=as.newName(),CN={"&light":"."+kN,"&dark":"."+SN};function Rx(n,e,t){return new as(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,l=>{if(l=="&")return n;if(!t||!t[l])throw new RangeError(`Unsupported selector: ${l}`);return t[l]}):n+" "+i}})}const Rj=Rx("."+Dx,{"&":{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:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},CN),jj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},u0=Ce.ie&&Ce.ie_version<=11;class _j{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new cR,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 i of t)this.queue.push(i);(Ce.ie&&Ce.ie_version<=11||Ce.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Ce.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ce.chrome&&Ce.chrome_version<126)&&(this.editContext=new zj(e),e.state.facet(cl)&&(e.contentDOM.editContext=this.editContext.editContext)),u0&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.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(t=>{t.length>0&&t[t.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(this.pendingRecords().length>0),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,i)=>t!=e[i]))){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:i}=this,l=this.selectionRange;if(i.state.facet(cl)?i.root.activeElement!=this.dom:!ru(this.dom,l))return;let o=l.anchorNode&&i.docView.tile.nearest(l.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Ce.ie&&Ce.ie_version<=11||Ce.android&&Ce.chrome)&&!i.state.selection.main.empty&&l.focusNode&&lu(l.focusNode,l.focusOffset,l.anchorNode,l.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=yu(e.root);if(!t)return!1;let i=Ce.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Lj(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let l=ru(this.dom,i);return l&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&va(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(l)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{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,i=-1,l=!1;for(let o of e){let a=this.readMutation(o);a&&(a.typeOver&&(l=!0),t==-1?{from:t,to:i}=a:(t=Math.min(a.from,t),i=Math.max(a.to,i)))}return{from:t,to:i,typeOver:l}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),l=this.selectionChanged&&ru(this.dom,this.selectionRange);if(e<0&&!l)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new ZR(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let l=this.view.state,o=fN(this.view,i);return this.view.state==l&&(i.domChanged||t)&&this.view.update([]),o}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 i=DS(t,e.previousSibling||e.target.previousSibling,-1),l=DS(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:l?t.posBefore(l):t.posAtEnd,typeOver:!1}}else 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(cl)!=e.state.facet(cl)&&(e.view.contentDOM.editContext=e.state.facet(cl)?this.editContext.editContext:null))}destroy(){var e,t,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let l of this.scrollTargets)l.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 DS(n,e,t){for(;e;){let i=Gt.get(e);if(i&&i.parent==n)return i;let l=e.parentNode;e=l!=n.dom?l:t>0?e.nextSibling:e.previousSibling}return null}function RS(n,e){let t=e.startContainer,i=e.startOffset,l=e.endContainer,o=e.endOffset,a=n.docView.domAtPos(n.state.selection.main.anchor,1);return lu(a.node,a.offset,l,o)&&([t,i,l,o]=[l,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}}function Lj(n,e){if(e.getComposedRanges){let l=e.getComposedRanges(n.root)[0];if(l)return RS(n,l)}let t=null;function i(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?RS(n,t):null}class zj{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=i=>{let l=e.state.selection.main,{anchor:o,head:a}=l,u=this.toEditorPos(i.updateRangeStart),f=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:u,drifted:!1});let d=f-u>i.text.length;u==this.from&&othis.to&&(f=o);let m=hN(e.state.sliceDoc(u,f),i.text,(d?l.from:l.to)-u,d?"end":null);if(!m){let b=le.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));Tx(b,l)||e.dispatch({selection:b,userEvent:"select"});return}let g={from:m.from+u,to:m.toA+u,insert:pt.of(i.text.slice(m.from,m.toB).split(` -`))};if((Ce.mac||Ce.android)&&g.from==a-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(g={from:u,to:f,insert:pt.of([i.text.replace("."," ")])}),this.pendingContextChange=g,!e.state.readOnly){let b=this.to-this.from+(g.to-g.from+g.insert.length);Ly(e,g,le.single(this.toEditorPos(i.selectionStart,b),this.toEditorPos(i.selectionEnd,b)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),g.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let l=[],o=null;for(let a=this.toEditorPos(i.rangeStart),u=this.toEditorPos(i.rangeEnd);a{let l=[];for(let o of i.getTextFormats()){let a=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),d=this.toEditorPos(o.rangeEnd);if(f{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:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let l=yu(i.root);l&&l.rangeCount&&this.editContext.updateSelectionBounds(l.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,l=this.pendingContextChange;return e.changes.iterChanges((o,a,u,f,d)=>{if(i)return;let m=d.length-(a-o);if(l&&a>=l.to)if(l.from==o&&l.to==a&&l.insert.eq(d)){l=this.pendingContextChange=null,t+=m,this.to+=m;return}else l=null,this.revertPending(e.state);if(o+=t,a+=t,a<=this.from)this.from+=m,this.to+=m;else if(othis.to||this.to-this.from+d.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(a),d.toString()),this.to+=m}t+=m}),l&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(l=>!l.isUserEvent("input.type")&&l.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,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),l=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=l)&&this.editContext.updateSelection(i,l)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.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])}}class Ee{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={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,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:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(l=>l.forEach(o=>i(o,this)))||(l=>this.update(l)),this.dispatch=this.dispatch.bind(this),this._root=e.root||uR(e.parent)||document,this.viewState=new ES(this,e.state||gt.create(e)),e.scrollTo&&e.scrollTo.is(kh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(da).map(l=>new r0(l));for(let l of this.plugins)l.update(this);this.observer=new _j(this),this.inputState=new nj(this),this.inputState.ensureHandlers(this.plugins),this.docView=new gS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof pn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,l,o=this.state;for(let b of e){if(b.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=b.state}if(this.destroyed){this.viewState.state=o;return}let a=this.hasFocus,u=0,f=null;e.some(b=>b.annotation(yN))?(this.inputState.notifiedFocused=a,u=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,f=bN(o,a),f||(u=1));let d=this.observer.delayedAndroidKey,m=null;if(d?(this.observer.clearDelayedAndroidKey(),m=this.observer.readChange(),(m&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(m=null)):this.observer.clear(),o.facet(gt.phrases)!=this.state.facet(gt.phrases))return this.setState(o);l=vd.create(this,o,e),l.flags|=u;let g=this.viewState.scrollTarget;try{this.updateState=2;for(let b of e){if(g&&(g=g.map(b.changes)),b.scrollIntoView){let{main:v}=b.state.selection,{x:w,y:S}=this.state.facet(Ee.cursorScrollMargin);g=new wa(v.empty?v:le.cursor(v.head,v.head>v.anchor?-1:1),"nearest","nearest",S,w)}for(let v of b.effects)v.is(kh)&&(g=v.value.clip(this.state))}this.viewState.update(l,g),this.bidiCache=Od.update(this.bidiCache,l.changes),l.empty||(this.updatePlugins(l),this.inputState.update(l)),t=this.docView.update(l),this.state.facet(Zc)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(b=>b.isUserEvent("select.pointer")))}finally{this.updateState=0}if(l.startState.facet(Ah)!=l.state.facet(Ah)&&(this.viewState.mustMeasureContent=!0),(t||i||g||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!l.empty)for(let b of this.state.facet(Sx))try{b(l)}catch(v){gi(this.state,v,"update listener")}(f||m)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),m&&!fN(this,m)&&d.force&&va(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 i of this.plugins)i.destroy(this);this.viewState=new ES(this,e),this.plugins=e.facet(da).map(i=>new r0(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new gS(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(da),i=e.state.facet(da);if(t!=i){let l=[];for(let o of i){let a=t.indexOf(o);if(a<0)l.push(new r0(o));else{let u=this.plugins[a];u.mustUpdate=e,l.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=l,this.pluginMap.clear()}else for(let l of this.plugins)l.mustUpdate=e;for(let l=0;l-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,i=this.viewState.scrollParent,l=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:a,scaleY:u}=this.viewState;Math.abs(l-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(a<0){if(PO(i||this.win))o=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let w=this.viewState.scrollAnchorAt(l);o=w.from,a=w.top}u=this.viewState.scaleY}this.updateState=1;let d=this.viewState.measure();if(!d&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let m=[];d&4||([this.measureRequests,m]=[m,this.measureRequests]);let g=m.map(w=>{try{return w.read(this)}catch(S){return gi(this.state,S),jS}}),b=vd.create(this,this.state,[]),v=!1;b.flags|=d,t?t.flags|=d:t=b,this.updateState=2,b.empty||(this.updatePlugins(b),this.inputState.update(b),this.updateAttrs(),v=this.docView.update(b),v&&this.docViewUpdate());for(let w=0;w1||S<-1)&&!(Ce.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){l=l+S,i?o<0?i.scrollTop=i.scrollHeight:i.scrollTop+=S:this.win.scrollBy(0,S),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let f of this.state.facet(Sx))f(t)}get themeClasses(){return Dx+" "+(this.state.facet(Mx)?SN:kN)+" "+this.state.facet(Ah)}updateAttrs(){let e=_S(this,nN,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(cl)?"true":"false",class:"cm-content",style:`${Ce.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),_S(this,Ry,t);let i=this.observer.ignore(()=>{let l=uS(this.contentDOM,this.contentAttrs,t),o=uS(this.dom,this.editorAttrs,e);return l||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let l of i.effects)if(l.is(Ee.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=l.value}}mountStyles(){this.styleModules=this.state.facet(Zc);let e=this.state.facet(Ee.cspNonce);as.mount(this.root,this.styleModules.concat(Rj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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;ti.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,i){return a0(this,e,xS(this,e,t,i))}moveByGroup(e,t){return a0(this,e,xS(this,e,t,i=>XR(this,e.head,i)))}visualLineSide(e,t){return t?le.cursor(e.to,1):le.cursor(e.from,-1)}moveToLineBoundary(e,t,i=!0){return QR(this,e,t,i)}moveVertically(e,t,i){return a0(this,e,$R(this,e,t,i))}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 i=Nx(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),Nx(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),l=this.bidiSpans(i),o=l[_r.find(l,e-i.from,-1,t)];return i.length&&(e==i.from&&t<0||e==i.to&&t>0)&&o.dir!=this.textDirectionAt(i.from)&&(e==i.to?(e=i.from+o.from,t=1):(e=i.from+o.to,t=-1)),this.docView.coordsAt(e,t,o.dir==At.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(ZO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Bj)return VO(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||qO(o.isolates,i=dS(this,e))))return o.order;i||(i=dS(this,e));let l=yR(e.text,t,i);return this.bidiCache.push(new Od(e.from,e.to,t,i,!0,l)),l}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ce.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{BO(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.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,l,o,a;return kh.of(new wa(typeof e=="number"?le.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(l=t.x)!==null&&l!==void 0?l:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(a=t.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return kh.of(new wa(le.cursor(i.from),"start","start",i.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 en.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return en.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=as.newName(),l=[Ah.of(i),Zc.of(Rx(`.${i}`,e))];return t&&t.dark&&l.push(Mx.of(!0)),l}static baseTheme(e){return mo.lowest(Zc.of(Rx("."+Dx,e,CN)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),l=i&&Gt.get(i)||Gt.get(e);return((t=l==null?void 0:l.root)===null||t===void 0?void 0:t.view)||null}}Ee.styleModule=Zc;Ee.inputHandler=KO;Ee.clipboardInputFilter=My;Ee.clipboardOutputFilter=Dy;Ee.scrollHandler=eN;Ee.focusChangeEffect=WO;Ee.perLineTextDirection=ZO;Ee.exceptionSink=GO;Ee.updateListener=Sx;Ee.editable=cl;Ee.mouseSelectionStyle=YO;Ee.dragMovesSelection=$O;Ee.clickAddsSelectionRange=XO;Ee.decorations=nm;Ee.blockWrappers=iN;Ee.outerDecorations=jy;Ee.atomicRanges=_u;Ee.bidiIsolatedRanges=rN;Ee.cursorScrollMargin=Ne.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});Ee.scrollMargins=sN;Ee.darkTheme=Mx;Ee.cspNonce=Ne.define({combine:n=>n.length?n[0]:""});Ee.contentAttributes=Ry;Ee.editorAttributes=nN;Ee.lineWrapping=Ee.contentAttributes.of({class:"cm-lineWrapping"});Ee.announce=Ke.define();const Bj=4096,jS={};class Od{constructor(e,t,i,l,o,a){this.from=e,this.to=t,this.dir=i,this.isolates=l,this.fresh=o,this.order=a}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],l=e.length?e[e.length-1].dir:At.LTR;for(let o=Math.max(0,e.length-10);o=0;l--){let o=i[l],a=typeof o=="function"?o(n):o;a&&Ty(a,t)}return t}const Pj=Ce.mac?"mac":Ce.windows?"win":Ce.linux?"linux":"key";function Hj(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let l,o,a,u;for(let f=0;fi.concat(l),[]))),t}function Uj(n,e,t){return NN(ON(n.state),e,n,t)}let es=null;const Fj=4e3;function qj(n,e=Pj){let t=Object.create(null),i=Object.create(null),l=(a,u)=>{let f=i[a];if(f==null)i[a]=u;else if(f!=u)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},o=(a,u,f,d,m)=>{var g,b;let v=t[a]||(t[a]=Object.create(null)),w=u.split(/ (?!$)/).map(N=>Hj(N,e));for(let N=1;N{let U=es={view:M,prefix:j,scope:a};return setTimeout(()=>{es==U&&(es=null)},Fj),!0}]})}let S=w.join(" ");l(S,!1);let C=v[S]||(v[S]={preventDefault:!1,stopPropagation:!1,run:((b=(g=v._any)===null||g===void 0?void 0:g.run)===null||b===void 0?void 0:b.slice())||[]});f&&C.run.push(f),d&&(C.preventDefault=!0),m&&(C.stopPropagation=!0)};for(let a of n){let u=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let d of u){let m=t[d]||(t[d]=Object.create(null));m._any||(m._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:g}=a;for(let b in m)m[b].run.push(v=>g(v,jx))}let f=a[e]||a.key;if(f)for(let d of u)o(d,f,a.run,a.preventDefault,a.stopPropagation),a.shift&&o(d,"Shift-"+f,a.shift,a.preventDefault,a.stopPropagation)}return t}let jx=null;function NN(n,e,t,i){jx=e;let l=iR(e),o=di(l,0),a=Rr(o)==l.length&&l!=" ",u="",f=!1,d=!1,m=!1;es&&es.view==t&&es.scope==i&&(u=es.prefix+" ",mN.indexOf(e.keyCode)<0&&(d=!0,es=null));let g=new Set,b=C=>{if(C){for(let N of C.run)if(!g.has(N)&&(g.add(N),N(t)))return C.stopPropagation&&(m=!0),!0;C.preventDefault&&(C.stopPropagation&&(m=!0),d=!0)}return!1},v=n[i],w,S;return v&&(b(v[u+Eh(l,e,!a)])?f=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ce.windows&&e.ctrlKey&&e.altKey)&&!(Ce.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(w=cs[e.keyCode])&&w!=l?(b(v[u+Eh(w,e,!0)])||e.shiftKey&&(S=gu[e.keyCode])!=l&&S!=w&&b(v[u+Eh(S,e,!1)]))&&(f=!0):a&&e.shiftKey&&b(v[u+Eh(l,e,!0)])&&(f=!0),!f&&b(v._any)&&(f=!0)),d&&(f=!0),f&&m&&e.stopPropagation(),jx=null,f}class lo{constructor(e,t,i,l,o){this.className=e,this.left=t,this.top=i,this.width=l,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(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(e,t,i){if(i.empty){let l=e.coordsAtPos(i.head,i.assoc||1);if(!l)return[];let o=TN(e);return[new lo(t,l.left-o.left,l.top-o.top,null,l.bottom-l.top)]}else return Vj(e,t,i)}}function TN(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==At.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function zS(n,e,t,i){let l=n.coordsAtPos(e,t*2);if(!l)return i;let o=n.dom.getBoundingClientRect(),a=(l.top+l.bottom)/2,u=n.posAtCoords({x:o.left+1,y:a}),f=n.posAtCoords({x:o.right-1,y:a});return u==null||f==null?i:{from:Math.max(i.from,Math.min(u,f)),to:Math.min(i.to,Math.max(u,f))}}function Vj(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),l=Math.min(t.to,n.viewport.to),o=n.textDirection==At.LTR,a=n.contentDOM,u=a.getBoundingClientRect(),f=TN(n),d=a.querySelector(".cm-line"),m=d&&window.getComputedStyle(d),g=u.left+(m?parseInt(m.paddingLeft)+Math.min(0,parseInt(m.textIndent)):0),b=u.right-(m?parseInt(m.paddingRight):0),v=Ox(n,i,1),w=Ox(n,l,-1),S=v.type==Bn.Text?v:null,C=w.type==Bn.Text?w:null;if(S&&(n.lineWrapping||v.widgetLineBreaks)&&(S=zS(n,i,1,S)),C&&(n.lineWrapping||w.widgetLineBreaks)&&(C=zS(n,l,-1,C)),S&&C&&S.from==C.from&&S.to==C.to)return j(M(t.from,t.to,S));{let H=S?M(t.from,null,S):U(v,!1),E=C?M(null,t.to,C):U(w,!0),D=[];return(S||v).to<(C||w).from-(S&&C?1:0)||v.widgetLineBreaks>1&&H.bottom+n.defaultLineHeight/2_&&pe.from=Z)break;T>ce&&V(Math.max(W,ce),H==null&&W<=_,Math.min(T,Z),E==null&&T>=ie,G.dir)}if(ce=oe.to+1,ce>=Z)break}return F.length==0&&V(_,H==null,ie,E==null,n.textDirection),{top:I,bottom:ne,horizontal:F}}function U(H,E){let D=u.top+(E?H.top:H.bottom);return{top:D,bottom:D,horizontal:[]}}}function Qj(n,e){return n.constructor==e.constructor&&n.eq(e)}class Xj{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(sd)!=e.state.facet(sd)&&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,i=e.facet(sd);for(;t!Qj(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let l of e)l.update&&t&&l.constructor&&this.drawn[i].constructor&&l.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(l.draw(),t);for(;t;){let l=t.nextSibling;t.remove(),t=l}this.drawn=e,Ce.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const sd=Ne.define();function AN(n){return[en.define(e=>new Xj(e,n)),sd.of(n)]}const _x=!Ce.ios,ja=Ne.define({combine(n){return Ur(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function $j(n={}){return[ja.of(n),Yj,Gj,Wj,JO.of(!0)]}function EN(n){return n.startState.facet(ja)!=n.state.facet(ja)}const Yj=AN({above:!0,markers(n){let{state:e}=n,t=e.facet(ja),i=[];for(let l of e.selection.ranges){let o=l==e.selection.main;if(l.empty||t.drawRangeCursor&&!(o&&Ce.ios&&t.iosSelectionHandles)){let a=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=l.empty?l:le.cursor(l.head,l.assoc);for(let f of lo.forRange(n,a,u))i.push(f)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=EN(n);return t&&BS(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){BS(e.state,n)},class:"cm-cursorLayer"});function BS(n,e){e.style.animationDuration=n.facet(ja).cursorBlinkRate+"ms"}const Gj=AN({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let l of i)if(!l.empty&&(_x||l!=t))for(let o of lo.forRange(n,"cm-selectionBackground",l))e.push(o);if(Ce.ios&&!t.empty&&n.state.facet(ja).iosSelectionHandles){for(let l of lo.forRange(n,"cm-selectionHandle cm-selectionHandle-start",le.cursor(t.from,1)))e.push(l);for(let l of lo.forRange(n,"cm-selectionHandle cm-selectionHandle-end",le.cursor(t.to,1)))e.push(l)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||EN(n)},class:"cm-selectionLayer"}),Kj=Ce.gecko&&Ce.gecko_version==153?"#ffffff01":"transparent",Wj=mo.highest(Ee.theme({".cm-line":{..._x?{"& ::selection, &::selection":{backgroundColor:`${Kj} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",..._x?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),MN=Ke.define({map(n,e){return n==null?null:e.mapPos(n)}}),eu=Qn.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(MN)?i.value:t,n)}}),Zj=en.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(eu);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(eu)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(eu),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(eu)!=n&&this.view.dispatch({effects:MN.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Jj(){return[eu,Zj]}function PS(n,e,t,i,l){e.lastIndex=0;for(let o=n.iterRange(t,i),a=t,u;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;u=e.exec(o.value);)l(a+u.index,u)}function e_(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:l,to:o}of t)l=Math.max(n.state.doc.lineAt(l).from,l-e),o=Math.min(n.state.doc.lineAt(o).to,o+e),i.length&&i[i.length-1].to>=l?i[i.length-1].to=o:i.push({from:l,to:o});return i}class t_{constructor(e){const{regexp:t,decoration:i,decorate:l,boundary:o,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,l)this.addMatch=(u,f,d,m)=>l(m,d,d+u[0].length,u,f);else if(typeof i=="function")this.addMatch=(u,f,d,m)=>{let g=i(u,f,d);g&&m(d,d+u[0].length,g)};else if(i)this.addMatch=(u,f,d,m)=>m(d,d+u[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=a}createDeco(e){let t=new Hr,i=t.add.bind(t);for(let{from:l,to:o}of e_(e,this.maxLength))PS(e.state.doc,this.regexp,l,o,(a,u)=>this.addMatch(u,e,a,i));return t.finish()}updateDeco(e,t){let i=1e9,l=-1;return e.docChanged&&e.changes.iterChanges((o,a,u,f)=>{f>=e.view.viewport.from&&u<=e.view.viewport.to&&(i=Math.min(u,i),l=Math.max(f,l))}),e.viewportMoved||l-i>1e3?this.createDeco(e.view):l>-1?this.updateRange(e.view,t.map(e.changes),i,l):t}updateRange(e,t,i,l){for(let o of e.visibleRanges){let a=Math.max(o.from,i),u=Math.min(o.to,l);if(u>=a){let f=e.state.doc.lineAt(a),d=f.tof.from;a--)if(this.boundary.test(f.text[a-1-f.from])){m=a;break}for(;ub.push(N.range(S,C));if(f==d)for(this.regexp.lastIndex=m-f.from;(v=this.regexp.exec(f.text))&&v.indexthis.addMatch(C,e,S,w));t=t.update({filterFrom:m,filterTo:g,filter:(S,C)=>Sg,add:b})}}return t}}const Lx=/x/.unicode!=null?"gu":"g",n_=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Lx),i_={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"};let f0=null;function r_(){var n;if(f0==null&&typeof document<"u"&&document.body){let e=document.body.style;f0=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return f0||!1}const od=Ne.define({combine(n){let e=Ur(n,{render:null,specialChars:n_,addSpecialChars:null});return(e.replaceTabs=!r_())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Lx)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Lx)),e}});function l_(n={}){return[od.of(n),s_()]}let HS=null;function s_(){return HS||(HS=en.fromClass(class{constructor(n){this.view=n,this.decorations=Fe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(od)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new t_({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:l}=t.state,o=di(e[0],0);if(o==9){let a=l.lineAt(i),u=t.state.tabSize,f=Ba(a.text,u,i-a.from);return Fe.replace({widget:new u_((u-f%u)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Fe.replace({widget:new c_(n,o)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(od);n.startState.facet(od)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const o_="•";function a_(n){return n>=32?o_:n==10?"␤":String.fromCharCode(9216+n)}class c_ extends gl{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=a_(this.code),i=e.state.phrase("Control character")+" "+(i_[this.code]||"0x"+this.code.toString(16)),l=this.options.render&&this.options.render(this.code,i,t);if(l)return l;let o=document.createElement("span");return o.textContent=t,o.title=i,o.setAttribute("aria-label",i),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class u_ extends gl{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 f_(){return d_}const h_=Fe.line({class:"cm-activeLine"}),d_=en.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let l=n.lineBlockAt(i.head);l.from>e&&(t.push(h_.range(l.from)),e=l.from)}return Fe.set(t)}},{decorations:n=>n.decorations}),zx=2e3;function m_(n,e,t){let i=Math.min(e.line,t.line),l=Math.max(e.line,t.line),o=[];if(e.off>zx||t.off>zx||e.col<0||t.col<0){let a=Math.min(e.off,t.off),u=Math.max(e.off,t.off);for(let f=i;f<=l;f++){let d=n.doc.line(f);d.length<=u&&o.push(le.range(d.from+a,d.to+u))}}else{let a=Math.min(e.col,t.col),u=Math.max(e.col,t.col);for(let f=i;f<=l;f++){let d=n.doc.line(f),m=hx(d.text,a,n.tabSize,!0);if(m<0)o.push(le.cursor(d.to));else{let g=hx(d.text,u,n.tabSize);o.push(le.range(d.from+m,d.from+g))}}}return o}function p_(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function IS(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),l=t-i.from,o=l>zx?-1:l==i.length?p_(n,e.clientX):Ba(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:o,off:l}}function g_(n,e){let t=IS(n,e),i=n.state.selection;return t?{update(l){if(l.docChanged){let o=l.changes.mapPos(l.startState.doc.line(t.line).from),a=l.state.doc.lineAt(o);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},i=i.map(l.changes)}},get(l,o,a){let u=IS(n,l);if(!u)return i;let f=m_(n.state,t,u);return f.length?a?le.create(f.concat(i.ranges)):le.create(f):i}}:null}function x_(n){let e=(t=>t.altKey&&t.button==0);return Ee.mouseSelectionStyle.of((t,i)=>e(i)?g_(t,i):null)}const y_={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},b_={style:"cursor: crosshair"};function v_(n={}){let[e,t]=y_[n.key||"Alt"],i=en.fromClass(class{constructor(l){this.view=l,this.isDown=!1}set(l){this.isDown!=l&&(this.isDown=l,this.view.update([]))}},{eventObservers:{keydown(l){this.set(l.keyCode==e||t(l))},keyup(l){(l.keyCode==e||!t(l))&&this.set(!1)},mousemove(l){this.set(t(l))}}});return[i,Ee.contentAttributes.of(l=>{var o;return!((o=l.plugin(i))===null||o===void 0)&&o.isDown?b_:null})]}const Mh="-10000px";class DN{constructor(e,t,i,l){this.facet=t,this.createTooltipView=i,this.removeTooltipView=l,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let o=null;this.tooltipViews=this.tooltips.map(a=>o=i(a,o))}update(e,t){var i;let l=e.state.facet(this.facet),o=l.filter(f=>f);if(l===this.input){for(let f of this.tooltipViews)f.update&&f.update(e);return!1}let a=[],u=t?[]:null;for(let f=0;ft[d]=f),t.length=u.length),this.input=l,this.tooltips=o,this.tooltipViews=a,!0}}function RN(n){let e=n.dom.ownerDocument.documentElement,t=e.clientWidth,i=getComputedStyle(e);if(!/stable/.test(i.scrollbarGutter||""))return{left:0,right:t};let l=e.getBoundingClientRect(),o=n.win.scrollX;return{left:Math.max(0,l.left+o-parseFloat(i.marginLeft)),right:Math.min(t,l.right+o+parseFloat(i.marginRight))}}function w_(n){let{left:e,right:t}=RN(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const h0=Ne.define({combine:n=>{var e,t,i;return{position:Ce.ios?"absolute":((e=n.find(l=>l.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(l=>l.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(l=>l.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||w_}}}),US=new WeakMap,Py=en.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(h0);this.position=e.position,this.parent=e.parent,this.classes=n.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 DN(n,Hy,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.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 n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(h0);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let l of this.manager.tooltipViews)l.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let l of this.manager.tooltipViews)this.container.appendChild(l.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let l=document.createElement("div");l.className="cm-tooltip-arrow",t.dom.appendChild(l)}return t.dom.style.position=this.position,t.dom.style.top=Mh,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1,i=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(Ce.safari){let u=a.getBoundingClientRect();t=Math.abs(u.top+1e4)>1||Math.abs(u.left)>1}else t=!!a.offsetParent&&a.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(n=a.width/this.parent.offsetWidth,e=a.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);else i=RN(this.view).left;let l=this.view.scrollDOM.getBoundingClientRect(),o=_y(this.view);return{visible:{left:l.left+o.left,top:l.top+o.top,right:l.right-o.right,bottom:l.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,u)=>{let f=this.manager.tooltipViews[u];return f.getCoords?f.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(h0).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t,fixedLeft:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let u of this.manager.tooltipViews)u.dom.style.position="absolute"}let{visible:t,space:i,scaleX:l,scaleY:o}=n,a=[];for(let u=0;u=Math.min(t.bottom,i.bottom)||g.rightMath.min(t.right,i.right)+.1)){m.style.top=Mh;continue}let v=f.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,w=v?7:0,S=b.right-b.left,C=(e=US.get(d))!==null&&e!==void 0?e:b.bottom-b.top,N=d.offset||S_,j=this.view.textDirection==At.LTR,M=b.width>i.right-i.left?j?i.left:i.right-b.width:j?Math.max(i.left,Math.min(g.left-(v?14:0)+N.x,i.right-S)):Math.min(Math.max(i.left,g.left-S+(v?14:0)-N.x),i.right-S),U=this.above[u];!f.strictSide&&(U?g.top-C-w-N.yi.bottom)&&U==i.bottom-g.bottom>g.top-i.top&&(U=this.above[u]=!U);let H=(U?g.top-i.top:i.bottom-g.bottom)-w;if(HM&&I.topE&&(E=U?I.top-C-2-w:I.bottom+w+2);if(this.position=="absolute"?(m.style.top=(E-n.parent.top)/o+"px",FS(m,(M-n.parent.left)/l)):(m.style.top=E/o+"px",FS(m,(M-n.fixedLeft)/l)),v){let I=g.left+(j?N.x:-N.x)-(M+14-7);v.style.left=I/l+"px"}d.overlap!==!0&&a.push({left:M,top:E,right:D,bottom:E+C}),m.classList.toggle("cm-tooltip-above",U),m.classList.toggle("cm-tooltip-below",!U),d.positioned&&d.positioned(n.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 n of this.manager.tooltipViews)n.dom.style.top=Mh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function FS(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const k_=Ee.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"}}}),S_={x:0,y:0},Hy=Ne.define({enables:[Py,k_]}),Nd=Ne.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class sm{static create(e){return new sm(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new DN(e,Nd,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}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===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let l=i[e];if(l!==void 0){if(t===void 0)t=l;else if(t!==l)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")}}const C_=Hy.compute([Nd],n=>{let e=n.facet(Nd);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:sm.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),jN=Ne.define();class O_{constructor(e,t,i,l,o,a){this.view=e,this.source=t,this.field=i,this.locked=l,this.setHover=o,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;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(l)).find(d=>d.from<=l&&d.to>=l),f=u&&u.dir==At.RTL?-1:1;o=t.x{if(u&&!(Array.isArray(u)&&!u.length)){let f=Array.isArray(u)?u:[u];l&&this.locked.set(f,l),e.dispatch({effects:this.setHover.of(f)})}};if(o&&"then"in o){let u=this.pending={pos:t};o.then(f=>{this.pending==u&&(this.pending=null,a(f))},f=>gi(e.state,f,"hover tooltip"))}else a(o)}get tooltip(){let e=this.view.plugin(Py),t=e?e.manager.tooltips.findIndex(i=>i.create==sm.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:l,tooltip:o}=this;if(l.length&&!this.locked.has(l)&&o&&!N_(o.dom,e)||this.pending){let{pos:a}=l[0]||this.pending,u=(i=(t=l[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:a;(a==u?this.view.posAtCoords(this.lastMove)!=a:!T_(this.view,a,u,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:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:l}=this;l.length&&!this.locked.has(l)&&!this.view.dom.contains(i.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)}}const Dh=4;function N_(n,e){let{left:t,right:i,top:l,bottom:o}=n.getBoundingClientRect(),a;if(a=n.querySelector(".cm-tooltip-arrow")){let u=a.getBoundingClientRect();l=Math.min(u.top,l),o=Math.max(u.bottom,o)}return e.clientX>=t-Dh&&e.clientX<=i+Dh&&e.clientY>=l-Dh&&e.clientY<=o+Dh}function T_(n,e,t,i,l,o){let a=n.scrollDOM.getBoundingClientRect(),u=n.documentTop+n.documentPadding.top+n.contentHeight;if(a.left>i||a.rightl||Math.min(a.bottom,u)=e&&f<=t}function A_(n,e={}){let t=Ke.define(),i=new WeakMap,l=Qn.define({create(){return[]},update(a,u){let f=i.get(a);if(a.length&&(e.hideOnChange&&(u.docChanged||u.selection)?a=[]:f&&f(u)?a=[]:e.hideOn&&(a=a.filter(d=>!e.hideOn(u,d)))),u.docChanged&&a.length){let d=[];for(let m of a){let g=u.changes.mapPos(m.pos,-1,ni.TrackDel);if(g!=null){let b=Object.assign(Object.create(null),m);b.pos=g,b.end!=null&&(b.end=u.changes.mapPos(b.end)),d.push(b)}}a=d}for(let d of u.effects)d.is(t)&&(a=d.value,f=void 0),(d.is(M_)&&!d.value||d.value==l)&&(a=[]);return a.length&&f&&i.set(a,f),a},provide:a=>Nd.from(a)});const o=en.define(a=>new O_(a,n,l,i,t,e.hoverTime||300));return{active:l,extension:[l,o,jN.of(o),C_]}}function E_(n,e,t,i={}){var l;let o=n.state.facet(jN).map(a=>n.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=o.find(u=>u.field==i.tooltip.active);a&&(o=[a])}for(let a of o)a.activateHover(n,e,t,(l=i.until)!==null&&l!==void 0?l:(()=>!1))}function _N(n,e){let t=n.plugin(Py);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const M_=Ke.define(),qS=Ne.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function om(n,e){let t=n.plugin(LN),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const LN=en.fromClass(class{constructor(n){this.input=n.state.facet(vu),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(qS);this.top=new Rh(n,!0,e.topContainer),this.bottom=new Rh(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(qS);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Rh(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Rh(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(vu);if(t!=this.input){let i=t.filter(f=>f),l=[],o=[],a=[],u=[];for(let f of i){let d=this.specs.indexOf(f),m;d<0?(m=f(n.view),u.push(m)):(m=this.panels[d],m.update&&m.update(n)),l.push(m),(m.top?o:a).push(m)}this.specs=i,this.panels=l,this.top.sync(o),this.bottom.sync(a);for(let f of u)f.dom.classList.add("cm-panel"),f.mount&&f.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>Ee.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Rh{constructor(e,t,i){this.view=e,this.top=t,this.container=i,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(),this.dom=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 t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=VS(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=VS(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 VS(n){let e=n.nextSibling;return n.remove(),e}const vu=Ne.define({enables:LN});function D_(n,e){let t,i=new Promise(a=>t=a),l=a=>j_(a,e,t);n.state.field(ad,!1)?n.dispatch({effects:zN.of(l)}):n.dispatch({effects:Ke.appendConfig.of(ad.init(()=>[l]))});let o=BN.of(l);return{close:o,result:i.then(a=>((n.win.queueMicrotask||(f=>n.win.setTimeout(f,10)))(()=>{n.state.field(ad).indexOf(l)>-1&&n.dispatch({effects:o})}),a))}}function R_(n,e){let t=n.state.field(ad,!1)||[];for(let i of t){let l=om(n,i);if(l&&l.dom.classList.contains(e))return l}return null}const ad=Qn.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(zN)?n=[t.value].concat(n):t.is(BN)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>vu.computeN([n],e=>e.field(n))}),zN=Ke.define(),BN=Ke.define();function j_(n,e,t){let i=e.content?e.content(n,()=>u(null)):null;if(!i){if(i=Tt("form"),e.input){let f=Tt("input",e.input);/^(text|password|number|email|tel|url)$/.test(f.type)&&f.classList.add("cm-textfield"),f.name||(f.name="input"),i.appendChild(Tt("label",(e.label||"")+": ",f))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(Tt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let l=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let f=0;f{m.keyCode==27?(m.preventDefault(),u(null)):m.keyCode==13&&(m.preventDefault(),u(d))}),d.addEventListener("submit",m=>{m.preventDefault(),u(d)})}let o=Tt("div",i,Tt("button",{onclick:()=>u(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(o.className=e.class),o.classList.add("cm-dialog");let a=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function u(f){o.contains(o.ownerDocument.activeElement)&&n.focus(),t(f)}return{dom:o,top:e.top,mount:()=>{a&&("select"in a?a.select():"focus"in a&&a.focus())},destroy:()=>t(null)}}class dl extends os{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}dl.prototype.elementClass="";dl.prototype.toDOM=void 0;dl.prototype.mapMode=ni.TrackBefore;dl.prototype.startSide=dl.prototype.endSide=-1;dl.prototype.point=!0;const cd=Ne.define(),__=Ne.define(),L_={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>lt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},ou=Ne.define();function z_(n){return[PN(),ou.of({...L_,...n})]}const QS=Ne.define({combine:n=>n.some(e=>e)});function PN(n){return[B_]}const B_=en.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.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=n.state.facet(ou).map(e=>new $S(n,e)),this.fixed=!n.state.facet(QS);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),n.scrollDOM.insertBefore(this.dom,n.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(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.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(QS)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=lt.iter(this.view.state.facet(cd),this.view.viewport.from),i=[],l=this.gutters.map(o=>new P_(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(o.type)){let a=!0;for(let u of o.type)if(u.type==Bn.Text&&a){Bx(t,i,u.from);for(let f of l)f.line(this.view,u,i);a=!1}else if(u.widget)for(let f of l)f.widget(this.view,u)}else if(o.type==Bn.Text){Bx(t,i,o.from);for(let a of l)a.line(this.view,o,i)}else if(o.widget)for(let a of l)a.widget(this.view,o);for(let o of l)o.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(ou),t=n.state.facet(ou),i=n.docChanged||n.heightChanged||n.viewportChanged||!lt.eq(n.startState.facet(cd),n.state.facet(cd),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let l of this.gutters)l.update(n)&&(i=!0);else{i=!0;let l=[];for(let o of t){let a=e.indexOf(o);a<0?l.push(new $S(this.view,o)):(this.gutters[a].update(n),l.push(this.gutters[a]))}for(let o of this.gutters)o.dom.remove(),l.indexOf(o)<0&&o.destroy();for(let o of l)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=l}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>Ee.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,l=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==At.LTR?{left:i,right:l}:{right:i,left:l}})});function XS(n){return Array.isArray(n)?n:[n]}function Bx(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class P_{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=lt.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:l}=this,o=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==l.elements.length){let u=new HN(e,a,o,i);l.elements.push(u),l.dom.appendChild(u.dom)}else l.elements[this.i].update(e,a,o,i);this.height=t.bottom,this.i++}line(e,t,i){let l=[];Bx(this.cursor,l,t.from),i.length&&(l=l.concat(i));let o=this.gutter.config.lineMarker(e,t,l);o&&l.unshift(o);let a=this.gutter;l.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,l)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),l=i?[i]:null;for(let o of e.state.facet(__)){let a=o(e,t.widget,t);a&&(l||(l=[])).push(a)}l&&this.addElement(e,t,l)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class $S{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 i in t.domEventHandlers)this.dom.addEventListener(i,l=>{let o=l.target,a;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();a=(f.top+f.bottom)/2}else a=l.clientY;let u=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,u,l)&&l.preventDefault()});this.markers=XS(t.markers(e)),t.initialSpacer&&(this.spacer=new HN(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=XS(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let l=this.config.updateSpacer(this.spacer.markers[0],e);l!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[l])}let i=e.view.viewport;return!lt.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class HN{constructor(e,t,i,l){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,l)}update(e,t,i,l){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),H_(this.markers,l)||this.setMarkers(e,l)}setMarkers(e,t){let i="cm-gutterElement",l=this.dom.firstChild;for(let o=0,a=0;;){let u=a,f=oo(u,f,d)||a(u,f,d):a}return i}})}});class d0 extends dl{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function m0(n,e){return n.state.facet(ma).formatNumber(e,n.state)}const F_=ou.compute([ma],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(I_)},lineMarker(e,t,i){return i.some(l=>l.toDOM)?null:new d0(m0(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let l of e.state.facet(U_)){let o=l(e,t,i);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(ma)!=e.state.facet(ma),initialSpacer(e){return new d0(m0(e,YS(e.state.doc.lines)))},updateSpacer(e,t){let i=m0(t.view,YS(t.view.state.doc.lines));return i==e.number?e:new d0(i)},domEventHandlers:n.facet(ma).domEventHandlers,side:"before"}));function q_(n={}){return[ma.of(n),PN(),F_]}function YS(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.head).from;l>t&&(t=l,e.push(V_.range(l)))}return lt.of(e)});function X_(){return Q_}const IN=1024;let $_=0;class p0{constructor(e,t){this.from=e,this.to=t}}class nt{constructor(e={}){this.id=$_++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=yi.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}nt.closedBy=new nt({deserialize:n=>n.split(" ")});nt.openedBy=new nt({deserialize:n=>n.split(" ")});nt.group=new nt({deserialize:n=>n.split(" ")});nt.isolate=new nt({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});nt.contextHash=new nt({perNode:!0});nt.lookAhead=new nt({perNode:!0});nt.mounted=new nt({perNode:!0});class au{constructor(e,t,i,l=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=l}static get(e){return e&&e.props&&e.props[nt.mounted.id]}}const Y_=Object.create(null);class yi{constructor(e,t,i,l=0){this.name=e,this.props=t,this.id=i,this.flags=l}static define(e){let t=e.props&&e.props.length?Object.create(null):Y_,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new yi(e.name||"",t,e.id,i);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(l)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return l}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(nt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let l of i.split(" "))t[l]=e[i];return i=>{for(let l=i.prop(nt.group),o=-1;o<(l?l.length:0);o++){let a=t[o<0?i.name:l[o]];if(a)return a}}}}yi.none=new yi("",Object.create(null),0,8);class Iy{constructor(e){this.types=e;for(let t=0;t0;for(let f=this.cursor(a|Yt.IncludeAnonymous);;){let d=!1;if(f.from<=o&&f.to>=l&&(!u&&f.type.isAnonymous||t(f)!==!1)){if(f.firstChild())continue;d=!0}for(;d&&i&&(u||!f.type.isAnonymous)&&i(f),!f.nextSibling();){if(!f.parent())return;d=!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(e={}){return this.children.length<=8?this:qy(yi.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,l)=>new un(this.type,t,i,l,this.propValues),e.makeTree||((t,i,l)=>new un(yi.none,t,i,l)))}static build(e){return Z_(e)}}un.empty=new un(yi.none,[],[],0);class Uy{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 Uy(this.buffer,this.index)}}class fs{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return yi.none}toString(){let e=[];for(let t=0;t0));f=a[f+3]);return u}slice(e,t,i){let l=this.buffer,o=new Uint16Array(t-e),a=0;for(let u=e,f=0;u=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function wu(n,e,t,i){for(var l;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?u.length:-1;e!=d;e+=t){let m=u[e],g=f[e]+a.from,b;if(!(!(o&Yt.EnterBracketed&&m instanceof un&&(b=au.get(m))&&!b.overlay&&b.bracketed&&i>=g&&i<=g+m.length)&&!UN(l,i,g,g+m.length))){if(m instanceof fs){if(o&Yt.ExcludeBuffers)continue;let v=m.findChild(0,m.buffer.length,t,i-g,l);if(v>-1)return new ns(new G_(a,m,e,g),null,v)}else if(o&Yt.IncludeAnonymous||!m.type.isAnonymous||Fy(m)){let v;if(!(o&Yt.IgnoreMounts)&&(v=au.get(m))&&!v.overlay)return new Yi(v.tree,g,e,a);let w=new Yi(m,g,e,a);return o&Yt.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?m.children.length-1:0,t,i,l,o)}}}if(o&Yt.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))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(e,t,i=0){let l;if(!(i&Yt.IgnoreOverlays)&&(l=au.get(this._tree))&&l.overlay){let o=e-this.from,a=i&Yt.EnterBracketed&&l.bracketed;for(let{from:u,to:f}of l.overlay)if((t>0||a?u<=o:u=o:f>o))return new Yi(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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 KS(n,e,t,i){let l=n.cursor(),o=[];if(!l.firstChild())return o;if(t!=null){for(let a=!1;!a;)if(a=l.type.is(t),!l.nextSibling())return o}for(;;){if(i!=null&&l.type.is(i))return o;if(l.type.is(e)&&o.push(l.node),!l.nextSibling())return i==null?o:[]}}function Px(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class G_{constructor(e,t,i,l){this.parent=e,this.buffer=t,this.index=i,this.start=l}}class ns extends FN{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,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new ns(this.context,this,o)}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(e,t,i=0){if(i&Yt.ExcludeBuffers)return null;let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new ns(this.context,this,o)}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:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ns(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new ns(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,l=this.index+4,o=i.buffer[this.index+3];if(o>l){let a=i.buffer[this.index+1];e.push(i.slice(l,o,a)),t.push(0)}return new un(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function qN(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||a.to=e){let u=new Yi(a.tree,a.overlay[0].from+o.from,-1,o);(l||(l=[i])).push(wu(u,e,t,!1))}}return l?qN(l):i}class Hx{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&~Yt.EnterBracketed,e instanceof Yi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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:i,buffer:l}=this.buffer;return this.type=t||l.set.types[l.buffer[e]],this.from=i+l.buffer[e+1],this.to=i+l.buffer[e+2],!0}yield(e){return e?e instanceof Yi?(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,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:l}=this.buffer,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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,i=this.mode){return this.buffer?i&Yt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Yt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Yt.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,i=this.stack.length-1;if(e<0){let l=i<0?0:this.stack[i]+4;if(this.index!=l)return this.yieldBuf(t.findChild(l,this.index,-1,0,4))}else{let l=t.buffer[this.index+3];if(l<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(l)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:l}=this;if(l){if(e>0){if(this.index-1)for(let o=t+e,a=e<0?-1:i._tree.children.length;o!=a;o+=e){let u=i._tree.children[o];if(this.mode&Yt.IncludeAnonymous||u instanceof fs||!u.type.isAnonymous||Fy(u))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=0;){for(let a=e;a;a=a._parent)if(a.index==l){if(l==this.index)return a;t=a,i=o+1;break e}l=this.stack[--o]}for(let l=i;l=0;o--){if(o<0)return Px(this._tree,e,l);let a=i[t.buffer[this.stack[o]]];if(!a.isAnonymous){if(e[l]&&e[l]!=a.name)return!1;l--}}return!0}}function Fy(n){return n.children.some(e=>e instanceof fs||!e.type.isAnonymous||Fy(e))}function Z_(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:l=IN,reused:o=[],minRepeatType:a=i.types.length}=n,u=Array.isArray(t)?new Uy(t,t.length):t,f=i.types,d=0,m=0;function g(H,E,D,I,ne,F){let{id:V,start:_,end:ie,size:pe}=u,ce=m,Z=d;if(pe<0)if(u.next(),pe==-1){let de=o[V];D.push(de),I.push(_-H);return}else if(pe==-3){d=V;return}else if(pe==-4){m=V;return}else throw new RangeError(`Unrecognized record size: ${pe}`);let oe=f[V],G,W,T=_-H;if(ie-_<=l&&(W=C(u.pos-E,ne))){let de=new Uint16Array(W.size-W.skip),be=u.pos-W.size,z=de.length;for(;u.pos>be;)z=N(W.start,de,z);G=new fs(de,ie-W.start,i),T=W.start-H}else{let de=u.pos-pe;u.next();let be=[],z=[],R=V>=a?V:-1,X=0,he=ie,ge=ce;for(;u.pos>de;)R>=0&&u.id==R&&u.size>=0?(u.end<=he-l&&(w(be,z,_,X,u.end,he,R,ge,Z),X=be.length,he=u.end,ge=m),u.next()):F>2500?b(_,de,be,z):(R>=0&&u.size==-1&&o[u.id].type==i.types[R]&&(X=0&&X>0&&X-1&&X>0){let ze=v(oe,Z);G=qy(oe,be,z,0,be.length,0,ie-_,ze,ze)}else G=S(oe,be,z,ie-_,ce-ie,Z)}D.push(G),I.push(T)}function b(H,E,D,I){let ne=[],F=0,V=-1;for(;u.pos>E;){let{id:_,start:ie,end:pe,size:ce}=u;if(ce>4)u.next();else{if(V>-1&&ie=0;pe-=3)_[ce++]=ne[pe],_[ce++]=ne[pe+1]-ie,_[ce++]=ne[pe+2]-ie,_[ce++]=ce;D.push(new fs(_,ne[2]-ie,i)),I.push(ie-H)}}function v(H,E){return(D,I,ne)=>{let F=0,V=D.length-1,_,ie;if(V>=0&&(_=D[V])instanceof un){if(!V&&_.type==H&&_.length==ne)return _;(ie=_.prop(nt.lookAhead))&&(F=I[V]+_.length+ie-ne)}return S(H,D,I,ne,F,E)}}function w(H,E,D,I,ne,F,V,_,ie){let pe=[],ce=[];for(;H.length>I;)pe.push(H.pop()),ce.push(E.pop()+D-ne);H.push(S(i.types[V],pe,ce,F-ne,_-F,ie)),E.push(ne-D)}function S(H,E,D,I,ne,F,V){if(F){let _=[nt.contextHash,F];V=V?[_].concat(V):[_]}if(ne>25){let _=[nt.lookAhead,ne];V=V?[_].concat(V):[_]}return new un(H,E,D,I,V)}function C(H,E){let D=u.fork(),I=0,ne=0,F=0,V=D.end-l,_={size:0,start:0,skip:0};e:for(let ie=D.pos-H;D.pos>ie;){let pe=D.size;if(D.id==E&&pe>=0){_.size=I,_.start=ne,_.skip=F,F+=4,I+=4,D.next();continue}let ce=D.pos-pe;if(pe<0||ce=a?4:0,oe=D.start;for(D.next();D.pos>ce;){if(D.size<0)if(D.size==-3||D.size==-4)Z+=4;else break e;else D.id>=a&&(Z+=4);D.next()}ne=oe,I+=pe,F+=Z}return(E<0||I==H)&&(_.size=I,_.start=ne,_.skip=F),_.size>4?_:void 0}function N(H,E,D){let{id:I,start:ne,end:F,size:V}=u;if(u.next(),V>=0&&I4){let ie=u.pos-(V-4);for(;u.pos>ie;)D=N(H,E,D)}E[--D]=_,E[--D]=F-H,E[--D]=ne-H,E[--D]=I}else V==-3?d=I:V==-4&&(m=I);return D}let j=[],M=[];for(;u.pos>0;)g(n.start||0,n.bufferStart||0,j,M,-1,0);let U=(e=n.length)!==null&&e!==void 0?e:j.length?M[0]+j[0].length:0;return new un(f[n.topID],j.reverse(),M.reverse(),U)}const WS=new WeakMap;function ud(n,e){if(!n.isAnonymous||e instanceof fs||e.type!=n)return 1;let t=WS.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof un)){t=1;break}t+=ud(n,i)}WS.set(e,t)}return t}function qy(n,e,t,i,l,o,a,u,f){let d=0;for(let w=i;w=m)break;E+=D}if(M==U+1){if(E>m){let D=w[U];v(D.children,D.positions,0,D.children.length,S[U]+j);continue}g.push(w[U])}else{let D=S[M-1]+w[M-1].length-H;g.push(qy(n,w,S,U,M,H,D,null,f))}b.push(H+j-o)}}return v(e,t,i,l,0),(u||f)(g,b,a)}class so{constructor(e,t,i,l,o=!1,a=!1){this.from=e,this.to=t,this.tree=i,this.offset=l,this.open=(o?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let l=[new so(0,e.length,e,0,!1,i)];for(let o of t)o.to>e.length&&l.push(o);return l}static applyChanges(e,t,i=128){if(!t.length)return e;let l=[],o=1,a=e.length?e[0]:null;for(let u=0,f=0,d=0;;u++){let m=u=i)for(;a&&a.from=b.from||g<=b.to||d){let v=Math.max(b.from,f)-d,w=Math.min(b.to,g)-d;b=v>=w?null:new so(v,w,b.tree,b.offset+d,u>0,!!m)}if(b&&l.push(b),a.to>g)break;a=onew p0(l.from,l.to)):[new p0(0,0)]:[new p0(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let l=this.startParse(e,t,i);for(;;){let o=l.advance();if(o)return o}}}class J_{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 nt({perNode:!0});let eL=0,ol=class Ix{constructor(e,t,i,l){this.name=e,this.set=t,this.base=i,this.modified=l,this.id=eL++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof Ix&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let l=new Ix(i,[],null,[]);if(l.set.push(l),t)for(let o of t.set)l.set.push(o);return l}static defineModifier(e){let t=new Td(e);return i=>i.modified.indexOf(t)>-1?i:Td.get(i.base||i,i.modified.concat(t).sort((l,o)=>l.id-o.id))}},tL=0;class Td{constructor(e){this.name=e,this.instances=[],this.id=tL++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(u=>u.base==e&&nL(t,u.modified));if(i)return i;let l=[],o=new ol(e.name,l,e,t);for(let u of t)u.instances.push(o);let a=iL(t);for(let u of e.set)if(!u.modified.length)for(let f of a)l.push(Td.get(u,f));return o}}function nL(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function iL(n){let e=[[]];for(let t=0;ti.length-t.length)}function QN(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let l of t.split(" "))if(l){let o=[],a=2,u=l;for(let g=0;;){if(u=="..."&&g>0&&g+3==l.length){a=1;break}let b=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!b)throw new RangeError("Invalid path: "+l);if(o.push(b[0]=="*"?"":b[0][0]=='"'?JSON.parse(b[0]):b[0]),g+=b[0].length,g==l.length)break;let v=l[g++];if(g==l.length&&v=="!"){a=0;break}if(v!="/")throw new RangeError("Invalid path: "+l);u=l.slice(g)}let f=o.length-1,d=o[f];if(!d)throw new RangeError("Invalid path: "+l);let m=new ku(i,a,f>0?o.slice(0,f):null);e[d]=m.sort(e[d])}}return XN.add(e)}const XN=new nt({combine(n,e){let t,i,l;for(;n||e;){if(!n||e&&n.depth<=e.depth?(l=e,e=e.next):(l=n,n=n.next),t&&t.mode==l.mode&&!l.context&&!t.context)continue;let o=new ku(l.tags,l.mode,l.context);t?t.next=o:i=o,t=o}return i}});class ku{constructor(e,t,i,l){this.tags=e,this.mode=t,this.context=i,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=l;for(let u of o)for(let f of u.set){let d=t[f.id];if(d){a=a?a+" "+d:d;break}}return a},scope:i}}function rL(n,e){let t=null;for(let i of n){let l=i.style(e);l&&(t=t?t+" "+l:l)}return t}function lL(n,e,t,i=0,l=n.length){let o=new sL(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,l,"",o.highlighters),o.flush(l)}class sL{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,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,i,l,o){let{type:a,from:u,to:f}=e;if(u>=i||f<=t)return;a.isTop&&(o=this.highlighters.filter(v=>!v.scope||v.scope(a)));let d=l,m=oL(e)||ku.empty,g=rL(o,m.tags);if(g&&(d&&(d+=" "),d+=g,m.mode==1&&(l+=(l?" ":"")+g)),this.startSpan(Math.max(t,u),d),m.opaque)return;let b=e.tree&&e.tree.prop(nt.mounted);if(b&&b.overlay){let v=e.node.enter(b.overlay[0].from+u,1),w=this.highlighters.filter(C=>!C.scope||C.scope(b.tree.type)),S=e.firstChild();for(let C=0,N=u;;C++){let j=C=M||!e.nextSibling())););if(!j||M>i)break;N=j.to+u,N>t&&(this.highlightRange(v.cursor(),Math.max(t,j.from+u),Math.min(i,N),"",w),this.startSpan(Math.min(i,N),d))}S&&e.parent()}else if(e.firstChild()){b&&(l="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,l,o),this.startSpan(Math.min(i,e.to),d)}while(e.nextSibling());e.parent()}}}function oL(n){let e=n.type.prop(XN);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const Se=ol.define,_h=Se(),Wl=Se(),ZS=Se(Wl),JS=Se(Wl),Zl=Se(),Lh=Se(Zl),g0=Se(Zl),Ar=Se(),$s=Se(Ar),Nr=Se(),Tr=Se(),Ux=Se(),Vc=Se(Ux),zh=Se(),me={comment:_h,lineComment:Se(_h),blockComment:Se(_h),docComment:Se(_h),name:Wl,variableName:Se(Wl),typeName:ZS,tagName:Se(ZS),propertyName:JS,attributeName:Se(JS),className:Se(Wl),labelName:Se(Wl),namespace:Se(Wl),macroName:Se(Wl),literal:Zl,string:Lh,docString:Se(Lh),character:Se(Lh),attributeValue:Se(Lh),number:g0,integer:Se(g0),float:Se(g0),bool:Se(Zl),regexp:Se(Zl),escape:Se(Zl),color:Se(Zl),url:Se(Zl),keyword:Nr,self:Se(Nr),null:Se(Nr),atom:Se(Nr),unit:Se(Nr),modifier:Se(Nr),operatorKeyword:Se(Nr),controlKeyword:Se(Nr),definitionKeyword:Se(Nr),moduleKeyword:Se(Nr),operator:Tr,derefOperator:Se(Tr),arithmeticOperator:Se(Tr),logicOperator:Se(Tr),bitwiseOperator:Se(Tr),compareOperator:Se(Tr),updateOperator:Se(Tr),definitionOperator:Se(Tr),typeOperator:Se(Tr),controlOperator:Se(Tr),punctuation:Ux,separator:Se(Ux),bracket:Vc,angleBracket:Se(Vc),squareBracket:Se(Vc),paren:Se(Vc),brace:Se(Vc),content:Ar,heading:$s,heading1:Se($s),heading2:Se($s),heading3:Se($s),heading4:Se($s),heading5:Se($s),heading6:Se($s),contentSeparator:Se(Ar),list:Se(Ar),quote:Se(Ar),emphasis:Se(Ar),strong:Se(Ar),link:Se(Ar),monospace:Se(Ar),strikethrough:Se(Ar),inserted:Se(),deleted:Se(),changed:Se(),invalid:Se(),meta:zh,documentMeta:Se(zh),annotation:Se(zh),processingInstruction:Se(zh),definition:ol.defineModifier("definition"),constant:ol.defineModifier("constant"),function:ol.defineModifier("function"),standard:ol.defineModifier("standard"),local:ol.defineModifier("local"),special:ol.defineModifier("special")};for(let n in me){let e=me[n];e instanceof ol&&(e.name=n)}$N([{tag:me.link,class:"tok-link"},{tag:me.heading,class:"tok-heading"},{tag:me.emphasis,class:"tok-emphasis"},{tag:me.strong,class:"tok-strong"},{tag:me.keyword,class:"tok-keyword"},{tag:me.atom,class:"tok-atom"},{tag:me.bool,class:"tok-bool"},{tag:me.url,class:"tok-url"},{tag:me.labelName,class:"tok-labelName"},{tag:me.inserted,class:"tok-inserted"},{tag:me.deleted,class:"tok-deleted"},{tag:me.literal,class:"tok-literal"},{tag:me.string,class:"tok-string"},{tag:me.number,class:"tok-number"},{tag:[me.regexp,me.escape,me.special(me.string)],class:"tok-string2"},{tag:me.variableName,class:"tok-variableName"},{tag:me.local(me.variableName),class:"tok-variableName tok-local"},{tag:me.definition(me.variableName),class:"tok-variableName tok-definition"},{tag:me.special(me.variableName),class:"tok-variableName2"},{tag:me.definition(me.propertyName),class:"tok-propertyName tok-definition"},{tag:me.typeName,class:"tok-typeName"},{tag:me.namespace,class:"tok-namespace"},{tag:me.className,class:"tok-className"},{tag:me.macroName,class:"tok-macroName"},{tag:me.propertyName,class:"tok-propertyName"},{tag:me.operator,class:"tok-operator"},{tag:me.comment,class:"tok-comment"},{tag:me.meta,class:"tok-meta"},{tag:me.invalid,class:"tok-invalid"},{tag:me.punctuation,class:"tok-punctuation"}]);var x0;const pa=new nt;function aL(n){return Ne.define({combine:n?e=>e.concat(n):void 0})}const cL=new nt;class ar{constructor(e,t,i=[],l=""){this.data=e,this.name=l,gt.prototype.hasOwnProperty("tree")||Object.defineProperty(gt.prototype,"tree",{get(){return Vn(this)}}),this.parser=t,this.extension=[hs.of(this),gt.languageData.of((o,a,u)=>{let f=e2(o,a,u),d=f.type.prop(pa);if(!d)return[];let m=o.facet(d),g=f.type.prop(cL);if(g){let b=f.resolve(a-f.from,u);for(let v of g)if(v.test(b,o)){let w=o.facet(v.facet);return v.type=="replace"?w:w.concat(m)}}return m})].concat(i)}isActiveAt(e,t,i=-1){return e2(e,t,i).type.prop(pa)==this.data}findRegions(e){let t=e.facet(hs);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],l=(o,a)=>{if(o.prop(pa)==this.data){i.push({from:a,to:a+o.length});return}let u=o.prop(nt.mounted);if(u){if(u.tree.prop(pa)==this.data){if(u.overlay)for(let f of u.overlay)i.push({from:f.from+a,to:f.to+a});else i.push({from:a,to:a+o.length});return}else if(u.overlay){let f=i.length;if(l(u.tree,u.overlay[0].from+a),i.length>f)return}}for(let f=0;fi.isTop?t:void 0)]}),e.name)}configure(e,t){return new Ad(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Vn(n){let e=n.field(ar.state,!1);return e?e.tree:un.empty}class uL{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 i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let Qc=null;class Ed{constructor(e,t,i=[],l,o,a,u,f){this.parser=e,this.state=t,this.fragments=i,this.tree=l,this.treeLen=o,this.viewport=a,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new Ed(e,t,[],un.empty,0,i,[],null)}startParse(){return this.parser.startParse(new uL(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=un.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let l=Date.now()+e;e=()=>Date.now()>l}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=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(so.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Qc;Qc=this;try{return e()}finally{Qc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=t2(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:l,treeLen:o,viewport:a,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((d,m,g,b)=>f.push({fromA:d,toA:m,fromB:g,toB:b})),i=so.applyChanges(i,f),l=un.empty,o=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){u=[];for(let d of this.skipped){let m=e.mapPos(d.from,1),g=e.mapPos(d.to,-1);me.from&&(this.fragments=t2(this.fragments,l,o),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends VN{createParse(t,i,l){let o=l[0].from,a=l[l.length-1].to;return{parsedPos:o,advance(){let f=Qc;if(f){for(let d of l)f.tempSkipped.push(d);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=a,new un(yi.none,[],[],a-o)},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 Qc}}function t2(n,e,t){return so.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class _a{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new _a(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Ed.create(e.facet(hs).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new _a(i)}}ar.state=Qn.define({create:_a.init,update(n,e){for(let t of e.effects)if(t.is(ar.setState))return t.value;return e.startState.facet(hs)!=e.state.facet(hs)?_a.init(e.state):n.apply(e)}});let YN=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(YN=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const y0=typeof navigator<"u"&&(!((x0=navigator.scheduling)===null||x0===void 0)&&x0.isInputPending)?()=>navigator.scheduling.isInputPending():null,fL=en.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(ar.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(ar.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=YN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndl+1e3,f=o.context.work(()=>y0&&y0()||Date.now()>a,l+(u?0:1e5));this.chunkBudget-=Date.now()-t,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:ar.setState.of(new _a(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>gi(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),hs=Ne.define({combine(n){return n.length?n[0]:null},enables:n=>[ar.state,fL,Ee.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class hL{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const dL=Ne.define(),Vy=Ne.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Md(n){let e=n.facet(Vy);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Su(n,e){let t="",i=n.tabSize,l=n.facet(Vy)[0];if(l==" "){for(;e>=i;)t+=" ",e-=i;l=" "}for(let o=0;o=e?mL(n,t,e):null}class am{constructor(e,t={}){this.state=e,this.options=t,this.unit=Md(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:l,simulateDoubleBreak:o}=this.options;return l!=null&&l>=i.from&&l<=i.to?o&&l==e?{text:"",from:e}:(t<0?l-1&&(o+=a-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return Ba(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:l}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let a=o(l);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const GN=new nt;function mL(n,e,t){let i=e.resolveStack(t),l=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(l!=i.node){let o=[];for(let a=l;a&&!(a.fromi.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)o.push(a);for(let a=o.length-1;a>=0;a--)i={node:o[a],next:i}}return KN(i,n,t)}function KN(n,e,t){for(let i=n;i;i=i.next){let l=gL(i.node);if(l)return l(Xy.create(e,t,i))}return 0}function pL(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function gL(n){let e=n.type.prop(GN);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(nt.closedBy))){let l=n.lastChild,o=l&&i.indexOf(l.name)>-1;return a=>WN(a,!0,1,void 0,o&&!pL(a)?l.from:void 0)}return n.parent==null?xL:null}function xL(){return 0}class Xy extends am{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Xy(e,t,i)}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 i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(yL(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return KN(this.context.next,this.base,this.pos)}}function yL(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function bL(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let l=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),a=l==null||l<=o.from?o.to:Math.min(o.to,l);for(let u=t.to;;){let f=e.childAfter(u);if(!f||f==i)return null;if(!f.type.isSkipped){if(f.from>=a)return null;let d=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+d}}u=f.to}}function n2({closing:n,align:e=!0,units:t=1}){return i=>WN(i,e,t,n)}function WN(n,e,t,i,l){let o=n.textAfter,a=o.match(/^\s*/)[0].length,u=i&&o.slice(a,a+i.length)==i||l==n.pos+a,f=e?bL(n):null;return f?u?n.column(f.from):n.column(f.to):n.baseIndent+(u?0:n.unit*t)}const vL=200;function wL(){return gt.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,l=t.lineAt(i);if(i>l.from+vL)return n;let o=t.sliceString(l.from,i);if(!e.some(d=>d.test(o)))return n;let{state:a}=n,u=-1,f=[];for(let{head:d}of a.selection.ranges){let m=a.doc.lineAt(d);if(m.from==u)continue;u=m.from;let g=Qy(a,m.from);if(g==null)continue;let b=/^\s*/.exec(m.text)[0],v=Su(a,g);b!=v&&f.push({from:m.from,to:m.from+b.length,insert:v})}return f.length?[n,{changes:f,sequential:!0}]:n})}const kL=Ne.define(),ZN=new nt;function SL(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(o&&u.from=e&&d.to>t&&(o=d)}}return o}function OL(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function Dd(n,e,t){for(let i of n.facet(kL)){let l=i(n,e,t);if(l)return l}return CL(n,e,t)}function JN(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const cm=Ke.define({map:JN}),Lu=Ke.define({map:JN});function eT(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const fo=Qn.define({create(){return Fe.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,l)=>n=i2(n,i,l)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(cm)&&!NL(n,i.value.from,i.value.to)?t.push(i.value):i.is(Lu)&&(n=n.update({filter:(l,o)=>i.value.from!=l||i.value.to!=o,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(iT),l=t.map(o=>(i?Fe.replace({widget:new jL(i(e.state,o))}):r2).range(o.from,o.to));n=n.update({add:l})}return e.selection&&(n=i2(n,e.selection.main.head)),n},provide:n=>Ee.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,l)=>{t.push(i,l)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{le&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(l,o)=>l>=t||o<=e}):n}function Rd(n,e,t){var i;let l=null;return(i=n.field(fo,!1))===null||i===void 0||i.between(e,t,(o,a)=>{(!l||l.from>o)&&(l={from:o,to:a})}),l}function NL(n,e,t){let i=!1;return n.between(e,e,(l,o)=>{l==e&&o==t&&(i=!0)}),i}function tT(n,e){return n.field(fo,!1)?e:e.concat(Ke.appendConfig.of(rT()))}const TL=n=>{for(let e of eT(n)){let t=Dd(n.state,e.from,e.to);if(t)return n.dispatch({effects:tT(n.state,[cm.of(t),nT(n,t)])}),!0}return!1},AL=n=>{if(!n.state.field(fo,!1))return!1;let e=[];for(let t of eT(n)){let i=Rd(n.state,t.from,t.to);i&&e.push(Lu.of(i),nT(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function nT(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,l=n.state.doc.lineAt(e.to).number;return Ee.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${l}.`)}const EL=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(fo,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,l)=>{t.push(Lu.of({from:i,to:l}))}),n.dispatch({effects:t}),!0},DL=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:TL},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:AL},{key:"Ctrl-Alt-[",run:EL},{key:"Ctrl-Alt-]",run:ML}],RL={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},iT=Ne.define({combine(n){return Ur(n,RL)}});function rT(n){return[fo,zL]}function lT(n,e){let{state:t}=n,i=t.facet(iT),l=a=>{let u=n.lineBlockAt(n.posAtDOM(a.target)),f=Rd(n.state,u.from,u.to);f&&n.dispatch({effects:Lu.of(f)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,l,e);let o=document.createElement("span");return o.textContent=i.placeholderText,o.setAttribute("aria-label",t.phrase("folded code")),o.title=t.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=l,o}const r2=Fe.replace({widget:new class extends gl{toDOM(n){return lT(n,null)}}});class jL extends gl{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return lT(e,this.value)}}const _L={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class b0 extends dl{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 LL(n={}){let e={..._L,...n},t=new b0(e,!0),i=new b0(e,!1),l=en.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet(hs)!=a.state.facet(hs)||a.startState.field(fo,!1)!=a.state.field(fo,!1)||Vn(a.startState)!=Vn(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let u=new Hr;for(let f of a.viewportLineBlocks){let d=Rd(a.state,f.from,f.to)?i:Dd(a.state,f.from,f.to)?t:null;d&&u.add(f.from,f.from,d)}return u.finish()}}),{domEventHandlers:o}=e;return[l,z_({class:"cm-foldGutter",markers(a){var u;return((u=a.plugin(l))===null||u===void 0?void 0:u.markers)||lt.empty},initialSpacer(){return new b0(e,!1)},domEventHandlers:{...o,click:(a,u,f)=>{if(o.click&&o.click(a,u,f))return!0;let d=Rd(a.state,u.from,u.to);if(d)return a.dispatch({effects:Lu.of(d)}),!0;let m=Dd(a.state,u.from,u.to);return m?(a.dispatch({effects:cm.of(m)}),!0):!1}}}),rT()]}const zL=Ee.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"}});class zu{constructor(e,t){this.specs=e;let i;function l(u){let f=as.newName();return(i||(i=Object.create(null)))["."+f]=u,f}const o=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,a=t.scope;this.scope=a instanceof ar?u=>u.prop(pa)==a.data:a?u=>u==a:void 0,this.style=$N(e.map(u=>({tag:u.tag,class:u.class||l(Object.assign({},u,{tag:null}))})),{all:o}).style,this.module=i?new as(i):null,this.themeType=t.themeType}static define(e,t){return new zu(e,t||{})}}const Fx=Ne.define(),sT=Ne.define({combine(n){return n.length?[n[0]]:null}});function v0(n){let e=n.facet(Fx);return e.length?e:n.facet(sT)}function oT(n,e){let t=[PL],i;return n instanceof zu&&(n.module&&t.push(Ee.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(sT.of(n)):i?t.push(Fx.computeN([Ee.darkTheme],l=>l.facet(Ee.darkTheme)==(i=="dark")?[n]:[])):t.push(Fx.of(n)),t}class BL{constructor(e){this.markCache=Object.create(null),this.tree=Vn(e.state),this.decorations=this.buildDeco(e,v0(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Vn(e.state),i=v0(e.state),l=i!=v0(e.startState),{viewport:o}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||l)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return Fe.none;let i=new Hr;for(let{from:l,to:o}of e.visibleRanges)lL(this.tree,t,(a,u,f)=>{i.add(a,u,this.markCache[f]||(this.markCache[f]=Fe.mark({class:f})))},l,o);return i.finish()}}const PL=mo.high(en.fromClass(BL,{decorations:n=>n.decorations})),HL=zu.define([{tag:me.meta,color:"#404740"},{tag:me.link,textDecoration:"underline"},{tag:me.heading,textDecoration:"underline",fontWeight:"bold"},{tag:me.emphasis,fontStyle:"italic"},{tag:me.strong,fontWeight:"bold"},{tag:me.strikethrough,textDecoration:"line-through"},{tag:me.keyword,color:"#708"},{tag:[me.atom,me.bool,me.url,me.contentSeparator,me.labelName],color:"#219"},{tag:[me.literal,me.inserted],color:"#164"},{tag:[me.string,me.deleted],color:"#a11"},{tag:[me.regexp,me.escape,me.special(me.string)],color:"#e40"},{tag:me.definition(me.variableName),color:"#00f"},{tag:me.local(me.variableName),color:"#30a"},{tag:[me.typeName,me.namespace],color:"#085"},{tag:me.className,color:"#167"},{tag:[me.special(me.variableName),me.macroName],color:"#256"},{tag:me.definition(me.propertyName),color:"#00c"},{tag:me.comment,color:"#940"},{tag:me.invalid,color:"#f00"}]),IL=Ee.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),aT=1e4,cT="()[]{}",uT=Ne.define({combine(n){return Ur(n,{afterCursor:!0,brackets:cT,maxScanDistance:aT,renderMatch:qL})}}),UL=Fe.mark({class:"cm-matchingBracket"}),FL=Fe.mark({class:"cm-nonmatchingBracket"});function qL(n){let e=[],t=n.matched?UL:FL;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function l2(n){let e=[],t=n.facet(uT);for(let i of n.selection.ranges){if(!i.empty)continue;let l=Lr(n,i.head,-1,t)||i.head>0&&Lr(n,i.head-1,1,t)||t.afterCursor&&(Lr(n,i.head,1,t)||i.headn.decorations}),QL=[VL,IL];function XL(n={}){return[uT.of(n),QL]}const $L=new nt;function qx(n,e,t){let i=n.prop(e<0?nt.openedBy:nt.closedBy);if(i)return i;if(n.name.length==1){let l=t.indexOf(n.name);if(l>-1&&l%2==(e<0?1:0))return[t[l+e]]}return null}function Vx(n){let e=n.type.prop($L);return e?e(n.node):n}function Lr(n,e,t,i={}){let l=i.maxScanDistance||aT,o=i.brackets||cT,a=Vn(n),u=a.resolveInner(e,t);for(let f=u;f;f=f.parent){let d=qx(f.type,t,o);if(d&&f.from0?e>=m.from&&em.from&&e<=m.to))return YL(n,e,t,f,m,d,o)}}return GL(n,e,t,a,u.type,l,o)}function YL(n,e,t,i,l,o,a){let u=i.parent,f={from:l.from,to:l.to},d=0,m=u==null?void 0:u.cursor();if(m&&(t<0?m.childBefore(i.from):m.childAfter(i.to)))do if(t<0?m.to<=i.from:m.from>=i.to){if(d==0&&o.indexOf(m.type.name)>-1&&m.from0)return null;let d={from:t<0?e-1:e,to:t>0?e+1:e},m=n.doc.iterRange(e,t>0?n.doc.length:0),g=0;for(let b=0;!m.next().done&&b<=o;){let v=m.value;t<0&&(b+=v.length);let w=e+b*t;for(let S=t>0?0:v.length-1,C=t>0?v.length:-1;S!=C;S+=t){let N=a.indexOf(v[S]);if(!(N<0||i.resolveInner(w+S,1).type!=l))if(N%2==0==t>0)g++;else{if(g==1)return{start:d,end:{from:w+S,to:w+S+1},matched:N>>1==f>>1};g--}}t>0&&(b+=v.length)}return m.done?{start:d,matched:!1}:null}const KL=Object.create(null),s2=[yi.none],o2=[],a2=Object.create(null),WL=Object.create(null);for(let[n,e]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"]])WL[n]=ZL(KL,e);function w0(n,e){o2.indexOf(n)>-1||(o2.push(n),console.warn(e))}function ZL(n,e){let t=[];for(let u of e.split(" ")){let f=[];for(let d of u.split(".")){let m=n[d]||me[d];m?typeof m=="function"?f.length?f=f.map(m):w0(d,`Modifier ${d} used at start of tag`):f.length?w0(d,`Tag ${d} used as modifier`):f=Array.isArray(m)?m:[m]:w0(d,`Unknown highlighting tag ${d}`)}for(let d of f)t.push(d)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),l=i+" "+t.map(u=>u.id),o=a2[l];if(o)return o.id;let a=a2[l]=yi.define({id:s2.length,name:i,props:[QN({[i]:t})]});return s2.push(a),a.id}At.RTL,At.LTR;const JL=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=Yy(n.state,t.from);return i.line?ez(n):i.block?nz(n):!1};function $y(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let l=n(e,t);return l?(i(t.update(l)),!0):!1}}const ez=$y(lz,0),tz=$y(fT,0),nz=$y((n,e)=>fT(n,e,rz(e)),0);function Yy(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const Xc=50;function iz(n,{open:e,close:t},i,l){let o=n.sliceDoc(i-Xc,i),a=n.sliceDoc(l,l+Xc),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(a)[0].length,d=o.length-u;if(o.slice(d-e.length,d)==e&&a.slice(f,f+t.length)==t)return{open:{pos:i-u,margin:u&&1},close:{pos:l+f,margin:f&&1}};let m,g;l-i<=2*Xc?m=g=n.sliceDoc(i,l):(m=n.sliceDoc(i,i+Xc),g=n.sliceDoc(l-Xc,l));let b=/^\s*/.exec(m)[0].length,v=/\s*$/.exec(g)[0].length,w=g.length-v-t.length;return m.slice(b,b+e.length)==e&&g.slice(w,w+t.length)==t?{open:{pos:i+b+e.length,margin:/\s/.test(m.charAt(b+e.length))?1:0},close:{pos:l-v-t.length,margin:/\s/.test(g.charAt(w-1))?1:0}}:null}function rz(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),l=t.to<=i.to?i:n.doc.lineAt(t.to);l.from>i.from&&l.from==t.to&&(l=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=l.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:l.to})}return e}function fT(n,e,t=e.selection.ranges){let i=t.map(o=>Yy(e,o.from).block);if(!i.every(o=>o))return null;let l=t.map((o,a)=>iz(e,i[a],o.from,o.to));if(n!=2&&!l.every(o=>o))return{changes:e.changes(t.map((o,a)=>l[a]?[]:[{from:o.from,insert:i[a].open+" "},{from:o.to,insert:" "+i[a].close}]))};if(n!=1&&l.some(o=>o)){let o=[];for(let a=0,u;al&&(o==a||a>g.from)){l=g.from;let b=/^\s*/.exec(g.text)[0].length,v=b==g.length,w=g.text.slice(b,b+d.length)==d?b:-1;bo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:d,empty:m,single:g}of i)(g||!m)&&o.push({from:u.from+d,insert:f+" "});let a=e.changes(o);return{changes:a,selection:e.selection.map(a,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:a,comment:u,token:f}of i)if(u>=0){let d=a.from+u,m=d+f.length;a.text[m-a.from]==" "&&m++,o.push({from:d,to:m})}return{changes:o}}return null}const Qx=pl.define(),sz=pl.define(),oz=Ne.define(),hT=Ne.define({combine(n){return Ur(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,l)=>e(i,l)||t(i,l)})}}),dT=Qn.define({create(){return zr.empty},update(n,e){let t=e.state.facet(hT),i=e.annotation(Qx);if(i){let f=xi.fromTransaction(e,i.selection),d=i.side,m=d==0?n.undone:n.done;return f?m=jd(m,m.length,t.minDepth,f):m=gT(m,e.startState.selection),new zr(d==0?i.rest:m,d==0?m:i.rest)}let l=e.annotation(sz);if((l=="full"||l=="before")&&(n=n.isolate()),e.annotation(pn.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let o=xi.fromTransaction(e),a=e.annotation(pn.time),u=e.annotation(pn.userEvent);return o?n=n.addChanges(o,a,u,t,e):e.selection&&(n=n.addSelection(e.startState.selection,a,u,t.newGroupDelay)),(l=="full"||l=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new zr(n.done.map(xi.fromJSON),n.undone.map(xi.fromJSON))}});function az(n={}){return[dT,hT.of(n),Ee.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?mT:e.inputType=="historyRedo"?Xx:null;return i?(e.preventDefault(),i(t)):!1}})]}function um(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let l=t.field(dT,!1);if(!l)return!1;let o=l.pop(n,t,e);return o?(i(o),!0):!1}}const mT=um(0,!1),Xx=um(1,!1),cz=um(0,!0),uz=um(1,!0);class xi{constructor(e,t,i,l,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=l,this.selectionsAfter=o}setSelAfter(e){return new xi(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(e){return new xi(e.changes&&mn.fromJSON(e.changes),[],e.mapped&&Pr.fromJSON(e.mapped),e.startSelection&&le.fromJSON(e.startSelection),e.selectionsAfter.map(le.fromJSON))}static fromTransaction(e,t){let i=Xi;for(let l of e.startState.facet(oz)){let o=l(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new xi(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,Xi)}static selection(e){return new xi(void 0,Xi,void 0,void 0,e)}}function jd(n,e,t,i){let l=e+1>t+20?e-t-1:0,o=n.slice(l,e);return o.push(i),o}function fz(n,e){let t=[],i=!1;return n.iterChangedRanges((l,o)=>t.push(l,o)),e.iterChangedRanges((l,o,a,u)=>{for(let f=0;f=d&&a<=m&&(i=!0)}}),i}function hz(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function pT(n,e){return n.length?e.length?n.concat(e):n:e}const Xi=[],dz=200;function gT(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-dz));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),jd(n,n.length-1,1e9,t.setSelAfter(i)))}else return[xi.selection([e])]}function mz(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function k0(n,e){if(!n.length)return n;let t=n.length,i=Xi;for(;t;){let l=pz(n[t-1],e,i);if(l.changes&&!l.changes.empty||l.effects.length){let o=n.slice(0,t);return o[t-1]=l,o}else e=l.mapped,t--,i=l.selectionsAfter}return i.length?[xi.selection(i)]:Xi}function pz(n,e,t){let i=pT(n.selectionsAfter.length?n.selectionsAfter.map(u=>u.map(e)):Xi,t);if(!n.changes)return xi.selection(i);let l=n.changes.map(e),o=e.mapDesc(n.changes,!0),a=n.mapped?n.mapped.composeDesc(o):o;return new xi(l,Ke.mapEffects(n.effects,e),a,n.startSelection.map(o),i)}const gz=/^(input\.type|delete)($|\.)/;class zr{constructor(e,t,i=0,l=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=l}isolate(){return this.prevTime?new zr(this.done,this.undone):this}addChanges(e,t,i,l,o){let a=this.done,u=a[a.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!i||gz.test(i))&&(!u.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):fm(t,e))}function Xn(n){return n.textDirectionAt(n.state.selection.main.head)==At.LTR}const yT=n=>xT(n,!Xn(n)),bT=n=>xT(n,Xn(n));function vT(n,e){return dr(n,t=>t.empty?n.moveByGroup(t,e):fm(t,e))}const yz=n=>vT(n,!Xn(n)),bz=n=>vT(n,Xn(n));function vz(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function hm(n,e,t){let i=Vn(n).resolveInner(e.head),l=t?nt.closedBy:nt.openedBy;for(let f=e.head;;){let d=t?i.childAfter(f):i.childBefore(f);if(!d)break;vz(n,d,l)?i=d:f=t?d.to:d.from}let o=i.type.prop(l),a,u;return o&&(a=t?Lr(n,i.from,1):Lr(n,i.to,-1))&&a.matched?u=t?a.end.to:a.end.from:u=t?i.to:i.from,le.cursor(u,t?-1:1)}const wz=n=>dr(n,e=>hm(n.state,e,!Xn(n))),kz=n=>dr(n,e=>hm(n.state,e,Xn(n)));function wT(n,e){return dr(n,t=>{if(!t.empty)return fm(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const kT=n=>wT(n,!1),ST=n=>wT(n,!0);function CT(n){let e=n.scrollDOM.clientHeighta.empty?n.moveVertically(a,e,t.height):fm(a,e));if(l.eq(i.selection))return!1;let o;if(t.selfScroll){let a=n.coordsAtPos(i.selection.main.head),u=n.scrollDOM.getBoundingClientRect(),f=u.top+t.marginTop,d=u.bottom-t.marginBottom;a&&a.top>f&&a.bottomOT(n,!1),$x=n=>OT(n,!0);function ps(n,e,t){let i=n.lineBlockAt(e.head),l=n.moveToLineBoundary(e,t);if(l.head==e.head&&l.head!=(t?i.to:i.from)&&(l=n.moveToLineBoundary(e,t,!1)),!t&&l.head==i.from&&i.length){let o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(l=le.cursor(i.from+o))}return l}const Sz=n=>dr(n,e=>ps(n,e,!0)),Cz=n=>dr(n,e=>ps(n,e,!1)),Oz=n=>dr(n,e=>ps(n,e,!Xn(n))),Nz=n=>dr(n,e=>ps(n,e,Xn(n))),Tz=n=>dr(n,e=>n.moveToLineBoundary(e,!1,!1)),Az=n=>dr(n,e=>n.moveToLineBoundary(e,!0,!1));function Ez(n,e,t){let i=!1,l=Pa(n.selection,o=>{let a=Lr(n,o.head,-1)||Lr(n,o.head,1)||o.head>0&&Lr(n,o.head-1,1)||o.headEz(n,e);function Gi(n,e,t){let i=Pa(n.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=e&&(l=le.range(l.head,l.anchor));let o=t(l);return le.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(hr(n.state,i)),!0)}function NT(n,e){return Gi(n,e,t=>n.moveByChar(t,e))}const TT=n=>NT(n,!Xn(n)),AT=n=>NT(n,Xn(n));function ET(n,e){return Gi(n,e,t=>n.moveByGroup(t,e))}const Dz=n=>ET(n,!Xn(n)),Rz=n=>ET(n,Xn(n)),jz=n=>{let e=!Xn(n);return Gi(n,e,t=>hm(n.state,t,e))},_z=n=>{let e=Xn(n);return Gi(n,e,t=>hm(n.state,t,e))};function MT(n,e){return Gi(n,e,t=>n.moveVertically(t,e))}const DT=n=>MT(n,!1),RT=n=>MT(n,!0);function jT(n,e){return Gi(n,e,t=>n.moveVertically(t,e,CT(n).height))}const u2=n=>jT(n,!1),f2=n=>jT(n,!0),Lz=n=>Gi(n,!0,e=>ps(n,e,!0)),zz=n=>Gi(n,!1,e=>ps(n,e,!1)),Bz=n=>{let e=!Xn(n);return Gi(n,e,t=>ps(n,t,e))},Pz=n=>{let e=Xn(n);return Gi(n,e,t=>ps(n,t,e))},Hz=n=>Gi(n,!1,e=>le.cursor(n.lineBlockAt(e.head).from)),Iz=n=>Gi(n,!0,e=>le.cursor(n.lineBlockAt(e.head).to)),h2=({state:n,dispatch:e})=>(e(hr(n,{anchor:0})),!0),d2=({state:n,dispatch:e})=>(e(hr(n,{anchor:n.doc.length})),!0),m2=({state:n,dispatch:e})=>(e(hr(n,{anchor:n.selection.main.anchor,head:0})),!0),p2=({state:n,dispatch:e})=>(e(hr(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),Uz=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Fz=({state:n,dispatch:e})=>{let t=dm(n).map(({from:i,to:l})=>le.undirectionalRange(i,Math.min(l+1,n.doc.length)));return e(n.update({selection:le.create(t),userEvent:"select"})),!0},qz=({state:n,dispatch:e})=>{let t=Pa(n.selection,i=>{let l=Vn(n),o=l.resolveStack(i.from,1);if(i.empty){let a=l.resolveStack(i.from,-1);a.node.from>=o.node.from&&a.node.to<=o.node.to&&(o=a)}for(let a=o;a;a=a.next){let{node:u}=a;if((u.from=i.to||u.to>i.to&&u.from<=i.from)&&a.next)return le.undirectionalRange(u.from,u.to)}return i});return t.eq(n.selection)?!1:(e(hr(n,t)),!0)};function _T(n,e){let{state:t}=n,i=t.selection,l=t.selection.ranges.slice();for(let o of t.selection.ranges){let a=t.doc.lineAt(o.head);if(e?a.to0)for(let u=o;;){let f=n.moveVertically(u,e);if(f.heada.to){l.some(d=>d.head==f.head)||l.push(f);break}else{if(f.head==u.head)break;u=f}}}return l.length==i.ranges.length?!1:(n.dispatch(hr(t,le.create(l,l.length-1))),!0)}const Vz=n=>_T(n,!1),Qz=n=>_T(n,!0),Xz=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=le.create([t.main]):t.main.empty||(i=le.create([le.cursor(t.main.head)])),i?(e(hr(n,i)),!0):!1};function Bu(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,l=i.changeByRange(o=>{let{from:a,to:u}=o;if(a==u){let f=e(o);fa&&(t="delete.forward",f=Bh(n,f,!0)),a=Math.min(a,f),u=Math.max(u,f)}else a=Bh(n,a,!1),u=Bh(n,u,!0);return a==u?{range:o}:{changes:{from:a,to:u},range:le.cursor(a,al(n)))i.between(e,e,(l,o)=>{le&&(e=t?o:l)});return e}const LT=(n,e,t)=>Bu(n,i=>{let l=i.from,{state:o}=n,a=o.doc.lineAt(l),u,f;if(t&&!e&&l>a.from&&lLT(n,!1,!0),zT=n=>LT(n,!0,!1),BT=(n,e)=>Bu(n,t=>{let i=t.head,{state:l}=n,o=l.doc.lineAt(i),a=l.charCategorizer(i);for(let u=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?l.doc.lines:1)&&(i+=e?1:-1);break}let f=wn(o.text,i-o.from,e)+o.from,d=o.text.slice(Math.min(i,f)-o.from,Math.max(i,f)-o.from),m=a(d);if(u!=null&&m!=u)break;(d!=" "||i!=t.head)&&(u=m),i=f}return i}),PT=n=>BT(n,!1),$z=n=>BT(n,!0),Yz=n=>Bu(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headBu(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),Kz=n=>Bu(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:pt.of(["",""])},range:le.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},Zz=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let l=i.from,o=n.doc.lineAt(l),a=l==o.from?l-1:wn(o.text,l-o.from,!1)+o.from,u=l==o.to?l+1:wn(o.text,l-o.from,!0)+o.from;return{changes:{from:a,to:u,insert:n.doc.slice(l,u).append(n.doc.slice(a,l))},range:le.cursor(u)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function dm(n){let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=l.number){let a=e[e.length-1];a.to=o.to,a.ranges.push(i)}else e.push({from:l.from,to:o.to,ranges:[i]});t=o.number+1}return e}function HT(n,e,t){if(n.readOnly)return!1;let i=[],l=[];for(let o of dm(n)){if(t?o.to==n.doc.length:o.from==0)continue;let a=n.doc.lineAt(t?o.to+1:o.from-1),u=a.length+1;if(t){i.push({from:o.to,to:a.to},{from:o.from,insert:a.text+n.lineBreak});for(let f of o.ranges)l.push(le.range(Math.min(n.doc.length,f.anchor+u),Math.min(n.doc.length,f.head+u)))}else{i.push({from:a.from,to:o.from},{from:o.to,insert:n.lineBreak+a.text});for(let f of o.ranges)l.push(le.range(f.anchor-u,f.head-u))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:le.create(l,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const Jz=({state:n,dispatch:e})=>HT(n,e,!1),e6=({state:n,dispatch:e})=>HT(n,e,!0);function IT(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of dm(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.to)});let l=n.changes(i);return e(n.update({changes:l,selection:n.selection.map(l,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const t6=({state:n,dispatch:e})=>IT(n,e,!1),n6=({state:n,dispatch:e})=>IT(n,e,!0),i6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(dm(e).map(({from:l,to:o})=>(l>0?l--:o{let o;if(n.lineWrapping){let a=n.lineBlockAt(l.head),u=n.coordsAtPos(l.head,l.assoc||1);u&&(o=a.bottom+n.documentTop-u.bottom+n.defaultLineHeight/2)}return n.moveVertically(l,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function r6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Vn(n).resolveInner(e),i=t.childBefore(e),l=t.childAfter(e),o;return i&&l&&i.to<=e&&l.from>=e&&(o=i.type.prop(nt.closedBy))&&o.indexOf(l.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(l.from).from&&!/\S/.test(n.sliceDoc(i.to,l.from))?{from:i.to,to:l.from}:null}const g2=UT(!1),l6=UT(!0);function UT(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(l=>{let{from:o,to:a}=l,u=e.doc.lineAt(o),f=!n&&o==a&&r6(e,o);n&&(o=a=(a<=u.to?u:e.doc.lineAt(a)).to);let d=new am(e,{simulateBreak:o,simulateDoubleBreak:!!f}),m=Qy(d,o);for(m==null&&(m=Ba(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));au.from&&o{let l=[];for(let a=i.from;a<=i.to;){let u=n.doc.lineAt(a);u.number>t&&(i.empty||i.to>u.from)&&(e(u,l,i),t=u.number),a=u.to+1}let o=n.changes(l);return{changes:l,range:le.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}const s6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new am(n,{overrideIndentation:o=>{let a=t[o];return a??-1}}),l=Gy(n,(o,a,u)=>{let f=Qy(i,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let d=/^\s*/.exec(o.text)[0],m=Su(n,f);(d!=m||u.fromn.readOnly?!1:(e(n.update(Gy(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Vy)})}),{userEvent:"input.indent"})),!0),a6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Gy(n,(t,i)=>{let l=/^\s*/.exec(t.text)[0];if(!l)return;let o=Ba(l,n.tabSize),a=0,u=Su(n,Math.max(0,o-Md(n)));for(;a(n.setTabFocusMode(),!0),u6=[{key:"Ctrl-b",run:yT,shift:TT,preventDefault:!0},{key:"Ctrl-f",run:bT,shift:AT},{key:"Ctrl-p",run:kT,shift:DT},{key:"Ctrl-n",run:ST,shift:RT},{key:"Ctrl-a",run:Tz,shift:Hz},{key:"Ctrl-e",run:Az,shift:Iz},{key:"Ctrl-d",run:zT},{key:"Ctrl-h",run:Yx},{key:"Ctrl-k",run:Yz},{key:"Ctrl-Alt-h",run:PT},{key:"Ctrl-o",run:Wz},{key:"Ctrl-t",run:Zz},{key:"Ctrl-v",run:$x}],f6=[{key:"ArrowLeft",run:yT,shift:TT,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:yz,shift:Dz,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Oz,shift:Bz,preventDefault:!0},{key:"ArrowRight",run:bT,shift:AT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:bz,shift:Rz,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Nz,shift:Pz,preventDefault:!0},{key:"ArrowUp",run:kT,shift:DT,preventDefault:!0},{mac:"Cmd-ArrowUp",run:h2,shift:m2},{mac:"Ctrl-ArrowUp",run:c2,shift:u2},{key:"ArrowDown",run:ST,shift:RT,preventDefault:!0},{mac:"Cmd-ArrowDown",run:d2,shift:p2},{mac:"Ctrl-ArrowDown",run:$x,shift:f2},{key:"PageUp",run:c2,shift:u2},{key:"PageDown",run:$x,shift:f2},{key:"Home",run:Cz,shift:zz,preventDefault:!0},{key:"Mod-Home",run:h2,shift:m2},{key:"End",run:Sz,shift:Lz,preventDefault:!0},{key:"Mod-End",run:d2,shift:p2},{key:"Enter",run:g2,shift:g2},{key:"Mod-a",run:Uz},{key:"Backspace",run:Yx,shift:Yx,preventDefault:!0},{key:"Delete",run:zT,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:PT,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$z,preventDefault:!0},{mac:"Mod-Backspace",run:Gz,preventDefault:!0},{mac:"Mod-Delete",run:Kz,preventDefault:!0}].concat(u6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),h6=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:wz,shift:jz},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:kz,shift:_z},{key:"Alt-ArrowUp",run:Jz},{key:"Shift-Alt-ArrowUp",run:t6},{key:"Alt-ArrowDown",run:e6},{key:"Shift-Alt-ArrowDown",run:n6},{key:"Mod-Alt-ArrowUp",run:Vz},{key:"Mod-Alt-ArrowDown",run:Qz},{key:"Escape",run:Xz},{key:"Mod-Enter",run:l6},{key:"Alt-l",mac:"Ctrl-l",run:Fz},{key:"Mod-i",run:qz,preventDefault:!0},{key:"Mod-[",run:a6},{key:"Mod-]",run:o6},{key:"Mod-Alt-\\",run:s6},{key:"Shift-Mod-k",run:i6},{key:"Shift-Mod-\\",run:Mz},{key:"Mod-/",run:JL},{key:"Alt-A",mac:"Ctrl-A",run:tz},{key:"Ctrl-m",mac:"Shift-Alt-m",run:c6}].concat(f6),x2=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class La{constructor(e,t,i=0,l=e.length,o,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(i,l),this.bufferStart=i,this.normalize=o?u=>o(x2(u)):x2,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 di(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=ky(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=Rr(e);let l=this.normalize(t);if(l.length)for(let o=0,a=i,u=!0;;o++){let f=l.charCodeAt(o),d=this.match(f,a,u,this.bufferPos+this.bufferStart,o==l.length-1);if(d)return this.value=d,this;if(o==l.length-1)break;u&&othis.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 i=this.curLineStart+t.index,l=i+t[0].length;if(this.matchPos=_d(this.text,l+(i==l?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||l.to<=t){let u=new ka(t,e.sliceString(t,i));return S0.set(e,u),u}if(l.from==t&&l.to==i)return l;let{text:o,from:a}=l;return a>t&&(o=e.sliceString(t,a)+o,a=t),l.to=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 i=this.flat.from+t.index,l=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this.matchPos=_d(this.text,l+(i==l?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=ka.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(qT.prototype[Symbol.iterator]=VT.prototype[Symbol.iterator]=function(){return this});function d6(n){try{return new RegExp(n,Ky),!0}catch{return!1}}function _d(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const m6=n=>{let e=R_(n,"cm-goto-line");if(e){let a=e.dom.querySelector("input[type=text]");return a&&a.select(),!0}let{state:t}=n,i=String(t.doc.lineAt(n.state.selection.main.head).number),{close:l,result:o}=D_(n,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return o.then(a=>{let u=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!u){n.dispatch({effects:l});return}let f=t.doc.lineAt(t.selection.main.head),[,d,m,g,b]=u,v=g?+g.slice(1):0,w=m?+m:f.number;if(m&&b){let N=w/100;d&&(N=N*(d=="-"?-1:1)+f.number/t.doc.lines),w=Math.round(t.doc.lines*N)}else m&&d&&(w=w*(d=="-"?-1:1)+f.number);let S=t.doc.line(Math.max(1,Math.min(t.doc.lines,w))),C=le.cursor(S.from+Math.max(0,Math.min(v,S.length)));n.dispatch({effects:[l,Ee.scrollIntoView(C.from,{y:"center"})],selection:C})}),!0},p6={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},g6=Ne.define({combine(n){return Ur(n,p6,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function x6(n){return[k6,w6]}const y6=Fe.mark({class:"cm-selectionMatch"}),b6=Fe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function y2(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=Ut.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=Ut.Word)}function v6(n,e,t,i){return n(e.sliceDoc(t,t+1))==Ut.Word&&n(e.sliceDoc(i-1,i))==Ut.Word}const w6=en.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(g6),{state:t}=n,i=t.selection;if(i.ranges.length>1)return Fe.none;let l=i.main,o,a=null;if(l.empty){if(!e.highlightWordAroundCursor)return Fe.none;let f=t.wordAt(l.head);if(!f)return Fe.none;a=t.charCategorizer(l.head),o=t.sliceDoc(f.from,f.to)}else{let f=l.to-l.from;if(f200)return Fe.none;if(e.wholeWords){if(o=t.sliceDoc(l.from,l.to),a=t.charCategorizer(l.head),!(y2(a,t,l.from,l.to)&&v6(a,t,l.from,l.to)))return Fe.none}else if(o=t.sliceDoc(l.from,l.to),!o)return Fe.none}let u=[];for(let f of n.visibleRanges){let d=new La(t.doc,o,f.from,f.to);for(;!d.next().done;){let{from:m,to:g}=d.value;if((!a||y2(a,t,m,g))&&(l.empty&&m<=l.from&&g>=l.to?u.push(b6.range(m,g)):(m>=l.to||g<=l.from)&&u.push(y6.range(m,g)),u.length>e.maxMatches))return Fe.none}}return Fe.set(u)}},{decorations:n=>n.decorations}),k6=Ee.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),S6=({state:n,dispatch:e})=>{let{selection:t}=n,i=le.create(t.ranges.map(l=>n.wordAt(l.head)||le.cursor(l.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function C6(n,e){let{main:t,ranges:i}=n.selection,l=n.wordAt(t.head),o=l&&l.from==t.from&&l.to==t.to;for(let a=!1,u=new La(n.doc,e,i[i.length-1].to);;)if(u.next(),u.done){if(a)return null;u=new La(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(f=>f.from==u.value.from))continue;if(o){let f=n.wordAt(u.value.from);if(!f||f.from!=u.value.from||f.to!=u.value.to)continue}return u.value}}const O6=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(o=>o.from===o.to))return S6({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(o=>n.sliceDoc(o.from,o.to)!=i))return!1;let l=C6(n,i);return l?(e(n.update({selection:n.selection.addRange(le.range(l.from,l.to),!1),effects:Ee.scrollIntoView(l.to)})),!0):!1},Ha=Ne.define({combine(n){return Ur(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new H6(e),scrollToMatch:e=>Ee.scrollIntoView(e)})}});class QT{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||d6(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,(t,i)=>i=="n"?` -`:i=="r"?"\r":i=="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 D6(this):new A6(this)}getCursor(e,t=0,i){let l=e.doc?e:gt.create({doc:e});return i==null&&(i=l.doc.length),this.regexp?aa(this,l,t,i):oa(this,l,t,i)}}class XT{constructor(e){this.spec=e}}function N6(n,e,t){return(i,l,o,a)=>{if(t&&!t(i,l,o,a))return!1;let u=i>=a&&l<=a+o.length?o.slice(i-a,l-a):e.doc.sliceString(i,l);return n(u,e,i,l)}}function oa(n,e,t,i){let l;return n.wholeWord&&(l=T6(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(l=N6(n.test,e,l)),new La(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:o=>o.toLowerCase(),l)}function T6(n,e){return(t,i,l,o)=>((o>t||o+l.length=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=oa(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}function E6(n,e,t){return(i,l,o)=>(!t||t(i,l,o))&&n(o[0],e,i,l)}function aa(n,e,t,i){let l;return n.wholeWord&&(l=M6(e.charCategorizer(e.selection.main.head))),n.test&&(l=E6(n.test,e,l)),new qT(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:l},t,i)}function Ld(n,e){return n.slice(wn(n,e,!1),e)}function zd(n,e){return n.slice(e,wn(n,e))}function M6(n){return(e,t,i)=>!i[0].length||(n(Ld(i.input,i.index))!=Ut.Word||n(zd(i.input,i.index))!=Ut.Word)&&(n(zd(i.input,i.index+i[0].length))!=Ut.Word||n(Ld(i.input,i.index+i[0].length))!=Ut.Word)}class D6 extends XT{nextMatch(e,t,i){let l=aa(this.spec,e,i,e.doc.length).next();return l.done&&(l=aa(this.spec,e,0,t).next()),l.done?null:l.value}prevMatchInRange(e,t,i){for(let l=1;;l++){let o=Math.max(t,i-l*1e4),a=aa(this.spec,e,o,i),u=null;for(;!a.next().done;)u=a.value;if(u&&(o==t||u.from>o+10))return u;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let l=i.length;l>0;l--){let o=+i.slice(0,l);if(o>0&&o=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=aa(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}const Cu=Ke.define(),Wy=Ke.define(),ls=Qn.define({create(n){return new C0(Gx(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Cu)?n=new C0(t.value.create(),n.panel):t.is(Wy)&&(n=new C0(n.query,t.value?Zy:null));return n},provide:n=>vu.from(n,e=>e.panel)});class C0{constructor(e,t){this.query=e,this.panel=t}}const R6=Fe.mark({class:"cm-searchMatch"}),j6=Fe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),_6=en.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(ls))}update(n){let e=n.state.field(ls);(e!=n.startState.field(ls)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Fe.none;let{view:t}=this,i=new Hr;for(let l=0,o=t.visibleRanges,a=o.length;lo[l+1].from-500;)f=o[++l].to;n.highlight(t.state,u,f,(d,m)=>{let g=t.state.selection.ranges.some(b=>b.from==d&&b.to==m);i.add(d,m,g?j6:R6)})}return i.finish()}},{decorations:n=>n.decorations});function Pu(n){return e=>{let t=e.state.field(ls,!1);return t&&t.query.spec.valid?n(e,t):GT(e)}}const Bd=Pu((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let l=le.single(i.from,i.to),o=n.state.facet(Ha);return n.dispatch({selection:l,effects:[Jy(n,i),o.scrollToMatch(l.main,n)],userEvent:"select.search"}),YT(n),!0}),Pd=Pu((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,l=e.prevMatch(t,i,i);if(!l)return!1;let o=le.single(l.from,l.to),a=n.state.facet(Ha);return n.dispatch({selection:o,effects:[Jy(n,l),a.scrollToMatch(o.main,n)],userEvent:"select.search"}),YT(n),!0}),L6=Pu((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:le.create(t.map(i=>le.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),z6=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:l}=t.main,o=[],a=0;for(let u=new La(n.doc,n.sliceDoc(i,l));!u.next().done;){if(o.length>1e3)return!1;u.value.from==i&&(a=o.length),o.push(le.range(u.value.from,u.value.to))}return e(n.update({selection:le.create(o,a),userEvent:"select.search.matches"})),!0},b2=Pu((n,{query:e})=>{let{state:t}=n,{from:i,to:l}=t.selection.main;if(t.readOnly)return!1;let o=e.nextMatch(t,i,i);if(!o)return!1;let a=o,u=[],f,d,m=[];a.precise?a.from==i&&a.to==l&&(d=t.toText(e.getReplacement(a)),u.push({from:a.from,to:a.to,insert:d}),a=e.nextMatch(t,a.from,a.to),m.push(Ee.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):a=e.nextMatch(t,a.from,a.to);let g=n.state.changes(u);return a&&(f=le.single(a.from,a.to).map(g),m.push(Jy(n,a)),m.push(t.facet(Ha).scrollToMatch(f.main,n))),n.dispatch({changes:g,selection:f,effects:m,userEvent:"input.replace"}),!0}),B6=Pu((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let l of e.matchAll(n.state,1e9)){let{from:o,to:a,precise:u}=l;u&&t.push({from:o,to:a,insert:e.getReplacement(l)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:Ee.announce.of(i),userEvent:"input.replace.all"}),!0});function Zy(n){return n.state.facet(Ha).createPanel(n)}function Gx(n,e){var t,i,l,o,a;let u=n.selection.main,f=u.empty||u.to>u.from+100?"":n.sliceDoc(u.from,u.to);if(e&&!f)return e;let d=n.facet(Ha);return new QT({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:d.literal)?f:f.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:d.caseSensitive,literal:(l=e==null?void 0:e.literal)!==null&&l!==void 0?l:d.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:d.regexp,wholeWord:(a=e==null?void 0:e.wholeWord)!==null&&a!==void 0?a:d.wholeWord})}function $T(n){let e=om(n,Zy);return e&&e.dom.querySelector("[main-field]")}function YT(n){let e=$T(n);e&&e==n.root.activeElement&&e.select()}const GT=n=>{let e=n.state.field(ls,!1);if(e&&e.panel){let t=$T(n);if(t&&t!=n.root.activeElement){let i=Gx(n.state,e.query.spec);i.valid&&n.dispatch({effects:Cu.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Wy.of(!0),e?Cu.of(Gx(n.state,e.query.spec)):Ke.appendConfig.of(U6)]});return!0},KT=n=>{let e=n.state.field(ls,!1);if(!e||!e.panel)return!1;let t=om(n,Zy);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Wy.of(!1)}),!0},P6=[{key:"Mod-f",run:GT,scope:"editor search-panel"},{key:"F3",run:Bd,shift:Pd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:Bd,shift:Pd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:KT,scope:"editor search-panel"},{key:"Mod-Shift-l",run:z6},{key:"Mod-Alt-g",run:m6},{key:"Mod-d",run:O6,preventDefault:!0}];class H6{constructor(e){this.view=e;let t=this.query=e.state.field(ls).query.spec;this.commit=this.commit.bind(this),this.searchField=Tt("input",{value:t.search,placeholder:Ei(e,"Find"),"aria-label":Ei(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Tt("input",{value:t.replace,placeholder:Ei(e,"Replace"),"aria-label":Ei(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Tt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Tt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Tt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(l,o,a){return Tt("button",{class:"cm-button",name:l,onclick:o,type:"button"},a)}this.dom=Tt("div",{onkeydown:l=>this.keydown(l),class:"cm-search"},[this.searchField,i("next",()=>Bd(e),[Ei(e,"next")]),i("prev",()=>Pd(e),[Ei(e,"previous")]),i("select",()=>L6(e),[Ei(e,"all")]),Tt("label",null,[this.caseField,Ei(e,"match case")]),Tt("label",null,[this.reField,Ei(e,"regexp")]),Tt("label",null,[this.wordField,Ei(e,"by word")]),...e.state.readOnly?[]:[Tt("br"),this.replaceField,i("replace",()=>b2(e),[Ei(e,"replace")]),i("replaceAll",()=>B6(e),[Ei(e,"replace all")])],Tt("button",{name:"close",onclick:()=>KT(e),"aria-label":Ei(e,"close"),type:"button"},["×"])])}commit(){let e=new QT({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:Cu.of(e)}))}keydown(e){Uj(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Pd:Bd)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),b2(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Cu)&&!i.value.eq(this.query)&&this.setQuery(i.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(Ha).top}}function Ei(n,e){return n.state.phrase(e)}const Ph=30,Hh=/[\s\.,:;?!]/;function Jy(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),l=n.state.doc.lineAt(t).to,o=Math.max(i.from,e-Ph),a=Math.min(l,t+Ph),u=n.state.sliceDoc(o,a);if(o!=i.from){for(let f=0;fu.length-Ph;f--)if(!Hh.test(u[f-1])&&Hh.test(u[f])){u=u.slice(0,f);break}}return Ee.announce.of(`${n.state.phrase("current match")}. ${u} ${n.state.phrase("on line")} ${i.number}.`)}const I6=Ee.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"}}),U6=[ls,mo.low(_6),I6];class WT{constructor(e,t,i,l){this.state=e,this.pos=t,this.explicit=i,this.view=l,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Vn(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),i=Math.max(t.from,this.pos-250),l=t.text.slice(i-t.from,this.pos-t.from),o=l.search(ZT(e,!1));return o<0?null:{from:i+o,to:this.pos,text:l.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function v2(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function F6(n){let e=Object.create(null),t=Object.create(null);for(let{label:l}of n){e[l[0]]=!0;for(let o=1;otypeof l=="string"?{label:l}:l),[t,i]=e.every(l=>/^\w+$/.test(l.label))?[/\w*$/,/\w+$/]:F6(e);return l=>{let o=l.matchBefore(i);return o||l.explicit?{from:o?o.from:l.pos,options:e,validFor:t}:null}}class w2{constructor(e,t,i,l){this.completion=e,this.source=t,this.match=i,this.score=l}}function oo(n){return n.selection.main.from}function ZT(n,e){var t;let{source:i}=n,l=e&&i[0]!="^",o=i[i.length-1]!="$";return!l&&!o?n:new RegExp(`${l?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const JT=pl.define();function V6(n,e,t,i){let{main:l}=n.selection,o=t-l.from,a=i-l.from;return{...n.changeByRange(u=>{if(u!=l&&t!=i&&n.sliceDoc(u.from+o,u.from+a)!=n.sliceDoc(t,i))return{range:u};let f=n.toText(e);return{changes:{from:u.from+o,to:i==l.from?u.to:u.from+a,insert:f},range:le.cursor(u.from+o+f.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const k2=new WeakMap;function Q6(n){if(!Array.isArray(n))return n;let e=k2.get(n);return e||k2.set(n,e=q6(n)),e}const Hd=Ke.define(),Ou=Ke.define();class X6{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=48&&H<=57||H>=97&&H<=122?2:H>=65&&H<=90?1:0:(E=ky(H))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!j||D==1&&C||U==0&&D!=0)&&(t[g]==H||i[g]==H&&(b=!0)?a[g++]=j:a.length&&(N=!1)),U=D,j+=Rr(H)}return g==f&&a[0]==0&&N?this.result(-100+(b?-200:0),a,e):v==f&&w==0?this.ret(-200-e.length+(S==e.length?0:-100),[0,S]):u>-1?this.ret(-700-e.length,[u,u+this.pattern.length]):v==f?this.ret(-900-e.length,[w,S]):g==f?this.result(-100+(b?-200:0)+-700+(N?0:-1100),a,e):t.length==2?null:this.result((l[0]?-700:0)+-200+-1100,l,e)}result(e,t,i){let l=[],o=0;for(let a of t){let u=a+(this.astral?Rr(di(i,a)):1);o&&l[o-1]==a?l[o-1]=u:(l[o++]=a,l[o++]=u)}return this.ret(e-i.length,l)}}class $6{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Y6,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)=>i=>S2(e(i),t(i)),optionClass:(e,t)=>i=>S2(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function S2(n,e){return n?e?n+" "+e:n:e}function Y6(n,e,t,i,l,o){let a=n.textDirection==At.RTL,u=a,f=!1,d="top",m,g,b=e.left-l.left,v=l.right-e.right,w=i.right-i.left,S=i.bottom-i.top;if(u&&b=S||j>e.top?m=t.bottom-e.top:(d="bottom",m=e.bottom-t.top)}let C=(e.bottom-e.top)/o.offsetHeight,N=(e.right-e.left)/o.offsetWidth;return{style:`${d}: ${m/C}px; max-width: ${g/N}px`,class:"cm-completionInfo-"+(f?a?"left-narrow":"right-narrow":u?"left":"right")}}const eb=Ke.define();function G6(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(l=>"cm-completionIcon-"+l)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,l,o){let a=document.createElement("span");a.className="cm-completionLabel";let u=t.displayLabel||t.label,f=0;for(let d=0;df&&a.appendChild(document.createTextNode(u.slice(f,m)));let b=a.appendChild(document.createElement("span"));b.appendChild(document.createTextNode(u.slice(m,g))),b.className="cm-completionMatchedText",f=g}return ft.position-i.position).map(t=>t.render)}function O0(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let l=Math.floor(e/t);return{from:l*t,to:(l+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class K6{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:f=>this.placeInfo(f),key:this},this.space=null,this.currentClass="";let l=e.state.field(t),{options:o,selected:a}=l.open,u=e.state.facet(vn);this.optionContent=G6(u),this.optionClass=u.optionClass,this.tooltipClass=u.tooltipClass,this.range=O0(o.length,a,u.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",f=>{let{options:d}=e.state.field(t).open;for(let m=f.target,g;m&&m!=this.dom;m=m.parentNode)if(m.nodeName=="LI"&&(g=/-(\d+)$/.exec(m.id))&&+g[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;m!=null&&(e.dispatch({effects:eb.of(m)}),f.preventDefault())}}),this.dom.addEventListener("focusout",f=>{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(vn).closeOnBlur&&f.relatedTarget!=e.contentDOM&&e.dispatch({effects:Ou.of(null)})}),this.showOptions(o,l.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){var t;let i=e.state.field(this.stateField),l=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=l){let{options:o,selected:a,disabled:u}=i.open;(!l.open||l.open.options!=o)&&(this.range=O0(o.length,a,e.state.facet(vn).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),u!=((t=l.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!u)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);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.to)&&(this.range=O0(t.options.length,t.selected,this.view.state.facet(vn).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:l}=t.options[t.selected],{info:o}=l;if(!o)return;let a=typeof o=="string"?document.createTextNode(o):o(l);if(!a)return;"then"in a?a.then(u=>{u&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(u,l)}).catch(u=>gi(this.view.state,u,"completion info")):(this.addInfoPane(a,l),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:l,destroy:o}=e;i.appendChild(l),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,l=this.range.from;i;i=i.nextSibling,l++)i.nodeName!="LI"||!i.id?l--:l==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&Z6(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),l=e.getBoundingClientRect(),o=this.space;if(!o){let a=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return l.top>Math.min(o.bottom,t.bottom)-10||l.bottom{a.target==l&&a.preventDefault()});let o=null;for(let a=i.from;ai.from||i.from==0))if(o=b,typeof d!="string"&&d.header)l.appendChild(d.header(d));else{let v=l.appendChild(document.createElement("completion-section"));v.textContent=b}}const m=l.appendChild(document.createElement("li"));m.id=t+"-"+a,m.setAttribute("role","option");let g=this.optionClass(u);g&&(m.className=g);for(let b of this.optionContent){let v=b(u,this.view.state,this.view,f);v&&m.appendChild(v)}}return i.from&&l.classList.add("cm-completionListIncompleteTop"),i.tonew K6(t,n,e)}function Z6(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),l=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/l)}function C2(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function J6(n,e){let t=[],i=null,l=null,o=m=>{t.push(m);let{section:g}=m.completion;if(g){i||(i=[]);let b=typeof g=="string"?g:g.name;i.some(v=>v.name==b)||i.push(typeof g=="string"?{name:b}:g)}},a=e.facet(vn);for(let m of n)if(m.hasResult()){let g=m.result.getMatch;if(m.result.filter===!1)for(let b of m.result.options)o(new w2(b,m.source,g?g(b):[],1e9-t.length));else{let b=e.sliceDoc(m.from,m.to),v,w=a.filterStrict?new $6(b):new X6(b);for(let S of m.result.options)if(v=w.match(S.label)){let C=S.displayLabel?g?g(S,v.matched):[]:v.matched,N=v.score+(S.boost||0);if(o(new w2(S,m.source,C,N)),typeof S.section=="object"&&S.section.rank==="dynamic"){let{name:j}=S.section;l||(l=Object.create(null)),l[j]=Math.max(N,l[j]||-1e9)}}}}if(i){let m=Object.create(null),g=0,b=(v,w)=>(v.rank==="dynamic"&&w.rank==="dynamic"?l[w.name]-l[v.name]:0)||(typeof v.rank=="number"?v.rank:1e9)-(typeof w.rank=="number"?w.rank:1e9)||(v.nameb.score-g.score||d(g.completion,b.completion))){let g=m.completion;!f||f.label!=g.label||f.detail!=g.detail||f.type!=null&&g.type!=null&&f.type!=g.type||f.apply!=g.apply||f.boost!=g.boost?u.push(m):C2(m.completion)>C2(f)&&(u[u.length-1]=m),f=m.completion}return u}class ga{constructor(e,t,i,l,o,a){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=l,this.selected=o,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new ga(this.options,O2(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,l,o,a){if(l&&!a&&e.some(d=>d.isPending))return l.setDisabled();let u=J6(e,t);if(!u.length)return l&&e.some(d=>d.isPending)?l.setDisabled():null;let f=t.facet(vn).selectOnOpen?0:-1;if(l&&l.selected!=f&&l.selected!=-1){let d=l.options[l.selected].completion;for(let m=0;mm.hasResult()?Math.min(d,m.from):d,1e8),create:lB,above:o.aboveCursor},l?l.timestamp:Date.now(),f,!1)}map(e){return new ga(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new ga(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class Id{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new Id(iB,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(vn),o=(i.override||t.languageDataAt("autocomplete",oo(t)).map(Q6)).map(f=>(this.active.find(m=>m.source==f)||new $i(f,this.active.some(m=>m.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((f,d)=>f==this.active[d])&&(o=this.active);let a=this.open,u=e.effects.some(f=>f.is(tb));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||o.some(f=>f.hasResult()&&e.changes.touchesRange(f.from,f.to))||!eB(o,this.active)||u?a=ga.build(o,t,this.id,a,i,u):a&&a.disabled&&!o.some(f=>f.isPending)&&(a=null),!a&&o.every(f=>!f.isPending)&&o.some(f=>f.hasResult())&&(o=o.map(f=>f.hasResult()?new $i(f.source,0):f));for(let f of e.effects)f.is(eb)&&(a=a&&a.setSelected(f.value,this.id));return o==this.active&&a==this.open?this:new Id(o,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?tB:nB}}function eB(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const iB=[];function eA(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(JT);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class $i{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=eA(e,t),l=this;(i&8||i&16&&this.touches(e))&&(l=new $i(l.source,0)),i&4&&l.state==0&&(l=new $i(this.source,1)),l=l.updateFor(e,i);for(let o of e.effects)if(o.is(Hd))l=new $i(l.source,1,o.value);else if(o.is(Ou))l=new $i(l.source,0);else if(o.is(tb))for(let a of o.value)a.source==l.source&&(l=a);return l}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(oo(e.state))}}class Sa extends $i{constructor(e,t,i,l,o,a){super(e,3,t),this.limit=i,this.result=l,this.from=o,this.to=a}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let l=this.result;l.map&&!e.changes.empty&&(l=l.map(l,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),u=oo(e.state);if(u>a||!l||t&2&&(oo(e.startState)==this.from||ut.map(e))}}),mi=Qn.define({create(){return Id.start()},update(n,e){return n.update(e)},provide:n=>[Hy.from(n,e=>e.tooltip),Ee.contentAttributes.from(n,e=>e.attrs)]});function nb(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(mi).active.find(l=>l.source==e.source);return i instanceof Sa?(typeof t=="string"?n.dispatch({...V6(n.state,t,i.from,i.to),annotations:JT.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const lB=W6(mi,nb);function Ih(n,e="option"){return t=>{let i=t.state.field(mi,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+l*(n?1:-1):n?0:a-1;return u<0?u=e=="page"?0:a-1:u>=a&&(u=e=="page"?a-1:0),t.dispatch({effects:eb.of(u)}),!0}}const sB=n=>{let e=n.state.field(mi,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(mi,!1)?(n.dispatch({effects:Hd.of(!0)}),!0):!1,oB=n=>{let e=n.state.field(mi,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Ou.of(null)}),!0)};class aB{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const cB=50,uB=1e3,fB=en.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(mi).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(mi),t=n.state.facet(vn);if(!n.selectionSet&&!n.docChanged&&n.startState.field(mi)==e)return;let i=n.transactions.some(o=>{let a=eA(o,t);return a&8||(o.selection||o.docChanged)&&!(a&3)});for(let o=0;ocB&&Date.now()-a.time>uB){for(let u of a.context.abortListeners)try{u()}catch(f){gi(this.view.state,f)}a.context.abortListeners=null,this.running.splice(o--,1)}else a.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(a=>a.is(Hd)))&&(this.pendingStart=!0);let l=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(a=>a.active.source==o.source))?setTimeout(()=>this.startUpdate(),l):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(mi);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(vn).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=oo(e),i=new WT(e,t,n.explicit,this.view),l=new aB(n,i);this.running.push(l),Promise.resolve(n.source(i)).then(o=>{l.context.aborted||(l.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Ou.of(null)}),gi(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(vn).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(vn),i=this.view.state.field(mi);for(let l=0;lu.source==o.active.source);if(a&&a.isPending)if(o.done==null){let u=new $i(o.active.source,0);for(let f of o.updates)u=u.update(f,t);u.isPending||e.push(u)}else this.startQuery(a)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:tb.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(mi,!1);if(e&&e.tooltip&&this.view.state.facet(vn).closeOnBlur){let t=e.open&&_N(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Ou.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Hd.of(!1)}),20),this.composing=0}}}),hB=typeof navigator=="object"&&/Win/.test(navigator.platform),dB=mo.highest(Ee.domEventHandlers({keydown(n,e){let t=e.state.field(mi,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(hB&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],l=t.active.find(a=>a.source==i.source),o=i.completion.commitCharacters||l.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&nb(e,i),!1}})),mB=Ee.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"}}}),Nu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},no=Ke.define({map(n,e){let t=e.mapPos(n,-1,ni.TrackAfter);return t??void 0}}),ib=new class extends os{};ib.startSide=1;ib.endSide=-1;const tA=Qn.define({create(){return lt.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(no)&&(n=n.update({add:[ib.range(t.value,t.value+1)]}));return n}});function pB(){return[xB,tA]}const T0="()[]{}<>«»»«[]{}";function nA(n){for(let e=0;e{if((gB?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let l=n.state.selection.main;if(i.length>2||i.length==2&&Rr(di(i,0))==1||e!=l.from||t!=l.to)return!1;let o=vB(n.state,i);return o?(n.dispatch(o),!0):!1}),yB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=iA(n,n.selection.main.head).brackets||Nu.brackets,l=null,o=n.changeByRange(a=>{if(a.empty){let u=wB(n.doc,a.head);for(let f of i)if(f==u&&mm(n.doc,a.head)==nA(di(f,0)))return{changes:{from:a.head-f.length,to:a.head+f.length},range:le.cursor(a.head-f.length)}}return{range:l=a}});return l||e(n.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!l},bB=[{key:"Backspace",run:yB}];function vB(n,e){let t=iA(n,n.selection.main.head),i=t.brackets||Nu.brackets;for(let l of i){let o=nA(di(l,0));if(e==l)return o==l?CB(n,l,i.indexOf(l+l+l)>-1,t):kB(n,l,o,t.before||Nu.before);if(e==o&&rA(n,n.selection.main.from))return SB(n,l,o)}return null}function rA(n,e){let t=!1;return n.field(tA).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function mm(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Rr(di(t,0)))}function wB(n,e){let t=n.sliceString(e-2,e);return Rr(di(t,0))==t.length?t:t.slice(1)}function kB(n,e,t,i){let l=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:no.of(a.to+e.length),range:le.range(a.anchor+e.length,a.head+e.length)};let u=mm(n.doc,a.head);return!u||/\s/.test(u)||i.indexOf(u)>-1?{changes:{insert:e+t,from:a.head},effects:no.of(a.head+e.length),range:le.cursor(a.head+e.length)}:{range:l=a}});return l?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function SB(n,e,t){let i=null,l=n.changeByRange(o=>o.empty&&mm(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:le.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function CB(n,e,t,i){let l=i.stringPrefixes||Nu.stringPrefixes,o=null,a=n.changeByRange(u=>{if(!u.empty)return{changes:[{insert:e,from:u.from},{insert:e,from:u.to}],effects:no.of(u.to+e.length),range:le.range(u.anchor+e.length,u.head+e.length)};let f=u.head,d=mm(n.doc,f),m;if(d==e){if(N2(n,f))return{changes:{insert:e+e,from:f},effects:no.of(f+e.length),range:le.cursor(f+e.length)};if(rA(n,f)){let b=t&&n.sliceDoc(f,f+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:f,to:f+b.length,insert:b},range:le.cursor(f+b.length)}}}else{if(t&&n.sliceDoc(f-2*e.length,f)==e+e&&(m=T2(n,f-2*e.length,l))>-1&&N2(n,m))return{changes:{insert:e+e+e+e,from:f},effects:no.of(f+e.length),range:le.cursor(f+e.length)};if(n.charCategorizer(f)(d)!=Ut.Word&&T2(n,f,l)>-1&&!OB(n,f,e,l))return{changes:{insert:e+e,from:f},effects:no.of(f+e.length),range:le.cursor(f+e.length)}}return{range:o=u}});return o?null:n.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function N2(n,e){let t=Vn(n).resolveInner(e+1);return t.parent&&t.from==e}function OB(n,e,t,i){let l=Vn(n).resolveInner(e,-1),o=i.reduce((a,u)=>Math.max(a,u.length),0);for(let a=0;a<5;a++){let u=n.sliceDoc(l.from,Math.min(l.to,l.from+t.length+o)),f=u.indexOf(t);if(!f||f>-1&&i.indexOf(u.slice(0,f))>-1){let m=l.firstChild;for(;m&&m.from==l.from&&m.to-m.from>t.length+f;){if(n.sliceDoc(m.to-t.length,m.to)==t)return!1;m=m.firstChild}return!0}let d=l.to==e&&l.parent;if(!d)break;l=d}return!1}function T2(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Ut.Word)return e;for(let l of t){let o=e-l.length;if(n.sliceDoc(o,e)==l&&i(n.sliceDoc(o-1,o))!=Ut.Word)return o}return-1}function NB(n={}){return[dB,mi,vn.of(n),fB,TB,mB]}const lA=[{key:"Ctrl-Space",run:N0},{mac:"Alt-`",run:N0},{mac:"Alt-i",run:N0},{key:"Escape",run:oB},{key:"ArrowDown",run:Ih(!0)},{key:"ArrowUp",run:Ih(!1)},{key:"PageDown",run:Ih(!0,"page")},{key:"PageUp",run:Ih(!1,"page")},{key:"Enter",run:sB}],TB=mo.highest(By.computeN([vn],n=>n.facet(vn).defaultKeymap?[lA]:[]));class A2{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class Js{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let l=i.facet(Tu).markerFilter;l&&(e=l(e,i));let o=e.slice().sort((v,w)=>v.from-w.from||v.to-w.to),a=new Hr,u=[],f=0,d=i.doc.iter(),m=0,g=i.doc.length;for(let v=0;;){let w=v==o.length?null:o[v];if(!w&&!u.length)break;let S,C;if(u.length)S=f,C=u.reduce((M,U)=>Math.min(M,U.to),w&&w.from>S?w.from:1e8);else{if(S=w.from,S>g)break;C=w.to,u.push(w),v++}for(;vM.from||M.to==S))u.push(M),v++,C=Math.min(M.to,C);else{C=Math.min(M.from,C);break}}C=Math.min(C,g);let N=!1;if(u.some(M=>M.from==S&&(M.to==C||C==g))&&(N=S==C,!N&&C-S<10)){let M=S-(m+d.value.length);M>0&&(d.next(M),m=S);for(let U=S;;){if(U>=C){N=!0;break}if(!d.lineBreak&&m+d.value.length>U)break;U=m+d.value.length,m+=d.value.length,d.next()}}let j=IB(u);if(N)a.add(S,S,Fe.widget({widget:new zB(j),diagnostics:u.slice()}));else{let M=u.reduce((U,H)=>H.markClass?U+" "+H.markClass:U,"");a.add(S,C,Fe.mark({class:"cm-lintRange cm-lintRange-"+j+M,diagnostics:u.slice(),inclusiveEnd:u.some(U=>U.to>C)}))}if(f=C,f==g)break;for(let M=0;M{if(!(e&&a.diagnostics.indexOf(e)<0))if(!i)i=new A2(l,o,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new A2(i.from,o,i.diagnostic)}}),i}function AB(n,e){let t=e.pos,i=e.end||t,l=n.state.facet(Tu).hideOn(n,t,i);if(l!=null)return l;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(a=>a.is(sA))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function EB(n,e){return n.field(ji,!1)?e:e.concat(Ke.appendConfig.of(UB))}const sA=Ke.define(),rb=Ke.define(),oA=Ke.define(),ji=Qn.define({create(){return new Js(Fe.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,l=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);i=ds(t,n.selected.diagnostic,o)||ds(t,null,o)}!t.size&&l&&e.state.facet(Tu).autoPanel&&(l=null),n=new Js(t,l,i)}for(let t of e.effects)if(t.is(sA)){let i=e.state.facet(Tu).autoPanel?t.value.length?Au.open:null:n.panel;n=Js.init(t.value,i,e.state)}else t.is(rb)?n=new Js(n.diagnostics,t.value?Au.open:null,n.selected):t.is(oA)&&(n=new Js(n.diagnostics,n.panel,t.value));return n},provide:n=>[vu.from(n,e=>e.panel),Ee.decorations.from(n,e=>e.diagnostics)]}),MB=Fe.mark({class:"cm-lintRange cm-lintRange-active"});function DB(n,e,t){let{diagnostics:i}=n.state.field(ji),l,o=-1,a=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(f,d,{spec:m})=>{if(e>=f&&e<=d&&(f==d||(e>f||t>0)&&(ecA(n,t,!1)))}const jB=n=>{let e=n.state.field(ji,!1);(!e||!e.panel)&&n.dispatch({effects:EB(n.state,[rb.of(!0)])});let t=om(n,Au.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},E2=n=>{let e=n.state.field(ji,!1);return!e||!e.panel?!1:(n.dispatch({effects:rb.of(!1)}),!0)},_B=n=>{let e=n.state.field(ji,!1);if(!e)return!1;let t=n.state.selection.main,i=ds(e.diagnostics,null,t.to+1);return!i&&(i=ds(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),E_(n,i.from,1,{tooltip:uA,until:l=>l.docChanged||l.newSelection.main.headi.to}),!0)},LB=[{key:"Mod-Shift-m",run:jB,preventDefault:!0},{key:"F8",run:_B}],Tu=Ne.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Ur(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:M2,tooltipFilter:M2,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,l,o)=>e(i,l,o)||t(i,l,o):e:t,autoPanel:(e,t)=>e||t})}}});function M2(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function aA(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;io.toLowerCase()==l.toLowerCase())){e.push(l);continue e}}e.push("")}return e}function cA(n,e,t){var i;let l=t?aA(e.actions):[];return Tt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Tt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,a)=>{let u=!1,f=v=>{if(v.preventDefault(),u)return;u=!0;let w=ds(n.state.field(ji).diagnostics,e);w&&o.apply(n,w.from,w.to)},{name:d}=o,m=l[a]?d.indexOf(l[a]):-1,g=m<0?d:[d.slice(0,m),Tt("u",d.slice(m,m+1)),d.slice(m+1)],b=o.markClass?" "+o.markClass:"";return Tt("button",{type:"button",class:"cm-diagnosticAction"+b,onclick:f,onmousedown:f,"aria-label":` Action: ${d}${m<0?"":` (access key "${l[a]})"`}.`},g)}),e.source&&Tt("div",{class:"cm-diagnosticSource"},e.source))}class zB extends gl{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Tt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class D2{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=cA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Au{constructor(e){this.view=e,this.items=[];let t=l=>{if(!(l.ctrlKey||l.altKey||l.metaKey)){if(l.keyCode==27)E2(this.view),this.view.focus();else if(l.keyCode==38||l.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(l.keyCode==40||l.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(l.keyCode==36)this.moveSelection(0);else if(l.keyCode==35)this.moveSelection(this.items.length-1);else if(l.keyCode==13)this.view.focus();else if(l.keyCode>=65&&l.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],a=aA(o.actions);for(let u=0;u{for(let o=0;oE2(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(ji).selected;if(!e)return-1;for(let t=0;t{for(let m of d.diagnostics){if(a.has(m))continue;a.add(m);let g=-1,b;for(let v=i;vi&&(this.items.splice(i,g-i),l=!0)),t&&b.diagnostic==t.diagnostic?b.dom.hasAttribute("aria-selected")||(b.dom.setAttribute("aria-selected","true"),o=b):b.dom.hasAttribute("aria-selected")&&b.dom.removeAttribute("aria-selected"),i++}});i({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:u,panel:f})=>{let d=f.height/this.list.offsetHeight;u.topf.bottom&&(this.list.scrollTop+=(u.bottom-f.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),l&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ji),i=ds(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:oA.of(i)})}static open(e){return new Au(e)}}function BB(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function Uh(n){return BB(``,'width="6" height="3"')}const PB=Ee.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:Uh("#f11")},".cm-lintRange-warning":{backgroundImage:Uh("orange")},".cm-lintRange-info":{backgroundImage:Uh("#999")},".cm-lintRange-hint":{backgroundImage:Uh("#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 HB(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function IB(n){let e="hint",t=1;for(let i of n){let l=HB(i.severity);l>t&&(t=l,e=i.severity)}return e}const uA=A_(DB,{hideOn:AB}),UB=[ji,Ee.decorations.compute([ji],n=>{let{selected:e,panel:t}=n.field(ji);return!e||!t||e.from==e.to?Fe.none:Fe.set([MB.range(e.from,e.to)])}),uA,PB],FB=[q_(),X_(),l_(),az(),LL(),$j(),Jj(),gt.allowMultipleSelections.of(!0),wL(),oT(HL,{fallback:!0}),XL(),pB(),NB(),x_(),v_(),f_(),x6(),By.of([...bB,...h6,...P6,...xz,...DL,...lA,...LB])];var R2={};class Ud{constructor(e,t,i,l,o,a,u,f,d,m=0,g){this.p=e,this.stack=t,this.state=i,this.reducePos=l,this.pos=o,this.score=a,this.buffer=u,this.bufferBase=f,this.curContext=d,this.lookAhead=m,this.parent=g}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let l=e.parser.context;return new Ud(e,[],t,i,i,0,[],0,l?new j2(l,l.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){var t;let i=e>>19,l=e&65535,{parser:o}=this.p,a=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[l])===null||t===void 0)&&t.isAnonymous)&&(d==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=m):this.p.lastBigReductionSizef;)this.stack.pop();this.reduceContext(l,d)}storeNode(e,t,i,l=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(t==i)return;if(this.buffer[a-2]>=t){this.buffer[a-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,l);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let u=!1;for(let f=a;f>0&&this.buffer[f-2]>i;f-=4)if(this.buffer[f-1]>=0){u=!0;break}if(u)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,l>4&&(l-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=i,this.buffer[a+3]=l}}shift(e,t,i,l){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:a}=this.p;this.pos=l;let u=a.stateFlag(o,1);!u&&(l>i||t<=a.maxNode)&&(this.reducePos=l),this.pushState(o,u?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=a.maxNode&&this.buffer.push(t,i,l,4)}else this.pos=l,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,l,4)}apply(e,t,i,l){e&65536?this.reduce(e):this.shift(e,t,i,l)}useNode(e,t,i){let l=this.p.reused.length-1;(l<0||this.p.reused[l]!=e)&&(this.p.reused.push(e),l++);let o=this.reducePos=this.pos=i+e.length;this.pushState(t,i),this.buffer.push(l,i,o,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),l=e.bufferBase+t;for(;e&&l==e.bufferBase;)e=e.parent;return new Ud(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,l,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new qB(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}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 l=[];for(let o=0,a;of&1&&u==a)||l.push(t[o],a)}t=l}let i=[];for(let l=0;l>19,l=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],l,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}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=[],i=(l,o)=>{if(!t.includes(l))return t.push(l),e.allActions(l,a=>{if(!(a&393216))if(a&65536){let u=(a>>19)-o;if(u>1){let f=a&65535,d=this.stack.length-u*3;if(d>=0&&e.getGoto(this.stack[d],f,!1)>=0)return u<<19|65536|f}}else{let u=i(a,o+1);if(u!=null)return u}})};return i(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;t0&&this.emitLookAhead()}}class j2{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class qB{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let l=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=l}}class Fd{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new Fd(e,t,t-e.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 Fd(this.stack,this.pos,this.index)}}function Fh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,l=0;i=92&&a--,a>=34&&a--;let f=a-32;if(f>=46&&(f-=46,u=!0),o+=f,u)break;o*=46}t?t[l++]=o:t=new e(o)}return t}class fd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const _2=new fd;class VB{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=_2,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 i=this.range,l=this.rangeIndex,o=this.pos+e;for(;oi.to:o>=i.to;){if(l==this.ranges.length-1)return null;let a=this.ranges[++l];o+=a.from-i.to,i=a}return o}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,l;if(t>=0&&t=this.chunk2Pos&&iu.to&&(this.chunk2=this.chunk2.slice(0,u.to-i)),l=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),l}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=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=_2,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&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 i="";for(let l of this.ranges){if(l.from>=t)break;l.to>e&&(i+=this.input.read(Math.max(l.from,e),Math.min(l.to,t)))}return i}}class Ca{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;QB(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Ca.prototype.contextual=Ca.prototype.fallback=Ca.prototype.extend=!1;Ca.prototype.fallback=Ca.prototype.extend=!1;class pm{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function QB(n,e,t,i,l,o){let a=0,u=1<0){let w=n[v];if(f.allows(w)&&(e.token.value==-1||e.token.value==w||XB(w,e.token.value,l,o))){e.acceptToken(w);break}}let m=e.next,g=0,b=n[a+2];if(e.next<0&&b>g&&n[d+b*3-3]==65535){a=n[d+b*3-1];continue e}for(;g>1,w=d+v+(v<<1),S=n[w],C=n[w+1]||65536;if(m=C)g=v+1;else{a=n[w+2],e.advance();continue e}}break}}function L2(n,e,t){for(let i=e,l;(l=n[i])!=65535;i++)if(l==t)return i-e;return-1}function XB(n,e,t,i){let l=L2(t,i,e);return l<0||L2(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class $B{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?z2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?z2(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(ee)return this.nextStart=a,null;if(o instanceof un){let u=a>this.lastRepeatPos&&o.type.id>=this.minRepeat;if(a==e||u){let f=a+o.length,d;if(a>=this.safeFrom&&f<=this.safeTo&&(!(d=o.prop(nt.lookAhead))||f+d=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+o.length}}}class YB{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new fd)}getActions(e){let t=0,i=null,{parser:l}=e.p,{tokenizers:o}=l,a=l.stateSlot(e.state,3),u=e.curContext?e.curContext.hash:0,f=0;for(let d=0;dg.end+25&&(f=Math.max(g.lookAhead,f)),g.value!=0)){let b=t;if(g.extended>-1&&(t=this.addActions(e,g.extended,g.end,t)),t=this.addActions(e,g.value,g.end,t),!m.extend&&(i=g,t>b))break}}for(;this.actions.length>t;)this.actions.pop();return f&&e.setLookAhead(f),!i&&e.pos==this.stream.end&&(i=new fd,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new fd,{pos:i,p:l}=e;return t.start=i,t.end=Math.min(i+1,l.stream.end),t.value=i==l.stream.end?l.parser.eofTerm:0,t}updateCachedToken(e,t,i){let l=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(l,e),i),e.value>-1){let{parser:o}=i.p;for(let a=0;a=0&&i.p.parser.dialect.allows(u>>1)){(u&1)==0?e.value=u>>1:e.extended=u>>1;break}}}else e.value=0,e.end=this.stream.clipPos(l+1)}putAction(e,t,i,l){for(let o=0;oe.bufferLength*4?new $B(i,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],l,o;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)i.push(u);else{if(this.advanceStack(u,i,e))continue;{l||(l=[],o=[]),l.push(u);let f=this.tokens.getMainToken(u);o.push(f.value,f.end)}}break}}if(!i.length){let a=l&&ZB(l);if(a)return Mi&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw Mi&&l&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&l){let a=this.stoppedAt!=null&&l[0].pos>this.stoppedAt?l[0]:this.runRecovery(l,o,i);if(a)return Mi&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((u,f)=>f.score-u.score);i.length>a;)i.pop();i.some(u=>u.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&d.buffer.length>500)if((u.score-d.score||u.buffer.length-d.buffer.length)>0)i.splice(f--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,u)=>u.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a-1&&i.length&&(!o||(i.prop(nt.contextHash)||0)==a))return e.useNode(i,u,t),i;if(i.children.length==0||i.positions[0]>0)break;let f=i.children[0];if(f instanceof un&&(!l||f.type.id>=this.parser.minRepeatTerm))i=f;else break}return null}advanceStack(e,t,i){let l=e.pos,{parser:o}=this,a=Mi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&l>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let d=e.reducePos0)return e.reduce(u),Mi&&console.log(a+this.stackID(e)+` (via always-reduce ${o.getName(u&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let f=this.tokens.getActions(e);for(let d=0;dl?t.push(w):i.push(w)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return B2(e,t),!0}}runRecovery(e,t,i){let l=null,o=!1;for(let a=0;a ":"";if(u.deadEnd&&(o||(o=!0,u.restart(),Mi&&console.log(m+this.stackID(u)+" (restarted)"),this.advanceFully(u,i))))continue;let g=u.split(),b=m;for(let v=0;v<10&&g.forceReduce()&&(Mi&&console.log(b+this.stackID(g)+" (via force-reduce)"),!this.advanceFully(g,i));v++)Mi&&(b=this.stackID(g)+" -> ");for(let v of u.recoverByInsert(f))Mi&&console.log(m+this.stackID(v)+" (via recover-insert)"),this.advanceFully(v,i);this.stream.end>u.pos?(d==u.pos&&(d++,f=0),u.recoverByDelete(f,d),Mi&&console.log(m+this.stackID(u)+` (via recover-delete ${this.parser.getName(f)})`),B2(u,i)):(!l||l.scoren;class WB{constructor(e){this.start=e.start,this.shift=e.shift||E0,this.reduce=e.reduce||E0,this.reuse=e.reuse||E0,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class qd extends VN{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let u=0;ue.topRules[u][1]),l=[];for(let u=0;u=0)o(m,f,u[d++]);else{let g=u[d+-m];for(let b=-m;b>0;b--)o(u[d++],f,g);d++}}}this.nodeSet=new Iy(t.map((u,f)=>yi.define({name:f>=this.minRepeatTerm?void 0:u,id:f,props:l[f],top:i.indexOf(f)>-1,error:f==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(f)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=IN;let a=Fh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let u=0;utypeof u=="number"?new Ca(a,u):u),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,i){let l=new GB(this,e,t,i);for(let o of this.wrappers)l=o(l,e,t,i);return l}getGoto(e,t,i=!1){let l=this.goto;if(t>=l[0])return-1;for(let o=l[t+1];;){let a=l[o++],u=a&1,f=l[o++];if(u&&i)return f;for(let d=o+(a>>1);o0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),l=i?t(i):void 0;for(let o=this.stateSlot(e,1);l==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=al(this.data,o+2);else break;l=t(al(this.data,o+1))}return l}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=al(this.data,i+2);else break;if((this.data[i+2]&1)==0){let l=this.data[i+1];t.some((o,a)=>a&1&&o==l)||t.push(this.data[i],l)}}return t}configure(e){let t=Object.assign(Object.create(qd.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let l=e.tokenizers.find(o=>o.from==i);return l?l.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,l)=>{let o=e.specializers.find(u=>u.from==i.external);if(!o)return i;let a=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[l]=P2(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}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),i=t.map(()=>!1);if(e)for(let o of e.split(" ")){let a=t.indexOf(o);a>=0&&(i[a]=!0)}let l=null;for(let o=0;oi)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const ca=63,H2=64,JB=1,e9=2,fA=3,t9=4,hA=5,n9=6,i9=7,dA=65,r9=66,l9=8,s9=9,o9=10,a9=11,c9=12,mA=13,u9=19,f9=20,h9=29,d9=33,m9=34,p9=47,g9=0,lb=1,Kx=2,Eu=3,Wx=4;class eo{constructor(e,t,i){this.parent=e,this.depth=t,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+i}}eo.top=new eo(null,-1,g9);function cu(n,e){for(let t=0,i=e-n.pos-1;;i--,t++){let l=n.peek(i);if(ml(l)||l==-1)return t}}function Zx(n){return n==32||n==9}function ml(n){return n==10||n==13}function pA(n){return Zx(n)||ml(n)}function io(n){return n<0||pA(n)}const x9=new WB({start:eo.top,reduce(n,e){return n.type==Eu&&(e==f9||e==m9)?n.parent:n},shift(n,e,t,i){if(e==fA)return new eo(n,cu(i,i.pos),lb);if(e==dA||e==hA)return new eo(n,cu(i,i.pos),Kx);if(e==ca)return n.parent;if(e==u9||e==d9)return new eo(n,0,Eu);if(e==mA&&n.type==Wx)return n.parent;if(e==p9){let l=/[1-9]/.exec(i.read(i.pos,t.pos));if(l)return new eo(n,n.depth+ +l[0],Wx)}return n},hash(n){return n.hash}});function za(n,e,t=0){return n.peek(t)==e&&n.peek(t+1)==e&&n.peek(t+2)==e&&io(n.peek(t+3))}const y9=new pm((n,e)=>{if(n.next==-1&&e.canShift(H2))return n.acceptToken(H2);let t=n.peek(-1);if((ml(t)||t<0)&&e.context.type!=Eu){if(za(n,45))if(e.canShift(ca))n.acceptToken(ca);else return n.acceptToken(JB,3);if(za(n,46))if(e.canShift(ca))n.acceptToken(ca);else return n.acceptToken(e9,3);let i=0;for(;n.next==32;)i++,n.advance();(i{if(e.context.type==Eu){n.next==63&&(n.advance(),io(n.next)&&n.acceptToken(i9));return}if(n.next==45)n.advance(),io(n.next)&&n.acceptToken(e.context.type==lb&&e.context.depth==cu(n,n.pos-1)?t9:fA);else if(n.next==63)n.advance(),io(n.next)&&n.acceptToken(e.context.type==Kx&&e.context.depth==cu(n,n.pos-1)?n9:hA);else{let t=n.pos;for(;;)if(Zx(n.next)){if(n.pos==t)return;n.advance()}else if(n.next==33)gA(n);else if(n.next==38)Jx(n);else if(n.next==42){Jx(n);break}else if(n.next==39||n.next==34){if(sb(n,!0))break;return}else if(n.next==91||n.next==123){if(!w9(n))return;break}else{xA(n,!0,!1,0);break}for(;Zx(n.next);)n.advance();if(n.next==58){if(n.pos==t&&e.canShift(h9))return;let i=n.peek(1);io(i)&&n.acceptTokenTo(e.context.type==Kx&&e.context.depth==cu(n,t)?r9:dA,t)}}},{contextual:!0});function v9(n){return n>32&&n<127&&n!=34&&n!=37&&n!=44&&n!=60&&n!=62&&n!=92&&n!=94&&n!=96&&n!=123&&n!=124&&n!=125}function I2(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function U2(n,e){return n.next==37?(n.advance(),I2(n.next)&&n.advance(),I2(n.next)&&n.advance(),!0):v9(n.next)||e&&n.next==44?(n.advance(),!0):!1}function gA(n){if(n.advance(),n.next==60){for(n.advance();;)if(!U2(n,!0)){n.next==62&&n.advance();break}}else for(;U2(n,!1););}function Jx(n){for(n.advance();!io(n.next)&&Vd(n.next)!="f";)n.advance()}function sb(n,e){let t=n.next,i=!1,l=n.pos;for(n.advance();;){let o=n.next;if(o<0)break;if(n.advance(),o==t)if(o==39)if(n.next==39)n.advance();else break;else break;else if(o==92&&t==34)n.next>=0&&n.advance();else if(ml(o)){if(e)return!1;i=!0}else if(e&&n.pos>=l+1024)return!1}return!i}function w9(n){for(let e=[],t=n.pos+1024;;)if(n.next==91||n.next==123)e.push(n.next),n.advance();else if(n.next==39||n.next==34){if(!sb(n,!0))return!1}else if(n.next==93||n.next==125){if(e[e.length-1]!=n.next-2)return!1;if(e.pop(),n.advance(),!e.length)return!0}else{if(n.next<0||n.pos>t||ml(n.next))return!1;n.advance()}}const k9="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function Vd(n){return n<33?"u":n>125?"s":k9[n-33]}function M0(n,e){let t=Vd(n);return t!="u"&&!(e&&t=="f")}function xA(n,e,t,i){if(Vd(n.next)=="s"||(n.next==63||n.next==58||n.next==45)&&M0(n.peek(1),t))n.advance();else return!1;let l=n.pos;for(;;){let o=n.next,a=0,u=i+1;for(;pA(o);){if(ml(o)){if(e)return!1;u=0}else u++;o=n.peek(++a)}if(!(o>=0&&(o==58?M0(n.peek(a+1),t):o==35?n.peek(a-1)!=32:M0(o,t)))||!t&&u<=i||u==0&&!t&&(za(n,45,a)||za(n,46,a)))break;if(e&&Vd(o)=="f")return!1;for(let d=a;d>=0;d--)n.advance();if(e&&n.pos>l+1024)return!1}return!0}const S9=new pm((n,e)=>{if(n.next==33)gA(n),n.acceptToken(c9);else if(n.next==38||n.next==42){let t=n.next==38?o9:a9;Jx(n),n.acceptToken(t)}else n.next==39||n.next==34?(sb(n,!1),n.acceptToken(s9)):xA(n,!1,e.context.type==Eu,e.context.depth)&&n.acceptToken(l9)}),C9=new pm((n,e)=>{let t=e.context.type==Wx?e.context.depth:-1,i=n.pos;e:for(;;){let l=0,o=n.next;for(;o==32;)o=n.peek(++l);if(!l&&(za(n,45,l)||za(n,46,l))||!ml(o)&&(t<0&&(t=Math.max(e.context.depth+1,l)),lYAN>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:x9,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[O9],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:[y9,b9,S9,C9,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),T9=Ad.define({name:"yaml",parser:N9.configure({props:[GN.add({Stream:n=>{for(let e=n.node.resolve(n.pos,-1);e&&e.to>=n.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.fromn.pos)return null}}return null},FlowMapping:n2({closing:"}"}),FlowSequence:n2({closing:"]"})}),ZN.add({"FlowMapping FlowSequence":SL,"Item Pair BlockLiteral":(n,e)=>({from:e.doc.lineAt(n.from).to,to:n.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function A9(){return new hL(T9)}const F2='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], video[tabindex], [tabindex]:not([tabindex="-1"])';function gs({isOpen:n,onClose:e,dialogRef:t,initialFocusRef:i}){return A.useEffect(()=>{if(!n)return;const l=document.activeElement instanceof HTMLElement?document.activeElement:null,o=requestAnimationFrame(()=>{var f;const u=(i==null?void 0:i.current)??((f=t.current)==null?void 0:f.querySelector(F2))??t.current;u==null||u.focus()}),a=u=>{if(u.key!=="Tab")return;const f=t.current;if(!f)return;const d=Array.from(f.querySelectorAll(F2));if(!d.length)return;const m=d[0],g=d[d.length-1],b=document.activeElement;if(!(b instanceof Node&&f.contains(b))){u.preventDefault(),(u.shiftKey?g:m).focus();return}u.shiftKey&&(b===m||b===f)?(u.preventDefault(),g.focus()):!u.shiftKey&&(b===g||b===f)&&(u.preventDefault(),m.focus())};return window.addEventListener("keydown",a,!0),()=>{cancelAnimationFrame(o),l==null||l.focus(),window.removeEventListener("keydown",a,!0)}},[n]),l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),e())}}function ro({isOpen:n,title:e,message:t,confirmLabel:i="Confirm",cancelLabel:l="Cancel",danger:o=!1,onConfirm:a,onCancel:u}){const f=A.useRef(null),d=A.useRef(null),m=gs({isOpen:n,onClose:u,dialogRef:f,initialFocusRef:d});return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:u,children:y.jsxs("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-dialog-title",onKeyDown:m,onClick:g=>g.stopPropagation(),className:"animate-modal-in w-[400px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-3 flex items-center gap-2.5",children:[y.jsx("span",{className:`grid h-9 w-9 shrink-0 place-items-center rounded-lg ${o?"bg-status-danger-bg text-status-danger-text":"bg-chip-indigo-bg text-chip-indigo-text"}`,children:y.jsx(wy,{className:"h-5 w-5"})}),y.jsx("h2",{id:"confirm-dialog-title",className:"text-sm font-semibold text-ink",children:e})]}),y.jsx("div",{className:"mb-5 whitespace-pre-line text-xs text-ink-secondary",children:t}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{ref:d,type:"button",onClick:u,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:l}),y.jsx("button",{type:"button",onClick:a,className:`min-h-9 rounded-lg border px-4 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${o?"border-status-danger-border bg-status-danger-bg/30 text-status-danger-text hover:bg-status-danger-bg/60":"btn-primary border-transparent bg-indigo-600 text-white hover:bg-indigo-500"}`,children:i})]})]})}):null}var E9=GC();const Mr=8,is=8,M9=400,q2={top:"bottom",bottom:"top",left:"right",right:"left"},D9={top:"-bottom-1 left-1/2 -translate-x-1/2",bottom:"-top-1 left-1/2 -translate-x-1/2",left:"-right-1 top-1/2 -translate-y-1/2",right:"-left-1 top-1/2 -translate-y-1/2"},R9={top:"border-b border-r",bottom:"border-t border-l",left:"border-t border-r",right:"border-b border-l"},V2=(n,e,t)=>{switch(n){case"top":return e.top-is-t.h>=Mr;case"bottom":return e.bottom+is+t.h<=window.innerHeight-Mr;case"left":return e.left-is-t.w>=Mr;default:return e.right+is+t.w<=window.innerWidth-Mr}},j9=(n,e,t)=>{if(n==="top"||n==="bottom"){const a=e.left+e.width/2-t.w/2,u=window.innerWidth-t.w-Mr;return{x:Math.min(Math.max(a,Mr),Math.max(Mr,u))-a,y:0}}const i=e.top+e.height/2-t.h/2,l=window.innerHeight-t.h-Mr;return{x:0,y:Math.min(Math.max(i,Mr),Math.max(Mr,l))-i}},Xe=({text:n,children:e,block:t=!0,placement:i="top",suppress:l=!1})=>{const o=A.useRef(null),a=A.useRef(null),u=A.useId(),f=A.useRef(null),[d,m]=A.useState(!1),[g,b]=A.useState(i),[v,w]=A.useState({x:0,y:0}),[S,C]=A.useState({left:-9999,top:-9999}),N=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)};A.useEffect(()=>{l&&(N(),m(!1))},[l]),A.useEffect(()=>()=>N(),[]);const j=A.useCallback(()=>{const E=o.current,D=a.current;if(!E||!D)return;const I=E.getBoundingClientRect(),ne={w:D.offsetWidth,h:D.offsetHeight},F=V2(i,I,ne)?i:V2(q2[i],I,ne)?q2[i]:i,V=j9(F,I,ne);b(F),w(V);const _=I.left+I.width/2,ie=I.top+I.height/2;C(F==="top"?{left:_,top:I.top-is-ne.h}:F==="bottom"?{left:_,top:I.bottom+is}:F==="left"?{left:I.left-is-ne.w,top:ie}:{left:I.right+is,top:ie})},[i]);A.useEffect(()=>{if(!d)return;const E=()=>m(!1);return window.addEventListener("resize",E),window.addEventListener("scroll",E,!0),()=>{window.removeEventListener("resize",E),window.removeEventListener("scroll",E,!0)}},[d]);const M=E=>{if(l)return;N();const D=()=>{j(),m(!0)};E?D():f.current=window.setTimeout(D,M9)},U=()=>{N(),m(!1)};A.useEffect(()=>{if(!d)return;const E=D=>{D.key==="Escape"&&m(!1)};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[d]),A.useEffect(()=>{if(!d)return;const E=()=>!!document.querySelector('[role="dialog"][aria-modal="true"], dialog[open]');if(E()){m(!1);return}const D=new MutationObserver(()=>{E()&&m(!1)});return D.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","open","class"]}),()=>D.disconnect()},[d]);const H={onMouseEnter:()=>M(!1),onMouseLeave:U,onFocus:()=>M(!0),onBlur:U,"aria-describedby":u};return y.jsxs("div",{ref:o,className:`group relative ${t?"flex min-w-0 flex-1 items-center":"inline-flex shrink-0 items-center"}`,onMouseEnter:()=>M(!1),onMouseLeave:U,onFocus:()=>M(!0),onBlur:U,children:[A.cloneElement(e,H),E9.createPortal(y.jsxs("span",{ref:a,id:u,role:"tooltip",className:`pointer-events-none invisible fixed z-[var(--z-tooltip)] w-max max-w-[calc(100vw-16px)] rounded-md border border-line bg-elevated px-2 py-1 text-left text-[11px] leading-relaxed text-ink shadow-lg ${d?"visible opacity-100":"opacity-0"}`,style:{left:S.left,top:S.top,transform:g==="top"||g==="bottom"?`translateX(calc(-50% + ${v.x}px))`:`translateY(calc(-50% + ${v.y}px))`},children:[n,y.jsx("span",{className:`absolute h-2 w-2 rotate-45 border-line bg-elevated ${D9[g]} ${R9[g]}`,style:g==="top"||g==="bottom"?{left:`calc(50% - ${v.x}px)`}:void 0})]}),document.body)]})},_9=[".profiles",".profiles.yaml"];function L9(n){const e=n.trim();if(!e)return null;const t=e.toLowerCase(),i=_9.find(l=>t.endsWith(l));if(i!==void 0){const l=e.slice(0,e.length-i.length);return!l.trim()||l!==l.trimEnd()?null:e}return t.includes(".")?null:`${e}.profiles`}function z9({open:n,onCancel:e,onConfirm:t}){const[i,l]=A.useState(null),[o,a]=A.useState(""),[u,f]=A.useState(""),[d,m]=A.useState(null),[g,b]=A.useState(!1),[v,w]=A.useState(null),[S,C]=A.useState(null),N=A.useRef(null),j=A.useRef(null),M=A.useRef(null),U=A.useCallback(async I=>{b(!0),w(null);try{const ne=await WC(I);l(ne),a(ne.current_path)}catch(ne){w(ne instanceof Error?ne.message:String(ne))}finally{b(!1)}},[]);A.useEffect(()=>{if(!n)return;f(""),m(null),C(null),U(o);const I=requestAnimationFrame(()=>{var ne;return(ne=j.current)==null?void 0:ne.focus()});return()=>cancelAnimationFrame(I)},[n]);const H=gs({isOpen:n,onClose:e,dialogRef:N,initialFocusRef:j});function E(){if(!i)return;const I=L9(u);if(I===null){m("Not a ProFiles configuration file. Allowed extensions: .profiles, .profiles.yaml");return}m(null);const ne=o.trim()||i.current_path;if(o.trim()===i.current_path&&i.items.some(_=>!_.is_dir&&_.name===I)){C({filename:I,directory:ne});return}t({filename:I,directory:ne,overwrite:!1})}if(!n)return null;const D=(i==null?void 0:i.items.filter(I=>I.is_dir))??[];return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:N,role:"dialog","aria-modal":"true","aria-labelledby":"save-as-dialog-title",onKeyDown:H,onClick:I=>I.stopPropagation(),className:"animate-modal-in flex max-h-[calc(100dvh-2rem)] w-[min(94vw,560px)] flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",children:[y.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(lO,{className:"h-4 w-4 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"save-as-dialog-title",className:"text-sm font-semibold text-ink",children:"Save configuration as"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(i==null?void 0:i.current_path)||"…"})]})]})}),y.jsxs("div",{className:"border-b border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:M,id:"save-as-path",type:"text",value:o,onChange:I=>a(I.target.value),onKeyDown:I=>{I.key==="Enter"&&U(o.trim())},placeholder:"/path/to/directory",className:"h-9 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>void U(o.trim()),className:"inline-flex h-9 shrink-0 items-center rounded-lg border border-line bg-elevated px-3 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Xe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void U(""),"aria-label":"Home directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Zd,{className:"h-4 w-4"})})}),(i==null?void 0:i.parent_path)&&y.jsx(Xe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void U(i.parent_path),"aria-label":"Parent directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Wd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-24 flex-1 overflow-y-auto px-2 py-2 sm:px-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(fl,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>void U(o||(i==null?void 0:i.current_path)||""),className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[D.map(I=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>void U(I.path),className:"flex min-h-9 w-full items-center gap-2.5 rounded-lg px-3 py-1.5 text-left text-sm text-ink-secondary transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400",children:[y.jsx(Du,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:I.name})]})},I.path)),D.length===0&&y.jsxs("li",{className:"flex min-h-16 flex-col items-center justify-center gap-2 text-center text-sm text-ink-muted",children:[y.jsx(rs,{className:"h-6 w-6 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"shrink-0 border-t border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-filename",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"File name"}),y.jsx("input",{ref:j,id:"save-as-filename",type:"text",value:u,onChange:I=>{f(I.target.value),m(null)},onKeyDown:I=>{I.key==="Enter"&&u.trim()&&E()},placeholder:"machine.profiles",className:"h-9 w-full rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),d&&y.jsx("p",{role:"alert","data-testid":"save-as-error",className:"mt-1.5 text-xs text-status-danger-text",children:d}),y.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:e,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:E,disabled:!u.trim()||!i||g,title:"Save the configuration to the selected folder",className:"btn btn-primary min-h-9 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Br,{className:"h-4 w-4"}),"Save"]})]})]})]})}),y.jsx(ro,{isOpen:S!==null,title:"Replace configuration?",message:`A configuration named "${S==null?void 0:S.filename}" already exists in this folder. -Saving will replace it.`,confirmLabel:"Replace",cancelLabel:"Keep existing",danger:!0,onConfirm:()=>{const I=S;C(null),I&&t({...I,overwrite:!0})},onCancel:()=>C(null)})]})}const B9=800,P9=Ee.theme({"&":{height:"100%",fontSize:"12.5px",color:"var(--app-text-primary)",backgroundColor:"var(--app-editor-bg)"},".cm-scroller":{fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",lineHeight:"1.6"},".cm-content":{caretColor:"var(--color-indigo-500, #6366f1)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--color-indigo-500, #6366f1)"},"&.cm-focused":{outline:"none"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--app-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--app-editor-active-line)"},".cm-matchingBracket":{color:"inherit",backgroundColor:"var(--app-editor-selection)",outline:"1px solid var(--app-editor-border)"},".cm-nonmatchingBracket":{color:"inherit",outline:"1px solid var(--status-danger-border, #fb7185)"},".cm-gutters":{backgroundColor:"var(--app-editor-gutter-bg)",color:"var(--app-text-faint)",border:"none",borderRight:"1px solid var(--app-editor-border)"},".cm-activeLineGutter":{backgroundColor:"var(--app-editor-active-line)",color:"var(--app-text-secondary)"},".cm-panels":{backgroundColor:"var(--app-editor-bg)",color:"var(--app-text-primary)"},".cm-tooltip":{border:"1px solid var(--app-border)",backgroundColor:"var(--app-glass-panel-strong)",color:"var(--app-text-primary)"}}),H9=zu.define([{tag:me.lineComment,color:"var(--app-editor-syntax-comment)"},{tag:[me.propertyName,me.definition(me.propertyName)],color:"var(--app-editor-syntax-key)"},{tag:[me.string,me.special(me.string)],color:"var(--app-editor-syntax-string)"},{tag:me.content,color:"var(--app-editor-syntax-string)"},{tag:[me.keyword,me.typeName],color:"var(--app-editor-syntax-keyword)"},{tag:me.labelName,color:"var(--app-editor-syntax-label)"}]);function D0(n){return n.replace(/\r\n?/g,` -`)}function qh(n,e){return n!==null&&n.state.doc.toString()!==e}function I9(n){return n instanceof yy&&Array.isArray(n.detail)?{text:n.message,issues:n.detail}:{text:n instanceof Error?n.message:String(n),issues:[]}}function U9({open:n,onClose:e,onApplied:t,onLoadConfig:i,reloadKey:l=0}){const[o,a]=A.useState({status:"loading"}),[u,f]=A.useState(!1),[d,m]=A.useState(!1),[g,b]=A.useState(null),[v,w]=A.useState([]),[S,C]=A.useState({kind:"unknown"}),[N,j]=A.useState(!1),[M,U]=A.useState({line:1,col:1}),[H,E]=A.useState(null),[D,I]=A.useState(null),[ne,F]=A.useState(null),[V,_]=A.useState(null),ie=A.useRef(null),pe=A.useRef(null),ce=A.useRef(null),Z=A.useRef(null),oe=A.useRef(""),G=A.useRef(null),W=A.useRef(0),T=A.useRef(new Map),de=A.useRef(null),be=A.useRef(null),z=A.useRef(!1),R=A.useRef(()=>{}),X=A.useRef(()=>{});z.current=D!==null||ne!==null||V!==null;const he=gs({isOpen:n,onClose:Te,dialogRef:ie});A.useEffect(()=>{if(!n){oe.current="",G.current=null,ce.current=null,a({status:"loading"}),f(!1),m(!1),b(null),w([]),C({kind:"unknown"}),j(!1),U({line:1,col:1}),E(null),I(null),F(null),_(null),de.current!==null&&(clearTimeout(de.current),de.current=null),be.current=null,W.current+=1,T.current.clear();return}let ue=!1;return Hk().then(ye=>{if(ue)return;const Re=D0(ye.content);oe.current=Re,G.current=ye.content_hash??null,be.current=Re,a({status:"ready",data:{...ye,content:Re}})}).catch(ye=>{ue||(oe.current="",a({status:"error",message:ye instanceof Error?ye.message:String(ye)}))}),()=>{ue=!0}},[n,l]);const ge=A.useCallback(()=>{de.current!==null&&(clearTimeout(de.current),de.current=null)},[]),ze=A.useCallback(ue=>{z.current||ue!==be.current&&(ge(),de.current=window.setTimeout(()=>{if(de.current=null,T.current.has("test")){X.current(ue);return}R.current()},B9))},[ge]);A.useEffect(()=>{if(!n||o.status!=="ready")return;const ue=pe.current;if(!ue)return;const ye=new Ee({doc:o.data.content,extensions:[FB,A9(),oT(H9),P9,Ee.updateListener.of(Re=>{if(Re.selectionSet||Re.docChanged){const ct=Re.state.selection.main.head,vt=Re.state.doc.lineAt(ct);U({line:vt.number,col:ct-vt.from+1})}Re.docChanged&&(f(qh(Re.view,oe.current)),b(null),w([]),C({kind:"unknown"}),j(!1),ze(Re.state.doc.toString()))})],parent:ue});return ce.current=ye,()=>{ye.destroy(),ce.current=null,ge()}},[n,o]);function Te(){if(qh(ce.current,oe.current)){m(!0);return}e()}const He=A.useCallback(()=>{DM().catch(ue=>{console.error("Failed to open config file in OS editor:",ue)})},[]);function ke(){var ue;return((ue=ce.current)==null?void 0:ue.state.doc.toString())??oe.current}const Ae=A.useCallback(async(ue,ye)=>{if(T.current.has(ue))return;const Re=++W.current;T.current.set(ue,Re);try{await ye(Re)}finally{T.current.get(ue)===Re&&T.current.delete(ue)}},[]),Qt=A.useCallback(()=>Ae("new",async ue=>{b(null),w([]);try{const ye=await TM();if(ue!==W.current)return;const Re=D0(ye.content);oe.current=Re,G.current=null,f(!1),a(ct=>ct.status==="ready"?{status:"ready",data:{...ct.data,filename:ye.filename,content:Re,config_path:null}}:ct),b({kind:"ok",text:"New configuration template loaded."})}catch(ye){if(ue!==W.current)return;b({kind:"error",text:ye instanceof Error?ye.message:String(ye)})}}),[Ae]),Ft=A.useCallback(()=>Ae("revert",async ue=>{b(null),w([]);try{const ye=await Hk();if(ue!==W.current)return;const Re=D0(ye.content);oe.current=Re,G.current=ye.content_hash??null,f(!1),a({status:"ready",data:{...ye,content:Re}}),b({kind:"ok",text:"Configuration reloaded from disk."})}catch(ye){if(ue!==W.current)return;b({kind:"error",text:ye instanceof Error?ye.message:String(ye)})}}),[Ae]);function gn(){if(qh(ce.current,oe.current)){E("new");return}Qt()}function Ht(){if(qh(ce.current,oe.current)){E("revert");return}Ft()}const Ot=A.useCallback(()=>Ae("test",async ue=>{if(o.status!=="ready")return;ge();const ye=ke();be.current=ye,C({kind:"validating"});try{const Re=await Ik(o.data.filename,ye);if(ue!==W.current)return;w(Re.issues),Re.valid?(C({kind:"valid"}),b({kind:"ok",text:"Configuration is valid."})):(C({kind:"invalid",count:Re.issues.length}),j(!0),b({kind:"error",text:`Validation failed with ${Re.issues.length} issue${Re.issues.length===1?"":"s"}.`}))}catch(Re){if(ue!==W.current)return;w([]),C({kind:"unknown"}),b({kind:"error",text:Re instanceof Error?Re.message:String(Re)})}}),[o,Ae]);R.current=()=>void Ot(),X.current=ze;const st=A.useCallback(()=>Ae("apply",async ue=>{if(o.status==="ready")try{const ye=await KC(o.data.filename,ke());if(ue!==W.current)return;b({kind:"ok",text:"Configuration applied (session trial)."}),t==null||t(ye)}catch(ye){if(ue!==W.current)return;b({kind:"error",text:ye instanceof Error?ye.message:String(ye)})}}),[o,t,Ae]),tn=A.useCallback(ue=>new Promise(ye=>{I({issues:ue,resolve:Re=>{I(null),ye(Re)}})}),[]),Pn=A.useCallback(()=>new Promise(ue=>{F({resolve:ye=>{F(null),ue(ye)}})}),[]),qt=A.useCallback(()=>new Promise(ue=>{_({resolve:ye=>{_(null),ue(ye)}})}),[]),Kt=A.useCallback((ue,ye,Re)=>{if(oe.current=ye,G.current=Re,f(!1),w([]),C({kind:"unknown"}),I(null),F(null),ue.config_path){const ct=ue.config_path.split(/[\\/]/).pop()||ue.title||"configuration";a(vt=>vt.status!=="ready"||!(vt.data.filename!==ct||vt.data.config_path!==ue.config_path||vt.data.session_trial)?vt:{status:"ready",data:{...vt.data,filename:ct,config_path:ue.config_path,session_trial:!1,content:ye}})}t==null||t(ue)},[t]),Oe=A.useCallback(ue=>{const ye=I9(ue);I(null),F(null),w(ye.issues),ye.issues.length>0?(C({kind:"invalid",count:ye.issues.length}),j(!0)):C({kind:"unknown"}),b({kind:"error",text:ye.text})},[]),qe=A.useCallback((ue,ye)=>Ae(ue,async Re=>{if(o.status!=="ready")return;const ct=ke();b(null),w([]),C({kind:"validating"});try{const vt=await Ik(ye,ct);if(Re!==W.current)return;let Sn=!1;if(vt.valid)C({kind:"valid"});else{if(C({kind:"invalid",count:vt.issues.length}),w(vt.issues),j(!0),Sn=await tn(vt.issues),Re!==W.current)return;if(!Sn){b({kind:"error",text:"Save cancelled — fix the listed issues, or force-save anyway."});return}}if(ue==="save-as"){const Cn=await Pn();if(Re!==W.current||Cn===null)return;const Et=await AM({content:ct,filename:Cn.filename,directory:Cn.directory,force:Sn,overwrite:Cn.overwrite});if(Re!==W.current)return;Kt(Et.config,ct,Et.contentHash),b({kind:"ok",text:`Configuration saved as ${Cn.filename}.`})}else{let Cn;try{Cn=await Uk(ct,Sn,{baselineHash:G.current})}catch(Et){if(!(Et instanceof yy)||Et.status!==409)throw Et;const Wt=await qt();if(Re!==W.current)return;if(!Wt){Ft();return}Cn=await Uk(ct,Sn,{baselineHash:G.current,overwriteChanges:!0})}if(Re!==W.current)return;Kt(Cn.config,ct,Cn.contentHash),b({kind:"ok",text:`Configuration saved to ${ye}.`})}}catch(vt){if(Re!==W.current)return;Oe(vt)}}),[tn,Pn,qt,o,Kt,Oe,Ft,Ae]),$e=A.useCallback(()=>qe("save",o.status==="ready"?o.data.filename:""),[o,qe]),mt=A.useCallback(()=>qe("save-as",o.status==="ready"?o.data.filename:""),[o,qe]),te=A.useRef(()=>{});if(te.current=()=>{o.status==="ready"&&(D!==null||ne!==null||V!==null||d||H!==null||(o.data.config_path!==null?$e():st()))},A.useEffect(()=>{if(!n)return;const ue=ye=>{(ye.metaKey||ye.ctrlKey)&&!ye.altKey&&!ye.shiftKey&&ye.key.toLowerCase()==="s"&&(ye.preventDefault(),ye.stopPropagation(),te.current())};return window.addEventListener("keydown",ue,!0),()=>window.removeEventListener("keydown",ue,!0)},[n]),!n)return null;const fe=o.status==="ready"?o.data.filename:"",Le=o.status==="ready"?o.data.session_trial:!1,Be=o.status!=="ready",bt=o.status==="ready"&&o.data.config_path!==null;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:ie,role:"dialog","aria-modal":"true","aria-labelledby":"config-editor-title",onKeyDown:he,onMouseDown:ue=>{Z.current=ue.target===ue.currentTarget?{x:ue.clientX,y:ue.clientY}:null},onClick:ue=>{const ye=Z.current;Z.current=null,!(!ye||ue.target!==ue.currentTarget)&&Te()},className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",children:y.jsxs("div",{className:"animate-modal-in flex h-[90vh] w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-frame-line glass-panel",onClick:ue=>ue.stopPropagation(),children:[y.jsxs("div",{"data-testid":"editor-header",className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(R4,{className:"h-4 w-4"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"config-editor-title",className:"text-sm font-semibold text-ink",children:"Configuration Editor"}),y.jsxs("p",{className:"truncate text-xs text-ink-muted",children:[fe||"…",Le?" • session trial (not anchored to disk)":""]})]})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsxs("button",{type:"button",onClick:gn,disabled:Be,title:"Load the starter configuration template",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(z4,{className:"h-3.5 w-3.5"}),"New"]}),y.jsxs("button",{type:"button",onClick:()=>void Ot(),disabled:Be,title:"Validate the editor content in memory",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(I4,{className:"h-3.5 w-3.5"}),"Test"]}),y.jsxs("button",{type:"button",onClick:Ht,disabled:Be,title:"Discard edits and reload the file from disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(hD,{className:"h-3.5 w-3.5"}),"Revert"]}),bt&&y.jsxs("button",{type:"button",onClick:()=>void $e(),disabled:Be,title:"Save to the configuration file on disk (Ctrl/Cmd+S)",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(lO,{className:"h-3.5 w-3.5"}),"Save"]}),y.jsxs("button",{type:"button",onClick:()=>void mt(),disabled:Be,title:"Save the configuration to a new file — also anchors a session trial onto disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(mD,{className:"h-3.5 w-3.5"}),"Save As"]}),y.jsxs("button",{type:"button",onClick:()=>void st(),disabled:Be,title:"Trial the editor content as the session configuration",className:"btn btn-primary px-2.5 py-1.5 font-semibold",children:[y.jsx(ss,{className:"h-3.5 w-3.5"}),"Apply"]}),i&&y.jsxs("button",{type:"button",onClick:i,title:"Load a different .profiles file",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(fa,{className:"h-3.5 w-3.5"}),"Load config file…"]}),bt&&y.jsxs("button",{type:"button",onClick:He,title:"Open the configuration file with the OS default editor",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-2.5 py-1.5 text-xs font-medium text-ink-secondary hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:[y.jsx(iO,{className:"h-3.5 w-3.5"}),"Open in OS"]}),y.jsx("button",{type:"button",onClick:Te,"aria-label":"Close editor",className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(_i,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex min-h-0 flex-1 gap-2 p-3 sm:p-4",children:[y.jsx("div",{"data-testid":"editor-card",className:"min-w-0 flex-1 overflow-hidden rounded-lg border border-[var(--app-editor-border)] bg-[var(--app-editor-bg)]",children:o.status==="loading"?y.jsx("div",{className:"flex h-full items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):o.status==="error"?y.jsx("div",{className:"flex h-full items-center justify-center p-6",children:y.jsx("div",{className:"max-w-md rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:o.message})}):y.jsx("div",{ref:pe,className:"h-full"})}),o.status==="ready"&&N&&y.jsxs("aside",{"data-testid":"problems-panel","aria-live":"polite",className:"flex w-[280px] shrink-0 flex-col overflow-hidden rounded-lg border border-line bg-surface",children:[y.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-3 py-1.5",children:[y.jsx("span",{className:"text-xs font-semibold text-ink-secondary",children:"Problems"}),y.jsx("button",{type:"button",onClick:()=>j(!1),"aria-label":"Close problems",className:"rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(_i,{className:"h-3.5 w-3.5"})})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:v.length===0?y.jsx("p",{className:"px-2 py-1 text-xs text-ink-faint",children:"No problems detected."}):y.jsx("ul",{"data-testid":"editor-issues",className:"space-y-1",children:v.map((ue,ye)=>y.jsxs("li",{tabIndex:0,className:`flex items-start gap-2 rounded-md border px-2.5 py-1.5 text-xs ${ue.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":ue.severity==="warning"?"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text":"border-line bg-surface text-ink-secondary"}`,children:[ue.severity==="error"?y.jsx(du,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):ue.severity==="warning"?y.jsx(wy,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):y.jsx(by,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),y.jsx("span",{className:"min-w-0",children:ue.message})]},`${ue.severity}-${ye}`))})})]})]}),o.status==="ready"&&y.jsxs("footer",{"data-testid":"editor-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-1.5 text-xs",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[y.jsxs("button",{type:"button","data-testid":"validity-chip",onClick:()=>j(ue=>!ue),title:"Toggle the problems panel","aria-pressed":N,className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 ${S.kind==="valid"?"border-status-success-border bg-status-success-bg text-status-success-text":S.kind==="invalid"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-line bg-surface text-ink-muted"}`,children:[S.kind==="valid"?y.jsx(Br,{className:"h-3 w-3"}):S.kind==="invalid"?y.jsx(du,{className:"h-3 w-3"}):S.kind==="validating"?y.jsx(fl,{className:"h-3 w-3 animate-spin"}):y.jsx(d4,{className:"h-3 w-3"}),S.kind==="valid"?"Valid":S.kind==="invalid"?`${S.count} issue${S.count===1?"":"s"}`:S.kind==="validating"?"Validating…":"Not validated"]}),u&&y.jsxs("span",{role:"status",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-chip-amber-border bg-chip-amber-bg px-2 py-0.5 text-[10px] font-bold text-chip-amber-text",children:[y.jsx(p4,{className:"h-3 w-3"}),"Unsaved changes"]}),g!==null&&y.jsx("div",{"data-testid":"editor-status","aria-live":"polite",className:`min-w-0 truncate rounded-md border px-2 py-0.5 font-medium ${g.kind==="ok"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:g.text})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-ink-muted",children:[y.jsxs("span",{className:"font-mono",children:["Ln ",M.line,", Col ",M.col]}),y.jsx("span",{className:"text-ink-faint",children:"YAML"}),y.jsx("span",{className:"max-w-[220px] truncate font-mono",children:fe})]})]})]})}),y.jsx(ro,{isOpen:d,title:"Discard changes?",message:`The editor contains unsaved changes. -Closing now will discard them.`,confirmLabel:"Discard",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{m(!1),e()},onCancel:()=>m(!1)}),y.jsx(ro,{isOpen:H!==null,title:"Replace current edits?",message:H==="revert"?`The editor contains unsaved changes. -Reverting will discard them and reload the file from disk.`:`The editor contains unsaved changes. -Loading the starter template will discard them.`,confirmLabel:"Replace",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{const ue=H;E(null),ue==="new"?Qt():ue==="revert"&&Ft()},onCancel:()=>E(null)}),y.jsx(ro,{isOpen:D!==null,title:"Save with validation issues?",danger:!0,message:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"Saving will write these issues to disk; the file may fail to load until they are fixed."}),y.jsx("ul",{className:"mt-2 space-y-1",children:D==null?void 0:D.issues.map((ue,ye)=>y.jsx("li",{className:`rounded-md border px-3 py-1.5 text-xs ${ue.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text"}`,children:ue.message},`${ue.severity}-${ye}`))})]}),confirmLabel:"Force save anyway",cancelLabel:"Go back and fix",onConfirm:()=>D==null?void 0:D.resolve(!0),onCancel:()=>D==null?void 0:D.resolve(!1)}),y.jsx(ro,{isOpen:V!==null,title:"File changed on disk",danger:!0,message:`The configuration file was modified outside this editor since it was loaded. - -Reload disk version: discard your edits and load the file as it is on disk. -Overwrite anyway: save your edits and replace the file's current content.`,confirmLabel:"Overwrite anyway",cancelLabel:"Reload disk version",onConfirm:()=>V==null?void 0:V.resolve(!0),onCancel:()=>V==null?void 0:V.resolve(!1)}),y.jsx(z9,{open:ne!==null,onCancel:()=>ne==null?void 0:ne.resolve(null),onConfirm:ue=>ne==null?void 0:ne.resolve(ue)})]})}function F9({position:n,onClose:e,onLaunch:t,onLaunchWithArgs:i,onReveal:l,onOpenFolder:o,onOpenTerminal:a,onScanDirectory:u,onFilterFolder:f,onFilterExtension:d,onCopyPath:m,onCopyFilename:g,onCopyUri:b,onComputeHash:v,onVerifyHash:w,onProperties:S,onClearFile:C,onGenerateBarcode:N,showToast:j}){const[M,U]=A.useState(!1),[H,E]=A.useState(""),D=A.useRef(null),I=A.useRef(null),ne=A.useRef(null),[F,V]=A.useState(null);if(A.useEffect(()=>{var W;M&&((W=I.current)==null||W.showModal())},[M]),A.useLayoutEffect(()=>{if(!n){V(null);return}const W=()=>{const T=D.current;if(!T)return;const de=T.getBoundingClientRect(),be=8;V({left:Math.max(be,Math.min(n.x,window.innerWidth-de.width-be)),top:Math.max(be,Math.min(n.y,window.innerHeight-de.height-be))})};return W(),window.addEventListener("resize",W),()=>window.removeEventListener("resize",W)},[n]),A.useEffect(()=>{if(!n)return;ne.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const W=window.requestAnimationFrame(()=>{var T,de;(de=(T=D.current)==null?void 0:T.querySelector("[role='menuitem']"))==null||de.focus()});return()=>{var T;window.cancelAnimationFrame(W),(T=ne.current)==null||T.focus()}},[n]),!n)return null;const{file:_,x:ie,y:pe}=n,ce=()=>{i(_,H),U(!1),e()},Z=W=>{const T=W.lastIndexOf(".");return T!==-1?W.slice(T):""},oe=W=>{const T=Math.max(W.lastIndexOf("/"),W.lastIndexOf("\\"));return T!==-1?W.slice(0,T):W},G=W=>{const T=Math.max(W.lastIndexOf("/"),W.lastIndexOf("\\"));return T!==-1?W.slice(0,T):""};return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-[calc(var(--z-context-menu)-1)]",onClick:e,onContextMenu:W=>{W.preventDefault(),e()},"aria-hidden":"true"}),y.jsxs("div",{ref:D,role:"menu","aria-label":`Actions for ${_.filename}`,tabIndex:0,onKeyDown:W=>{var be,z,R,X;["Escape","ArrowDown","ArrowUp","Home","End"].includes(W.key)&&W.stopPropagation();const T=Array.from(((be=D.current)==null?void 0:be.querySelectorAll("[role='menuitem']"))??[]),de=T.indexOf(document.activeElement);if(W.key==="Escape")W.preventDefault(),e();else if(W.key==="ArrowDown"||W.key==="ArrowUp"){W.preventDefault();const he=W.key==="ArrowDown"?1:-1;(z=T[(de+he+T.length)%T.length])==null||z.focus()}else W.key==="Home"?(W.preventDefault(),(R=T[0])==null||R.focus()):W.key==="End"&&(W.preventDefault(),(X=T.at(-1))==null||X.focus())},className:"animate-modal-in fixed z-[var(--z-context-menu)] max-h-[calc(100dvh-16px)] w-56 max-w-[calc(100vw-16px)] overflow-y-auto rounded-lg border border-line bg-surface-glass py-1 text-xs text-ink shadow-2xl backdrop-blur-md",style:F??{left:ie,top:pe,visibility:"hidden"},children:[y.jsx("div",{className:"border-b border-line px-3 py-2 font-medium text-ink-muted truncate",children:_.filename}),y.jsxs("button",{role:"menuitem",onClick:()=>{t(_),e()},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${_.filename}`,children:[y.jsx(ss,{className:"h-3.5 w-3.5 fill-current text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Launch"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{U(!0)},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${_.filename} with arguments`,children:[y.jsx(ss,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Launch with arguments..."})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{l(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Reveal ${_.filename} in file manager`,children:[y.jsx(Z0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Reveal in File Manager"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{o(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open folder containing ${_.filename}`,children:[y.jsx(rs,{className:"h-3.5 w-3.5 text-chip-amber-text group-hover:text-white"}),y.jsx("span",{children:"Open Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{a(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open terminal in directory containing ${_.filename}`,children:[y.jsx(oO,{className:"h-3.5 w-3.5 text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Open Terminal in Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{N(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Generate QR Code",children:[y.jsx(vy,{className:"h-3.5 w-3.5 text-chip-fuchsia-text group-hover:text-white"}),y.jsx("span",{children:"Generate QR Code"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{const W=oe(_.path);u(W),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Scan to Directory",children:[y.jsx(rs,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Scan to Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const W=G(_.rel_path);W&&f(W),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view to folder ${_.filename} is in`,children:[y.jsx(J0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter to Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const W=Z(_.filename);W&&d(W),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view by extension ${Z(_.filename)}`,children:[y.jsx(J0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter by Extension"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(_,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy full path of ${_.filename}`,children:[y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Full Path"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(_,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy path of ${_.filename} with forward slashes`,children:[y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Path (Forward Slashes)"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(_,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${_.filename}`,children:[y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(_,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${_.filename} without extension`,children:[y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename (no ext)"})]}),y.jsxs("button",{role:"menuitem",onClick:async()=>{const W=oe(_.path);e();try{await navigator.clipboard.writeText(W),j==null||j(`Copied: ${W}`)}catch(T){j==null||j(`Copy failed: ${(T==null?void 0:T.message)??T}`,"error")}},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Copy Directory",children:[y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{b(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy URI of ${_.filename}`,children:[y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy URI"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(_,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute MD5 hash of ${_.filename}`,children:[y.jsx(ha,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(_,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute SHA256 hash of ${_.filename}`,children:[y.jsx(ha,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute SHA256 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(_,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify MD5 hash of ${_.filename}`,children:[y.jsx(ha,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(_,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify SHA256 hash of ${_.filename}`,children:[y.jsx(ha,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify SHA256 Hash"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{S(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`View properties of ${_.filename}`,children:[y.jsx(Z0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Properties"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{C(_),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Remove ${_.filename} from list`,children:[y.jsx(cO,{className:"h-3.5 w-3.5 text-status-danger-text group-hover:text-white"}),y.jsx("span",{children:"Delete"})]})]}),M&&y.jsx("dialog",{ref:I,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 rounded-xl","aria-labelledby":"args-modal-title",onClick:W=>{W.target===I.current&&U(!1)},onCancel:W=>{W.preventDefault(),U(!1)},children:y.jsxs("div",{className:"animate-modal-in w-96 rounded-xl border border-frame-line glass-panel p-4",children:[y.jsx("h3",{id:"args-modal-title",className:"mb-2 text-sm font-semibold text-ink",children:"Launch with Arguments"}),y.jsx("p",{className:"mb-3 text-xs text-ink-muted truncate",children:_.filename}),y.jsx("input",{type:"text",autoFocus:!0,placeholder:"Arguments (e.g. --verbose --port 80)",value:H,onChange:W=>E(W.target.value),onKeyDown:W=>{W.key==="Enter"&&ce(),W.key==="Escape"&&U(!1)},className:"mb-4 w-full rounded-md border border-line bg-elevated px-3 py-2 text-xs text-ink outline-none focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500","aria-label":"Command line arguments"}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{onClick:()=>U(!1),className:"rounded-md px-3 py-1.5 text-xs text-ink-muted hover:bg-elevated hover:text-ink focus:outline-none focus:ring-2 focus:ring-indigo-500","aria-label":"Cancel launch",children:"Cancel"}),y.jsx("button",{onClick:ce,className:"btn btn-primary px-3 py-1.5","aria-label":`Launch ${_.filename} with arguments`,children:"Launch"})]})]})})]})}function q9({isOpen:n,initialPath:e,onClose:t,onSelect:i}){const[l,o]=A.useState(null),[a,u]=A.useState(null),[f,d]=A.useState(""),[m,g]=A.useState(!1),[b,v]=A.useState(null),w=A.useRef(null),S=A.useRef(null),C=A.useRef(null);A.useEffect(()=>{var H;if(!n){(H=C.current)==null||H.focus();return}C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v(null),N(e||"");const U=requestAnimationFrame(()=>{var E;return(E=S.current)==null?void 0:E.focus()});return()=>{var E;cancelAnimationFrame(U),(E=C.current)==null||E.focus()}},[n]);const N=async U=>{g(!0),v(null);try{const H=await fetch(`/api/fs/browse?path=${encodeURIComponent(U)}`);if(!H.ok)throw new Error("Failed to browse directory");const E=await H.json();o(E),u(E.current_path),d(E.current_path)}catch(H){v(H.message||"Navigation failed")}finally{g(!1)}},j=()=>{const U=f.trim()||a;U&&(i(U),t())},M=U=>{var I;if(U.key==="Escape"){U.preventDefault(),t();return}if(U.key!=="Tab")return;const H=(I=w.current)==null?void 0:I.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(H!=null&&H.length))return;const E=H[0],D=H[H.length-1];U.shiftKey&&document.activeElement===E?(U.preventDefault(),D.focus()):!U.shiftKey&&document.activeElement===D&&(U.preventDefault(),E.focus())};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:t,children:y.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",onKeyDown:M,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:U=>U.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(rs,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"directory-picker-title",className:"text-sm font-semibold text-ink",children:"Select a directory"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(l==null?void 0:l.current_path)||""})]})]}),y.jsx(Xe,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:t,"aria-label":"Close directory picker",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(_i,{className:"h-4 w-4"})})})]}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"directory-picker-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:S,id:"directory-picker-path",type:"text",value:f,onChange:U=>d(U.target.value),onKeyDown:U=>{U.key==="Enter"&&N(f.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>N(f.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Xe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>N(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Zd,{className:"h-4 w-4"})})}),(l==null?void 0:l.parent_path)&&y.jsx(Xe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>N(l.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Wd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":m,children:m?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(fl,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):b?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:b}),y.jsx("button",{type:"button",onClick:()=>N(f||(l==null?void 0:l.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[l==null?void 0:l.items.filter(U=>U.is_dir).map(U=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>N(U.path),onDoubleClick:()=>{d(U.path),i(U.path),t()},className:`flex min-h-10 w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${a===U.path?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(Du,{className:"h-5 w-5 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:U.name})]}),a===U.path&&y.jsx(Br,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},U.path)),(l==null?void 0:l.items.filter(U=>U.is_dir).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(rs,{className:"h-7 w-7 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected folder"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:a||f,children:a||f||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:t,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:j,disabled:!f.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(rs,{className:"h-4 w-4"}),"Select folder"]})]})]})]})}):null}function V9({visible:n,onFileSelected:e}){const t=A.useRef(null);return n?y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-drop-overlay)] flex items-center justify-center bg-black/65 backdrop-blur-sm",onClick:()=>{var i;return(i=t.current)==null?void 0:i.click()},"data-testid":"drop-config-overlay",children:[y.jsx("input",{ref:t,type:"file",accept:".profiles,.profiles.yaml,.profiles.yml,.yaml,.yml",className:"hidden",onChange:i=>{var o;const l=(o=i.target.files)==null?void 0:o[0];l&&e(l),i.target.value=""}}),y.jsxs("div",{className:"rounded-xl border-2 border-dashed border-chip-indigo-border bg-surface px-8 py-6 text-center shadow-2xl",children:[y.jsx("span",{className:"mx-auto mb-3 grid h-9 w-9 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(fa,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsx("p",{className:"text-sm font-semibold text-ink",children:"Drop configuration file"}),y.jsx("p",{className:"mt-1 text-xs text-ink-muted",children:".profiles, .profiles.yaml, .yml, .yaml — session-only preview"})]})]}):null}function Q9({items:n,columnTemplate:e,resizePointerRef:t,resizeMovedRef:i}){return y.jsx("div",{className:"grid select-none items-center border-b border-l-2 border-l-transparent border-line/40 bg-surface/60 font-medium text-ink-muted shadow-sm backdrop-blur-md",role:"row","aria-rowindex":1,"data-file-list-header":!0,style:{gridTemplateColumns:e},children:n.map((l,o)=>{const a=!!(l.onSort&&l.sortKey),u=l.active?l.direction==="asc"?"ascending":"descending":"none";return y.jsxs("div",{role:"columnheader","data-column-key":l.sortKey,className:`group relative flex items-center gap-1.5 truncate px-3 py-2 ${a?"cursor-pointer hover:text-ink transition-colors":""} ${l.active?"text-ink":""}`,...a?{"aria-sort":u,tabIndex:0,onClick:l.onSort,onKeyDown:f=>{var d;(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),(d=l.onSort)==null||d.call(l))}}:{},children:[l.icon,y.jsx("span",{className:"truncate",children:l.label}),a?l.active?l.direction==="asc"?y.jsx(e4,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(eO,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(Yk,{className:"ml-auto h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-40 hover:opacity-40"}):o>0&&y.jsx(Yk,{className:"ml-auto h-3 w-3 shrink-0 opacity-40"}),l.canResize&&l.onResizeBy&&y.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${l.label} column`,"aria-valuemin":xa,"aria-valuemax":Qd,"aria-valuenow":l.width??l.defaultWidth??hd,"aria-valuetext":`${l.width??l.defaultWidth??hd} pixels wide`,title:"Drag to resize; use arrow keys or click either side to adjust",tabIndex:0,onClick:f=>{var g;f.preventDefault(),f.stopPropagation();const d=i.current;if(i.current=!1,d)return;const m=f.currentTarget.getBoundingClientRect();(g=l.onResizeBy)==null||g.call(l,f.clientX{f.preventDefault(),f.stopPropagation();const d=f.currentTarget.parentElement;i.current=!1,t.current={pointerId:f.pointerId,startX:f.clientX,startWidth:l.width??(d==null?void 0:d.getBoundingClientRect().width)??l.defaultWidth??hd,resizeTo:l.onResizeTo},f.currentTarget.setPointerCapture(f.pointerId)},onPointerMove:f=>{const d=t.current;if(!d||d.pointerId!==f.pointerId)return;const m=f.clientX-d.startX;Math.abs(m)>2&&(i.current=!0),d.resizeTo(d.startWidth+m)},onPointerUp:f=>{var d;((d=t.current)==null?void 0:d.pointerId)===f.pointerId&&(f.currentTarget.releasePointerCapture(f.pointerId),t.current=null,window.setTimeout(()=>{i.current=!1},0))},onPointerCancel:()=>{t.current=null,i.current=!1},onKeyDown:f=>{var d,m;f.stopPropagation(),f.key==="ArrowLeft"||f.key==="ArrowRight"?(f.preventDefault(),(d=l.onResizeBy)==null||d.call(l,f.key==="ArrowLeft"?-Qh:Qh)):(f.key==="Home"||f.key==="End")&&(f.preventDefault(),(m=l.onResizeTo)==null||m.call(l,f.key==="Home"?xa:Qd))},className:"absolute inset-y-0 right-0 z-10 w-3 cursor-col-resize touch-none border-r border-transparent transition-colors hover:border-indigo-400 focus-visible:border-indigo-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500"})]},o)})})}const lr=28,Vh=12,R0=500,xa=80,Qd=960,hd=160,Qh=24,Q2=44,Xh={File:2,Path:3,FileName:1,Type:1,Version:1};function X9({files:n,totalCount:e,rawLoadedCount:t,onLoadMore:i,loadingMore:l=!1,scanning:o=!1,hasScanned:a=!1,activeDirectory:u="",recursive:f=!1,onDisableRecursive:d,onOpenDirectory:m,onLoadConfig:g,filterText:b,onClearFilter:v,prefilterNote:w,columnHeaders:S,columnNames:C,selectedIndex:N,onSelectIndex:j,onLaunch:M,onContextMenu:U,rowColors:H,sort:E,onSortChange:D}){const I=["File"],ne=C.length>0?C:I,F=S.length>0?S:ne,V=Array.from({length:Math.max(ne.length,F.length)},(Oe,qe)=>({key:ne[qe]??I[0],header:F[qe]??ne[qe]??I[0]})),_=A.useRef(null),[ie,pe]=A.useState(0),[ce,Z]=A.useState(600),[oe,G]=A.useState(0),[W,T]=A.useState({}),de=A.useRef(null),be=A.useRef(!1),z=ne.reduce((Oe,qe)=>Oe+(Xh[qe]??1),1),R=(Oe,qe)=>{const $e=Math.min(Qd,Math.max(xa,Math.round(qe)));T(mt=>({...mt,[Oe]:$e}))},X=(Oe,qe)=>{var te;const $e=Array.from(((te=_.current)==null?void 0:te.querySelectorAll("[data-column-key]"))??[]).find(fe=>fe.dataset.columnKey===Oe),mt=W[Oe]??($e==null?void 0:$e.getBoundingClientRect().width)??hd;R(Oe,mt+qe)},he=[`${Q2}px`,...ne.map(Oe=>W[Oe]?`${W[Oe]}px`:`minmax(${xa}px, ${Xh[Oe]??1}fr)`)].join(" "),ge=A.useRef(!1),ze=A.useRef(null),Te=n.length,He=t??Te,ke=e??He,Ae=He{const Oe=_.current;if(!Oe)return;const qe=new ResizeObserver($e=>{for(const mt of $e)Z(mt.contentRect.height),G(mt.contentRect.width)});return qe.observe(Oe),Z(Oe.clientHeight||600),G(Oe.clientWidth||0),()=>qe.disconnect()},[]),A.useEffect(()=>{var fe;const Oe=_.current;if(!Oe||N<0||N>=Te)return;const qe=((fe=Oe.querySelector("[data-file-list-header]"))==null?void 0:fe.offsetHeight)??0,$e=qe+N*lr,mt=$e+lr;let te=Oe.scrollTop;$eOe.scrollTop+Oe.clientHeight&&(te=mt-Oe.clientHeight),te!==Oe.scrollTop&&(Oe.scrollTop=te,pe(te))},[N,Te]),A.useEffect(()=>{const Oe=_.current;if(!Oe)return;const qe=()=>{if(ge.current||!Ft||!i)return;const $e=Oe.scrollTop+Oe.clientHeight,mt=Te*lr;mt-$e$e&&(ge.current=!0,window.setTimeout(()=>{ge.current=!1},200),i())};return Oe.addEventListener("scroll",qe,{passive:!0}),window.addEventListener("scroll",qe,{passive:!0}),()=>{Oe.removeEventListener("scroll",qe),window.removeEventListener("scroll",qe)}},[n,Ft,i,Te]),A.useEffect(()=>{if(ge.current||!Ft||!i)return;const Oe=Te*lr,qe=ie+ce;if(!(Oe-qeqe))return;const mt=`${Te}:${He}:${ke}`;ze.current=mt,i()});const gn=A.useCallback(Oe=>{pe(Oe.currentTarget.scrollTop)},[]),Ht=Math.max(0,Math.floor(ie/lr)-Vh),Ot=Math.ceil(ce/lr)+Vh*2,st=Math.min(Te,Ht+Ot),tn=Ht*lr,Pn=(Oe,qe)=>{if(qe)return{className:"bg-chip-indigo-bg border-l-4 border-chip-indigo-border text-ink",style:{}};for(const[$e,mt]of H)if(Oe.toLowerCase().includes($e.toLowerCase()))return{className:"hover:bg-elevated border-l-4 text-ink",style:{borderLeftColor:mt,borderLeftWidth:"4px"}};return{className:"border-l-4 border-transparent text-ink-secondary hover:bg-elevated/60",style:{borderLeftColor:"transparent",borderLeftWidth:"4px"}}},qt=(Ft?Te+Ot:Te)*lr,Kt="btn btn-secondary px-3 py-1.5";return y.jsxs("div",{ref:_,onScroll:gn,className:"flex-1 overflow-auto bg-app text-xs transition-colors duration-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 focus-visible:outline-offset-[-2px]","data-testid":"file-list","data-loaded-count":He,"aria-busy":o,role:"grid","aria-label":"Discovered files","aria-rowcount":Math.max(ke,Te===0?1:0)+1,"aria-colcount":ne.length+1,"aria-activedescendant":Te>0?`file-row-${N}`:void 0,tabIndex:0,children:[y.jsx("div",{className:"sticky top-0 z-10",role:"presentation",children:y.jsx(Q9,{columnTemplate:he,resizePointerRef:de,resizeMovedRef:be,items:[{label:"#",icon:y.jsx(J0,{className:"h-3.5 w-3.5"})},...V.map(({key:Oe,header:qe})=>({label:qe,weight:Xh[Oe]??1,width:W[Oe],defaultWidth:Math.min(Qd,Math.max(xa,Math.round((oe-Q2)*(Xh[Oe]??1)/z))),canResize:!0,onResizeBy:$e=>X(Oe,$e),onResizeTo:$e=>R(Oe,$e),sortKey:Oe,active:(E==null?void 0:E.column)===Oe,direction:E==null?void 0:E.direction,onSort:()=>{(E==null?void 0:E.column)!==Oe?D({column:Oe,direction:"asc"}):E.direction==="asc"?D({column:Oe,direction:"desc"}):D(null)}}))]})}),w&&Te>0&&y.jsxs("div",{role:"note","data-testid":"prefilter-note",className:"flex items-center gap-1.5 border-b border-line/40 bg-surface px-3 py-1 text-[11px] text-ink-faint",children:[y.jsx(by,{className:"h-3 w-3 shrink-0 text-ink-faint","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 truncate",children:w})]}),Te===0?y.jsx("div",{role:"row","aria-rowindex":2,"data-testid":"file-list-empty",children:y.jsx("div",{role:"gridcell","aria-colspan":ne.length+1,className:"p-8 text-center text-ink-faint",children:o?y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx(fl,{className:"h-5 w-5 animate-spin text-chip-indigo-text motion-reduce:animate-none"}),y.jsx("span",{children:"Scanning files..."})]}):!u.trim()&&g?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"Select a directory first."}),y.jsx("button",{type:"button",onClick:g,className:Kt,children:"Choose configuration"})]}):a?b.trim()?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsxs("span",{children:["No files match “",b,"”."]}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[y.jsx("button",{type:"button",onClick:v,className:Kt,children:"Clear filter"}),f&&d&&y.jsx("button",{type:"button",onClick:d,className:Kt,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:Kt,children:"Open directory"})]})]}):y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"No files found for the current directory and extension."}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[f&&d&&y.jsx("button",{type:"button",onClick:d,className:Kt,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:Kt,children:"Open directory"})]})]}):y.jsx("span",{children:"Select a directory and scan to find files."})})}):y.jsxs("div",{className:"relative",style:{height:qt},role:"rowgroup",children:[l&&y.jsx("div",{className:"pointer-events-none absolute left-1/2 top-2 z-20 -translate-x-1/2","aria-hidden":"true",children:y.jsx(fl,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})}),y.jsx("div",{style:{transform:`translateY(${tn}px)`},"data-testid":"file-list-window",role:"presentation",children:n.slice(Ht,st).map((Oe,qe)=>{const $e=Ht+qe,mt=$e===N,te=Pn(Oe.filename,mt);return y.jsxs("div",{id:`file-row-${$e}`,"data-row-index":$e,role:"row","aria-rowindex":$e+2,"aria-selected":mt,onClick:()=>{var fe;j($e),(fe=_.current)==null||fe.focus()},onDoubleClick:()=>M(Oe),onContextMenu:fe=>U(fe,Oe,$e),className:`grid cursor-pointer items-center transition-colors ${te.className}`,style:{...te.style,height:lr,gridTemplateColumns:he},children:[y.jsxs("div",{className:"flex items-center justify-end gap-1 px-3 font-mono text-ink-faint",children:[Oe.has_hook&&y.jsx("span",{title:Oe.hook_pattern?`Launch workflow: ${Oe.hook_pattern}`:"Launch workflow configured","aria-label":"Workflow hook attached",className:"inline-flex items-center text-status-warning-text hover:brightness-95",children:y.jsx(uO,{className:"h-3 w-3 shrink-0"})}),y.jsx("span",{className:"hidden sm:inline",children:$e+1})]}),ne.map((fe,Le)=>{const Be=Oe.column_values[fe]||(fe==="File"?Oe.filename:"-");return y.jsx("div",{role:"gridcell","data-column-key":fe,className:"truncate px-3 font-mono",style:{minWidth:xa},title:fe==="Path"?Oe.path:Be,children:Be},Le)})]},Oe.path||$e)})}),Ae&&y.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full border border-line bg-surface-strong px-3 py-1 text-[11px] text-ink-muted shadow","data-testid":"file-list-paging",children:[l?y.jsx(GM,{className:"mr-1.5 h-4 w-4 animate-spin motion-reduce:animate-none text-ink-muted"}):null,"(",He," of ",ke," loaded)"]})]})]})}function ey({id:n,ariaLabel:e,value:t,options:i,onChange:l,placeholder:o,className:a="",inputClassName:u="",optionLabel:f=g=>g,onOpenChange:d,commitOn:m="change"}){const g=A.useId(),b=A.useRef(null),[v,w]=A.useState(!1),[S,C]=A.useState(""),[N,j]=A.useState(-1),[M,U]=A.useState(null),H=i.filter(V=>f(V).toLocaleLowerCase().includes(S.toLocaleLowerCase())),E=N>=0&&H[N]?`${g}-option-${N}`:void 0;A.useEffect(()=>{const V=_=>{var ie;(ie=b.current)!=null&&ie.contains(_.target)||w(!1)};return document.addEventListener("mousedown",V),()=>document.removeEventListener("mousedown",V)},[]),A.useEffect(()=>{d==null||d(v)},[v,d]),A.useEffect(()=>{var V;N<0||(V=document.getElementById(`${g}-option-${N}`))==null||V.scrollIntoView({block:"nearest"})},[N,g]);const D=()=>{C(""),j(-1),w(!0)},I=V=>{U(null),l(V)},ne=V=>{I(V),C(""),j(-1),w(!1)},F=V=>{if(V.key==="ArrowDown"){if(V.preventDefault(),!v){D(),j(0);return}j(_=>Math.min(_+1,H.length-1))}else if(V.key==="ArrowUp"){if(V.preventDefault(),!v){D(),j(H.length-1);return}j(_=>_<=0?H.length-1:_-1)}else V.key==="Enter"&&v&&H[N]!==void 0?(V.preventDefault(),V.stopPropagation(),ne(H[N])):V.key==="Enter"&&m==="deferred"&&M!==null&&M!==t?(V.preventDefault(),V.stopPropagation(),I(M)):V.key==="Escape"&&w(!1)};return y.jsxs("div",{ref:b,onBlur:V=>{var _;(_=b.current)!=null&&_.contains(V.relatedTarget)||(w(!1),m==="deferred"&&M!==null&&M!==t&&I(M))},className:`relative flex min-w-0 ${a}`,children:[y.jsx("input",{id:n,type:"text",role:"combobox","aria-label":e,"aria-autocomplete":"list","aria-expanded":v,"aria-controls":g,"aria-activedescendant":E,value:m==="deferred"&&M!==null?M:t,placeholder:o,onChange:V=>{const _=V.target.value;C(_),j(-1),w(!0),m==="deferred"?U(_):l(_)},onKeyDown:F,className:`min-w-0 flex-1 rounded-l-md border border-line bg-elevated px-3 py-1.5 text-ink outline-none transition-colors hover:bg-surface-strong focus:border-indigo-500 ${u}`}),y.jsx("button",{type:"button","aria-label":`Show ${e.toLowerCase()} options`,"aria-expanded":v,title:`Show ${e.toLowerCase()} options`,onMouseDown:V=>V.preventDefault(),onClick:()=>v?w(!1):D(),className:"shrink-0 rounded-r-md border border-l-0 border-line bg-elevated px-2 text-ink-muted hover:bg-surface-strong hover:text-ink focus-visible:z-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 transition-colors",children:y.jsx(a4,{className:`h-3.5 w-3.5 transition-transform ${v?"rotate-180":""}`})}),v&&y.jsx("ul",{id:g,role:"listbox","aria-label":`${e} options`,className:"absolute left-0 top-full z-[var(--z-combobox-list)] mt-1 max-h-60 w-full min-w-48 overflow-y-auto rounded-md border border-line bg-surface py-1 text-ink shadow-xl",children:H.length>0?H.map((V,_)=>{const ie=f(V),pe=_===N,ce=V===t;return y.jsx("li",{id:`${g}-option-${_}`,role:"option","aria-selected":ce,title:ie||void 0,onMouseEnter:()=>j(_),onMouseDown:Z=>Z.preventDefault(),onClick:()=>ne(V),className:`cursor-pointer truncate px-3 py-1.5 ${pe?"bg-elevated text-ink":"text-ink-secondary"} ${ce?"font-semibold":""}`,children:ie||"(No filter)"},`${V}-${_}`)}):y.jsx("li",{className:"px-3 py-1.5 text-ink-muted",children:"No matching presets"})})]})}function $9(n){const e=n.match(/^(.*?)\.(?:dev|post)\d+/);if(e)return e[1];const t=n.indexOf("+");return t>-1?n.slice(0,t):n}function Y9({title:n,release:e,directories:t,activeDirectory:i,onDirectoryChange:l,onBrowseDirectory:o,onGoToParentDirectory:a,onGoToHomeDirectory:u,onOpenActiveDirectory:f,onOpenTerminal:d}){const[m,g]=A.useState(!1),b=e||"0.0.0-dev",[v,w]=A.useState(!1),S=A.useRef(null),C=async()=>{try{await navigator.clipboard.writeText(b),w(!0),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>w(!1),1500)}catch{}};return A.useEffect(()=>()=>{S.current!==null&&window.clearTimeout(S.current)},[]),y.jsxs("header",{className:"relative z-30 flex flex-wrap items-center gap-3 border-b border-line bg-app/90 px-5 py-2 text-xs backdrop-blur-xl shadow-xs transition-all duration-200",children:[y.jsx("div",{className:"flex shrink-0 items-center gap-3",children:y.jsxs("div",{className:"flex items-center gap-3.5",children:[y.jsxs("div",{className:"relative flex h-9 w-9 items-center justify-center rounded-xl border border-chip-indigo-border shadow-xs",children:[y.jsx("img",{src:"/profiles-128.png",alt:"ProFiles logo",className:"h-9 w-9 rounded-xl object-cover"}),y.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex h-2.5 w-2.5 items-center justify-center rounded-full bg-emerald-500 ring-2 ring-app"})]}),y.jsxs("div",{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h1",{className:"text-sm font-bold tracking-tight text-ink font-heading",children:"ProFiles"}),n&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"/"}),y.jsx("span",{className:"text-xs font-medium text-chip-indigo-text bg-chip-indigo-bg px-2 py-0.5 rounded-md border border-chip-indigo-border/50",children:n})]})]}),y.jsxs("p",{className:"text-[11px] font-medium text-ink-muted tracking-wide mt-0.5",children:["Crafted by ",y.jsx("span",{className:"text-ink font-semibold",children:"Florent ALBANY"})," •"," ",y.jsx(Xe,{text:v?"Copied!":`v${b}`,block:!1,placement:"bottom",children:y.jsxs("button",{type:"button",onClick:()=>void C(),"aria-label":`Copy full version ${b}`,className:"cursor-pointer font-mono text-chip-indigo-text hover:text-chip-indigo-text/80",children:["v",$9(b)]})})]})]})]})}),y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[y.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 font-medium text-ink-secondary text-xs",children:[y.jsx(Du,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),y.jsx("span",{children:"Directory:"})]}),y.jsx(Xe,{text:"Select or type a directory path to scan files from.",suppress:m,children:y.jsx(ey,{id:"directory-combobox",ariaLabel:"Directory",value:i,options:t,onChange:l,commitOn:"deferred",onOpenChange:g,placeholder:"/path/to/directory",className:"w-full",inputClassName:"font-mono"})}),f&&y.jsx(Xe,{text:"Open the active directory in the OS file manager",block:!1,children:y.jsx("button",{type:"button",onClick:f,"aria-label":"Open active directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(WM,{className:"h-3.5 w-3.5"})})}),a&&y.jsx(Xe,{text:"Go to parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:a,"aria-label":"Go to parent directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Wd,{className:"h-3.5 w-3.5 rotate-180"})})}),o&&y.jsx(Xe,{text:"Browse for a folder on this system",block:!1,children:y.jsx("button",{type:"button",onClick:o,"aria-label":"Browse directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(rs,{className:"h-3.5 w-3.5"})})}),d&&y.jsx(Xe,{text:"Open the active directory in a terminal",block:!1,children:y.jsx("button",{type:"button",onClick:()=>d(i),"aria-label":"Open directory in terminal",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(oO,{className:"h-3.5 w-3.5"})})}),u&&y.jsx(Xe,{text:"Set directory to your home folder",block:!1,children:y.jsx("button",{type:"button",onClick:u,"aria-label":"Go to home directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Zd,{className:"h-3.5 w-3.5"})})})]})]})}function G9({message:n,onRetry:e,retrying:t=!1}){return y.jsx("div",{className:"flex flex-1 items-center justify-center p-8",role:"alert","data-testid":"init-error-panel",children:y.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-line bg-surface p-6 text-center shadow-xl",children:[y.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-full border border-status-danger-border bg-status-danger-bg",children:y.jsx(tu,{className:"h-5 w-5 text-status-danger-text/80"})}),y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Couldn't load the app"}),y.jsx("p",{className:"mt-1 break-words text-xs text-ink-secondary",children:n}),y.jsxs("button",{type:"button",onClick:e,disabled:t,className:"btn btn-primary mx-auto mt-4 px-3.5 py-1.5 font-semibold shadow-sm",children:[y.jsx(Jd,{className:`h-3.5 w-3.5 ${t?"animate-spin motion-reduce:animate-none":""}`}),y.jsx("span",{children:t?"Retrying...":"Retry"})]})]})})}const X2=/"([^"]*)"|(\S+)/g,$2=/"([^"]*)"/g,K9="Unmatched quote";function W9(n){const e=[];let t;for(X2.lastIndex=0;(t=X2.exec(n))!==null;){const a=t[1]!==void 0?t[1]:t[2];a&&a.trim()&&e.push(a)}let i="",l=0;$2.lastIndex=0;let o;for(;(o=$2.exec(n))!==null;)i+=n.slice(l,o.index),l=o.index+o[0].length;return i+=n.slice(l),{terms:e,error:i.includes('"')?K9:null}}function yA(n){const e=n.trim();if(!e)return{error:null,groups:[]};const{terms:t,error:i}=W9(e);if(t.length===0)return{error:i,groups:[]};const l=[];let o={includes:[],excludes:[]};for(const a of t){if(a.toUpperCase()==="OR"){l.push(o),o={includes:[],excludes:[]};continue}a==="-"||a==="+"||(a.startsWith("-")&&a.length>1?o.excludes.push(a.slice(1)):a.startsWith("+")&&a.length>1?o.includes.push(a.slice(1)):o.includes.push(a))}return l.push(o),{error:i,groups:l}}const Z9=256,Ys=new Map;function Y2(n){return n.toLowerCase()}function J9(n){const e=Ys.get(n);if(e)return Ys.delete(n),Ys.set(n,e),e;const{groups:t}=yA(n),i={groups:t.map(l=>({includes:l.includes.map(Y2),excludes:l.excludes.map(Y2)}))};if(Ys.size>=Z9){const l=Ys.keys().next().value;l!==void 0&&Ys.delete(l)}return Ys.set(n,i),i}function e8(n,e){return e.includes.every(t=>n.includes(t))&&!e.excludes.some(t=>n.includes(t))}function t8(n,e){const{groups:t}=J9(e);if(t.length===0)return!0;const i=n.toLowerCase();return t.some(l=>e8(i,l))}function n8({query:n,visible:e}){if(!e)return null;const t=yA(n);return t.error?y.jsx("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-status-danger-border bg-surface-strong px-3 py-2 text-[11px] leading-5 text-status-danger-text/90 shadow-xl",children:t.error}):t.groups.length===0?null:y.jsxs("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-line bg-surface-strong px-3 py-2 text-[11px] leading-5 text-ink-secondary shadow-xl",children:[y.jsx("span",{className:"mr-1.5 align-[1px] text-[10px] uppercase tracking-wide text-ink-muted",children:"reads as"}),t.groups.map((i,l)=>y.jsxs("span",{"data-testid":"filter-syntax-group",children:[l>0&&y.jsx("span",{className:"mx-1 font-mono text-chip-indigo-text",children:"OR"}),i.includes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"font-mono text-chip-indigo-text",children:o})]},`i-${a}`)),i.includes.length>0&&i.excludes.length>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),i.excludes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"text-ink-muted",children:"✕ "}),y.jsx("span",{className:"font-mono text-status-danger-text/70 line-through",children:o})]},`x-${a}`))]},l))]})}const G2=y.jsxs("span",{className:"flex flex-col gap-1 whitespace-nowrap text-left",children:[y.jsx("span",{className:"font-semibold",children:"Supported operators"}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a b"})," — AND (both terms)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a OR b"})," — either term"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"-a"})," — NOT (exclude)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"+a"})," — force include"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:'"a b"'})," — exact phrase"]})]});function i8({extensions:n,activeExtension:e,onExtensionChange:t,filterOptions:i,filterText:l,onFilterTextChange:o,recursive:a,onRecursiveChange:u,onScan:f,scanning:d,barcodeMode:m,onBarcodeToggle:g,onCameraBarcodeClick:b,autoRescanActive:v,onTimerClick:w}){const[S,C]=A.useState(!1),[N,j]=A.useState(!1),[M,U]=A.useState(!1);return y.jsxs("div",{className:"flex w-full flex-wrap items-center gap-3 border-b border-line bg-surface-glass p-3 text-xs",children:[y.jsx(Xe,{text:G2,suppress:N,children:y.jsxs("div",{className:"relative min-w-0 flex-1 basis-64",onFocusCapture:H=>{H.target.tagName==="INPUT"&&C(!0)},onBlurCapture:H=>{H.target.tagName==="INPUT"&&C(!1)},children:[y.jsx(sO,{className:"pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 text-ink-secondary"}),y.jsx(ey,{id:"filter-combobox",ariaLabel:"File filter",value:l,options:i||[],onChange:o,onOpenChange:j,placeholder:"Filter files: keyword, a OR b, -tag, exact phrase...",className:"w-full",inputClassName:"pl-9 pr-3",optionLabel:H=>H||"(No filter)"}),y.jsx(n8,{query:l,visible:S&&!N&&l.trim().length>0})]})}),y.jsx(Xe,{text:G2,block:!1,suppress:M,children:y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsx("span",{className:"text-ink-muted",children:"Ext:"}),y.jsx(ey,{id:"extension-combobox",ariaLabel:"Extension filter",value:e,options:n,onChange:t,commitOn:"deferred",onOpenChange:U,placeholder:".py OR .toml",className:"w-44",inputClassName:"font-mono px-2.5"})]})}),y.jsx(Xe,{text:"Include subdirectories when scanning",block:!1,children:y.jsxs("label",{className:"flex shrink-0 cursor-pointer select-none items-center gap-1.5 text-ink-secondary",children:[y.jsx("input",{type:"checkbox",checked:a,onChange:H=>u(H.target.checked),className:"rounded border-line text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-1 focus-visible:ring-offset-app"}),y.jsx("span",{children:"Recursive"})]})}),y.jsx(Xe,{text:"Run the scan with the current criteria (Enter)",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"btn btn-primary shrink-0 px-3.5 py-1.5 font-semibold shadow-sm",children:[d?y.jsx(Jd,{className:"h-3.5 w-3.5 animate-spin motion-reduce:animate-none"}):y.jsx(ss,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:d?"Scanning...":"Scan"})]})}),y.jsx(Xe,{text:v?"Auto-rescan is active. Click to configure.":"Configure periodic auto-rescan (hot-folder mode)",block:!1,children:y.jsx("button",{type:"button",onClick:w,"aria-label":"Configure timer / auto-rescan",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${v?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(aO,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`})})}),y.jsx(Xe,{text:"Toggle barcode scanner mode (USB HID). When active, scan a barcode to auto-fill controls and trigger a scan.",block:!1,children:y.jsx("button",{type:"button",onClick:g,"aria-label":m?"Disable barcode mode":"Enable barcode mode",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${m?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(vy,{className:`h-3.5 w-3.5 ${m?"animate-pulse":""}`})})}),b&&y.jsx(Xe,{text:"Scan barcode or QR code using webcam / camera (Ctrl + Shift + B)",block:!1,children:y.jsx("button",{type:"button",onClick:b,"aria-label":"Scan barcode with camera",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(tO,{className:"h-3.5 w-3.5"})})})]})}const r8=2e3,l8=500,s8=[{value:null,label:"ALL"},{value:"DEBUG",label:"DEBUG"},{value:"INFO",label:"INFO"},{value:"WARNING",label:"WARNING"},{value:"ERROR",label:"ERROR"},{value:"CRITICAL",label:"CRITICAL"}],K2={DEBUG:{icon:n4,className:"text-chip-sky-text"},INFO:{icon:by,className:"text-status-success-text"},WARNING:{icon:wy,className:"text-status-warning-text"},ERROR:{icon:du,className:"text-status-danger-text"},CRITICAL:{icon:du,className:"text-status-danger-text"},UNKNOWN:{icon:Na,className:"text-ink-faint"}};function o8({isOpen:n,onClose:e,onOpenExternally:t}){const[i,l]=A.useState([]),[o,a]=A.useState("profiles.log"),[u,f]=A.useState(0),[d,m]=A.useState(null),[g,b]=A.useState(""),[v,w]=A.useState(!1),[S,C]=A.useState(!0),[N,j]=A.useState(null),[M,U]=A.useState(!0),H=A.useRef(null),E=A.useRef(null),D=A.useRef(null),I=A.useRef(null),ne=A.useRef(S),F=A.useRef({level:d,search:g}),V=A.useRef(0),_=A.useRef(!0);ne.current=S,F.current={level:d,search:g};const ie=A.useCallback(async()=>{const G=++V.current,{level:W,search:T}=F.current;w(!0);try{const de=await wM({limit:l8,level:W,search:T});if(V.current!==G)return;l(de.entries),a(de.path),f(de.size_bytes),j(null)}catch(de){if(V.current!==G)return;j((de==null?void 0:de.message)||"Failed to read the log file")}finally{V.current===G&&w(!1)}},[]);A.useEffect(()=>{n&&ie()},[n,ie]),A.useEffect(()=>{if(!n||!S)return;const G=window.setInterval(()=>{ie()},r8);return()=>window.clearInterval(G)},[n,S,ie]),A.useEffect(()=>{if(!n){_.current=!0;return}if(_.current){_.current=!1;return}const G=window.setTimeout(()=>void ie(),250);return()=>window.clearTimeout(G)},[n,d,g,ie]),A.useEffect(()=>{if(!M)return;const G=D.current;G&&(G.scrollTop=G.scrollHeight)},[i,M]),A.useEffect(()=>{if(!n)return;const G=document.activeElement instanceof HTMLElement?document.activeElement:null,W=requestAnimationFrame(()=>{var T;return(T=E.current)==null?void 0:T.focus()});return()=>{cancelAnimationFrame(W),G==null||G.focus()}},[n]);const pe=G=>{var be;if(G.key==="Escape"){G.preventDefault(),e();return}if(G.key!=="Tab")return;const W=(be=H.current)==null?void 0:be.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(W!=null&&W.length))return;const T=W[0],de=W[W.length-1];G.shiftKey&&document.activeElement===T?(G.preventDefault(),de.focus()):!G.shiftKey&&document.activeElement===de&&(G.preventDefault(),T.focus())},ce=()=>{const G=D.current;if(!G)return;const W=G.scrollHeight-G.scrollTop-G.clientHeight<24;U(W)},Z=async()=>{try{await navigator.clipboard.writeText(i.map(G=>G.raw).join(` -`))}catch{}},oe=A.useMemo(()=>{const G=new Map;for(const W of i)G.set(W.level,(G.get(W.level)??0)+1);return G},[i]);return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:e,children:y.jsxs("div",{ref:H,role:"dialog","aria-modal":"true","aria-labelledby":"log-viewer-title",onKeyDown:pe,className:"animate-modal-in flex h-[min(84dvh,760px)] w-[clamp(560px,85vw,1500px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:G=>G.stopPropagation(),children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-line px-5 py-4 sm:px-6",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[y.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(Na,{className:"h-5 w-5 text-chip-indigo-text","aria-hidden":"true"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"log-viewer-title",className:"text-base font-semibold text-ink",children:"Application logs"}),y.jsxs("p",{className:"truncate font-mono text-xs text-ink-muted",children:[o,y.jsxs("span",{className:"text-ink-faint",children:[" · ",W2(u)]})]})]})]}),y.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[y.jsx(sO,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-faint","aria-hidden":"true"}),y.jsx("input",{ref:I,type:"search",value:g,onChange:G=>b(G.target.value),placeholder:"Filter log lines…","aria-label":"Filter log lines",className:"w-full rounded-lg border border-line bg-elevated py-1.5 pl-8 pr-2.5 font-mono text-xs text-ink placeholder:text-ink-faint focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400"})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[y.jsx(Xe,{text:S?"Pause live tail":"Resume live tail",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>C(G=>!G),"aria-pressed":S,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${S?"border-status-success-border bg-status-success-bg text-status-success-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx("span",{className:`h-2 w-2 rounded-full ${S?"bg-emerald-400":"bg-ink-faint"}`,"aria-hidden":"true"}),S?"Live":"Paused"]})}),y.jsx(Xe,{text:"Refresh now",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void ie(),disabled:v,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Jd,{className:`h-4 w-4 ${v?"animate-spin":""}`,"aria-hidden":"true"})})}),y.jsx(Xe,{text:"Copy visible lines",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void Z(),disabled:i.length===0,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(hi,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx(Xe,{text:"Open log file in the default application",block:!1,children:y.jsx("button",{type:"button",onClick:()=>{t==null||t(),e()},className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(iO,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx(Xe,{text:"Close",block:!1,children:y.jsx("button",{ref:E,type:"button",onClick:e,className:"rounded-lg p-2 text-ink-muted hover:bg-hover-surface hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(_i,{className:"h-4 w-4","aria-hidden":"true"})})})]})]}),y.jsxs("div",{ref:D,onScroll:ce,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain bg-app px-2 py-2 font-mono text-xs leading-relaxed sm:px-3",children:[y.jsxs("div",{className:"sticky top-0 z-10 mb-1 flex items-center gap-2 rounded-md border border-line/40 bg-surface/60 px-2 py-1 text-[10px] font-bold uppercase tracking-wider text-ink-muted shadow-sm backdrop-blur-md",role:"row",children:[y.jsx("span",{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink/70",children:"Time"}),y.jsx("span",{className:"w-[52px] shrink-0 text-ink/70",children:"Level"}),y.jsx("span",{className:"w-[150px] shrink-0 text-ink/70",children:"Source"}),y.jsx("span",{className:"min-w-0 flex-1 text-ink/70",children:"Message"})]}),N&&y.jsx("p",{role:"alert",className:"px-3 py-6 text-center text-xs text-status-danger-text",children:N}),!N&&i.length===0&&!v&&y.jsx("p",{className:"px-3 py-6 text-center text-xs text-ink-faint",children:"No log entries match the current filters."}),y.jsx("ul",{className:"space-y-0.5",children:i.map((G,W)=>{const T=K2[G.level]??K2.UNKNOWN,de=T.icon,be=G.level==="ERROR"||G.level==="CRITICAL";return y.jsxs("li",{className:`group flex items-start gap-2 rounded px-2 py-1 ${be?"bg-status-danger-bg/40":"hover:bg-elevated/50"}`,children:[y.jsx("span",{className:T.className,children:y.jsx(de,{className:"mt-0.5 h-3.5 w-3.5","aria-hidden":"true"})}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink-faint",children:G.timestamp}),y.jsx("span",{className:`w-[52px] shrink-0 text-[10px] font-semibold ${T.className}`,children:G.level}),y.jsx("span",{className:"w-[150px] shrink-0 truncate text-ink-faint",title:G.source,children:G.source}),y.jsx("span",{className:"min-w-0 flex-1 break-words text-ink-secondary",children:G.message})]},`${W}-${G.raw}`)})})]}),y.jsx("div",{className:"border-t border-line/60 bg-elevated/50 px-5 py-2.5 text-[11px] text-ink-faint shadow-sm backdrop-blur-md sm:px-6",children:y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[y.jsx("span",{className:"mr-auto min-w-0 max-w-full basis-full truncate sm:basis-auto",role:"status","aria-atomic":"true",children:v&&i.length===0?"Loading log entries…":`${i.length} of ${W2(u)} shown`}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"flex overflow-hidden rounded-lg border border-line/60 text-[11px] backdrop-blur-sm",role:"group","aria-label":"Filter by log level",children:s8.map(G=>{const W=d===G.value,T=G.value?oe.get(G.value)??0:i.length;return y.jsxs("button",{type:"button",onClick:()=>m(G.value),"aria-pressed":W,title:G.value?`Show ${G.value} and above`:"Show all levels",className:`flex items-center gap-1 px-2.5 py-1 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${W?"bg-indigo-600 text-white":"text-ink-muted hover:bg-elevated hover:text-ink"}`,children:[G.label,y.jsx("span",{className:W?"text-chip-indigo-text":"text-ink-faint",children:T})]},G.label)})}),y.jsx(Xe,{text:"Scroll to the newest entry",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>U(!0),"aria-pressed":M,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${M?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx(eO,{className:"h-3.5 w-3.5","aria-hidden":"true"}),y.jsx("span",{className:"hidden sm:inline",children:"Follow tail"})]})})]}),y.jsxs("span",{className:"hidden items-center gap-1.5 lg:flex",children:[y.jsx("span",{className:"hidden sm:inline",children:"Ctrl + Shift + L"}),y.jsx("span",{children:"toggles this viewer"})]})]})})]})}):null}function W2(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function a8({isOpen:n,onClose:e}){const t=A.useRef(null),i=gs({isOpen:n,onClose:e,dialogRef:t});if(!n)return null;const l=[{key:"F5",desc:"Refresh / re-scan file list"},{key:"Ctrl + R",desc:"Reload configuration & scan"},{key:"Enter",desc:"Execute / launch selected file"},{key:"P",desc:"Open properties for selected file"},{key:"↑ / ↓",desc:"Navigate file list"},{key:"Home / End",desc:"Jump to first / last file"},{key:"PageUp / PageDown",desc:"Page through the file list"},{key:"Ctrl + D",desc:"Focus Directory field"},{key:"Ctrl + E",desc:"Focus Extension field"},{key:"Ctrl + F",desc:"Focus Filter / Search field"},{key:"Ctrl + L",desc:"Focus File List"},{key:"Ctrl + Shift + L",desc:"Open the log viewer"},{key:"Ctrl + ,",desc:"Open the config editor"},{key:"Ctrl + Shift + T",desc:"Toggle theme (Dark / Light)"},{key:"Ctrl + B",desc:"Toggle barcode scanner mode"},{key:"Ctrl + Shift + B",desc:"Open webcam / camera barcode scanner"},{key:"Ctrl + T",desc:"Open auto-rescan timer modal"},{key:"Ctrl + H",desc:"Set directory to home folder"},{key:"? or Ctrl + /",desc:"Show keyboard shortcuts"},{key:"Y / S / N",desc:"Answer workflow guard: Yes / Skip / No (prompt open)"},{key:"Enter",desc:"Confirm active workflow prompt (prompt open)"},{key:"Escape",desc:"Close dialogs / context menu"}];return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:t,role:"dialog","aria-modal":"true","aria-label":"Keyboard Shortcuts",onKeyDown:i,className:"animate-modal-in w-[450px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(rO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Keyboard Shortcuts"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(_i,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"max-h-[60vh] space-y-2 overflow-y-auto pr-1 text-xs",children:l.map(({key:o,desc:a})=>y.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-elevated/50 px-3 py-2",children:[y.jsx("span",{className:"text-ink-secondary",children:a}),y.jsx("kbd",{className:"rounded bg-app px-2 py-0.5 font-mono text-[11px] font-semibold text-chip-indigo-text border border-line",children:o})]},o))}),y.jsx("div",{className:"mt-5 flex justify-end",children:y.jsx("button",{onClick:e,className:"btn btn-primary rounded-lg px-4 py-2 font-semibold",children:"Close"})})]})})}function c8({isOpen:n,activeConfigPath:e,configExists:t=!0,onClose:i,onLoaded:l}){const[o,a]=A.useState(null),[u,f]=A.useState(""),[d,m]=A.useState(null),[g,b]=A.useState(!1),[v,w]=A.useState(null),S=A.useRef(null),C=A.useRef(null),N=A.useRef(null),j=t===!1;A.useEffect(()=>{var V;if(!n){(V=N.current)==null||V.focus();return}N.current=document.activeElement instanceof HTMLElement?document.activeElement:null,w(null);const D=e??"",I=Math.max(D.lastIndexOf("/"),D.lastIndexOf("\\")),ne=I>0?D.slice(0,I):"";M(ne);const F=requestAnimationFrame(()=>{var _;return(_=C.current)==null?void 0:_.focus()});return()=>{var _;cancelAnimationFrame(F),(_=N.current)==null||_.focus()}},[n,e]);const M=async D=>{b(!0),w(null);try{const I=await EM(D);a(I),f(I.current_path),e&&I.items.some(ne=>ne.path===e)?m(e):m(null)}catch(I){w(I.message||"Navigation failed")}finally{b(!1)}},U=D=>{var V;if(D.key==="Escape"){D.preventDefault(),i();return}if(D.key!=="Tab")return;const I=(V=S.current)==null?void 0:V.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(I!=null&&I.length))return;const ne=I[0],F=I[I.length-1];D.shiftKey&&document.activeElement===ne?(D.preventDefault(),F.focus()):!D.shiftKey&&document.activeElement===F&&(D.preventDefault(),ne.focus())},H=async()=>{var I;const D=d||(((I=o==null?void 0:o.items.find(ne=>ne.is_config))==null?void 0:I.path)??null);if(!D){w("Select a configuration file to load.");return}try{b(!0);const ne=await CM(D);l(ne),i()}catch(ne){w(ne.message||"Unable to load configuration")}finally{b(!1)}},E=async()=>{const D=(u||(o==null?void 0:o.current_path)||"").trim();if(!D){w("Choose a directory before creating a configuration.");return}try{b(!0);const I=await NM(D);l(I),i()}catch(I){w(I.message||"Unable to create configuration")}finally{b(!1)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:i,children:y.jsxs("div",{ref:S,role:"dialog","aria-modal":"true","aria-labelledby":"load-config-title",onKeyDown:U,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:D=>D.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(fa,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"load-config-title",className:"text-sm font-semibold text-ink",children:j?"Create configuration":"Load configuration"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(o==null?void 0:o.current_path)||""})]})]}),y.jsx(Xe,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:i,"aria-label":"Close configuration modal",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(_i,{className:"h-4 w-4"})})})]}),j&&y.jsx("div",{className:"border-b border-line bg-chip-indigo-bg/20 px-4 py-3 text-xs text-ink-secondary",children:"No configuration file was found. Create one here?"}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"config-path-input",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Configuration directory"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:C,id:"config-path-input",type:"text",value:u,onChange:D=>f(D.target.value),onKeyDown:D=>{D.key==="Enter"&&M(u.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>M(u.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Xe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>M(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Zd,{className:"h-4 w-4"})})}),(o==null?void 0:o.parent_path)&&y.jsx(Xe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>M(o.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Wd,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(fl,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading configuration files…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>M(u||(o==null?void 0:o.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-1",children:[o==null?void 0:o.items.map(D=>{if(D.is_dir)return y.jsx("li",{children:y.jsx("button",{onClick:()=>M(D.path),onDoubleClick:()=>M(D.path),className:"flex w-full items-center justify-between rounded-md px-3 py-1.5 text-left text-xs text-ink-secondary hover:bg-elevated",children:y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx(Du,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),D.name]})})},D.path);const I=d===D.path;return y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>m(D.path),"aria-pressed":I,className:`flex w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${I?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(Na,{className:"h-5 w-5 shrink-0 text-chip-amber-text"}),y.jsx("span",{className:"truncate",children:D.name})]}),D.is_config&&y.jsx(fa,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),I&&y.jsx(Br,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},D.path)}),(o==null?void 0:o.items.filter(D=>D.is_config).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(Na,{className:"h-7 w-7 text-ink-faint"}),"No configuration files found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected file"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:d||u,children:d||u||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:i,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),j?y.jsxs("button",{type:"button",onClick:E,disabled:!u.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(fa,{className:"h-4 w-4"}),"Create configuration"]}):y.jsxs("button",{type:"button",onClick:H,disabled:!d,className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(fa,{className:"h-4 w-4"}),"Load configuration"]})]})]})]})}):null}function bA({isOpen:n,onClose:e,initialFilePath:t,md5:i}){const[l,o]=A.useState(null),[a,u]=A.useState(""),[f,d]=A.useState([]),[m,g]=A.useState(!1),[b,v]=A.useState(null),[w,S]=A.useState(null),[C,N]=A.useState(!1),[j,M]=A.useState(!1),[U,H]=A.useState(null),E=A.useRef(null),D=A.useRef(0),I=A.useRef(null),ne=gs({isOpen:n,onClose:e,dialogRef:E});A.useEffect(()=>{n||I.current!==null&&(window.clearTimeout(I.current),I.current=null)},[n]),A.useEffect(()=>{if(!n)return;async function T(){if(t){g(!0);try{const de=await Qk({filePath:t});o(de.image),u(de.content),F(de.content)}catch(de){v(de.message)}finally{g(!1)}}}T()},[n,t]);const F=T=>{const de=T.split(";").map(be=>{const z=be.split("=");return{key:z[0]||"",value:z[1]||""}}).filter(be=>be.key||be.value);d(de)},V=async T=>{const de=++D.current;try{const be=await Qk({content:T});if(D.current!==de)return;o(be.image),S(null)}catch(be){if(D.current!==de)return;S(be instanceof Error?be.message:"Failed to generate the barcode")}},_=T=>{const de=T.filter(be=>be.key.trim()).map(be=>`${be.key.trim()}=${be.value.trim()}`).join(";");if(u(de),I.current!==null&&(window.clearTimeout(I.current),I.current=null),!de){D.current+=1,o(null),S(null);return}I.current=window.setTimeout(()=>void V(de),250)},ie=(T,de,be)=>{const z=[...f];z[T][de]=be,d(z),_(z)},pe=()=>{const T=[...f,{key:"",value:""}];d(T)},ce=T=>{const de=f.filter((be,z)=>z!==T);d(de),_(de)},Z=()=>{if(!i||f.some(de=>de.key.toLowerCase()==="md5"))return;const T=[...f,{key:"md5",value:i}];d(T),_(T)},oe=async()=>{if(l){H("Saving…");try{const T=await LM(l,`profiles-qr-${Date.now()}.png`);H(T.path||T.message)}catch(T){H(`Save failed: ${(T==null?void 0:T.message)??T}`)}finally{setTimeout(()=>H(null),6e3)}}},G=async()=>{try{await navigator.clipboard.writeText(a),N(!0),setTimeout(()=>N(!1),2e3)}catch(T){console.error("Copy failed",T)}},W=async()=>{if(l)try{const de=await(await fetch(l)).blob();await navigator.clipboard.write([new ClipboardItem({[de.type]:de})]),M(!0),setTimeout(()=>M(!1),2e3)}catch(T){console.error("Image copy failed",T)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4",onClick:e,children:y.jsxs("div",{ref:E,role:"dialog","aria-modal":"true","aria-label":"QR Code Settings",onKeyDown:ne,className:"animate-modal-in w-full max-w-md rounded-xl border border-frame-line glass-panel p-6",onClick:T=>T.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"QR Code Settings"}),y.jsx("button",{onClick:e,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(_i,{className:"h-4 w-4"})})]}),m?y.jsx("div",{className:"flex h-48 items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):b?y.jsx("div",{className:"rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:b}):y.jsxs("div",{className:"space-y-6",children:[y.jsxs("div",{className:"flex flex-col items-center gap-4",children:[y.jsxs("div",{className:"relative group",children:[y.jsx("div",{className:"h-48 w-48 overflow-hidden rounded-lg border border-line bg-white p-2",children:l?y.jsx("img",{src:l,alt:"QR Code",className:"h-full w-full object-contain"}):y.jsx("div",{className:"flex h-full items-center justify-center text-xs text-slate-400",children:"No content"})}),l&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/20 rounded-lg",children:y.jsxs("button",{onClick:W,className:"focus-ring flex items-center gap-2 rounded-md bg-white/90 p-2 text-xs font-medium text-slate-900 shadow-sm hover:bg-white",children:[j?y.jsx(Br,{className:"h-3.5 w-3.5"}):y.jsx(hi,{className:"h-3.5 w-3.5"}),j?"Copied":"Copy Image"]})})]}),y.jsxs("div",{className:"flex w-full gap-2",children:[y.jsxs("button",{onClick:G,className:"btn btn-secondary flex-1 px-3 py-1.5",children:[C?y.jsx(Br,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(hi,{className:"h-3.5 w-3.5"}),"Copy Content"]}),y.jsxs("button",{onClick:oe,disabled:!l,className:"btn btn-primary flex-1 px-3 py-1.5",children:[y.jsx(nO,{className:"h-3.5 w-3.5"}),"Save Image"]})]}),U&&y.jsx("p",{className:"break-all text-center text-[11px] text-ink-muted",role:"status",children:U}),w&&y.jsx("p",{role:"alert",className:"break-all text-center text-[11px] text-status-danger-text",children:w})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("label",{className:"text-xs font-medium text-ink-muted uppercase tracking-wider",children:"Payload Fields"}),y.jsxs("div",{className:"flex gap-2",children:[i&&!f.some(T=>T.key==="md5")&&y.jsxs("button",{onClick:Z,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-purple-text border border-chip-purple-border",children:[y.jsx(ha,{className:"h-3 w-3"})," Inc. MD5"]}),y.jsxs("button",{onClick:pe,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-indigo-text border border-chip-indigo-border",children:[y.jsx(sD,{className:"h-3 w-3"})," Add Field"]})]})]}),y.jsxs("div",{className:"max-h-48 space-y-2 overflow-y-auto pr-1 custom-scrollbar",children:[f.map((T,de)=>y.jsxs("div",{className:"flex gap-2 items-center slide-in",children:[y.jsx("input",{type:"text",placeholder:"key",value:T.key,onChange:be=>ie(de,"key",be.target.value),className:"w-1/3 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("input",{type:"text",placeholder:"value",value:T.value,onChange:be=>ie(de,"value",be.target.value),className:"flex-1 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{onClick:()=>ce(de),className:"p-1 text-ink-muted hover:text-status-danger-text transition-colors","aria-label":"Remove field",children:y.jsx(cO,{className:"h-3.5 w-3.5"})})]},de)),f.length===0&&y.jsx("p",{className:"text-center py-4 text-xs text-ink-muted italic",children:"No fields defined"})]})]}),y.jsxs("div",{className:"pt-2 border-t border-line",children:[y.jsx("label",{className:"text-[10px] font-medium text-ink-muted uppercase tracking-wider block mb-1.5",children:"Raw Preview"}),y.jsx("div",{className:"rounded bg-elevated p-2 font-mono text-[10px] text-ink-secondary break-all border border-line",children:a||y.jsx("span",{className:"italic text-ink-muted/50",children:"empty"})})]})]})]})}):null}const Z2=["Bytes","KB","MB","GB","TB"];function vA(n){if(n===0)return"0 Bytes";const e=1024,t=Math.max(0,Math.min(Z2.length-1,Math.floor(Math.log(n)/Math.log(e))));return parseFloat((n/Math.pow(e,t)).toFixed(2))+" "+Z2[t]}function u8(n){const e=Math.max(n.lastIndexOf("\\"),n.lastIndexOf("/"));return e===-1?"":n.slice(0,e)}function f8(n){const e=[`File Properties: ${n.name}`,`Path: ${n.path}`,`Type: ${n.type}`,`Size: ${vA(n.size_bytes)}`,`Created: ${n.created}`,`Modified: ${n.modified}`];return n.md5&&e.push(`MD5: ${n.md5}`),n.sha256&&e.push(`SHA256: ${n.sha256}`),e.join(` -`)}function j0(n,e,t){return n.length<=e+t+1?n:`${n.slice(0,e)}…${n.slice(-t)}`}function h8(n){const e=n.includes("\\")?"\\":"/",t=n.split(/[\\/]/);return t.length<=5?n:[t[0],t[1],"…",t[t.length-2],t[t.length-1]].join(e)}const d8=[{ms:1e3*60,unit:"minute"},{ms:1e3*60*60,unit:"hour"},{ms:1e3*60*60*24,unit:"day"},{ms:1e3*60*60*24*30,unit:"month"},{ms:1e3*60*60*24*365,unit:"year"}];function J2(n,e=new Date){const t=new Date(n.replace(" ","T"));if(Number.isNaN(t.getTime()))return"just now";const i=e.getTime()-t.getTime();if(i<6e4)return"just now";let l="just now";for(const{ms:o,unit:a}of d8){if(i{var _;n||((_=M.current)==null||_.focus(),v(!1))},[n]),A.useEffect(()=>{if(!n||!e)return;const _=new AbortController;return U.current=_,o(null),N(null),u(!0),d(null),(async()=>{try{const ie=await jM(e.path,_.signal);if(U.current!==_)return;o(ie)}catch(ie){if(U.current!==_||ie instanceof DOMException&&ie.name==="AbortError")return;d(ie instanceof Error?ie.message:"Failed to load properties")}finally{U.current===_&&u(!1)}})(),()=>{U.current=null,_.abort()}},[n,e]),A.useEffect(()=>{if(!n)return;const _=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=_}},[n]),A.useEffect(()=>{if(!n)return;const _=ie=>{if(ie.key==="Escape"){if(b)return;t();return}if(ie.key!=="Tab")return;const pe=j.current;if(!pe)return;const ce=Array.from(pe.querySelectorAll('button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(W=>W.offsetParent!==null);if(ce.length===0)return;const Z=ce[0],oe=ce[ce.length-1],G=document.activeElement instanceof HTMLElement?document.activeElement:null;ie.shiftKey?(G===Z||!pe.contains(G))&&(ie.preventDefault(),oe.focus()):G===oe&&(ie.preventDefault(),Z.focus())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[n,b,t]),A.useEffect(()=>{if(!n)return;const _=document.activeElement instanceof HTMLElement?document.activeElement:null;M.current=_;const ie=requestAnimationFrame(()=>{var pe,ce;(ce=(pe=j.current)==null?void 0:pe.querySelector("button"))==null||ce.focus()});return()=>cancelAnimationFrame(ie)},[n]);const H=async(_,ie)=>{try{await navigator.clipboard.writeText(_),g(ie),setTimeout(()=>g(null),2e3)}catch(pe){console.error("Failed to copy:",pe)}},E=async(_,ie,pe)=>{S(_),N(null);try{await pe(),N(ie)}catch{N("Action failed")}finally{S(null)}},D=_=>`btn btn-chip rounded-md border px-3 py-2 text-xs ${{reveal:"bg-chip-sky-bg text-chip-sky-text border-chip-sky-border",launch:"border-emerald-500/30 bg-emerald-600 font-semibold text-white hover:bg-emerald-500",folder:"bg-chip-amber-bg text-chip-amber-text border-chip-amber-border"}[_]??"bg-chip-indigo-bg text-chip-indigo-text border-chip-indigo-border"}`,I=(_,ie,pe,ce=!1,Z)=>y.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[y.jsxs("span",{className:"text-ink-muted min-w-[100px] text-xs",children:[_,":"]}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-ink text-xs break-all ${ce?"font-mono":""}`,children:Z??ie})}),y.jsx(Xe,{text:"Copy to clipboard",block:!1,children:y.jsx("button",{onClick:()=>H(ie,pe),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-elevated","aria-label":`Copy ${_}`,children:m===pe?y.jsx(Br,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(hi,{className:"h-3.5 w-3.5 text-ink-muted"})})})]}),ne=(_,ie,pe)=>y.jsxs("div",{className:"rounded-lg border border-line bg-elevated p-4",children:[y.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[ie,y.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-ink-muted",children:_})]}),pe]}),F=()=>y.jsx(Xe,{text:"Click to copy full path",children:y.jsxs("button",{onClick:()=>void H(l.path,"path"),className:"group mb-3 flex w-full items-center gap-2 rounded-lg border border-line bg-elevated px-3 py-2 text-left hover:bg-surface",children:[y.jsx(Du,{className:"text-chip-amber-text h-4 w-4 flex-shrink-0"}),y.jsx("span",{className:"text-ink min-w-0 flex-1 truncate font-mono text-xs",children:h8(l.path)}),m==="path"?y.jsx(Br,{className:"text-status-success-text h-3.5 w-3.5"}):y.jsx(hi,{className:"text-ink-muted h-3.5 w-3.5"})]})});if(!n||!e)return null;const V=e;return y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 backdrop-blur-md p-4",role:"dialog","aria-modal":"true","aria-labelledby":"properties-modal-title",children:[y.jsx("div",{className:"absolute inset-0",onClick:t,onContextMenu:_=>{_.preventDefault(),t()}}),y.jsxs("div",{ref:j,className:"animate-modal-in relative w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-xl border border-frame-line glass-panel flex flex-col",children:[y.jsx("div",{className:"flex-shrink-0 border-b border-line px-6 py-4",children:y.jsxs("div",{className:"flex items-start justify-between gap-4",children:[y.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[y.jsx("div",{className:"rounded-lg bg-indigo-600 p-2 flex-shrink-0",children:y.jsx(Jg,{className:"h-5 w-5 text-white"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h3",{id:"properties-modal-title",className:"text-base font-semibold text-ink truncate",children:"File Properties"}),y.jsx("p",{className:"text-xs text-ink-muted truncate",children:e.filename})]}),y.jsx(Xe,{text:"Copy all properties to clipboard",block:!1,children:y.jsx("button",{onClick:()=>{l&&H(f8(l),"all")},disabled:!l||a||f!==null,className:"btn-chip ml-2 flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text","aria-label":"Copy all properties",children:m==="all"?y.jsx(Br,{className:"h-4 w-4 text-status-success-text"}):y.jsx(hi,{className:"h-4 w-4"})})}),y.jsx(Xe,{text:"Generate Barcode/QR Code",block:!1,children:y.jsx("button",{onClick:()=>v(!0),className:"btn-chip rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text",children:y.jsx(vy,{className:"h-4 w-4"})})})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink flex-shrink-0","aria-label":"Close",children:y.jsx(_i,{className:"h-4 w-4"})})]})}),y.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[a&&y.jsx("div",{className:"flex items-center justify-center py-8",children:y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"}),y.jsx("p",{className:"text-xs text-ink-muted",children:"Loading properties..."})]})}),f&&y.jsx("div",{className:"rounded-lg border border-status-danger-border bg-status-danger-bg p-4 text-center",children:y.jsx("p",{className:"text-xs text-status-danger-text",children:f})}),l&&!a&&!f&&y.jsxs("div",{children:[y.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-lg border border-line bg-elevated px-4 py-2.5",children:[y.jsx("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg px-2 py-0.5 text-xs font-semibold text-chip-indigo-text",children:l.type}),l.attributes.extension&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-line bg-surface px-2 py-0.5 text-xs font-medium text-ink-muted",children:l.attributes.extension}),y.jsxs("span",{className:"text-xs text-ink-muted",title:`${l.size_bytes} bytes`,children:["Size ",y.jsx("strong",{className:"text-ink font-medium",children:vA(l.size_bytes)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.created,children:["Created ",y.jsx("strong",{className:"text-ink font-medium",children:J2(l.created)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.modified,children:["Modified ",y.jsx("strong",{className:"text-ink font-medium",children:J2(l.modified)})]}),l.md5&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-chip-purple-border bg-chip-purple-bg px-2 py-0.5 font-mono text-xs font-medium text-chip-purple-text",title:`MD5 ${l.md5}`,children:j0(l.md5,4,4)}),l.attributes.is_symlink&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-fuchsia-border bg-chip-fuchsia-bg px-2 py-0.5 text-xs font-medium text-chip-fuchsia-text",children:[y.jsx(K4,{className:"h-3 w-3"})," Symlink"]})]}),F(),y.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[ne("Hashes",y.jsx(ha,{className:"text-chip-purple-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[I("MD5",l.md5,"md5",!0,j0(l.md5,10,6)),I("SHA256",l.sha256,"sha256",!0,j0(l.sha256,10,6))]})),ne("Timestamps",y.jsx(r4,{className:"text-chip-sky-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[I("Created",l.created,"created",!0),I("Modified",l.modified,"modified",!0)]})),ne("Identity",y.jsx(Jg,{className:"text-chip-indigo-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[I("Type",l.type,"type"),l.attributes.stem&&I("Stem",l.attributes.stem,"attrStem"),I("Extension",l.name.includes(".")?l.name.slice(l.name.lastIndexOf(".")):"None","extension"),I("Directory",u8(l.path)||"None","directory",!0)]})),ne("System",y.jsx(Jg,{className:"text-status-success-text h-3.5 w-3.5"}),y.jsxs("div",{children:[y.jsxs("div",{className:"mb-1 flex min-h-[24px] flex-wrap items-center gap-1.5",children:[l.attributes.is_readonly&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-status-danger-border bg-status-danger-bg px-2 py-0.5 text-xs text-status-danger-text",children:[y.jsx(J4,{className:"h-3 w-3"})," Read-only"]}),l.attributes.is_hidden&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-line bg-elevated px-2 py-0.5 text-xs text-ink-muted",children:[y.jsx(T4,{className:"h-3 w-3"})," Hidden"]}),!l.attributes.is_readonly&&!l.attributes.is_hidden&&!l.attributes.is_symlink&&y.jsx("span",{className:"text-xs text-ink-muted",children:"No special flags"})]}),y.jsxs("div",{className:"space-y-0.5",children:[I("File Type",l.attributes.is_file?"Regular File":l.attributes.is_dir?"Directory":"Other","fileType"),l.attributes.permissions&&I("Permissions",l.attributes.permissions,"permissions",!0),l.attributes.owner_uid!==void 0&&I("Owner UID",String(l.attributes.owner_uid),"ownerUid"),l.attributes.group_gid!==void 0&&I("Group GID",String(l.attributes.group_gid),"groupGid")]})]}))]})]})]}),y.jsx("div",{className:"flex-shrink-0 border-t border-line px-6 py-3",children:y.jsxs("div",{className:"flex justify-between items-center gap-2",children:[y.jsx("p",{className:"min-w-0 text-xs text-ink-muted truncate",children:C??"Click the copy icon next to any field to copy its value"}),y.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[y.jsx(Xe,{text:"Show file in Explorer",block:!1,children:y.jsxs("button",{onClick:()=>void E("reveal","Revealed in Explorer",()=>ZC(V.path)),disabled:w!==null,className:D("reveal"),children:[y.jsx(Z0,{className:"h-3.5 w-3.5"})," Reveal"]})}),y.jsx(Xe,{text:"Launch file with default association",block:!1,children:y.jsxs("button",{onClick:()=>{i&&(S("launch"),Promise.resolve(i(V)).finally(()=>S(null)))},disabled:w!==null||!i,className:D("launch"),children:[y.jsx(ss,{className:"h-3.5 w-3.5"})," Launch"]})}),y.jsx(Xe,{text:"Open containing folder",block:!1,children:y.jsxs("button",{onClick:()=>void E("folder","Opened folder",()=>W0(V.path)),disabled:w!==null,className:D("folder"),children:[y.jsx(rs,{className:"h-3.5 w-3.5"})," Open Folder"]})}),y.jsx("button",{onClick:t,className:"btn btn-primary px-4 py-2",children:"Close"})]})]})})]}),y.jsx(bA,{isOpen:b,onClose:()=>v(!1),initialFilePath:e.path,md5:l==null?void 0:l.md5})]})}const p8=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"],g8=250,x8=400,y8=.7;function b8(n,e=x8,t=y8){const i=n.videoWidth,l=n.videoHeight;if(!i||!l)return null;const o=Math.min(i,l),a=document.createElement("canvas");a.width=Math.min(e,o),a.height=a.width;const u=a.getContext("2d");if(!u)return null;u.drawImage(n,(i-o)/2,(l-o)/2,o,o,0,0,a.width,a.height);const f=a.toDataURL("image/jpeg",t);return f.slice(f.indexOf(",")+1)}function v8(n,e){const t=n.intervalMs??g8;let i=!1,l=!1;const o=()=>{i=!0,clearInterval(a)},a=setInterval(()=>{if(i||l)return;const u=n.capture();u&&(l=!0,n.decode(u).then(f=>{i||f.decoded&&(o(),e.onDetected(f.decoded))}).catch(f=>{i||(o(),e.onError(f instanceof Error?f.message:"Frame decoding failed"))}).finally(()=>{l=!1}))},t);return o}const w8=8e3;function k8({isOpen:n,onClose:e,onDetected:t}){const i=A.useRef(null),l=A.useRef(null),o=gs({isOpen:n,onClose:e,dialogRef:l}),a=A.useRef(null),u=A.useRef(null),f=A.useRef(null),[d,m]=A.useState(null),[g,b]=A.useState(!1),v=()=>{f.current&&(f.current(),f.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),a.current&&(a.current.getTracks().forEach(C=>C.stop()),a.current=null),i.current&&(i.current.srcObject=null)};A.useEffect(()=>{if(!n){v(),m(null);return}let C=!0;async function N(){var M,U,H,E,D;if(m(null),b(!1),typeof window<"u"&&!window.isSecureContext&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1"){m("Camera access requires HTTPS or localhost. If connecting across a local network IP (e.g. 192.168.x.x), modern browsers disable camera access for insecure HTTP.");return}const j=((U=(M=navigator.mediaDevices)==null?void 0:M.getUserMedia)==null?void 0:U.bind(navigator.mediaDevices))||((H=navigator.getUserMedia)==null?void 0:H.bind(navigator))||((E=navigator.webkitGetUserMedia)==null?void 0:E.bind(navigator))||((D=navigator.mozGetUserMedia)==null?void 0:D.bind(navigator));if(!j){m(window.isSecureContext?"Camera access is not supported by your browser or environment.":"Camera access is blocked because the page is not served over a secure origin (HTTPS or localhost/127.0.0.1).");return}try{let I;const ne=await Promise.race([j({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),new Promise((F,V)=>{I=window.setTimeout(()=>V(new DOMException("Camera did not start in time","TimeoutError")),w8)})]).finally(()=>{I!==void 0&&window.clearTimeout(I)});if(!C){ne.getTracks().forEach(F=>F.stop());return}a.current=ne,i.current&&(i.current.srcObject=ne,await i.current.play()),"BarcodeDetector"in window?S():w()}catch(I){if(!C)return;console.error("Camera access error:",I),m(I.name==="NotAllowedError"||I.name==="PermissionDeniedError"?"Camera permission denied. Please allow camera access in your browser settings.":I.name==="TimeoutError"?"The camera did not start in time. On macOS, camera capture needs the packaged desktop app — a bare Python process cannot access the camera. Alternatively, open ProFiles in Chrome, Edge or Safari.":`Could not access camera: ${I.message||"Unknown error"}`)}}return N(),()=>{C=!1,v()}},[n]);const w=()=>{b(!0),f.current=v8({capture:()=>i.current?b8(i.current):null,decode:C=>RM({imageBase64:C,formats:[...p8]})},{onDetected:C=>{v(),t(C)},onError:C=>{v(),m(C)}})},S=()=>{const C=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"];let N;try{N=new window.BarcodeDetector({formats:C})}catch(M){console.warn("BarcodeDetector formats unsupported:",M),N=new window.BarcodeDetector}const j=async()=>{if(!i.current||i.current.readyState<2){u.current=requestAnimationFrame(j);return}try{const M=await N.detect(i.current);if(M&&M.length>0){const U=M[0].rawValue;if(U){v(),t(U);return}}}catch(M){console.debug("Frame detection error:",M)}u.current=requestAnimationFrame(j)};u.current=requestAnimationFrame(j)};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Camera barcode scanner",onKeyDown:o,className:"relative w-full max-w-lg rounded-2xl border border-frame-line glass-panel p-6 flex flex-col",onClick:C=>C.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(tO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Scan with Camera"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink transition-colors","aria-label":"Close",children:y.jsx(_i,{className:"h-4 w-4"})})]}),d?y.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[y.jsx("div",{className:"rounded-full bg-status-danger-bg p-3 text-status-danger-text mb-3",children:y.jsx(tu,{className:"h-6 w-6"})}),y.jsx("p",{className:"text-xs text-status-danger-text max-w-xs",children:d}),y.jsx("button",{onClick:e,className:"btn btn-secondary mt-6 px-4 py-2",children:"Close"})]}):y.jsxs("div",{className:"flex flex-col items-center",children:[y.jsxs("div",{className:"relative aspect-video w-full overflow-hidden rounded-xl bg-black border border-line flex items-center justify-center",children:[y.jsx("video",{ref:i,playsInline:!0,muted:!0,className:"h-full w-full object-cover"}),y.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:y.jsxs("div",{className:"relative h-48 w-48 rounded-lg border-2 border-dashed border-indigo-400/80 bg-indigo-500/5 shadow-[0_0_0_9999px_rgba(0,0,0,0.45)]",children:[y.jsx("div",{className:"absolute top-0 left-0 h-4 w-4 border-t-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute top-0 right-0 h-4 w-4 border-t-2 border-r-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 left-0 h-4 w-4 border-b-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 right-0 h-4 w-4 border-b-2 border-r-2 border-indigo-400"})]})})]}),y.jsx("p",{className:"mt-4 text-center text-xs text-ink-muted",children:g?"Hold a QR code or barcode steady in front of your camera — frames are decoded by the local ProFiles server (no native Barcode Detector in this browser).":"Hold a QR code or barcode steady in front of your camera to auto-scan."})]})]})}):null}function S8({isOpen:n,file:e,onConfirm:t,onDismiss:i}){const l=A.useRef(null);return A.useEffect(()=>{var o;if(n){const a=u=>{u.key==="Enter"?(u.preventDefault(),t()):u.key==="Escape"&&(u.preventDefault(),i())};return window.addEventListener("keydown",a),(o=l.current)==null||o.focus(),()=>window.removeEventListener("keydown",a)}},[n,t,i]),!n||!e?null:y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:i,children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`1 file matched: ${e.filename}`,className:"animate-modal-in w-full max-w-sm rounded-xl border border-frame-line glass-panel p-5 flex flex-col gap-4",onClick:o=>o.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink text-sm",children:[e.has_hook?y.jsx(ED,{className:"h-4 w-4 text-chip-purple-text"}):y.jsx(ss,{className:"h-4 w-4 text-status-success-text"}),y.jsx("span",{children:"1 File Matched"})]}),y.jsx("button",{onClick:i,className:"focus-ring rounded p-1 text-ink-muted hover:bg-elevated hover:text-ink","aria-label":"Dismiss",children:y.jsx(_i,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-line bg-elevated/50 p-3",children:[y.jsx(Na,{className:"h-5 w-5 text-chip-indigo-text shrink-0 mt-0.5"}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h4",{className:"text-xs font-semibold text-ink truncate",children:e.filename}),y.jsx("p",{className:"text-[11px] text-ink-muted truncate mt-0.5",children:e.rel_path||e.path}),e.has_hook&&y.jsx("span",{className:"inline-block mt-1 text-[10px] text-chip-purple-text bg-chip-purple-bg px-1.5 py-0.5 rounded border border-chip-purple-border/50 font-medium",children:"Workflow Hook Configured"})]})]}),y.jsx("p",{className:"text-xs text-ink-muted text-center",children:"Launch this file now?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary flex-1 px-3 py-1.5",children:"Dismiss (Esc)"}),y.jsxs("button",{ref:l,type:"button",onClick:t,className:"btn btn-primary flex-1 px-3 py-1.5 shadow-md",children:[y.jsx(ss,{className:"h-3 w-3 fill-current"}),"Launch (Enter)"]})]})]})})}function C8({systemInfo:n,fileCount:e,theme:t,onToggleTheme:i,onOpenLog:l,onOpenConfig:o,onShowShortcuts:a,onReloadConfig:u,onExport:f,exportDisabled:d=!1,language:m="en",onLanguageChange:g,lanEnabled:b,onToggleLan:v}){return y.jsxs("footer",{className:"flex items-center justify-between border-t border-line bg-app px-4 py-2 text-[11px] text-ink-muted transition-colors duration-200",children:[y.jsx("div",{className:"flex items-center gap-4",children:n&&y.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 py-0.5 text-ink-secondary",children:[y.jsx(XM,{className:"h-3 w-3 text-status-success-text"}),y.jsx("a",{href:`http://${n.hostname}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.hostname}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.hostname}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx("a",{href:`http://${n.ip}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.ip}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.ip}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsxs("span",{className:"flex items-center gap-1",title:"Session user",children:[y.jsx(ND,{className:"h-3 w-3 text-ink-faint"}),y.jsx("span",{children:n.username||"operator"})]}),v!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx(Xe,{text:"LAN access",block:!1,children:y.jsxs("button",{onClick:()=>v(b!==!0),disabled:b===null,"aria-pressed":b===!0,className:`focus-ring flex items-center gap-1 rounded px-1 py-0.5 text-[10px] ${b===null?"text-ink-faint cursor-not-allowed":b===!0?"text-status-success-text":"text-ink-muted hover:text-ink"}`,children:[y.jsx(iD,{className:"h-3 w-3"}),y.jsx("span",{children:"LAN"})]})})]})]})}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("span",{children:[y.jsx("strong",{className:"text-ink",children:e})," files found"]}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx(Xe,{text:"Keyboard shortcuts (?)",block:!1,children:y.jsxs("button",{onClick:a,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(rO,{className:"h-3 w-3"}),y.jsx("span",{children:"Shortcuts"})]})}),y.jsx(Xe,{text:"Open the application log viewer",block:!1,children:y.jsxs("button",{onClick:l,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(Na,{className:"h-3 w-3"}),y.jsx("span",{children:"Logs"})]})}),y.jsx("span",{className:"text-ink-faint",children:"|"}),u&&y.jsx(Xe,{text:"Reload configuration from disk",block:!1,children:y.jsxs("button",{onClick:u,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(Jd,{className:"h-3 w-3"}),y.jsx("span",{children:"Reload"})]})}),f&&y.jsx(Xe,{text:"Export the current results as CSV",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"focus-ring flex items-center gap-1 rounded text-ink-muted hover:text-ink disabled:opacity-40 disabled:hover:text-ink-muted",children:[y.jsx(nO,{className:"h-3 w-3"}),y.jsx("span",{children:"Export CSV"})]})}),g&&y.jsxs("div",{className:"flex items-center overflow-hidden rounded border border-line text-[10px]",children:[y.jsx(Xe,{text:"English",block:!1,children:y.jsxs("button",{onClick:()=>g("en"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="en"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:[y.jsx(V4,{className:"h-3 w-3"}),y.jsx("span",{children:"EN"})]})}),y.jsx(Xe,{text:"Français",block:!1,children:y.jsx("button",{onClick:()=>g("fr"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="fr"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:y.jsx("span",{children:"FR"})})})]}),y.jsx(Xe,{text:"Open the configuration editor",block:!1,children:y.jsxs("button",{onClick:o,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(yD,{className:"h-3 w-3"}),y.jsx("span",{children:"Config"})]})}),y.jsx(Xe,{text:`Switch to ${t==="dark"?"light":"dark"} mode`,block:!1,children:y.jsxs("button",{onClick:i,className:"focus-ring flex items-center gap-1 rounded px-1.5 py-0.5 text-ink-muted hover:bg-elevated hover:text-status-warning-text",children:[t==="dark"?y.jsx(vD,{className:"h-3 w-3 text-status-warning-text"}):y.jsx(tD,{className:"h-3 w-3 text-chip-indigo-text"}),y.jsx("span",{children:t==="dark"?"Light":"Dark"})]})})]})]})}const O8=[{label:"5 seconds",seconds:5},{label:"10 seconds",seconds:10},{label:"30 seconds",seconds:30},{label:"1 minute",seconds:60},{label:"5 minutes",seconds:300}];function N8({isOpen:n,currentInterval:e,onClose:t,onSetInterval:i}){const l=A.useRef(null),o=gs({isOpen:n,onClose:t,dialogRef:l});if(!n)return null;const a=e>0,u=m=>{i(m)},f=m=>{m.preventDefault();const b=m.currentTarget.elements.namedItem("custom-interval"),v=parseInt(b.value,10);!isNaN(v)&&v>0&&i(v)},d=()=>{i(0)};return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Auto-Rescan Timer",onKeyDown:o,className:"animate-modal-in w-[420px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(aO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Auto-Rescan Timer"})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(_i,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"mb-4 rounded-lg bg-elevated/50 px-3 py-2 text-xs",children:a?y.jsxs("div",{className:"flex items-center gap-2 text-status-success-text",children:[y.jsx(b4,{className:"h-4 w-4 animate-pulse"}),y.jsxs("span",{children:["Auto-rescan every ",e,"s"]})]}):y.jsxs("div",{className:"flex items-center gap-2 text-ink-secondary",children:[y.jsx(x4,{className:"h-4 w-4"}),y.jsx("span",{children:"Auto-rescan is disabled"})]})}),y.jsxs("div",{className:"mb-4 space-y-1 text-xs",children:[y.jsx("p",{className:"text-ink-muted",children:"Presets:"}),y.jsx("div",{className:"grid grid-cols-2 gap-2",children:O8.map(m=>y.jsx("button",{onClick:()=>u(m.seconds),className:"rounded-lg border border-line bg-elevated/50 px-3 py-1.5 text-left font-medium text-ink-secondary hover:border-chip-indigo-border hover:bg-chip-indigo-bg/40 hover:text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:m.label},m.seconds))})]}),y.jsxs("form",{onSubmit:f,className:"mb-4",children:[y.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-ink-secondary",children:[y.jsx(k4,{className:"h-3.5 w-3.5"}),y.jsx("span",{children:"Custom interval (seconds):"})]}),y.jsxs("div",{className:"mt-1 flex gap-2",children:[y.jsx("input",{type:"number",name:"custom-interval",min:"1",placeholder:"e.g. 45",className:"flex-1 rounded-lg border border-line bg-app px-2 py-1 text-xs text-ink placeholder-ink-faint focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{type:"submit",className:"btn btn-primary rounded-lg px-3 py-1 font-semibold",children:"Set"})]})]}),a&&y.jsx("button",{onClick:d,className:"btn w-full rounded-lg border-line bg-elevated/50 px-3 py-2 text-status-warning-text hover:border-status-warning-border hover:bg-status-warning-bg/40",children:"Stop Auto-Rescan"}),y.jsx("div",{className:"flex justify-end gap-2 border-t border-line pt-3",children:y.jsx("button",{onClick:t,className:"rounded-lg border border-line bg-elevated px-4 py-2 text-xs font-semibold text-ink-secondary hover:bg-elevated/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:"Close"})})]})})}function T8(n,e){const t={};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const A8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,E8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,M8={};function eC(n,e){return(M8.jsx?E8:A8).test(n)}const D8=/[ \t\n\f\r]/g;function R8(n){return typeof n=="object"?n.type==="text"?tC(n.value):!1:tC(n)}function tC(n){return n.replace(D8,"")===""}class Hu{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}Hu.prototype.normal={};Hu.prototype.property={};Hu.prototype.space=void 0;function wA(n,e){const t={},i={};for(const l of n)Object.assign(t,l.property),Object.assign(i,l.normal);return new Hu(t,i,e)}function ty(n){return n.toLowerCase()}class bi{constructor(e,t){this.attribute=t,this.property=e}}bi.prototype.attribute="";bi.prototype.booleanish=!1;bi.prototype.boolean=!1;bi.prototype.commaOrSpaceSeparated=!1;bi.prototype.commaSeparated=!1;bi.prototype.defined=!1;bi.prototype.mustUseProperty=!1;bi.prototype.number=!1;bi.prototype.overloadedBoolean=!1;bi.prototype.property="";bi.prototype.spaceSeparated=!1;bi.prototype.space=void 0;let j8=0;const Qe=po(),cn=po(),ny=po(),xe=po(),jt=po(),ao=po(),Di=po();function po(){return 2**++j8}const iy=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:cn,commaOrSpaceSeparated:Di,commaSeparated:ao,number:xe,overloadedBoolean:ny,spaceSeparated:jt},Symbol.toStringTag,{value:"Module"})),_0=Object.keys(iy);class ob extends bi{constructor(e,t,i,l){let o=-1;if(super(e,t),nC(this,"space",l),typeof i=="number")for(;++o<_0.length;){const a=_0[o];nC(this,_0[o],(i&iy[a])===iy[a])}}}ob.prototype.defined=!0;function nC(n,e,t){t&&(n[e]=t)}function Ia(n){const e={},t={};for(const[i,l]of Object.entries(n.properties)){const o=new ob(i,n.transform(n.attributes||{},i),l,n.space);n.mustUseProperty&&n.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),e[i]=o,t[ty(i)]=i,t[ty(o.attribute)]=i}return new Hu(e,t,n.space)}const kA=Ia({properties:{ariaActiveDescendant:null,ariaAtomic:cn,ariaAutoComplete:null,ariaBusy:cn,ariaChecked:cn,ariaColCount:xe,ariaColIndex:xe,ariaColSpan:xe,ariaControls:jt,ariaCurrent:null,ariaDescribedBy:jt,ariaDetails:null,ariaDisabled:cn,ariaDropEffect:jt,ariaErrorMessage:null,ariaExpanded:cn,ariaFlowTo:jt,ariaGrabbed:cn,ariaHasPopup:null,ariaHidden:cn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:jt,ariaLevel:xe,ariaLive:null,ariaModal:cn,ariaMultiLine:cn,ariaMultiSelectable:cn,ariaOrientation:null,ariaOwns:jt,ariaPlaceholder:null,ariaPosInSet:xe,ariaPressed:cn,ariaReadOnly:cn,ariaRelevant:null,ariaRequired:cn,ariaRoleDescription:jt,ariaRowCount:xe,ariaRowIndex:xe,ariaRowSpan:xe,ariaSelected:cn,ariaSetSize:xe,ariaSort:null,ariaValueMax:xe,ariaValueMin:xe,ariaValueNow:xe,ariaValueText:null,role:null},transform(n,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function SA(n,e){return e in n?n[e]:e}function CA(n,e){return SA(n,e.toLowerCase())}const _8=Ia({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:ao,acceptCharset:jt,accessKey:jt,action:null,allow:null,allowFullScreen:Qe,allowPaymentRequest:Qe,allowUserMedia:Qe,alpha:Qe,alt:null,as:null,async:Qe,autoCapitalize:null,autoComplete:jt,autoFocus:Qe,autoPlay:Qe,blocking:jt,capture:null,charSet:null,checked:Qe,cite:null,className:jt,closedBy:null,colorSpace:null,cols:xe,colSpan:xe,command:null,commandFor:null,content:null,contentEditable:cn,controls:Qe,controlsList:jt,coords:xe|ao,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Qe,defer:Qe,dir:null,dirName:null,disabled:Qe,download:ny,draggable:cn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Qe,formTarget:null,headers:jt,height:xe,hidden:ny,high:xe,href:null,hrefLang:null,htmlFor:jt,httpEquiv:jt,id:null,imageSizes:null,imageSrcSet:null,inert:Qe,inputMode:null,integrity:null,is:null,isMap:Qe,itemId:null,itemProp:jt,itemRef:jt,itemScope:Qe,itemType:jt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Qe,low:xe,manifest:null,max:null,maxLength:xe,media:null,method:null,min:null,minLength:xe,multiple:Qe,muted:Qe,name:null,nonce:null,noModule:Qe,noValidate:Qe,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Qe,optimum:xe,pattern:null,ping:jt,placeholder:null,playsInline:Qe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Qe,referrerPolicy:null,rel:jt,required:Qe,reversed:Qe,rows:xe,rowSpan:xe,sandbox:jt,scope:null,scoped:Qe,seamless:Qe,selected:Qe,shadowRootClonable:Qe,shadowRootCustomElementRegistry:Qe,shadowRootDelegatesFocus:Qe,shadowRootMode:null,shadowRootSerializable:Qe,shape:null,size:xe,sizes:null,slot:null,span:xe,spellCheck:cn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:xe,step:null,style:null,tabIndex:xe,target:null,title:null,translate:null,type:null,typeMustMatch:Qe,useMap:null,value:cn,width:xe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:jt,axis:null,background:null,bgColor:null,border:xe,borderColor:null,bottomMargin:xe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Qe,declare:Qe,event:null,face:null,frame:null,frameBorder:null,hSpace:xe,leftMargin:xe,link:null,longDesc:null,lowSrc:null,marginHeight:xe,marginWidth:xe,noResize:Qe,noHref:Qe,noShade:Qe,noWrap:Qe,object:null,profile:null,prompt:null,rev:null,rightMargin:xe,rules:null,scheme:null,scrolling:cn,standby:null,summary:null,text:null,topMargin:xe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:xe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Qe,disablePictureInPicture:Qe,disableRemotePlayback:Qe,exportParts:ao,part:jt,prefix:null,property:null,results:xe,security:null,unselectable:null},space:"html",transform:CA}),L8=Ia({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Di,accentHeight:xe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:xe,amplitude:xe,arabicForm:null,ascent:xe,attributeName:null,attributeType:null,azimuth:xe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:xe,by:null,calcMode:null,capHeight:xe,className:jt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:xe,diffuseConstant:xe,direction:null,display:null,dur:null,divisor:xe,dominantBaseline:null,download:Qe,dx:null,dy:null,edgeMode:null,editable:null,elevation:xe,enableBackground:null,end:null,event:null,exponent:xe,externalResourcesRequired:null,fill:null,fillOpacity:xe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ao,g2:ao,glyphName:ao,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:xe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:xe,horizOriginX:xe,horizOriginY:xe,id:null,ideographic:xe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:xe,k:xe,k1:xe,k2:xe,k3:xe,k4:xe,kernelMatrix:Di,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:xe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:xe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:xe,overlineThickness:xe,paintOrder:null,panose1:null,path:null,pathLength:xe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:jt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:xe,pointsAtY:xe,pointsAtZ:xe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Di,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Di,rev:Di,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Di,requiredFeatures:Di,requiredFonts:Di,requiredFormats:Di,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:xe,specularExponent:xe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:xe,strikethroughThickness:xe,string:null,stroke:null,strokeDashArray:Di,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:xe,strokeOpacity:xe,strokeWidth:null,style:null,surfaceScale:xe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Di,tabIndex:xe,tableValues:null,target:null,targetX:xe,targetY:xe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Di,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:xe,underlineThickness:xe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:xe,values:null,vAlphabetic:xe,vMathematical:xe,vectorEffect:null,vHanging:xe,vIdeographic:xe,version:null,vertAdvY:xe,vertOriginX:xe,vertOriginY:xe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:xe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:SA}),OA=Ia({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(n,e){return"xlink:"+e.slice(5).toLowerCase()}}),NA=Ia({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:CA}),TA=Ia({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(n,e){return"xml:"+e.slice(3).toLowerCase()}}),z8={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},B8=/[A-Z]/g,iC=/-[a-z]/g,P8=/^data[-\w.:]+$/i;function H8(n,e){const t=ty(e);let i=e,l=bi;if(t in n.normal)return n.property[n.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&P8.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(iC,U8);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!iC.test(o)){let a=o.replace(B8,I8);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}l=ob}return new l(i,e)}function I8(n){return"-"+n.toLowerCase()}function U8(n){return n.charAt(1).toUpperCase()}const F8=wA([kA,_8,OA,NA,TA],"html"),ab=wA([kA,L8,OA,NA,TA],"svg");function q8(n){return n.join(" ").trim()}var rC=/\/\*(?:[^*]|\*(?!\/))*\*\//g,V8=/\n/g,Q8=/^\s*/,X8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,$8=/^:\s*/,Y8=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,G8=/^[;\s]*/,K8=` -`,lC="/",sC="*",$c="",W8="comment",Z8="declaration";function J8(n,e){if(typeof n!="string")throw new TypeError("First argument must be a string");if(!n)return[];e=e||{};var t=1,i=1;function l(w){var S=w.match(V8);S&&(t+=S.length);var C=w.lastIndexOf(K8);i=~C?w.length-C:i+w.length}function o(){var w={line:t,column:i};return function(S){return S.position=new a(w),d(),S}}function a(w){this.start=w,this.end={line:t,column:i},this.source=e.source}a.prototype.content=n;function u(w){var S=new Error(e.source+":"+t+":"+i+": "+w);if(S.reason=w,S.filename=e.source,S.line=t,S.column=i,S.source=n,!e.silent)throw S}function f(w){var S=w.exec(n);if(S){var C=S[0];return l(C),n=n.slice(C.length),S}}function d(){f(Q8)}function m(w){for(var S;S=g();)w.push(S);return w}function g(){var w=o();if(!(lC!=n.charAt(0)||sC!=n.charAt(1))){for(var S=2;$c!=n.charAt(S)&&(sC!=n.charAt(S)||lC!=n.charAt(S+1));)++S;if(S+=2,$c===n.charAt(S-1))return u("End of comment missing");var C=n.slice(2,S-2);return i+=2,l(C),n=n.slice(S),i+=2,w({type:W8,comment:C})}}function b(){var w=o(),S=f(X8);if(S){if(g(),!f($8))return u("property missing ':'");var C=f(Y8),N=w({type:Z8,property:S[0].replace(rC,$c).trim(),value:C?C[0].replace(rC,$c).trim():$c});return f(G8),N}}function v(){var w=[];m(w);for(var S;S=b();)w.push(S),m(w);return w}return d(),v()}function eP(n,e){let t=null;if(!n||typeof n!="string")return t;const i=J8(n),l=typeof e=="function";return i.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:u}=o;l?e(a,u,o):u&&(t=t??{},t[a]=u)}),t}const AA=EA("end"),cb=EA("start");function EA(n){return e;function e(t){const i=t&&t.position&&t.position[n]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function tP(n){const e=cb(n),t=AA(n);if(e&&t)return{start:e,end:t}}function uu(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?oC(n.position):"start"in n||"end"in n?oC(n):"line"in n||"column"in n?ry(n):""}function ry(n){return aC(n&&n.line)+":"+aC(n&&n.column)}function oC(n){return ry(n&&n.start)+"-"+ry(n&&n.end)}function aC(n){return n&&typeof n=="number"?n:1}class $n extends Error{constructor(e,t,i){super(),typeof t=="string"&&(i=t,t=void 0);let l="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?l=e:!o.cause&&e&&(a=!0,l=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof i=="string"){const f=i.indexOf(":");f===-1?o.ruleId=i:(o.source=i.slice(0,f),o.ruleId=i.slice(f+1))}if(!o.place&&o.ancestors&&o.ancestors){const f=o.ancestors[o.ancestors.length-1];f&&(o.place=f.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=u?u.line:void 0,this.name=uu(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}$n.prototype.file="";$n.prototype.name="";$n.prototype.reason="";$n.prototype.message="";$n.prototype.stack="";$n.prototype.column=void 0;$n.prototype.line=void 0;$n.prototype.ancestors=void 0;$n.prototype.cause=void 0;$n.prototype.fatal=void 0;$n.prototype.place=void 0;$n.prototype.ruleId=void 0;$n.prototype.source=void 0;const ub={}.hasOwnProperty,nP=new Map,iP=/[A-Z]/g,rP=/-([a-z])/g,lP=new Set(["table","tbody","thead","tfoot","tr"]),sP=new Set(["td","th"]),MA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function oP(n,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=e.filePath||void 0;let i;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=pP(t,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=mP(t,e.jsx,e.jsxs)}const l={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:i,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?ab:F8,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=DA(l,n,void 0);return o&&typeof o!="string"?o:l.create(n,l.Fragment,{children:o||void 0},void 0)}function DA(n,e,t){if(e.type==="element")return aP(n,e,t);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return cP(n,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return fP(n,e,t);if(e.type==="mdxjsEsm")return uP(n,e);if(e.type==="root")return hP(n,e,t);if(e.type==="text")return dP(n,e)}function aP(n,e,t){const i=n.schema;let l=i;e.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=ab,n.schema=l),n.ancestors.push(e);const o=jA(n,e.tagName,!1),a=gP(n,e);let u=hb(n,e);return lP.has(e.tagName)&&(u=u.filter(function(f){return typeof f=="string"?!R8(f):!0})),RA(n,a,o,e),fb(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function cP(n,e){if(e.data&&e.data.estree&&n.evaluater){const i=e.data.estree.body[0];return i.type,n.evaluater.evaluateExpression(i.expression)}Mu(n,e.position)}function uP(n,e){if(e.data&&e.data.estree&&n.evaluater)return n.evaluater.evaluateProgram(e.data.estree);Mu(n,e.position)}function fP(n,e,t){const i=n.schema;let l=i;e.name==="svg"&&i.space==="html"&&(l=ab,n.schema=l),n.ancestors.push(e);const o=e.name===null?n.Fragment:jA(n,e.name,!0),a=xP(n,e),u=hb(n,e);return RA(n,a,o,e),fb(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function hP(n,e,t){const i={};return fb(i,hb(n,e)),n.create(e,n.Fragment,i,t)}function dP(n,e){return e.value}function RA(n,e,t,i){typeof t!="string"&&t!==n.Fragment&&n.passNode&&(e.node=i)}function fb(n,e){if(e.length>0){const t=e.length>1?e:e[0];t&&(n.children=t)}}function mP(n,e,t){return i;function i(l,o,a,u){const d=Array.isArray(a.children)?t:e;return u?d(o,a,u):d(o,a)}}function pP(n,e){return t;function t(i,l,o,a){const u=Array.isArray(o.children),f=cb(i);return e(l,o,a,u,{columnNumber:f?f.column-1:void 0,fileName:n,lineNumber:f?f.line:void 0},void 0)}}function gP(n,e){const t={};let i,l;for(l in e.properties)if(l!=="children"&&ub.call(e.properties,l)){const o=yP(n,l,e.properties[l]);if(o){const[a,u]=o;n.tableCellAlignToStyle&&a==="align"&&typeof u=="string"&&sP.has(e.tagName)?i=u:t[a]=u}}if(i){const o=t.style||(t.style={});o[n.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return t}function xP(n,e){const t={};for(const i of e.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&n.evaluater){const o=i.data.estree.body[0];o.type;const a=o.expression;a.type;const u=a.properties[0];u.type,Object.assign(t,n.evaluater.evaluateExpression(u.argument))}else Mu(n,e.position);else{const{name:l}=i;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&n.evaluater){const u=i.value.data.estree.body[0];u.type,o=n.evaluater.evaluateExpression(u.expression)}else Mu(n,e.position);else o=i.value===null?!0:i.value;t[l]=o}return t}function hb(n,e){const t=[];let i=-1;const l=n.passKeys?new Map:nP;for(;++il?0:l+e:e=e>l?l:e,t=t>0?t:0,i.length<1e4)a=Array.from(i),a.unshift(e,t),n.splice(...a);else for(t&&n.splice(e,t);o0?(cr(n,n.length,0,e),n):e}const fC={}.hasOwnProperty;function LA(n){const e={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function ur(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ln=xs(/[A-Za-z]/),zn=xs(/[\dA-Za-z]/),AP=xs(/[#-'*+\--9=?A-Z^-~]/);function Xd(n){return n!==null&&(n<32||n===127)}const ly=xs(/\d/),EP=xs(/[\dA-Fa-f]/),BA=xs(/[!-/:-@[-`{-~]/);function Ie(n){return n!==null&&n<-2}function Lt(n){return n!==null&&(n<0||n===32)}function Je(n){return n===-2||n===-1||n===32}const gm=xs(new RegExp("\\p{P}|\\p{S}","u")),ho=xs(/\s/);function xs(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function Ua(n){const e=[];let t=-1,i=0,l=0;for(;++t55295&&o<57344){const u=n.charCodeAt(t+1);o<56320&&u>56319&&u<57344?(a=String.fromCharCode(o,u),l=1):a="�"}else a=String.fromCharCode(o);a&&(e.push(n.slice(i,t),encodeURIComponent(a)),i=t+l+1,a=""),l&&(t+=l,l=0)}return e.join("")+n.slice(i)}function xt(n,e,t,i){const l=i?i-1:1/0;let o=0;return a;function a(f){return Je(f)?(n.enter(t),u(f)):e(f)}function u(f){return Je(f)&&o++=l?e(m):t(m)}}const MP={tokenize:DP};function DP(n){const e=n.attempt(this.parser.constructs.contentInitial,i,l);let t;return e;function i(u){if(u===null){n.consume(u);return}return n.enter("lineEnding"),n.consume(u),n.exit("lineEnding"),xt(n,e,"linePrefix")}function l(u){return n.enter("paragraph"),o(u)}function o(u){const f=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=f),t=f,a(u)}function a(u){if(u===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(u);return}return Ie(u)?(n.consume(u),n.exit("chunkText"),o):(n.consume(u),a)}}let $d=class{constructor(){this.index=new Map,this.map=[]}add(e,t,i){hC(this,e,t,i,!1)}addBefore(e,t,i){hC(this,e,t,i,!0)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}};function hC(n,e,t,i,l){if(t===0&&i.length===0)return;const o=n.index.get(e);if(o){o[1]+=t,l?(i.push(...o[2]),o[2]=i):o[2].push(...i);return}const a=[e,t,i];n.map.push(a),n.index.set(e,a)}const RP={tokenize:jP},dC={tokenize:_P};function jP(n){const e=this,t=[];let i=0,l,o,a;return u;function u(M){if(ia))return;const D=e.events.length;let I=D,ne,F;for(;I--;)if(e.events[I][0]==="exit"&&e.events[I][1].type==="chunkFlow"){if(ne){F=e.events[I][1].end;break}ne=!0}for(N(i),E=D;EM;){const H=t[U];e.containerState=H[1],H[0].exit.call(e,n)}t.length=M}function j(){l.write([null]),o=void 0,l=void 0,e.containerState._closeFlow=void 0}}function _P(n,e,t){return xt(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function ms(n){if(n===null||Lt(n)||ho(n))return 1;if(gm(n))return 2}function xm(n,e,t){const i=[];let l=-1;for(;++l1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1,a={...n[l][1].end},u={...n[t][1].start};mC(a,-o),mC(u,o);const f={type:o>1?"strongSequence":"emphasisSequence",start:a,end:{...n[l][1].end}},d={type:o>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:u},m={type:o>1?"strongText":"emphasisText",start:{...n[l][1].end},end:{...n[t][1].start}},g={type:o>1?"strong":"emphasis",start:{...f.start},end:{...d.end}};n[l][1].end={...f.start},n[t][1].start={...d.end},i=[],n[l][1].end.offset-n[l][1].start.offset&&(i=Vi(i,[["enter",n[l][1],e],["exit",n[l][1],e]])),i=Vi(i,[["enter",g,e],["enter",f,e],["exit",f,e],["enter",m,e]]),i=Vi(i,xm(e.parser.constructs.insideSpan.null,n.slice(l+1,t),e)),i=Vi(i,[["exit",m,e],["enter",d,e],["exit",d,e],["exit",g,e]]);let b=0;n[t][1].end.offset-n[t][1].start.offset&&(b=2,i=Vi(i,[["enter",n[t][1],e],["exit",n[t][1],e]])),cr(n,l-1,t-l+3,i),t=l+i.length-b-2;break}}for(t=-1;++t0&&Je(E)?xt(n,j,"linePrefix",o+1)(E):j(E)}function j(E){return E===null||Ie(E)?n.check(oy,S,U)(E):(n.enter("codeFlowValue"),M(E))}function M(E){return E===null||Ie(E)?(n.exit("codeFlowValue"),j(E)):(n.consume(E),M)}function U(E){return n.exit("codeFenced"),e(E)}function H(E,D,I){let ne=0;return F;function F(ce){return E.enter("lineEnding"),E.consume(ce),E.exit("lineEnding"),V}function V(ce){return E.enter("codeFencedFence"),Je(ce)?xt(E,_,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ce):_(ce)}function _(ce){return ce===u?(E.enter("codeFencedFenceSequence"),ie(ce)):I(ce)}function ie(ce){return ce===u?(ne++,E.consume(ce),ie):ne>=a?(E.exit("codeFencedFenceSequence"),Je(ce)?xt(E,pe,"whitespace")(ce):pe(ce)):I(ce)}function pe(ce){return ce===null||Ie(ce)?(E.exit("codeFencedFence"),D(ce)):I(ce)}}}const z0={name:"codeIndented",tokenize:YP},$P={partial:!0,tokenize:GP};function YP(n,e,t){return i;function i(u){return n.enter("codeIndented"),PA(n,l,t,"linePrefix",4,4)(u)}function l(u){return u===null?a(u):Ie(u)?n.attempt($P,l,a)(u):(n.enter("codeFlowValue"),o(u))}function o(u){return u===null||Ie(u)?(n.exit("codeFlowValue"),l(u)):(n.consume(u),o)}function a(u){return n.exit("codeIndented"),e(u)}}function GP(n,e,t){const i=this;return l;function l(a){return i.parser.lazy[i.now().line]?t(a):Ie(a)?(n.enter("lineEnding"),n.consume(a),n.exit("lineEnding"),l):PA(n,e,o,"linePrefix",4,4)(a)}function o(a){return Ie(a)?l(a):t(a)}}const KP={name:"codeText",previous:ZP,resolve:WP,tokenize:JP};function WP(n){let e=n.length-4,t=3,i,l;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(i=t;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,t,i){const l=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&Yc(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),Yc(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Yc(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e=4?e(a):n.interrupt(i.parser.constructs.flow,t,e)(a)}}function qA(n,e,t,i,l,o,a,u,f){const d=f||Number.POSITIVE_INFINITY;let m=0;return g;function g(N){return N===60?(n.enter(i),n.enter(l),n.enter(o),n.consume(N),n.exit(o),b):N===null||N===32||N===41||Xd(N)?t(N):(n.enter(i),n.enter(a),n.enter(u),n.enter("chunkString",{contentType:"string"}),S(N))}function b(N){return N===62?(n.enter(o),n.consume(N),n.exit(o),n.exit(l),n.exit(i),e):(n.enter(u),n.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===62?(n.exit("chunkString"),n.exit(u),b(N)):N===null||N===60||Ie(N)?t(N):(n.consume(N),N===92?w:v)}function w(N){return N===60||N===62||N===92?(n.consume(N),v):v(N)}function S(N){return!m&&(N===null||N===41||Lt(N))?(n.exit("chunkString"),n.exit(u),n.exit(a),n.exit(i),e(N)):m999||v===null||v===91||v===93&&!f||v===94&&!u&&"_hiddenFootnoteSupport"in a.parser.constructs?t(v):v===93?(n.exit(o),n.enter(l),n.consume(v),n.exit(l),n.exit(i),e):Ie(v)?(n.enter("lineEnding"),n.consume(v),n.exit("lineEnding"),m):(n.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||Ie(v)||u++>999?(n.exit("chunkString"),m(v)):(n.consume(v),f||(f=!Je(v)),v===92?b:g)}function b(v){return v===91||v===92||v===93?(n.consume(v),u++,g):g(v)}}function QA(n,e,t,i,l,o){let a;return u;function u(b){return b===34||b===39||b===40?(n.enter(i),n.enter(l),n.consume(b),n.exit(l),a=b===40?41:b,f):t(b)}function f(b){return b===a?(n.enter(l),n.consume(b),n.exit(l),n.exit(i),e):(n.enter(o),d(b))}function d(b){return b===a?(n.exit(o),f(a)):b===null?t(b):Ie(b)?(n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),xt(n,d,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===a||b===null||Ie(b)?(n.exit("chunkString"),d(b)):(n.consume(b),b===92?g:m)}function g(b){return b===a||b===92?(n.consume(b),m):m(b)}}function fu(n,e){let t;return i;function i(l){return Ie(l)?(n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),t=!0,i):Je(l)?xt(n,i,t?"linePrefix":"lineSuffix")(l):e(l)}}const oH={name:"definition",tokenize:cH},aH={partial:!0,tokenize:uH};function cH(n,e,t){const i=this;let l;return o;function o(v){return n.enter("definition"),a(v)}function a(v){return VA.call(i,n,u,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function u(v){return l=ur(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),v===58?(n.enter("definitionMarker"),n.consume(v),n.exit("definitionMarker"),f):t(v)}function f(v){return Lt(v)?fu(n,d)(v):d(v)}function d(v){return qA(n,m,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function m(v){return n.attempt(aH,g,g)(v)}function g(v){return Je(v)?xt(n,b,"whitespace")(v):b(v)}function b(v){return v===null||Ie(v)?(n.exit("definition"),i.parser.defined.push(l),e(v)):t(v)}}function uH(n,e,t){return i;function i(u){return Lt(u)?fu(n,l)(u):t(u)}function l(u){return QA(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return Je(u)?xt(n,a,"whitespace")(u):a(u)}function a(u){return u===null||Ie(u)?e(u):t(u)}}const fH={name:"hardBreakEscape",tokenize:hH};function hH(n,e,t){return i;function i(o){return n.enter("hardBreakEscape"),n.consume(o),l}function l(o){return Ie(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}const dH={name:"headingAtx",resolve:mH,tokenize:pH};function mH(n,e){let t=n.length-2,i=3;if(n[i][1].type==="whitespace"&&(i+=2),t-2>i&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(i===t-1||t-4>i&&n[t-2][1].type==="whitespace")&&(t-=i+1===t?2:4),t>i){const l={type:"atxHeadingText",start:n[i][1].start,end:n[t][1].end},o={type:"chunkText",start:n[i][1].start,end:n[t][1].end,contentType:"text"};cr(n,i,t-i+1,[["enter",l,e],["enter",o,e],["exit",o,e],["exit",l,e]])}return n}function pH(n,e,t){let i=0;return l;function l(m){return n.enter("atxHeading"),o(m)}function o(m){return n.enter("atxHeadingSequence"),a(m)}function a(m){return m===35&&i++<6?(n.consume(m),a):m===null||Lt(m)?(n.exit("atxHeadingSequence"),u(m)):t(m)}function u(m){return m===35?(n.enter("atxHeadingSequence"),f(m)):m===null||Ie(m)?(n.exit("atxHeading"),e(m)):Je(m)?xt(n,u,"whitespace")(m):(n.enter("atxHeadingText"),d(m))}function f(m){return m===35?(n.consume(m),f):(n.exit("atxHeadingSequence"),u(m))}function d(m){return m===null||m===35||Lt(m)?(n.exit("atxHeadingText"),u(m)):(n.consume(m),d)}}const XA=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],ay=["pre","script","style","textarea"],gH={concrete:!0,name:"htmlFlow",resolveTo:yH,tokenize:bH},xH={partial:!0,tokenize:vH};function yH(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function bH(n,e,t){const i=this;let l,o,a,u,f;return d;function d(z){return m(z)}function m(z){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(z),g}function g(z){return z===33?(n.consume(z),b):z===47?(n.consume(z),o=!0,S):z===63?(n.consume(z),l=3,i.interrupt?e:T):Ln(z)?(n.consume(z),a=String.fromCharCode(z),C):t(z)}function b(z){return z===45?(n.consume(z),l=2,v):z===91?(n.consume(z),l=5,u=0,w):Ln(z)?(n.consume(z),l=4,i.interrupt?e:T):t(z)}function v(z){return z===45?(n.consume(z),i.interrupt?e:T):t(z)}function w(z){const R="CDATA[";return z===R.charCodeAt(u++)?(n.consume(z),u===R.length?i.interrupt?e:_:w):t(z)}function S(z){return Ln(z)?(n.consume(z),a=String.fromCharCode(z),C):t(z)}function C(z){if(z===null||z===47||z===62||Lt(z)){const R=z===47,X=a.toLowerCase();return!R&&!o&&ay.includes(X)?(l=1,i.interrupt?e(z):_(z)):XA.includes(a.toLowerCase())?(l=6,R?(n.consume(z),N):i.interrupt?e(z):_(z)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?t(z):o?j(z):M(z))}return z===45||zn(z)?(n.consume(z),a+=String.fromCharCode(z),C):t(z)}function N(z){return z===62?(n.consume(z),i.interrupt?e:_):t(z)}function j(z){return Je(z)?(n.consume(z),j):F(z)}function M(z){return z===47?(n.consume(z),F):z===58||z===95||Ln(z)?(n.consume(z),U):Je(z)?(n.consume(z),M):F(z)}function U(z){return z===45||z===46||z===58||z===95||zn(z)?(n.consume(z),U):H(z)}function H(z){return z===61?(n.consume(z),E):Je(z)?(n.consume(z),H):M(z)}function E(z){return z===null||z===60||z===61||z===62||z===96?t(z):z===34||z===39?(n.consume(z),f=z,D):Je(z)?(n.consume(z),E):I(z)}function D(z){return z===f?(n.consume(z),f=null,ne):z===null||Ie(z)?t(z):(n.consume(z),D)}function I(z){return z===null||z===34||z===39||z===47||z===60||z===61||z===62||z===96||Lt(z)?H(z):(n.consume(z),I)}function ne(z){return z===47||z===62||Je(z)?M(z):t(z)}function F(z){return z===62?(n.consume(z),V):t(z)}function V(z){return z===null||Ie(z)?_(z):Je(z)?(n.consume(z),V):t(z)}function _(z){return z===45&&l===2?(n.consume(z),Z):z===60&&l===1?(n.consume(z),oe):z===62&&l===4?(n.consume(z),de):z===63&&l===3?(n.consume(z),T):z===93&&l===5?(n.consume(z),W):Ie(z)&&(l===6||l===7)?(n.exit("htmlFlowData"),n.check(xH,be,ie)(z)):z===null||Ie(z)?(n.exit("htmlFlowData"),ie(z)):(n.consume(z),_)}function ie(z){return n.check(oy,pe,be)(z)}function pe(z){return n.enter("lineEnding"),n.consume(z),n.exit("lineEnding"),ce}function ce(z){return z===null||Ie(z)?ie(z):(n.enter("htmlFlowData"),_(z))}function Z(z){return z===45?(n.consume(z),T):_(z)}function oe(z){return z===47?(n.consume(z),a="",G):_(z)}function G(z){if(z===62){const R=a.toLowerCase();return ay.includes(R)?(n.consume(z),de):_(z)}return Ln(z)&&a.length<8?(n.consume(z),a+=String.fromCharCode(z),G):_(z)}function W(z){return z===93?(n.consume(z),T):_(z)}function T(z){return z===62?(n.consume(z),de):z===45&&l===2?(n.consume(z),T):_(z)}function de(z){return z===null||Ie(z)?(n.exit("htmlFlowData"),be(z)):(n.consume(z),de)}function be(z){return n.exit("htmlFlow"),e(z)}}function vH(n,e,t){return i;function i(l){return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),n.attempt(Iu,e,t)}}const wH={name:"htmlText",tokenize:kH};function kH(n,e,t){const i=this;let l,o,a;return u;function u(T){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(T),f}function f(T){return T===33?(n.consume(T),d):T===47?(n.consume(T),H):T===63?(n.consume(T),M):Ln(T)?(n.consume(T),I):t(T)}function d(T){return T===45?(n.consume(T),m):T===91?(n.consume(T),o=0,w):Ln(T)?(n.consume(T),j):t(T)}function m(T){return T===45?(n.consume(T),v):t(T)}function g(T){return T===null?t(T):T===45?(n.consume(T),b):Ie(T)?(a=g,oe(T)):(n.consume(T),g)}function b(T){return T===45?(n.consume(T),v):g(T)}function v(T){return T===62?Z(T):T===45?b(T):g(T)}function w(T){const de="CDATA[";return T===de.charCodeAt(o++)?(n.consume(T),o===de.length?S:w):t(T)}function S(T){return T===null?t(T):T===93?(n.consume(T),C):Ie(T)?(a=S,oe(T)):(n.consume(T),S)}function C(T){return T===93?(n.consume(T),N):S(T)}function N(T){return T===62?Z(T):T===93?(n.consume(T),N):S(T)}function j(T){return T===null||T===62?Z(T):Ie(T)?(a=j,oe(T)):(n.consume(T),j)}function M(T){return T===null?t(T):T===63?(n.consume(T),U):Ie(T)?(a=M,oe(T)):(n.consume(T),M)}function U(T){return T===62?Z(T):M(T)}function H(T){return Ln(T)?(n.consume(T),E):t(T)}function E(T){return T===45||zn(T)?(n.consume(T),E):D(T)}function D(T){return Ie(T)?(a=D,oe(T)):Je(T)?(n.consume(T),D):Z(T)}function I(T){return T===45||zn(T)?(n.consume(T),I):T===47||T===62||Lt(T)?ne(T):t(T)}function ne(T){return T===47?(n.consume(T),Z):T===58||T===95||Ln(T)?(n.consume(T),F):Ie(T)?(a=ne,oe(T)):Je(T)?(n.consume(T),ne):Z(T)}function F(T){return T===45||T===46||T===58||T===95||zn(T)?(n.consume(T),F):V(T)}function V(T){return T===61?(n.consume(T),_):Ie(T)?(a=V,oe(T)):Je(T)?(n.consume(T),V):ne(T)}function _(T){return T===null||T===60||T===61||T===62||T===96?t(T):T===34||T===39?(n.consume(T),l=T,ie):Ie(T)?(a=_,oe(T)):Je(T)?(n.consume(T),_):(n.consume(T),pe)}function ie(T){return T===l?(n.consume(T),l=void 0,ce):T===null?t(T):Ie(T)?(a=ie,oe(T)):(n.consume(T),ie)}function pe(T){return T===null||T===34||T===39||T===60||T===61||T===96?t(T):T===47||T===62||Lt(T)?ne(T):(n.consume(T),pe)}function ce(T){return T===47||T===62||Lt(T)?ne(T):t(T)}function Z(T){return T===62?(n.consume(T),n.exit("htmlTextData"),n.exit("htmlText"),e):t(T)}function oe(T){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(T),n.exit("lineEnding"),G}function G(T){return Je(T)?xt(n,W,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):W(T)}function W(T){return n.enter("htmlTextData"),a(T)}}const pb={name:"labelEnd",resolveAll:NH,resolveTo:TH,tokenize:AH},SH={tokenize:EH},CH={tokenize:MH},OH={tokenize:DH};function NH(n){let e=-1;const t=[];for(;++e0&&l[l.length-1]._balanced;)l.pop();o=l[l.length-1]}return u;function u(b){return o?o._inactive?g(b):(a=i.parser.defined.includes(ur(i.sliceSerialize({start:o.end,end:i.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(b),n.exit("labelMarker"),n.exit("labelEnd"),f):t(b)}function f(b){return b===40?n.attempt(SH,m,a?m:g)(b):b===91?n.attempt(CH,m,a?d:g)(b):a?m(b):g(b)}function d(b){return n.attempt(OH,m,g)(b)}function m(b){return l.pop(),e(b)}function g(b){return o._balanced=!0,t(b)}}function EH(n,e,t){return i;function i(g){return n.enter("resource"),n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),l}function l(g){return Lt(g)?fu(n,o)(g):o(g)}function o(g){return g===41?m(g):qA(n,a,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function a(g){return Lt(g)?fu(n,f)(g):m(g)}function u(g){return t(g)}function f(g){return g===34||g===39||g===40?QA(n,d,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):m(g)}function d(g){return Lt(g)?fu(n,m)(g):m(g)}function m(g){return g===41?(n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),n.exit("resource"),e):t(g)}}function MH(n,e,t){const i=this;return l;function l(u){return VA.call(i,n,o,a,"reference","referenceMarker","referenceString")(u)}function o(u){return i.parser.defined.includes(ur(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(u):t(u)}function a(u){return t(u)}}function DH(n,e,t){return i;function i(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),l}function l(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}const RH={name:"labelStartImage",resolveAll:pb.resolveAll,tokenize:jH};function jH(n,e,t){const i=this;let l;return o;function o(f){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(f),n.exit("labelImageMarker"),a}function a(f){return f===91?(n.enter("labelMarker"),n.consume(f),n.exit("labelMarker"),l=n.exit("labelImage"),u):t(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(f):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(f))}}const _H={name:"labelStartLink",resolveAll:pb.resolveAll,tokenize:LH};function LH(n,e,t){const i=this;let l;return o;function o(u){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(u),n.exit("labelMarker"),l=n.exit("labelLink"),a}function a(u){return u===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(u):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(u))}}const B0={name:"lineEnding",tokenize:zH};function zH(n,e){return t;function t(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),xt(n,e,"linePrefix")}}const dd={name:"thematicBreak",tokenize:BH};function BH(n,e,t){let i=0,l;return o;function o(d){return n.enter("thematicBreak"),a(d)}function a(d){return l=d,u(d)}function u(d){return d===l?(n.enter("thematicBreakSequence"),f(d)):i>=3&&(d===null||Ie(d))?(n.exit("thematicBreak"),e(d)):t(d)}function f(d){return d===l?(n.consume(d),i++,f):(n.exit("thematicBreakSequence"),Je(d)?xt(n,u,"whitespace")(d):u(d))}}const fi={continuation:{tokenize:UH},exit:qH,name:"list",tokenize:IH},PH={partial:!0,tokenize:VH},HH={partial:!0,tokenize:FH};function IH(n,e,t){const i=this,l=i.events[i.events.length-1];let o=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,a=0;return u;function u(v){const w=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:ly(v)){if(i.containerState.type||(i.containerState.type=w,n.enter(w,{_container:!0})),w==="listUnordered")return n.enter("listItemPrefix"),v===42||v===45?n.check(dd,t,d)(v):d(v);if(!i.interrupt||v===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),f(v)}return t(v)}function f(v){return ly(v)&&++a<10?(n.consume(v),f):(!i.interrupt||a<2)&&(i.containerState.marker?v===i.containerState.marker:v===41||v===46)?(n.exit("listItemValue"),d(v)):t(v)}function d(v){return n.enter("listItemMarker"),n.consume(v),n.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||v,n.check(Iu,i.interrupt?t:m,n.attempt(PH,b,g))}function m(v){return i.containerState.initialBlankLine=!0,o++,b(v)}function g(v){return Je(v)?(n.enter("listItemPrefixWhitespace"),n.consume(v),n.exit("listItemPrefixWhitespace"),b):t(v)}function b(v){return i.containerState.size=o+i.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(v)}}function UH(n,e,t){const i=this;return i.containerState._closeFlow=void 0,n.check(Iu,l,o);function l(u){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,xt(n,e,"listItemIndent",i.containerState.size+1)(u)}function o(u){return i.containerState.furtherBlankLines||!Je(u)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(u)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,n.attempt(HH,e,a)(u))}function a(u){return i.containerState._closeFlow=!0,i.interrupt=void 0,xt(n,n.attempt(fi,e,t),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function FH(n,e,t){const i=this;return xt(n,l,"listItemIndent",i.containerState.size+1);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?e(o):t(o)}}function qH(n){n.exit(this.containerState.type)}function VH(n,e,t){const i=this;return xt(n,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(o){const a=i.events[i.events.length-1];return!Je(o)&&a&&a[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}const gC={name:"setextUnderline",resolveTo:QH,tokenize:XH};function QH(n,e){const t=new $d;let i=n.length,l,o,a;for(;i--;)if(n[i][0]==="enter"){if(n[i][1].type==="content"){l=i;break}n[i][1].type==="paragraph"&&(o=i)}else n[i][1].type==="content"&&t.add(i,1,[]),!a&&n[i][1].type==="definition"&&(a=i);const u={type:"setextHeading",start:{...n[l][1].start},end:{...n[n.length-1][1].end}};return n[o][1].type="setextHeadingText",a?(t.add(o,0,[["enter",u,e]]),t.add(a+1,0,[["exit",n[l][1],e]]),n[l][1].end={...n[a][1].end}):n[l][1]=u,t.add(n.length,0,[["exit",u,e]]),t.consume(n),n}function XH(n,e,t){const i=this;let l;return o;function o(d){let m=i.events.length,g;for(;m--;)if(i.events[m][1].type!=="lineEnding"&&i.events[m][1].type!=="linePrefix"&&i.events[m][1].type!=="content"){g=i.events[m][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(n.enter("setextHeadingLine"),l=d,a(d)):t(d)}function a(d){return n.enter("setextHeadingLineSequence"),u(d)}function u(d){return d===l?(n.consume(d),u):(n.exit("setextHeadingLineSequence"),Je(d)?xt(n,f,"lineSuffix")(d):f(d))}function f(d){return d===null||Ie(d)?(n.exit("setextHeadingLine"),e(d)):t(d)}}const $H={tokenize:YH};function YH(n){const e=this,t=n.attempt(Iu,i,n.attempt(this.parser.constructs.flowInitial,l,xt(n,n.attempt(this.parser.constructs.flow,l,n.attempt(nH,l)),"linePrefix")));return t;function i(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function l(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}const GH={resolveAll:YA()},KH=$A("string"),WH=$A("text");function $A(n){return{resolveAll:YA(n==="text"?ZH:void 0),tokenize:e};function e(t){const i=this,l=this.parser.constructs[n],o=t.attempt(l,a,u);return a;function a(m){return d(m)?o(m):u(m)}function u(m){if(m===null){t.consume(m);return}return t.enter("data"),t.consume(m),f}function f(m){return d(m)?(t.exit("data"),o(m)):(t.consume(m),f)}function d(m){if(m===null)return!0;const g=l[m];let b=-1;if(g)for(;++b-1){const u=a[0];typeof u=="string"?a[0]=u.slice(i):a.shift()}o>0&&a.push(n[l].slice(0,o))}return a}function f7(n,e){let t=-1;const i=[];let l;for(;++t0&&l(e.beforeEnter,{...Le,sliceSerialize:te[ue][2].sliceSerialize},te[ue][1]),GA.call(ye,te[ue][1].type)&&ye[te[ue][1].type].call({...Le,sliceSerialize:te[ue][2].sliceSerialize},te[ue][1]),te[ue][0]==="exit"&&e.afterExit.length>0&&l(e.afterExit,{...Le,sliceSerialize:te[ue][2].sliceSerialize},te[ue][1])}if(Le.tokenStack.length>0){const ye=Le.tokenStack[Le.tokenStack.length-1];(ye[1]||yC).call(Le,void 0,ye[0])}for(fe.position={start:Kl(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:Kl(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},ue=-1;++ue0&&(i.className=["language-"+l[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:t}]};return e.meta&&(o.data={meta:e.meta}),n.patch(e,o),o=n.applyData(e,o),o={type:"element",tagName:"pre",properties:{},children:[o]},n.patch(e,o),o}function O7(n,e){const t={type:"element",tagName:"del",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function N7(n,e){const t={type:"element",tagName:"em",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function T7(n,e){const t=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",i=String(e.identifier).toUpperCase(),l=Ua(i.toLowerCase()),o=n.footnoteOrder.indexOf(i);let a,u=n.footnoteCounts.get(i);u===void 0?(u=0,n.footnoteOrder.push(i),a=n.footnoteOrder.length):a=o+1,u+=1,n.footnoteCounts.set(i,u);const f={type:"element",tagName:"a",properties:{href:"#"+t+"fn-"+l,id:t+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};n.patch(e,f);const d={type:"element",tagName:"sup",properties:{},children:[f]};return n.patch(e,d),n.applyData(e,d)}function A7(n,e){const t={type:"element",tagName:"h"+e.depth,properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function E7(n,e){if(n.options.allowDangerousHtml){const t={type:"raw",value:e.value};return n.patch(e,t),n.applyData(e,t)}}function WA(n,e){const t=e.referenceType;let i="]";if(t==="collapsed"?i+="[]":t==="full"&&(i+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+i}];const l=n.all(e),o=l[0];o&&o.type==="text"?o.value="["+o.value:l.unshift({type:"text",value:"["});const a=l[l.length-1];return a&&a.type==="text"?a.value+=i:l.push({type:"text",value:i}),l}function M7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return WA(n,e);const l={src:Ua(i.url||""),alt:e.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"img",properties:l,children:[]};return n.patch(e,o),n.applyData(e,o)}function D7(n,e){const t={src:Ua(e.url)};e.alt!==null&&e.alt!==void 0&&(t.alt=e.alt),e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"img",properties:t,children:[]};return n.patch(e,i),n.applyData(e,i)}function R7(n,e){const t={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};n.patch(e,t);const i={type:"element",tagName:"code",properties:{},children:[t]};return n.patch(e,i),n.applyData(e,i)}function j7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return WA(n,e);const l={href:Ua(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"a",properties:l,children:n.all(e)};return n.patch(e,o),n.applyData(e,o)}function _7(n,e){const t={href:Ua(e.url)};e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"a",properties:t,children:n.all(e)};return n.patch(e,i),n.applyData(e,i)}function L7(n,e,t){const i=n.all(e),l=t?z7(t):ZA(e),o={},a=[];if(typeof e.checked=="boolean"){const m=i[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u1}function B7(n,e){const t={},i=n.all(e);let l=-1;for(typeof e.start=="number"&&e.start!==1&&(t.start=e.start);++l0){const a={type:"element",tagName:"tbody",properties:{},children:n.wrap(t,!0)},u=cb(e.children[1]),f=AA(e.children[e.children.length-1]);u&&f&&(a.position={start:u,end:f}),l.push(a)}const o={type:"element",tagName:"table",properties:{},children:n.wrap(l,!0)};return n.patch(e,o),n.applyData(e,o)}function F7(n,e,t){const i=t?t.children:void 0,o=(i?i.indexOf(e):1)===0?"th":"td",a=t&&t.type==="table"?t.align:void 0,u=a?a.length:e.children.length;let f=-1;const d=[];for(;++f0,!0),i[0]),l=i.index+i[0].length,i=t.exec(e);return o.push(wC(e.slice(l),l>0,!1)),o.join("")}function wC(n,e,t){let i=0,l=n.length;if(e){let o=n.codePointAt(i);for(;o===bC||o===vC;)i++,o=n.codePointAt(i)}if(t){let o=n.codePointAt(l-1);for(;o===bC||o===vC;)l--,o=n.codePointAt(l-1)}return l>i?n.slice(i,l):""}function Q7(n,e){const t={type:"text",value:V7(String(e.value))};return n.patch(e,t),n.applyData(e,t)}function X7(n,e){const t={type:"element",tagName:"hr",properties:{},children:[]};return n.patch(e,t),n.applyData(e,t)}const $7={blockquote:k7,break:S7,code:C7,delete:O7,emphasis:N7,footnoteReference:T7,heading:A7,html:E7,imageReference:M7,image:D7,inlineCode:R7,linkReference:j7,link:_7,listItem:L7,list:B7,paragraph:P7,root:H7,strong:I7,table:U7,tableCell:q7,tableRow:F7,text:Q7,thematicBreak:X7,toml:$h,yaml:$h,definition:$h,footnoteDefinition:$h};function $h(){}const JA=-1,ym=0,hu=1,Yd=2,gb=3,xb=4,yb=5,bb=6,eE=7,tE=8,{defineProperty:Y7}=Object,nE=typeof self=="object"?self:globalThis,kC=(n,e)=>{switch(n){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+n)}return new nE[n](e)},G7=(n,e)=>{const t=(l,o)=>(n.set(o,l),l),i=l=>{if(n.has(l))return n.get(l);const[o,a]=e[l];switch(o){case ym:case JA:return t(a,l);case hu:{const u=t([],l);for(const f of a)u.push(i(f));return u}case Yd:{const u=t({},l);for(const[f,d]of a){const m=i(f),g=i(d);m==="__proto__"?Y7(u,m,{value:g,configurable:!0,enumerable:!0,writable:!0}):u[m]=g}return u}case gb:return t(new Date(a),l);case xb:{const{source:u,flags:f}=a;return t(new RegExp(u,f),l)}case yb:{const u=t(new Map,l);for(const[f,d]of a)u.set(i(f),i(d));return u}case bb:{const u=t(new Set,l);for(const f of a)u.add(i(f));return u}case eE:{const{name:u,message:f}=a;return t(typeof nE[u]=="function"?kC(u,f):new Error(f),l)}case tE:return t(BigInt(a),l);case"BigInt":return t(Object(BigInt(a)),l);case"ArrayBuffer":return t(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return t(new DataView(u),a)}case"-0":return-0}return t(kC(o,a),l)};return i},SC=n=>G7(new Map,n)(0),Ws="",{toString:K7}={},{keys:W7,is:Z7}=Object,Gc=n=>{const e=typeof n;if(e!=="object"||!n)return[ym,e];const t=K7.call(n).slice(8,-1);switch(t){case"Array":return[hu,Ws];case"Object":return[Yd,Ws];case"Date":return[gb,Ws];case"RegExp":return[xb,Ws];case"Map":return[yb,Ws];case"Set":return[bb,Ws];case"DataView":return[hu,t]}return t.includes("Array")?[hu,t]:n instanceof Error?[eE,n.name||"Error"]:[Yd,t]},Yh=([n,e])=>n===ym&&(e==="function"||e==="symbol"),J7=(n,e,t,i)=>{const l=(a,u)=>{const f=i.push(a)-1;return t.set(u,f),f},o=a=>{if(t.has(a))return t.get(a);let[u,f]=Gc(a);switch(u){case ym:{let m=a;switch(f){case"bigint":u=tE,m=a.toString();break;case"number":if(!a&&Z7(a,-0))return i.push(["-0"])-1;break;case"function":case"symbol":if(n)throw new TypeError("unable to serialize "+f);m=null;break;case"undefined":return l([JA],a)}return l([u,m],a)}case hu:{if(f){let b=a;return f==="DataView"?b=new Uint8Array(a.buffer):f==="ArrayBuffer"&&(b=new Uint8Array(a)),l([f,[...b]],a)}const m=[],g=l([u,m],a);for(const b of a)m.push(o(b));return g}case Yd:{if(f)switch(f){case"BigInt":return l([f,a.toString()],a);case"Boolean":case"Number":case"String":return l([f,a.valueOf()],a)}if(e&&"toJSON"in a)return o(a.toJSON());const m=[],g=l([u,m],a);for(const b of W7(a))(n||!Yh(Gc(a[b])))&&m.push([o(b),o(a[b])]);return g}case gb:return l([u,isNaN(a.getTime())?Ws:a.toISOString()],a);case xb:{const{source:m,flags:g}=a;return l([u,{source:m,flags:g}],a)}case yb:{const m=[],g=l([u,m],a);for(const[b,v]of a)(n||!(Yh(Gc(b))||Yh(Gc(v))))&&m.push([o(b),o(v)]);return g}case bb:{const m=[],g=l([u,m],a);for(const b of a)(n||!Yh(Gc(b)))&&m.push(o(b));return g}}const{message:d}=a;return l([u,{name:f,message:d}],a)};return o},CC=(n,{json:e,lossy:t}={})=>{const i=[];return J7(!(e||t),!!e,new Map,i)(n),i},Gd=typeof structuredClone=="function"?(n,e)=>e&&("json"in e||"lossy"in e)?SC(CC(n,e)):structuredClone(n):(n,e)=>SC(CC(n,e));function eI(n,e){const t=[{type:"text",value:"↩"}];return e>1&&t.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),t}function tI(n,e){return"Back to reference "+(n+1)+(e>1?"-"+e:"")}function nI(n){const e=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",t=n.options.footnoteBackContent||eI,i=n.options.footnoteBackLabel||tI,l=n.options.footnoteLabel||"Footnotes",o=n.options.footnoteLabelTagName||"h2",a=n.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let f=-1;for(;++f0&&w.push({type:"text",value:" "});let j=typeof t=="string"?t:t(f,v);typeof j=="string"&&(j={type:"text",value:j}),w.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(f,v),className:["data-footnote-backref"]},children:Array.isArray(j)?j:[j]})}const C=m[m.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const j=C.children[C.children.length-1];j&&j.type==="text"?j.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else m.push(...w);const N={type:"element",tagName:"li",properties:{id:e+"fn-"+b},children:n.wrap(m,!0)};n.patch(d,N),u.push(N)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Gd(a),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:` -`},{type:"element",tagName:"ol",properties:{},children:n.wrap(u,!0)},{type:"text",value:` -`}]}}const bm=(function(n){if(n==null)return sI;if(typeof n=="function")return vm(n);if(typeof n=="object")return Array.isArray(n)?iI(n):rI(n);if(typeof n=="string")return lI(n);throw new Error("Expected function, string, or object as test")});function iI(n){const e=[];let t=-1;for(;++t":""))+")"})}return C;function C(){const N=!o||d(b,v,w[w.length-1]||void 0);let j=iE;if(u&&N&&(j=OC(u(b,w,v)),j[0]===md))return j;if("children"in b&&b.children){const M=b;if(M.children&&j[0]!==cy){let U=(l?-1:M.children.length)+m;const H=[...w,M];for(;U>-1&&U0&&t.push({type:"text",value:` -`}),t}function NC(n){let e=0,t=n.charCodeAt(e);for(;t===9||t===32;)e++,t=n.charCodeAt(e);return n.slice(e)}function TC(n,e){const t=fI(n,e),i=t.one(n,void 0),l=nI(t),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&o.children.push({type:"text",value:` -`},l),o}function gI(n,e){return n&&"run"in n?async function(t,i){const l=TC(t,{file:i,...e});await n.run(l,i)}:function(t,i){return TC(t,{file:i,...n||e})}}function AC(n){if(n)throw n}var P0,EC;function xI(){if(EC)return P0;EC=1;var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=function(d){return typeof Array.isArray=="function"?Array.isArray(d):e.call(d)==="[object Array]"},o=function(d){if(!d||e.call(d)!=="[object Object]")return!1;var m=n.call(d,"constructor"),g=d.constructor&&d.constructor.prototype&&n.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!g)return!1;var b;for(b in d);return typeof b>"u"||n.call(d,b)},a=function(d,m){t&&m.name==="__proto__"?t(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},u=function(d,m){if(m==="__proto__")if(n.call(d,m)){if(i)return i(d,m).value}else return;return d[m]};return P0=function f(){var d,m,g,b,v,w,S=arguments[0],C=1,N=arguments.length,j=!1;for(typeof S=="boolean"&&(j=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});Ca.length;let f;u&&a.push(l);try{f=n.apply(this,a)}catch(d){const m=d;if(u&&t)throw m;return l(m)}u||(f&&f.then&&typeof f.then=="function"?f.then(o,l):f instanceof Error?l(f):o(f))}function l(a,...u){t||(t=!0,e(a,...u))}function o(a){l(null,a)}}const Er={basename:wI,dirname:kI,extname:SI,join:CI,sep:"/"};function wI(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Uu(n);let t=0,i=-1,l=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else i<0&&(o=!0,i=l+1);return i<0?"":n.slice(t,i)}if(e===n)return"";let a=-1,u=e.length-1;for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else a<0&&(o=!0,a=l+1),u>-1&&(n.codePointAt(l)===e.codePointAt(u--)?u<0&&(i=l):(u=-1,i=a));return t===i?i=a:i<0&&(i=n.length),n.slice(t,i)}function kI(n){if(Uu(n),n.length===0)return".";let e=-1,t=n.length,i;for(;--t;)if(n.codePointAt(t)===47){if(i){e=t;break}}else i||(i=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function SI(n){Uu(n);let e=n.length,t=-1,i=0,l=-1,o=0,a;for(;e--;){const u=n.codePointAt(e);if(u===47){if(a){i=e+1;break}continue}t<0&&(a=!0,t=e+1),u===46?l<0?l=e:o!==1&&(o=1):l>-1&&(o=-1)}return l<0||t<0||o===0||o===1&&l===t-1&&l===i+1?"":n.slice(l,t)}function CI(...n){let e=-1,t;for(;++e0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function NI(n,e){let t="",i=0,l=-1,o=0,a=-1,u,f;for(;++a<=n.length;){if(a2){if(f=t.lastIndexOf("/"),f!==t.length-1){f<0?(t="",i=0):(t=t.slice(0,f),i=t.length-1-t.lastIndexOf("/")),l=a,o=0;continue}}else if(t.length>0){t="",i=0,l=a,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",i=2)}else t.length>0?t+="/"+n.slice(l+1,a):t=n.slice(l+1,a),i=a-l-1;l=a,o=0}else u===46&&o>-1?o++:o=-1}return t}function Uu(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const TI={cwd:AI};function AI(){return"/"}function my(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function EI(n){if(typeof n=="string")n=new URL(n);else if(!my(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return MI(n)}function MI(n){if(n.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const e=n.pathname;let t=-1;for(;++t0){let[v,...w]=m;const S=i[b][1];dy(S)&&dy(v)&&(v=H0(!0,S,v)),i[b]=[d,v,...w]}}}}const _I=new wb().freeze();function q0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function V0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Q0(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function DC(n){if(!dy(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function RC(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Gh(n){return LI(n)?n:new rE(n)}function LI(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function zI(n){return typeof n=="string"||BI(n)}function BI(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const PI="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jC=[],_C={allowDangerousHtml:!0},HI=/^(https?|ircs?|mailto|xmpp)$/i,II=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function UI(n){const e=FI(n),t=qI(n);return VI(e.runSync(e.parse(t),t),n)}function FI(n){const e=n.rehypePlugins||jC,t=n.remarkPlugins||jC,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,..._C}:_C;return _I().use(w7).use(t).use(gI,i).use(e)}function qI(n){const e=n.children||"",t=new rE;return typeof e=="string"&&(t.value=e),t}function VI(n,e){const t=e.allowedElements,i=e.allowElement,l=e.components,o=e.disallowedElements,a=e.skipHtml,u=e.unwrapDisallowed,f=e.urlTransform||QI;for(const m of II)Object.hasOwn(e,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+PI+m.id,void 0);return vb(n,d),oP(n,{Fragment:y.Fragment,components:l,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function d(m,g,b){if(m.type==="raw"&&b&&typeof g=="number")return a?b.children.splice(g,1):b.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let v;for(v in L0)if(Object.hasOwn(L0,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],S=L0[v];(S===null||S.includes(m.tagName))&&(m.properties[v]=f(String(w||""),v,m))}}if(m.type==="element"){let v=t?!t.includes(m.tagName):o?o.includes(m.tagName):!1;if(!v&&i&&typeof g=="number"&&(v=!i(m,g,b)),v&&b&&typeof g=="number")return u&&m.children?b.children.splice(g,1,...m.children):b.children.splice(g,1),g}}}function QI(n){const e=n.indexOf(":"),t=n.indexOf("?"),i=n.indexOf("#"),l=n.indexOf("/");return e===-1||l!==-1&&e>l||t!==-1&&e>t||i!==-1&&e>i||HI.test(n.slice(0,e))?n:""}function XI(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function lE(n,e,t){const l=bm((t||{}).ignore||[]),o=$I(e);let a=-1;for(;++a0?{type:"text",value:E}:void 0),E===!1)v.lastIndex=U+1;else{if(S!==U&&M({type:"text",value:d.value.slice(S,U)}),Array.isArray(E))for(const D of E)M(D);else E&&M(E);S=U+j[0].length,C=!0}if(!v.global)break;j=v.exec(d.value)}return C?(S?\]}]+$/.exec(n);if(!e)return[n,void 0];n=n.slice(0,e.index);let t=e[0],i=t.indexOf(")");const l=LC(n,"(");let o=LC(n,")");for(;i!==-1&&l>o;)n+=t.slice(0,i+1),t=t.slice(i+1),i=t.indexOf(")"),o++;return[n,t]}function sE(n,e){const t=n.input.charCodeAt(n.index-1);return(n.index===0||ho(t)||gm(t))&&(!e||t!==47)}oE.peek=bU;function fU(){this.buffer()}function hU(n){this.enter({type:"footnoteReference",identifier:"",label:""},n)}function dU(){this.buffer()}function mU(n){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},n)}function pU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=ur(this.sliceSerialize(n)).toLowerCase(),t.label=e}function gU(n){this.exit(n)}function xU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=ur(this.sliceSerialize(n)).toLowerCase(),t.label=e}function yU(n){this.exit(n)}function bU(){return"["}function oE(n,e,t,i){const l=t.createTracker(i);let o=l.move("[^");const a=t.enter("footnoteReference"),u=t.enter("reference");return o+=l.move(t.safe(t.associationId(n),{after:"]",before:o})),u(),a(),o+=l.move("]"),o}function vU(){return{enter:{gfmFootnoteCallString:fU,gfmFootnoteCall:hU,gfmFootnoteDefinitionLabelString:dU,gfmFootnoteDefinition:mU},exit:{gfmFootnoteCallString:pU,gfmFootnoteCall:gU,gfmFootnoteDefinitionLabelString:xU,gfmFootnoteDefinition:yU}}}function wU(n){let e=!1;return n&&n.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:t,footnoteReference:oE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(i,l,o,a){const u=o.createTracker(a);let f=u.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return f+=u.move(o.safe(o.associationId(i),{before:f,after:"]"})),m(),f+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),f+=u.move((e?` -`:" ")+o.indentLines(o.containerFlow(i,u.current()),e?aE:kU))),d(),f}}function kU(n,e,t){return e===0?n:aE(n,e,t)}function aE(n,e,t){return(t?"":" ")+n}const SU=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];kb.attention=AU;kb.peek=EU;function CU(){return{canContainEols:["delete"],enter:{strikethrough:NU},exit:{strikethrough:TU}}}function OU(){return{handlers:{delete:kb},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:SU}]}}function NU(n){this.enter({type:"delete",children:[],position:void 0},n)}function TU(n){this.exit(n)}function kb(n,e,t,i){const l=t.createTracker(i),o=t.stack.includes("strikethrough")?"~":"~~",a=t.enter("strikethrough");let u=l.move(o);return u+=t.containerPhrasing(n,{...l.current(),before:u,after:"~"}),u+=l.move(o),a(),u}function AU(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function EU(){return"~"}function MU(n){return n.length}function DU(n,e){const t=e||{},i=(t.align||[]).concat(),l=t.stringLength||MU,o=[],a=[],u=[],f=[];let d=0,m=-1;for(;++md&&(d=n[m].length);++Nf[N])&&(f[N]=M)}S.push(j)}a[m]=S,u[m]=C}let g=-1;if(typeof i=="object"&&"length"in i)for(;++gf[g]&&(f[g]=j),v[g]=j),b[g]=M}a.splice(1,0,b),u.splice(1,0,v),m=-1;const w=[];for(;++m "),o.shift(2);const a=t.indentLines(t.containerFlow(n,o.current()),LU);return l(),a}function LU(n,e,t){return">"+(t?"":" ")+n}function zU(n,e){return BC(n,e.inConstruct,!0)&&!BC(n,e.notInConstruct,!1)}function BC(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let i=-1;for(;++ia&&(a=o):o=1,l=i+e.length,i=t.indexOf(e,l);return a}function PU(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^\n\r ]/.test(n.value)&&!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(n.value))}function HU(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function IU(n,e,t,i){const l=HU(t),o=n.value||"";if(PU(n,t)){const g=t.enter("codeIndented"),b=t.indentLines(o,UU);return g(),b}const a=t.createTracker(i),u=l.repeat(Math.max(BU(o,l)+1,3)),f=t.enter("codeFenced"),d=l==="`"?"GraveAccent":"Tilde";let m=a.move(u);if(n.lang){const g=t.enter(`codeFencedLang${d}`);m+=a.move(t.safe(n.lang,{before:m,after:" ",encode:["`"],...a.current()})),g()}if(n.lang&&n.meta){const g=t.enter(`codeFencedMeta${d}`);m+=a.move(" "),m+=a.move(t.safe(n.meta,{before:m,after:` -`,encode:["`"],...a.current()})),g()}return m+=a.move(` -`),o&&(m+=a.move(o+` -`)),m+=a.move(u),f(),m}function UU(n,e,t){return(t?"":" ")+n}function Sb(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function FU(n,e,t,i){const l=Sb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("definition");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("[");return d+=f.move(t.safe(t.associationId(n),{before:d,after:"]",...f.current()})),d+=f.move("]: "),u(),!n.url||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":` -`,...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),a(),d}function qU(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Kd(n){const e=n.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function Oa(n){const e=n.codePointAt(n.length-2);return e!==void 0&&e>65535?n.slice(-2):n.slice(-1)}function cE(n){return"&#x"+n.toString(16).toUpperCase()+";"}function HC(n,e,t){const i=ms(n),l=ms(e);return i===void 0?l===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function VU(n){if(n.charCodeAt(0)!==60)return;const e=n.charCodeAt(1);if(e===33){const u=n.charCodeAt(2);return u===45?2:u===91?5:Ln(u)?4:void 0}if(e===63)return 3;const t=e===47,i=t?2:1;let l=i,o=n.charCodeAt(l);if(!Ln(o))return;for(;o===45||zn(o);)o=n.charCodeAt(++l);const a=n.slice(i,l).toLowerCase();return!t&&o!==47&&ay.includes(a)?1:XA.includes(a)?6:7}const QU=new Map([["*",!1],["_",!0]]);function XU(n,e,t){const i=new Set;for(const o of n){const a=t.get(o);if(a&&o.attention&&e.some(u=>u.attention===o.attention))for(const u of a.tokens)i.add(u.attention)}const l=[];for(const o of n)o.attention&&i.delete(o.attention)&&l.push(o.attention);return l.reverse(),l}function uE(n,e,t){const i=[],l=new Map,o=new Map;let a=0;for(;at.index)return{chosen:f,mistake:m,tokens:d}}}}function YU(n,e){const t=new Map;for(const i of n){const l=i.tokens[0].value.charAt(0);let o=t.get(l);o||(o=[],t.set(l,o));let a=i.close?o.length:0;for(;a--&&i.start1&&d>1?2:1:d,g=u.markers.slice(u.end-m,u.end),b=i.markers.slice(i.start,i.start+m),v=g[0],w=b[0];if(v===g[m-1]&&v.value.length===m&&w===b[m-1]&&w.value.length===m&&v.attention===w.attention)e.delete(v),e.delete(w);else{const S=[...new Set([...g,...b])];for(const C of S){const N=e.get(C);N&&N.push(...S)}}u.end-=m,i.start+=m,u.start===u.end&&o.splice(a,1),a=o.length}i.open&&i.start0?w[0].value:"",C=HC(b.charCodeAt(b.length-1),S.charCodeAt(0),m);C.inside&&Kh(w,!0);const N=w.length>0?Oa(w[w.length-1].value):"",j=HC(v.charCodeAt(0),N.charCodeAt(N.length-1),m);j.inside&&Kh(w,!1),C.outside&&b!==` -`&&b!=="\r"&&Kh(l,!1),j.outside&&(o=v),l.push({value:d,attention:f},...w,{value:d,attention:f}),a=d.charAt(d.length-1)}return l}function wm(n,e,t){let i=new Map;const l=Ob(n,i,e,t);let o=l,a=uE(o,e,t);for(;a;){const f=$U(n,i,a,e,t);if(!f){o=l;break}i=f.chosen,o=f.tokens,a=f.mistake}let u="";for(const f of o)u+=f.value;return u}Nb.attention=fE;Nb.peek=WU;function Nb(n,e,t,i){const l=t.enter("phrasing"),o=Cb(n,fE,t,t.createTracker(i)),a=wm([o],i.before,i.after);return l(),a}function fE(n,e){return{construct:"emphasis",markers:qU(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function WU(n,e,t){return t.options.emphasis||"*"}function ZU(n,e){let t=!1;return vb(n,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return t=!0,md}),!!((!n.depth||n.depth<3)&&db(n)&&(e.options.setext||t))}function JU(n,e,t,i){const l=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(i);if(ZU(n,t)){const g=t.enter("headingSetext"),b=t.enter("phrasing"),v=t.containerPhrasing(n,{...o.current(),before:` -`,after:` -`});return b(),g(),v+` -`+(l===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(` -`))+1))}const a="#".repeat(l),u=t.enter("headingAtx"),f=t.enter("phrasing");o.move(a+" ");let d=t.containerPhrasing(n,{before:"# ",after:` -`,...o.current()});const m=d.charCodeAt(0);return(m===9||m===32)&&(d=cE(m)+d.slice(1)),d=d?a+" "+d:a,t.options.closeAtx&&(d+=" "+a),f(),u(),d}hE.peek=eF;function hE(n){return n.value||""}function eF(){return"<"}dE.peek=tF;function dE(n,e,t,i){const l=Sb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("image");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("![");return d+=f.move(t.safe(n.alt,{before:d,after:"]",...f.current()})),d+=f.move("]("),u(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":")",...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),d+=f.move(")"),a(),d}function tF(){return"!"}mE.peek=nF;function mE(n,e,t,i){const l=n.referenceType,o=t.enter("imageReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("![");const d=t.safe(n.alt,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function nF(){return"!"}pE.peek=iF;function pE(n,e,t){let i=n.value||"",l="`",o=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^\n\r ]/.test(i)&&(/^[\n\r ]/.test(i)&&/[\n\r ]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o\u007F]/.test(n.url))}xE.peek=rF;function xE(n,e,t,i){const l=Sb(t),o=l==='"'?"Quote":"Apostrophe",a=t.createTracker(i);if(gE(n,t)){const w=t.stack;t.stack=w.filter(function(N){return N!=="phrasing"});const S=t.enter("autolink");let C=a.move("<");return C+=a.move(t.containerPhrasing(n,{before:C,after:">",...a.current()})),C+=a.move(">"),S(),t.stack=w,C}const u=t.enter("link");let f=t.enter("label"),d=a.move("[");const m=t.containerPhrasing(n,{before:d,after:"](",...a.current()});d+=a.move(m),f(),d+=a.move("](");const g=/[\0- \u007F]/.test(n.url),b=i.before.charAt(i.before.length-1);let v=n.title||void 0;if(!v&&!g&&(b===` -`||b==="\r")){let w=0;for(;w",...a.current()})),d+=a.move(">")):(f=t.enter("destinationRaw"),d+=a.move(t.safe(n.url,{before:d,after:typeof v=="string"?" ":")",...a.current()}))),f(),typeof v=="string"&&(f=t.enter(`title${o}`),d+=a.move(" "+l),d+=a.move(t.safe(v,{before:d,after:l,...a.current()})),d+=a.move(l),f()),d+=a.move(")"),u(),d}function rF(n,e,t){return gE(n,t)?"<":"["}yE.peek=lF;function yE(n,e,t,i){const l=n.referenceType,o=t.enter("linkReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("[");const d=t.containerPhrasing(n,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function lF(){return"["}function Tb(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function sF(n){const e=Tb(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function oF(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function bE(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function aF(n,e,t,i){const l=t.enter("list"),o=t.bulletCurrent;let a=n.ordered?oF(t):Tb(t);const u=n.ordered?a==="."?")":".":sF(t);let f=e&&t.bulletLastUsed?a===t.bulletLastUsed:!1;if(!n.ordered){const m=n.children?n.children[0]:void 0;if((a==="*"||a==="-")&&m&&(!m.children||!m.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(f=!0),bE(t)===a&&m){let g=-1;for(;++g-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let a=o.length+1;(l==="tab"||l==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(a=Math.ceil(a/4)*4);const u=t.createTracker(i);u.move(o+" ".repeat(a-o.length)),u.shift(a);const f=t.enter("listItem"),d=t.indentLines(t.containerFlow(n,u.current()),m);return f(),d;function m(g,b,v){return b?(v?"":" ".repeat(a))+g:(v?o:o+" ".repeat(a-o.length))+g}}function fF(n,e,t,i){const l=t.enter("paragraph"),o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),l(),a}function hF(n,e,t,i){if(!n.children.some(function(u){return jU(u)}))return t.containerFlow(n,i);const o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),a}function dF(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}Ab.attention=vE;Ab.peek=mF;function Ab(n,e,t,i){const l=t.enter("phrasing"),o=Cb(n,vE,t,t.createTracker(i)),a=wm([o],i.before,i.after);return l(),a}function vE(n,e){return{construct:"strong",markers:dF(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function mF(n,e,t){return t.options.strong||"*"}function pF(n,e,t,i){const l=e?e.children:[],o=t.indexStack[t.indexStack.length-1];return t.safe(n.value,{...i,afterNode:l[o+1],beforeNode:l[o-1]})}function gF(n){const e=n.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function xF(n,e,t){const i=(bE(t)+(t.options.ruleSpaces?" ":"")).repeat(gF(t));return t.options.ruleSpaces?i.slice(0,-1):i}const wE={blockquote:_U,break:PC,code:IU,definition:FU,emphasis:Nb,hardBreak:PC,heading:JU,html:hE,image:dE,imageReference:mE,inlineCode:pE,link:xE,linkReference:yE,list:aF,listItem:uF,paragraph:fF,root:hF,strong:Ab,text:pF,thematicBreak:xF};function yF(){return{enter:{table:bF,tableData:IC,tableHeader:IC,tableRow:wF},exit:{codeText:kF,table:vF,tableData:G0,tableHeader:G0,tableRow:G0}}}function bF(n){const e=n._align;this.enter({type:"table",align:e.map(function(t){return t==="none"?null:t}),children:[]},n),this.data.inTable=!0}function vF(n){this.exit(n),this.data.inTable=void 0}function wF(n){this.enter({type:"tableRow",children:[]},n)}function G0(n){this.exit(n)}function IC(n){this.enter({type:"tableCell",children:[]},n)}function kF(n){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,SF));const t=this.stack[this.stack.length-1];t.type,t.value=e,this.exit(n)}function SF(n,e){return e==="|"?e:n}function CF(n){const e=n||{},t=e.tableCellPadding,i=e.tablePipeAlign,l=e.stringLength,o=t?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:a,tableCell:f,tableRow:u}};function a(v,w,S,C){return d(m(v,S,C),v.align)}function u(v,w,S,C){const N=g(v,S,C),j=d([N]);return j.slice(0,j.indexOf(` -`))}function f(v,w,S,C){const N=S.enter("tableCell"),j=S.enter("phrasing"),M=S.containerPhrasing(v,{...C,before:o,after:o});return j(),N(),M}function d(v,w){return DU(v,{align:w,alignDelimiters:i,padding:t,stringLength:l})}function m(v,w,S){const C=v.children;let N=-1;const j=[],M=w.enter("table");for(;++N0&&!t&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const FF={tokenize:KF,partial:!0};function qF(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:$F,continuation:{tokenize:YF},exit:GF}},text:{91:{name:"gfmFootnoteCall",tokenize:XF},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:VF,resolveTo:QF}}}}function VF(n,e,t){const i=this;let l=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a;for(;l--;){const f=i.events[l][1];if(f.type==="labelImage"){a=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return u;function u(f){if(!a||!a._balanced)return t(f);const d=ur(i.sliceSerialize({start:a.end,end:i.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?t(f):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(f),n.exit("gfmFootnoteCallLabelMarker"),e(f))}}function QF(n,e){let t=n.length;for(;t--;)if(n[t][1].type==="labelImage"&&n[t][0]==="enter"){n[t][1];break}n[t+1][1].type="data",n[t+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},n[t+3][1].start),end:Object.assign({},n[n.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},n[t+3][1].end),end:Object.assign({},n[t+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},n[n.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[n[t+1],n[t+2],["enter",i,e],n[t+3],n[t+4],["enter",l,e],["exit",l,e],["enter",o,e],["enter",a,e],["exit",a,e],["exit",o,e],n[n.length-2],n[n.length-1],["exit",i,e]];return n.splice(t,n.length-t+1,...u),n}function XF(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,a;return u;function u(g){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?t(g):(n.enter("gfmFootnoteCallMarker"),n.consume(g),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",d)}function d(g){if(o>999||g===93&&!a||g===null||g===91||Lt(g))return t(g);if(g===93){n.exit("chunkString");const b=n.exit("gfmFootnoteCallString");return l.includes(ur(i.sliceSerialize(b)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),e):t(g)}return Lt(g)||(a=!0),o++,n.consume(g),g===92?m:d}function m(g){return g===91||g===92||g===93?(n.consume(g),o++,d):d(g)}}function $F(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,a=0,u;return f;function f(w){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(w){return w===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",m):t(w)}function m(w){if(a>999||w===93&&!u||w===null||w===91||Lt(w))return t(w);if(w===93){n.exit("chunkString");const S=n.exit("gfmFootnoteDefinitionLabelString");return o=ur(i.sliceSerialize(S)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),b}return Lt(w)||(u=!0),a++,n.consume(w),w===92?g:m}function g(w){return w===91||w===92||w===93?(n.consume(w),a++,m):m(w)}function b(w){return w===58?(n.enter("definitionMarker"),n.consume(w),n.exit("definitionMarker"),l.includes(o)||l.push(o),xt(n,v,"gfmFootnoteDefinitionWhitespace")):t(w)}function v(w){return e(w)}}function YF(n,e,t){return n.check(Iu,e,n.attempt(FF,e,t))}function GF(n){n.exit("gfmFootnoteDefinition")}function KF(n,e,t){const i=this;return xt(n,l,"gfmFootnoteDefinitionIndent",5);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(o):t(o)}}function WF(n){let t=(n||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:l};return t==null&&(t=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(a,u){let f=-1;for(;++f1?f(w):(a.consume(w),g++,v);if(g<2&&!t)return f(w);const C=a.exit("strikethroughSequenceTemporary"),N=ms(w);return C._open=!N||N===2&&!!S,C._close=!S||S===2&&!!N,u(w)}}}class ZF{constructor(){this.map=[],this.index=new Map}add(e,t,i){JF(this,e,t,i)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}}function JF(n,e,t,i){if(t===0&&i.length===0)return;const l=n.index.get(e);if(l){l[1]+=t,l[2].push(...i);return}const o=[e,t,i];n.map.push(o),n.index.set(e,o)}function eq(n,e){let t=!1;const i=[];for(;e-1;){const{type:pe}=i.events[V][1];if(pe==="lineEnding"||pe==="linePrefix")V--;else break}const _=V>-1?i.events[V][1].type:null,ie=_==="tableHead"||_==="tableRow"?E:f;return ie===E&&i.parser.lazy[i.now().line]?t(F):ie(F)}function f(F){return n.enter("tableHead"),n.enter("tableRow"),d(F)}function d(F){return F===124||(a=!0,o+=1),m(F)}function m(F){return F===null?t(F):Ie(F)?o>1?(o=0,i.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(F),n.exit("lineEnding"),v):t(F):Je(F)?xt(n,m,"whitespace")(F):(o+=1,a&&(a=!1,l+=1),F===124?(n.enter("tableCellDivider"),n.consume(F),n.exit("tableCellDivider"),a=!0,m):(n.enter("data"),g(F)))}function g(F){return F===null||F===124||Lt(F)?(n.exit("data"),m(F)):(n.consume(F),F===92?b:g)}function b(F){return F===92||F===124?(n.consume(F),g):g(F)}function v(F){return i.interrupt=!1,i.parser.lazy[i.now().line]?t(F):(n.enter("tableDelimiterRow"),a=!1,Je(F)?xt(n,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(F):w(F))}function w(F){return F===45||F===58?C(F):F===124?(a=!0,n.enter("tableCellDivider"),n.consume(F),n.exit("tableCellDivider"),S):H(F)}function S(F){return Je(F)?xt(n,C,"whitespace")(F):C(F)}function C(F){return F===58?(o+=1,a=!0,n.enter("tableDelimiterMarker"),n.consume(F),n.exit("tableDelimiterMarker"),N):F===45?(o+=1,N(F)):F===null||Ie(F)?U(F):H(F)}function N(F){return F===45?(n.enter("tableDelimiterFiller"),j(F)):H(F)}function j(F){return F===45?(n.consume(F),j):F===58?(a=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(F),n.exit("tableDelimiterMarker"),M):(n.exit("tableDelimiterFiller"),M(F))}function M(F){return Je(F)?xt(n,U,"whitespace")(F):U(F)}function U(F){return F===124?w(F):F===null||Ie(F)?!a||l!==o?H(F):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(F)):H(F)}function H(F){return t(F)}function E(F){return n.enter("tableRow"),D(F)}function D(F){return F===124?(n.enter("tableCellDivider"),n.consume(F),n.exit("tableCellDivider"),D):F===null||Ie(F)?(n.exit("tableRow"),e(F)):Je(F)?xt(n,D,"whitespace")(F):(n.enter("data"),I(F))}function I(F){return F===null||F===124||Lt(F)?(n.exit("data"),D(F)):(n.consume(F),F===92?ne:I)}function ne(F){return F===92||F===124?(n.consume(F),I):I(F)}}function iq(n,e){let t=-1,i=!0,l=0,o=[0,0,0,0],a=[0,0,0,0],u=!1,f=0,d,m,g;const b=new ZF;for(;++tt[2]+1){const w=t[2]+1,S=t[3]-t[2]-1;n.add(w,S,[])}}n.add(t[3]+1,0,[["exit",g,e]])}return l!==void 0&&(o.end=Object.assign({},ua(e.events,l)),n.add(l,0,[["exit",o,e]]),o=void 0),o}function FC(n,e,t,i,l){const o=[],a=ua(e.events,t);l&&(l.end=Object.assign({},a),o.push(["exit",l,e])),i.end=Object.assign({},a),o.push(["exit",i,e]),n.add(t+1,0,o)}function ua(n,e){const t=n[e],i=t[0]==="enter"?"start":"end";return t[1][i]}const rq={name:"tasklistCheck",tokenize:sq};function lq(){return{text:{91:rq}}}function sq(n,e,t){const i=this;return l;function l(f){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?t(f):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),o)}function o(f){return Lt(f)?(n.enter("taskListCheckValueUnchecked"),n.consume(f),n.exit("taskListCheckValueUnchecked"),a):f===88||f===120?(n.enter("taskListCheckValueChecked"),n.consume(f),n.exit("taskListCheckValueChecked"),a):t(f)}function a(f){return f===93?(n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),u):t(f)}function u(f){return Ie(f)?e(f):Je(f)?n.check({tokenize:oq},e,t)(f):t(f)}}function oq(n,e,t){return xt(n,i,"whitespace");function i(l){return l===null?t(l):e(l)}}function aq(n){return LA([jF(),qF(),WF(n),tq(),lq()])}const cq={};function uq(n){const e=this,t=n||cq,i=e.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(aq(t)),o.push(EF()),a.push(MF(t))}function fq(n){return n.replace(/\\n/g,` -`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}const hq={h1:({children:n})=>y.jsx("h3",{className:"mt-3 mb-1.5 text-base font-bold text-ink first:mt-0",children:n}),h2:({children:n})=>y.jsx("h4",{className:"mt-3 mb-1 text-sm font-semibold text-ink first:mt-0",children:n}),h3:({children:n})=>y.jsx("h5",{className:"mt-2 mb-1 text-xs font-semibold text-ink first:mt-0",children:n}),p:({children:n})=>y.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",children:n}),strong:({children:n})=>y.jsx("strong",{className:"font-semibold text-ink",children:n}),em:({children:n})=>y.jsx("em",{className:"italic text-ink-secondary",children:n}),del:({children:n})=>y.jsx("del",{className:"text-ink-muted line-through",children:n}),a:({children:n,href:e})=>y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-chip-indigo-text underline underline-offset-2 hover:text-ink",children:n}),code:({children:n,className:e})=>y.jsx("code",{className:`break-words rounded bg-elevated px-1 py-0.5 font-mono text-chip-indigo-text whitespace-pre-wrap ${e??""}`,children:n}),pre:({children:n})=>y.jsx("pre",{className:"my-2 overflow-x-auto rounded-lg border border-line bg-elevated p-3 font-mono text-xs text-ink [&_code]:bg-transparent [&_code]:px-0 [&_code]:py-0 [&_code]:text-inherit",children:n}),ul:({children:n})=>y.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",children:n}),ol:({children:n})=>y.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",children:n}),li:({children:n})=>y.jsx("li",{className:"leading-relaxed",children:n}),blockquote:({children:n})=>y.jsx("blockquote",{className:"my-2 border-l-2 border-line-strong pl-3 text-ink-secondary italic",children:n}),table:({children:n})=>y.jsx("div",{className:"my-2 overflow-x-auto",children:y.jsx("table",{className:"w-full border-collapse text-xs",children:n})}),th:({children:n})=>y.jsx("th",{className:"border border-line bg-elevated px-2 py-1 text-left font-semibold",children:n}),td:({children:n})=>y.jsx("td",{className:"border border-line px-2 py-1 align-top",children:n}),hr:()=>y.jsx("hr",{className:"my-3 border-line"}),img:({alt:n,src:e,title:t})=>y.jsx("img",{src:e,alt:n,title:t,loading:"lazy",referrerPolicy:"no-referrer",className:"my-2 max-w-full rounded-lg border border-line"})};function Zh({text:n}){return n?y.jsx(UI,{remarkPlugins:[uq,ZI],components:hq,children:fq(n)}):null}function ME(n){return n==="completed"||n==="aborted"||n==="failed"}function Kc({label:n}){return y.jsx("kbd",{"aria-hidden":"true",className:"ml-1.5 inline-block rounded border border-line/60 bg-elevated/60 px-1 py-px font-mono text-[10px] font-normal leading-none opacity-90",children:n})}function qC(n){!n||ME(n.status)||PM(n.session_id).catch(()=>{})}const dq={running:"running",completed:"done",skipped:"skipped",failed:"failed",pending:"pending"};function Jh({text:n}){const[e,t]=A.useState(!1),i=A.useRef(void 0);A.useEffect(()=>()=>window.clearTimeout(i.current),[]);const l=async()=>{try{await navigator.clipboard.writeText(n),t(!0),window.clearTimeout(i.current),i.current=window.setTimeout(()=>t(!1),1500)}catch{}};return y.jsx("button",{type:"button",onClick:l,"aria-label":e?"Copied":"Copy content",title:e?"Copied!":"Copy content",className:"absolute right-2 top-2 rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:e?y.jsx(Br,{className:"h-3.5 w-3.5"}):y.jsx(hi,{className:"h-3.5 w-3.5"})})}function mq({isOpen:n,onClose:e,directory:t,filename:i,release:l,args:o,onFinished:a}){var be,z;const[u,f]=A.useState(null),[d,m]=A.useState(!1),[g,b]=A.useState(null),[v,w]=A.useState(null),[S,C]=A.useState(!1),[N,j]=A.useState(0),M=A.useRef(null),U=A.useRef(!1),H=A.useRef(null),E=A.useRef(!1);A.useEffect(()=>{if(!n||!t||!i){f(null),b(null),C(!1),w(null),E.current=!1;return}let R=!0;return m(!0),b(null),C(!1),w(null),zM({directory:t,filename:i,release:l,args:o}).then(X=>{R&&(f(X),m(!1),(X.status==="completed"||X.status==="aborted"||X.status==="failed")&&(a==null||a(X.status,X.final_message||"")))}).catch(X=>{R&&((X==null?void 0:X.status)===404&&C(!0),b(X.message||"Failed to start workflow"),m(!1))}),()=>{R=!1}},[n,t,i,l,o,N]);const D=async R=>{if(!(!u||U.current)){U.current=!0,m(!0);try{const X=await BM(u.session_id,R);f(X),(X.status==="completed"||X.status==="aborted"||X.status==="failed")&&(a==null||a(X.status,X.final_message||""))}catch(X){(X==null?void 0:X.status)===404?(C(!0),b(X.message||"Workflow session on the server has expired.")):b(X.message||"Failed to process workflow response")}finally{U.current=!1,m(!1)}}},I=A.useRef(u);I.current=u;const ne=A.useRef(D);ne.current=D;const F=A.useRef(v);F.current=v;const V=A.useRef([]),_=(R,X)=>{var ze,Te;if(R.key!=="ArrowDown"&&R.key!=="ArrowUp"&&R.key!=="Home"&&R.key!=="End")return;R.preventDefault();const he=((ze=I.current)==null?void 0:ze.steps.length)??0;if(he===0)return;const ge=R.key==="ArrowDown"?(X+1)%he:R.key==="ArrowUp"?(X-1+he)%he:R.key==="Home"?0:he-1;w(ge),(Te=V.current[ge])==null||Te.focus()};A.useEffect(()=>()=>qC(I.current),[]);const ie=()=>{E.current||(E.current=!0,qC(I.current),e())},pe=()=>{f(null),b(null),C(!1),w(null),E.current=!1,j(R=>R+1)},ce=gs({isOpen:n,onClose:ie,dialogRef:M,initialFocusRef:H});if(A.useEffect(()=>{if(!n)return;const R=X=>{var Ae,Qt,Ft;if(X.key==="Escape"){X.preventDefault(),ie();return}const he=I.current;if(!he)return;if(ME(he.status)){X.key==="Enter"&&!X.repeat&&!X.ctrlKey&&!X.metaKey&&!X.altKey&&!U.current&&((Ae=X.target)==null?void 0:Ae.tagName)!=="BUTTON"&&((Qt=document.activeElement)==null?void 0:Qt.tagName)!=="BUTTON"&&(X.preventDefault(),ie());return}if(U.current||X.repeat||X.ctrlKey||X.metaKey||X.altKey)return;const ge=X.target;if((ge==null?void 0:ge.tagName)==="INPUT"||(ge==null?void 0:ge.tagName)==="TEXTAREA"||ge!=null&&ge.isContentEditable)return;const ze=F.current,Te=ze===null||ze===he.current_index,He=he.status==="waiting_ask"?"yes":he.status==="waiting_notify"||he.status==="waiting_notice"?"ack":null;if(!Te||He===null)return;if(X.key==="Enter"){const gn=X.target;if((gn==null?void 0:gn.tagName)==="BUTTON"||((Ft=document.activeElement)==null?void 0:Ft.tagName)==="BUTTON")return;X.preventDefault(),ne.current(He);return}if(he.status!=="waiting_ask")return;const ke=X.key.toLowerCase();ke==="y"?(X.preventDefault(),ne.current("yes")):ke==="s"?(X.preventDefault(),ne.current("skip")):ke==="n"&&(X.preventDefault(),ne.current("no"))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n,e]),A.useEffect(()=>{if(!n||!u)return;const R=requestAnimationFrame(()=>{var X;return(X=H.current)==null?void 0:X.focus()});return()=>cancelAnimationFrame(R)},[n,u==null?void 0:u.status]),!n)return null;const Z=v!==null?u==null?void 0:u.steps[v]:u==null?void 0:u.steps[u.current_index],oe=(u==null?void 0:u.status)==="completed"||(u==null?void 0:u.status)==="aborted"||(u==null?void 0:u.status)==="failed",G=!!u&&!oe&&!S&&(((be=u.status)==null?void 0:be.startsWith("waiting"))??!1),W=(((z=u==null?void 0:u.steps[(u==null?void 0:u.current_index)??-1])==null?void 0:z.phase)??"pre")==="post",de=!S&&(v===null||v===(u==null?void 0:u.current_index))&&(Z!=null&&Z.command)&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_notice"||(u==null?void 0:u.status)==="waiting_ask")?y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsxs("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 pr-10 font-mono text-xs text-ink leading-relaxed",children:[y.jsx(Jh,{text:Z.command}),Z.command]})]}):null;return y.jsx("div",{ref:M,role:"dialog","aria-modal":"true","aria-labelledby":"workflow-runner-title",onKeyDown:ce,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-xs",children:y.jsxs("div",{className:"animate-modal-in flex h-[80vh] w-full max-w-5xl flex-col rounded-xl border border-frame-line glass-panel overflow-hidden",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line px-5 py-3.5 bg-surface-strong/30 shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(uO,{className:"h-4 w-4"})}),y.jsxs("div",{children:[y.jsx("h2",{id:"workflow-runner-title",className:"text-sm font-semibold text-ink",children:"Launch Workflow Engine"}),y.jsxs("p",{className:"text-xs text-ink-muted",children:[i," ",u!=null&&u.pattern?`• Pattern: ${u.pattern}`:""]})]})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[u&&!oe&&!S&&y.jsxs("button",{type:"button",disabled:!G||d,onClick:()=>D("bypass"),title:W?"Skip the remaining post-launch steps":"Skip the remaining steps and launch with the OS default app",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-3 py-1.5 text-xs font-medium text-status-warning-text hover:bg-status-warning-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 disabled:cursor-not-allowed disabled:opacity-40",children:[y.jsx(uD,{className:"h-3.5 w-3.5"}),W?"Skip rest":"Launch now"]}),y.jsx("button",{type:"button",onClick:ie,className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(_i,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[y.jsxs("div",{className:"w-72 border-r border-line bg-surface-strong/20 p-4 overflow-y-auto flex flex-col gap-2 shrink-0",children:[y.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-ink-muted px-1 mb-1",children:"Workflow Steps (Click to inspect)"}),u&&u.steps.length>0?y.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:u.steps.map((R,X)=>{const he=u.current_index===X&&!oe,ge=v===X||v===null&&he,ze=dq[R.status];return y.jsx("li",{children:y.jsxs("button",{ref:Te=>{V.current[X]=Te},type:"button",tabIndex:ge?0:-1,"aria-current":ge?"step":void 0,onKeyDown:Te=>_(Te,X),onClick:()=>w(X),className:`flex items-start text-left gap-2.5 rounded-lg border px-3 py-2.5 transition-colors cursor-pointer w-full ${ge?"border-chip-indigo-border bg-chip-indigo-bg shadow-xs ring-1 ring-chip-indigo-border/40":"border-line/60 bg-surface/60 hover:bg-elevated/80"}`,children:[y.jsxs("div",{className:"mt-0.5 shrink-0",children:[R.status==="running"&&y.jsx(fl,{className:"h-4 w-4 animate-spin text-chip-indigo-text"}),R.status==="completed"&&y.jsx(Gk,{className:"h-4 w-4 text-status-success-text"}),R.status==="skipped"&&y.jsx(M4,{className:"h-4 w-4 text-status-warning-text"}),R.status==="failed"&&y.jsx(tu,{className:"h-4 w-4 text-status-danger-text"}),R.status==="pending"&&y.jsx("div",{className:"h-4 w-4 rounded-full border border-line-strong flex items-center justify-center text-[10px] text-ink-faint font-mono",children:R.index})]}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"font-mono text-[11px] font-bold uppercase text-chip-indigo-text",children:R.action}),y.jsxs("span",{className:"text-[10px] font-mono text-ink-faint",children:["#",R.index," · ",ze]})]}),y.jsx("p",{className:"truncate font-mono text-[11px] text-ink-secondary mt-0.5",title:R.command,children:R.message?R.message.split(` -`)[0]:R.command}),R.note&&y.jsx("p",{className:"mt-1 text-[10px] text-ink-faint italic",children:R.note})]})]})},R.index)})}):y.jsx("div",{className:"p-4 text-center text-xs text-ink-faint",children:g||S?"Session unavailable — see the error panel.":"Loading steps..."})]}),y.jsxs("div",{className:"flex-1 flex flex-col bg-app",children:[y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:y.jsx("div",{className:"space-y-6",children:y.jsxs("div",{className:"rounded-xl border border-line bg-surface p-5 shadow-xs space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"rounded bg-chip-indigo-bg px-2 py-0.5 font-mono text-xs font-semibold uppercase text-chip-indigo-text",children:(Z==null?void 0:Z.action)||(u==null?void 0:u.status)}),y.jsx("span",{className:"text-xs text-ink-muted",children:Z?`Step ${Z.index} of ${u==null?void 0:u.steps.length}`:"Status"}),v!==null&&v!==(u==null?void 0:u.current_index)&&y.jsx("button",{type:"button",onClick:()=>w(null),className:"text-[11px] text-chip-indigo-text hover:underline ml-2",children:"(Return to active step)"})]}),d&&y.jsx(fl,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})]}),y.jsxs("div",{className:"space-y-3 text-xs text-ink font-sans leading-relaxed",children:[(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notify"&&u.notify_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notification Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Zh,{text:u.notify_message})}),de]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notice"&&u.notice_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notice:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Zh,{text:u.notice_message})}),de,y.jsx("p",{className:"text-[11px] text-ink-faint",children:"The command will run when you continue."})]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_ask"&&u.ask_prompt&&y.jsxs("div",{className:"space-y-2",children:[u.ask_message&&y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Zh,{text:u.ask_message})}),y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-status-warning-text",children:"Confirmation Prompt:"}),y.jsx("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-4 text-sm font-medium text-ink",children:u.ask_prompt}),de]}),oe&&v===null&&y.jsxs("div",{className:`rounded-xl border p-8 text-center space-y-4 ${(u==null?void 0:u.status)==="completed"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:[y.jsx("div",{className:"inline-flex h-12 w-12 items-center justify-center rounded-full bg-surface/50 mx-auto",children:(u==null?void 0:u.status)==="completed"?y.jsx(Gk,{className:"h-6 w-6 text-status-success-text"}):y.jsx(tu,{className:"h-6 w-6 text-status-danger-text"})}),y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-base font-bold",children:(u==null?void 0:u.status)==="completed"?"Workflow Finished":"Workflow Terminated"}),y.jsx("p",{className:"text-xs text-ink-secondary max-w-md mx-auto",children:(u==null?void 0:u.final_message)||"The launch sequence has ended."})]}),y.jsx("div",{className:"pt-2",children:y.jsx("button",{type:"button",onClick:e,className:"btn btn-primary px-8 py-2.5 font-bold shadow-lg",children:"Close Engine Runner"})})]}),oe&&v===null&&(u==null?void 0:u.last_output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Jh,{text:u.last_output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:u.last_output})]})]}),!S&&!(oe&&v===null)&&!((v===null||v===(u==null?void 0:u.current_index))&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_ask"||(u==null?void 0:u.status)==="waiting_notice"))&&y.jsxs("div",{className:"space-y-4",children:[(Z==null?void 0:Z.message)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-xs text-ink",children:y.jsx(Zh,{text:Z.message})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsx("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink leading-relaxed",children:Z!=null&&Z.command?y.jsxs(y.Fragment,{children:[y.jsx(Jh,{text:Z.command}),y.jsx("span",{className:"block pr-8",children:Z.command})]}):"Waiting..."})]}),(Z==null?void 0:Z.output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Jh,{text:Z.output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:Z.output})]})]}),(Z==null?void 0:Z.ask)&&y.jsxs("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-3 text-xs text-status-warning-text",children:[y.jsx("span",{className:"font-semibold",children:"Workflow Guard:"})," ",Z.ask]}),(Z==null?void 0:Z.note)&&y.jsxs("div",{className:"rounded-lg border border-line bg-surface-strong p-3 text-xs text-ink-muted italic",children:[y.jsx("span",{className:"font-semibold text-ink-secondary not-italic uppercase text-[10px]",children:"Log:"})," ",Z.note]})]})]})]})})}),(g||S)&&y.jsx("div",{className:"shrink-0 px-6 pt-3",children:y.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-status-danger-border bg-status-danger-bg p-3 text-xs text-status-danger-text",children:[y.jsx(tu,{className:"mt-0.5 h-4 w-4 shrink-0"}),y.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[y.jsx("p",{children:S?"Workflow session on the server has expired or ended.":g}),S?y.jsxs("div",{className:"space-y-2",children:[g&&y.jsxs("details",{className:"text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer select-none text-[11px] underline",children:"Raw error (for bug reports)"}),y.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-words font-mono text-[11px]",children:g})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:pe,className:"btn btn-primary px-4 py-1.5 text-xs font-semibold",children:"Restart workflow"}),y.jsx("button",{type:"button",onClick:ie,className:"btn rounded-md border-line bg-surface px-4 py-1.5 text-xs",children:"Close"})]})]}):null]})]})}),y.jsxs("div",{className:"shrink-0 px-6 pt-4 pb-4 border-t border-line flex items-center justify-between bg-app",children:[y.jsx("div",{className:"text-xs text-ink-muted","aria-live":"polite",children:S?"Session unavailable — restart or close above.":(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)?"Action required to proceed:":(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)?"Acknowledge message to proceed:":(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)?"Continue to run the command:":oe?"Session terminated.":"Step in progress..."}),y.jsxs("div",{className:"flex items-center gap-2",children:[!S&&(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:H,disabled:d,onClick:()=>D("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Run Command",y.jsx(Kc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:H,disabled:d,onClick:()=>D("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Continue Workflow",y.jsx(Kc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{type:"button",disabled:d,onClick:()=>D("no"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-danger-text hover:bg-status-danger-bg",children:["Abort Launch",y.jsx(Kc,{label:"N"})]}),y.jsxs("button",{type:"button",disabled:d,onClick:()=>D("skip"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-warning-text hover:bg-status-warning-bg",children:["Skip Step",y.jsx(Kc,{label:"S"})]}),y.jsxs("button",{type:"button",ref:H,disabled:d,onClick:()=>D("yes"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Execute Step",y.jsx(Kc,{label:"Y"})]})]}),oe&&y.jsx("button",{type:"button",ref:H,onClick:e,className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:"Close Runner"})]})]})]})]})]})})}function VC({url:n,label:e,className:t="",onCopied:i,onCopyError:l}){const o=async()=>{try{await navigator.clipboard.writeText(n),i==null||i(n)}catch{l==null||l(n)}};return y.jsxs("span",{className:`flex items-center justify-between gap-2 ${t}`.trim(),children:[y.jsx("code",{className:"truncate font-mono text-[11px] text-ink",children:n}),y.jsx("button",{type:"button",onClick:o,"aria-label":e??`Copy ${n}`,title:e??"Copy",className:"focus-ring shrink-0 rounded p-1 text-ink-faint transition-colors hover:bg-elevated hover:text-ink",children:y.jsx(hi,{className:"h-3.5 w-3.5"})})]})}const pq=";",QC="=";function gq(n){const e=n.trim().toLowerCase();return e==="extension"||e==="file_ext"||e==="filetype"?"ext":e==="directory"||e==="path"||e==="folder"?"dir":e==="recurse"||e==="recursive_search"?"recursive":e==="filter_text"||e==="query"||e==="search"?"filter":e}function XC(n){const e=n.trim();if(!e.includes(QC))return{values:{filter:e},isPlainFilter:!0};const t={};for(const i of e.split(pq)){const l=i.trim();if(!l)continue;const o=l.indexOf(QC);if(o===-1)continue;const a=gq(l.slice(0,o)),u=l.slice(o+1).trim();switch(a){case"filter":t.filter=u;break;case"ext":t.ext=u;break;case"recursive":t.recursive=$C(u,!0);break;case"dir":t.dir=u;break;case"scan":t.scan=$C(u,!1);break}}return{values:t,isPlainFilter:!1}}function $C(n,e){const t=n.toLowerCase();return["0","false","no","off"].includes(t)?!1:["1","true","yes","on"].includes(t)?!0:e}function Wc(n){return/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function xq(n,e,t,i){var f,d;const l=[],a=[["Exported",new Date().toISOString()],["App Version",(t==null?void 0:t.release)??"unknown"],["Config File",(t==null?void 0:t.config_path)??"none"],["Config Exists",String((t==null?void 0:t.config_exists)??!1)],["Directory",(t==null?void 0:t.active_directory)??""],["Extensions",((f=t==null?void 0:t.extensions)==null?void 0:f.join(" | "))??""],["Filter Text",i??((d=t==null?void 0:t.filters)==null?void 0:d[0])??""],["Recursive",String((t==null?void 0:t.recursive_search)??!0)],["Title",(t==null?void 0:t.title)??""],["Release",(t==null?void 0:t.release)??""]];for(const[m,g]of a)l.push(`${Wc(m)},${Wc(g)}`);l.push("");const u=e.length>0?e:["filename","path","rel_path"];l.push(u.map(Wc).join(","));for(const m of n){const g=u.map(b=>b in m?Wc(String(m[b]??"")):Wc(m.column_values[b]??""));l.push(g.join(","))}return l.join(`\r -`)}const yq=120,K0=800,bq=4e3,YC=20;function vq(){const[n,e]=A.useState("dark"),[t,i]=A.useState(null),[l,o]=A.useState(null),[a,u]=A.useState(""),[f,d]=A.useState(""),[m,g]=A.useState(""),[b,v]=A.useState(!0),[w,S]=A.useState([]),[C,N]=A.useState(0),[j,M]=A.useState(!1),[U,H]=A.useState(!1),[E,D]=A.useState(null),[I,ne]=A.useState(!1),[F,V]=A.useState(null),[_,ie]=A.useState(0),[pe,ce]=A.useState(!1),Z=A.useRef(0),oe=A.useRef(null),G=A.useRef(null),[W,T]=A.useState(""),[de,be]=A.useState(null),[z,R]=A.useState(!1),[X,he]=A.useState(null),[ge,ze]=A.useState(!1),[Te,He]=A.useState("en"),[ke,Ae]=A.useState(!1),[Qt,Ft]=A.useState(!1),[gn,Ht]=A.useState(!1),[Ot,st]=A.useState(0),[tn,Pn]=A.useState(!1),[qt,Kt]=A.useState(null),[Oe,qe]=A.useState(null),[$e,mt]=A.useState(!1),[te,fe]=A.useState(!1),[Le,Be]=A.useState(null),[bt,ue]=A.useState(null),[ye,Re]=A.useState(!1),ct=A.useRef(""),[vt,Sn]=A.useState(!1),[Cn,Et]=A.useState(void 0),[Wt,Yn]=A.useState(null),[Hn,ys]=A.useState(""),[Fu,bs]=A.useState(!1),[vs,Fa]=A.useState(null),[Ki,Gn]=A.useState(0),vi=A.useRef(null),fn=A.useRef(null),ve=(B,P="info")=>{B&&(he({message:B,kind:P}),fn.current&&clearTimeout(fn.current),fn.current=setTimeout(()=>he(null),P==="error"?1e4:3500))},km=()=>{fn.current&&clearTimeout(fn.current),he(null)},Sm=B=>{Be(B)},In=()=>{var P;G.current&&(clearTimeout(G.current),G.current=null),(P=oe.current)==null||P.abort(),oe.current=new AbortController;const B=++Z.current;return ce(!0),H(!1),B},Mt=B=>B===Z.current,On=B=>{Mt(B)&&ce(!1)},nn=A.useRef(null);A.useEffect(()=>{if(!m.trim()){T("");return}const B=window.setTimeout(()=>T(m),yq);return()=>window.clearTimeout(B)},[m]);const Dt=A.useMemo(()=>W.trim()===""?w:w.filter(B=>t8(B.rel_path,W)),[w,W]),ws=m.trim()&&w.length{const B=nn.current,P=B?Dt.findIndex(re=>re.path===B):-1;if(P>=0){ie(re=>P!==re?P:re);return}ie(re=>Math.min(re,Math.max(0,Dt.length-1)))},[Dt]);const qa=async(B,P=F)=>{var De;const re=await Zg({offset:0,limit:R0,sort_by:P==null?void 0:P.column,sort_dir:P==null?void 0:P.direction,signal:(De=oe.current)==null?void 0:De.signal});return Mt(B)?(S(re.items),N(re.count),M(!0),!0):!1},Li=async(B,P)=>{var De;if(!Mt(B))return!1;const re=await Fk(P,(De=oe.current)==null?void 0:De.signal);return re.warning&&Mt(B)&&ve(re.warning,"error"),!Mt(B)||!await qa(B)?!1:(nn.current=null,ie(0),!0)},qu=async()=>{if(U||w.length>=C)return;const B=Z.current;H(!0);try{const P=await Zg({offset:w.length,limit:R0,sort_by:F==null?void 0:F.column,sort_dir:F==null?void 0:F.direction});if(!Mt(B))return;const re=new Set(w.map(De=>De.path||De.filename));S(De=>[...De,...P.items.filter(ht=>!re.has(ht.path||ht.filename))]),N(P.count)}catch{ve("Couldn't load more results — scroll to try again.","error")}finally{Mt(B)&&H(!1)}},go=async()=>{if(ge)return;ze(!0),ve("Reloading configuration...");const B=In();try{const P=await ed();i(P);const re=await OM();o(re),e($k(re.theme));const De=re.active_directory||a,ht=re.extensions[0]??"",et=re.filters[0]??"";De&&u(De),d(ht),g(et),v(re.recursive_search),re.reloaded===!1?ve(`Config file not found: ${re.config_path||"(unknown path)"} — kept current configuration.`,"error"):ve("Configuration reloaded."),De&&await Li(B,{directory:De,extension:ht,filter_text:et,recursive:re.recursive_search})}catch(P){ve(`Failed to reload configuration: ${P.message}`,"error")}finally{ze(!1),On(B)}},mr=async B=>{const P=In();o(B),e($k(B.theme));const re=B.active_directory||a||(B.directories[0]??""),De=B.extensions[0]??"",ht=B.filters[0]??"";if(re&&u(re),d(De),g(ht),v(B.recursive_search),B.session_trial||ve(B.config_exists?`Loaded config: ${B.config_path}`:"Starter configuration created."),re)try{await Li(P,{directory:re,extension:De,filter_text:ht,recursive:B.recursive_search})}catch(et){ve(`Scan failed after config load: ${et.message}`,"error")}finally{On(P)}else On(P)},[Cm,Vu]=A.useState(!1),xo=A.useRef(td()),ks=B=>{xo.current=B,Vu(B.overlayVisible)},Ss=A.useRef(()=>{}),Va=async B=>{try{const P=await B.text(),re=await KC(B.name,P);await mr(re),ve(`Session config applied: ${B.name}`)}catch(P){ve(P.message||"Failed to apply dropped configuration","error")}};Ss.current=B=>{Va(B)};const yo=A.useRef(0),Qa=A.useRef(async()=>{});A.useEffect(()=>{Qa.current=async()=>{const B=await Bk();await mr(B)}}),A.useEffect(()=>{const B=async()=>{let re=[];try{re=(await bM(yo.current)).events}catch{return}for(const De of re){if(yo.current=Math.max(yo.current,De.id),De.config_applied)try{await Qa.current()}catch{}ve(De.message)}},P=setInterval(()=>void B(),bq);return()=>clearInterval(P)},[]),A.useEffect(()=>{const B=et=>{var Nn;return Array.from(((Nn=et.dataTransfer)==null?void 0:Nn.types)??[]).includes("Files")},P=et=>{ks(Xk(xo.current,"enter",B(et)))},re=et=>{B(et)&&et.preventDefault()},De=et=>{ks(Xk(xo.current,"leave",B(et)))},ht=et=>{var ut;et.preventDefault(),ks(td());const Nn=Array.from(((ut=et.dataTransfer)==null?void 0:ut.files)??[]),We=UM(Nn);if(!We){Nn.length>0&&ve("Not a ProFiles configuration file.","error");return}Ss.current(We)};return window.addEventListener("dragenter",P),window.addEventListener("dragover",re),window.addEventListener("dragleave",De),window.addEventListener("drop",ht),()=>{window.removeEventListener("dragenter",P),window.removeEventListener("dragover",re),window.removeEventListener("dragleave",De),window.removeEventListener("drop",ht)}},[]);const Wi=()=>{Ae(!0)},hn=async B=>{const P=In();Ae(!1),u(B),ve(`Directory selected: ${B}`);let re;try{re=await Pk(B),o(re)}catch(et){console.error("select-directory failed:",et)}if(!Mt(P))return;const De=re!=null&&re.extensions.includes(f)?f:(re==null?void 0:re.extensions[0])??f,ht=re!=null&&re.filters.includes(m)?m:(re==null?void 0:re.filters[0])??m;d(De),g(ht);try{await Li(P,{directory:B,extension:De,filter_text:ht,recursive:b})}catch(et){Mt(P)&&ve(`Scan failed: ${et.message}`,"error")}finally{On(P)}},Un=async(B,P)=>{if(!Mt(P))return;const re=B.theme==="auto"?"dark":B.theme==="light"?"light":"dark";e(re);try{localStorage.setItem("profiles-theme",re)}catch{}o(B);const De=B.active_directory||(B.directories.length>0?B.directories[0]:""),ht=B.extensions.length>0?B.extensions[0]:"",et=B.filters.length>0?B.filters[0]:"";if(De&&u(De),ht&&d(ht),B.recursive_search!==void 0&&v(B.recursive_search),et&&g(et),B.config_exists||Ft(!0),De)try{await Li(P,{directory:De,extension:ht,filter_text:et,recursive:B.recursive_search})}catch(Nn){Mt(P)&&ve(`Initial scan failed: ${Nn.message}`,"error")}},qr=async()=>{var P;(P=oe.current)==null||P.abort(),oe.current=new AbortController;const B=++Z.current;D(null),ne(!0);try{const re=await ed();i(re);const De=await Bk();await Un(De,B)}catch(re){D((re==null?void 0:re.message)||"Couldn't fetch system info or configuration.")}finally{ne(!1)}};A.useEffect(()=>{qr()},[]),A.useEffect(()=>()=>{var B;G.current&&(clearTimeout(G.current),G.current=null),(B=oe.current)==null||B.abort()},[]);const Cs=async B=>{const P=In();u(B);try{const re=await Pk(B);if(!Mt(P))return!1;o(re);const De=re.extensions.includes(f)?f:re.extensions[0]??"",ht=re.filters.includes(m)?m:re.filters[0]??"";return d(De),g(ht),await Li(P,{directory:B,extension:De,filter_text:ht,recursive:b}),!0}catch(re){return Mt(P)&&ve(`Directory change failed: ${re.message}`,"error"),!1}finally{On(P)}},yl=async()=>{if(!a)return;const B=In();try{await Li(B,{directory:a,extension:f,filter_text:m,recursive:b})}catch(P){Mt(B)&&ve(`Scan failed: ${(P==null?void 0:P.message)??P}`,"error")}finally{On(B)}},Vr=A.useRef(yl);A.useEffect(()=>{Vr.current=yl});const Qu=B=>{g(B),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{G.current=null,Vr.current()},K0)},Os=B=>{v(B),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{G.current=null,Vr.current()},K0)},bo=B=>{d(B),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{G.current=null,Vr.current()},K0)},vo=async()=>{if(g(""),!a)return;const B=In();try{await Li(B,{directory:a,extension:f,filter_text:"",recursive:b})}catch(P){Mt(B)&&ve(`Scan failed: ${(P==null?void 0:P.message)??P}`,"error")}finally{On(B)}},Qr=async()=>{if(v(!1),!a)return;const B=In();try{await Li(B,{directory:a,extension:f,filter_text:m,recursive:!1})}catch(P){Mt(B)&&ve(`Scan failed: ${P.message}`,"error")}finally{On(B)}},wi=async(B,P)=>{if(B.has_hook){ue({file:B,args:P});return}try{await MM({directory:a,filename:B.rel_path,release:l==null?void 0:l.release,args:P}),ve(`Launched ${B.filename}`)}catch(re){ve(`Launch error: ${re.message}`,"error")}},bl=()=>{Dt.length>0&&Dt[_]&&wi(Dt[_])},vl=B=>{var P;nn.current=((P=Dt[B])==null?void 0:P.path)??null,ie(B)},rn=async(B,P)=>{wi(B,P)},Xu=async B=>{try{await ZC(B.path),ve("Revealed in file manager.")}catch(P){ve(`Error: ${P.message}`,"error")}},$u=async B=>{try{await W0(B.path),ve("Folder opened in file manager.")}catch(P){ve(`Error: ${P.message}`,"error")}},Yu=async B=>{try{const P=await qk(B.path);ve(P.message||"Terminal opened.")}catch(P){ve(`Error: ${P.message}`,"error")}},Xr=async B=>{await Cs(B)&&ve(`Scanned directory: ${B}`)},wl=B=>{g(B);const P=In();Li(P,{directory:a,extension:f,filter_text:B,recursive:b}).catch(re=>{Mt(P)&&ve(`Scan failed: ${(re==null?void 0:re.message)??re}`,"error")}).finally(()=>On(P))},Om=B=>{d(B);const P=In();Li(P,{directory:a,extension:B,filter_text:m,recursive:b}).catch(re=>{Mt(P)&&ve(`Scan failed: ${(re==null?void 0:re.message)??re}`,"error")}).finally(()=>On(P))},Gu=async(B,P)=>{const re=P?B.path.replace(/\\/g,"/"):B.path;try{await navigator.clipboard.writeText(re),ve("Path copied to clipboard.")}catch(De){ve(`Copy failed: ${(De==null?void 0:De.message)??De}`,"error")}},Ku=async(B,P)=>{let re=B.filename;if(P){const De=re.lastIndexOf(".");De!==-1&&(re=re.slice(0,De))}try{await navigator.clipboard.writeText(re),ve("Filename copied to clipboard.")}catch(De){ve(`Copy failed: ${(De==null?void 0:De.message)??De}`,"error")}},Nm=async(B,P)=>{try{ve(`Computing ${P.toUpperCase()}...`);const re=await Vk(B.path,P);await navigator.clipboard.writeText(re.hash),ve(`${P.toUpperCase()} hash copied: ${re.hash.slice(0,12)}...`)}catch(re){ve(`Hash computation failed: ${re.message}`,"error")}},ft=async B=>{try{const P=new URL("file:///").href+B.path.replace(/\\/g,"/");await navigator.clipboard.writeText(P),ve("File URI copied to clipboard.")}catch(P){ve(`URI copy failed: ${P.message}`,"error")}},Xa=async(B,P,re)=>{ve(`Computing ${P.toUpperCase()}...`);try{const ht=(await Vk(B.path,P)).hash.toLowerCase()===re.trim().toLowerCase();ve(ht?`✅ ${P.toUpperCase()} matches!`:`❌ ${P.toUpperCase()} mismatch`)}catch(De){ve(`Verification failed: ${De.message}`,"error")}},wo=async(B,P)=>{let re;try{re=await navigator.clipboard.readText()}catch{ys(""),Yn({file:B,algorithm:P});return}if(!re.trim()){ve("Clipboard is empty — copy a hash first, then try again.");return}await Xa(B,P,re)},Ns=B=>{qe(B),Pn(!0)},Zi=B=>{Kt(B)},Kn=async()=>{const B=qt;if(Kt(null),!!B)try{if(ve("Deleting file..."),!(await fetch("/api/actions/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:B.path})})).ok)throw new Error("Failed to delete file");ve("File deleted successfully."),yl()}catch(P){ve(`Delete failed: ${P.message}`,"error")}},Wu=B=>{Et(B.path),Sn(!0)},Zu=async()=>{if(a)try{await W0(a),ve("Directory opened in file manager.")}catch(B){ve(`Error: ${B.message}`,"error")}},$a=async B=>{if(B)try{await qk(B),ve("Terminal opened in directory.")}catch(P){ve(`Error: ${P.message}`,"error")}},Ya=async()=>{try{await Cs("~"),ve("Directory set to home folder.")}catch(B){ve(`Error: ${B.message}`,"error")}},Tm=async()=>{if(a)try{const B=await WC(a);B.parent_path?(await Cs(B.parent_path),ve("Moved to parent directory.")):ve("Already at root directory.")}catch(B){ve(`Error: ${B.message}`,"error")}},li=async()=>{if(w.length===0){ve("No files to export.");return}try{const B=xq(w,(l==null?void 0:l.column_names)||[],l??void 0,m),P=`profiles-export-${new Date().toISOString().slice(0,19).replace(/[:.]/g,"-")}.csv`,re=await _M(B,P);ve(`Exported ${w.length} loaded row${w.length===1?"":"s"}${m?` matching "${m}"`:""} — ${re.message}`)}catch(B){ve(`Export failed: ${B.message}`,"error")}},Ga=async B=>{var We,ut;bs(!1),ve("Barcode detected!");const re=XC(B).values,De=re.dir!==void 0?re.dir:a,ht=re.ext!==void 0?re.ext:f,et=re.filter!==void 0?re.filter:m,Nn=re.recursive!==void 0?re.recursive:b;if(re.dir!==void 0&&u(re.dir),re.ext!==void 0&&d(re.ext),re.filter!==void 0&&g(re.filter),re.recursive!==void 0&&v(re.recursive),De){const tt=In();try{const Sl=await Fk({directory:De,extension:ht,filter_text:et,recursive:Nn},(We=oe.current)==null?void 0:We.signal);Sl.warning&&Mt(tt)&&ve(Sl.warning,"error");const $r=await Zg({offset:0,limit:R0,sort_by:F==null?void 0:F.column,sort_dir:F==null?void 0:F.direction,signal:(ut=oe.current)==null?void 0:ut.signal});if(!Mt(tt))return;S($r.items),N($r.count),M(!0),nn.current=null,ie(0),$r.count===1&&$r.items.length===1&&Fa($r.items[0])}catch(Sl){Mt(tt)&&ve(`Scan error: ${Sl.message}`,"error")}finally{On(tt)}}},Ju=()=>{Re(B=>{const P=!B;return P?(ct.current="",ve("Barcode mode ON — scan a barcode now.")):(ct.current="",ve("Barcode mode OFF.")),P})},Ka=B=>{B.filter!==void 0&&g(B.filter),B.ext!==void 0&&d(B.ext),B.recursive!==void 0&&v(B.recursive),B.dir!==void 0&&u(B.dir),(B.scan===!0||B.filter!==void 0||B.ext!==void 0||B.recursive!==void 0||B.dir!==void 0)&&(Re(!1),ct.current="",setTimeout(()=>{Vr.current()},50))};A.useEffect(()=>{if(!ye)return;const B=P=>{const re=P.target;if(!(re instanceof HTMLElement&&(re.isContentEditable||re instanceof HTMLInputElement||re instanceof HTMLTextAreaElement||re instanceof HTMLSelectElement)))if(P.key==="Enter"){const ht=ct.current;if(!ht){ct.current="";return}P.preventDefault(),ct.current="";const et=XC(ht);if(et.isPlainFilter)ve(`Barcode filter: ${et.values.filter}`),g(et.values.filter||""),Re(!1),setTimeout(()=>void Vr.current(),50);else{const Nn=et.values,We=Object.entries(Nn).map(([ut,tt])=>`${ut}=${tt}`).join(", ");ve(`Barcode applied: ${We}`),Ka(Nn)}}else P.key==="Escape"?(Re(!1),ct.current="",ve("Barcode mode cancelled.")):P.key.length===1&&!P.ctrlKey&&!P.metaKey&&!P.altKey&&(ct.current+=P.key)};return document.addEventListener("keydown",B,!0),()=>document.removeEventListener("keydown",B,!0)},[ye]),A.useEffect(()=>(Ki>0&&(vi.current=setInterval(()=>{Vr.current()},Ki*1e3)),()=>{vi.current&&(clearInterval(vi.current),vi.current=null)}),[Ki]);const kl=B=>{Gn(B),B>0?ve(`Auto-rescan every ${B}s.`):ve("Auto-rescan disabled.")},Wa=!!(de||z||ke||Qt||tn||$e||te||vt||Fu||vs||bt||qt);return A.useEffect(()=>{const B=P=>{var De,ht,et,Nn;if(P.key==="Escape"){be(null),R(!1),mt(!1),fe(!1),ks(td());return}if(Wa)return;if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="l"){P.preventDefault(),(De=document.querySelector("[data-testid='file-list']"))==null||De.focus();return}const re=P.target;if(!(re instanceof HTMLElement&&re.closest("button, a, [role='menuitem'], [role='option'], [role='columnheader'], [role='separator']"))){if(re instanceof HTMLInputElement||re instanceof HTMLSelectElement){P.key==="Enter"&&yl();return}if(P.key==="ContextMenu"||P.shiftKey&&P.key==="F10"){const We=Dt[_];if(!We)return;P.preventDefault();const ut=document.querySelector(`[data-row-index="${_}"]`),tt=ut==null?void 0:ut.getBoundingClientRect();be({x:tt?tt.left+24:24,y:tt?tt.top+tt.height/2:24,file:We});return}if(P.key==="F5"){P.preventDefault(),yl();return}if(P.ctrlKey&&P.key.toLowerCase()==="r"){P.preventDefault(),go();return}if(P.ctrlKey&&P.key.toLowerCase()==="d"){P.preventDefault(),(ht=document.querySelector("#directory-combobox"))==null||ht.focus();return}if(P.ctrlKey&&P.key.toLowerCase()==="e"){P.preventDefault(),(et=document.querySelector("#extension-combobox"))==null||et.focus();return}if(P.ctrlKey&&P.key.toLowerCase()==="f"){P.preventDefault(),(Nn=document.querySelector("#filter-combobox"))==null||Nn.focus();return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="l"){P.preventDefault(),mt(We=>!We);return}if(P.ctrlKey&&P.key===","){P.preventDefault(),Ht(!0);return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="t"){P.preventDefault(),e(We=>We==="dark"?"light":"dark");return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="b"){P.preventDefault(),Re(We=>!We);return}if(P.ctrlKey&&P.shiftKey&&P.key.toLowerCase()==="b"){P.preventDefault(),bs(We=>!We);return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="t"){P.preventDefault(),fe(!0);return}if(P.ctrlKey&&!P.shiftKey&&P.key.toLowerCase()==="h"){P.preventDefault(),Ya();return}if(P.key==="?"||P.ctrlKey&&P.key==="/"){P.preventDefault(),R(We=>!We);return}if(P.key.toLowerCase()==="p"&&!P.ctrlKey&&!P.shiftKey&&!P.altKey){const We=Dt[_];We&&(P.preventDefault(),Ns(We));return}P.key==="ArrowDown"?(P.preventDefault(),ie(We=>{var tt;const ut=Math.min(We+1,Math.max(0,Dt.length-1));return nn.current=((tt=Dt[ut])==null?void 0:tt.path)??null,ut})):P.key==="ArrowUp"?(P.preventDefault(),ie(We=>{var tt;const ut=Math.max(We-1,0);return nn.current=((tt=Dt[ut])==null?void 0:tt.path)??null,ut})):P.key==="Home"?(P.preventDefault(),ie(We=>{var ut;return nn.current=((ut=Dt[0])==null?void 0:ut.path)??null,We===0?We:0})):P.key==="End"?(P.preventDefault(),ie(We=>{var tt;const ut=Math.max(0,Dt.length-1);return nn.current=((tt=Dt[ut])==null?void 0:tt.path)??null,We===ut?We:ut})):P.key==="PageUp"?(P.preventDefault(),ie(We=>{var tt;const ut=Math.max(We-YC,0);return nn.current=((tt=Dt[ut])==null?void 0:tt.path)??null,ut})):P.key==="PageDown"?(P.preventDefault(),ie(We=>{var tt;const ut=Math.min(We+YC,Math.max(0,Dt.length-1));return nn.current=((tt=Dt[ut])==null?void 0:tt.path)??null,ut})):P.key==="Enter"&&(P.preventDefault(),bl())}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[Wa,Dt,_,a,f,m,b,ye]),A.useEffect(()=>{document.documentElement.setAttribute("data-theme",n);try{localStorage.setItem("profiles-theme",n)}catch{}},[n]),y.jsxs("div",{className:"flex h-dvh flex-col bg-elevated/30 p-1 font-sans text-ink transition-colors duration-200 sm:p-1.5",children:[y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-frame-line bg-app shadow-[0_2px_6px_rgb(0_0_0/0.35)] transition-colors duration-200 sm:rounded-xl",children:[y.jsx(Y9,{title:(l==null?void 0:l.title)||"",release:(l==null?void 0:l.release)||"",directories:(l==null?void 0:l.directories)||[],activeDirectory:a,onDirectoryChange:Cs,onBrowseDirectory:Wi,onGoToParentDirectory:Tm,onGoToHomeDirectory:Ya,onOpenActiveDirectory:Zu,onOpenTerminal:$a}),y.jsx(i8,{extensions:(l==null?void 0:l.extensions)||[],activeExtension:f,onExtensionChange:bo,filterOptions:(l==null?void 0:l.filters)||[],filterText:m,onFilterTextChange:Qu,recursive:b,onRecursiveChange:Os,onScan:yl,scanning:pe,barcodeMode:ye,onBarcodeToggle:Ju,onCameraBarcodeClick:()=>bs(!0),autoRescanActive:Ki>0,onTimerClick:()=>fe(!0)}),E?y.jsx(G9,{message:E,onRetry:()=>void qr(),retrying:I}):y.jsx(X9,{files:Dt,totalCount:C,rawLoadedCount:w.length,onLoadMore:qu,loadingMore:U,scanning:pe,hasScanned:j,activeDirectory:a,recursive:b,onDisableRecursive:Qr,onOpenDirectory:Zu,onLoadConfig:()=>Ft(!0),filterText:m,onClearFilter:vo,columnHeaders:(l==null?void 0:l.column_headers)||[],columnNames:(l==null?void 0:l.column_names)||[],selectedIndex:_,onSelectIndex:vl,prefilterNote:ws,onLaunch:wi,onContextMenu:(B,P,re)=>{B.preventDefault(),nn.current=P.path,ie(re),be({x:B.clientX,y:B.clientY,file:P})},rowColors:(l==null?void 0:l.row_colors)||[],sort:F,onSortChange:B=>{V(B),nn.current=null,ie(0);const P=In();qa(P,B).catch(re=>{Mt(P)&&ve(`Sort failed: ${re.message}`,"error")}).finally(()=>On(P))}}),y.jsx(_D,{onExecute:bl,scanning:pe,scanningDirectory:a,hasSelection:Dt.length>0,fileCount:Dt.length,totalCount:C,toastMessage:X,onToastDismiss:km}),y.jsx(C8,{systemInfo:t,fileCount:C,theme:n,onToggleTheme:()=>e(B=>B==="dark"?"light":"dark"),onOpenLog:()=>mt(!0),onOpenConfig:()=>Ht(!0),onShowShortcuts:()=>R(!0),onReloadConfig:go,onExport:li,exportDisabled:w.length===0||pe,language:Te,onLanguageChange:He,lanEnabled:(t==null?void 0:t.lan_enabled)??null,onToggleLan:Sm})]}),y.jsx(U9,{open:gn,onClose:()=>Ht(!1),onApplied:mr,onLoadConfig:()=>Ft(!0),reloadKey:Ot}),y.jsx(c8,{isOpen:Qt,activeConfigPath:l==null?void 0:l.config_path,configExists:l==null?void 0:l.config_exists,onClose:()=>Ft(!1),onLoaded:B=>{mr(B),st(P=>P+1)}}),y.jsx(V9,{visible:Cm,onFileSelected:B=>Ss.current(B)}),y.jsx(q9,{isOpen:ke,initialPath:a,onClose:()=>Ae(!1),onSelect:hn}),y.jsx(F9,{position:de,onClose:()=>be(null),onLaunch:wi,onLaunchWithArgs:rn,onReveal:Xu,onOpenFolder:$u,onOpenTerminal:Yu,onScanDirectory:Xr,onFilterFolder:wl,onFilterExtension:Om,onCopyPath:Gu,onCopyFilename:Ku,onCopyUri:ft,onComputeHash:Nm,onVerifyHash:wo,onProperties:Ns,onClearFile:Zi,onGenerateBarcode:Wu,showToast:ve}),y.jsx(a8,{isOpen:z,onClose:()=>R(!1)}),y.jsx(m8,{isOpen:tn,file:Oe,onLaunch:wi,onClose:()=>{Pn(!1),qe(null)}}),y.jsx(N8,{isOpen:te,currentInterval:Ki,onClose:()=>fe(!1),onSetInterval:kl}),y.jsx(o8,{isOpen:$e,onClose:()=>mt(!1),onOpenExternally:()=>{vM().then(B=>ve(B.message)).catch(B=>ve(B instanceof Error?B.message:"Failed to open the log file","error"))}}),y.jsx(mq,{isOpen:!!bt,onClose:()=>ue(null),directory:a,filename:(bt==null?void 0:bt.file.rel_path)||"",release:l==null?void 0:l.release,args:bt==null?void 0:bt.args,onFinished:(B,P)=>{B==="completed"?ve(P||"Workflow launched successfully."):(B==="aborted"||B==="failed")&&ve(`Workflow stopped: ${P}`,"error")}}),y.jsx(bA,{isOpen:vt,onClose:()=>{Sn(!1),Et(void 0)},initialFilePath:Cn}),Wt&&y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:()=>Yn(null),children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"verify-hash-title",onKeyDown:B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),Yn(null))},onClick:B=>B.stopPropagation(),className:"animate-modal-in w-[440px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("h2",{id:"verify-hash-title",className:"mb-1 text-sm font-semibold text-ink",children:["Verify ",Wt.algorithm.toUpperCase()]}),y.jsx("p",{className:"mb-3 text-xs text-ink-muted",children:"Clipboard access is unavailable here — paste the expected hash below."}),y.jsx("input",{autoFocus:!0,type:"text",value:Hn,onChange:B=>ys(B.target.value),placeholder:"Expected hash","aria-label":"Expected hash",className:"mb-4 w-full rounded-lg border border-line bg-elevated px-3 py-2 font-mono text-xs text-ink placeholder:text-ink-faint focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400"}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{type:"button",onClick:()=>Yn(null),className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsx("button",{type:"button",disabled:!Hn.trim(),onClick:()=>{const{file:B,algorithm:P}=Wt;Yn(null),Xa(B,P,Hn)},className:"min-h-9 rounded-lg border border-transparent bg-indigo-600 px-4 text-sm font-semibold text-white transition-colors hover:bg-indigo-500 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Verify"})]})]})}),y.jsx(k8,{isOpen:Fu,onClose:()=>bs(!1),onDetected:Ga}),y.jsx(ro,{isOpen:!!qt,title:"Delete file",message:`Delete this file? - -${(qt==null?void 0:qt.path)??""} - -This action cannot be undone.`,confirmLabel:"Delete",danger:!0,onConfirm:Kn,onCancel:()=>Kt(null)}),y.jsx(ro,{isOpen:Le!==null,title:Le?"Enable LAN access?":"Restrict to this machine?",message:Le?y.jsxs("span",{className:"block",children:["ProFiles will be reachable by anyone on this network:",y.jsx(VC,{url:`http://${t==null?void 0:t.hostname}:${window.location.port}`,label:"Copy hostname URL",className:"mt-1.5",onCopied:()=>ve("URL copied to clipboard."),onCopyError:()=>ve("Failed to copy URL.","error")}),y.jsx(VC,{url:`http://${t==null?void 0:t.ip}:${window.location.port}`,label:"Copy IP URL",className:"mt-1.5",onCopied:()=>ve("URL copied to clipboard."),onCopyError:()=>ve("Failed to copy URL.","error")})]}):"ProFiles will be reachable only on this machine.",confirmLabel:Le?"Enable LAN":"Restrict",onConfirm:async()=>{const B=Le;Be(null);try{await kM(B),ve(B?"Updating LAN binding…":"Restricting ProFiles to this machine…","info");const P=await SM(B);P&&i(P),(P==null?void 0:P.lan_enabled)===B?ve(B?"ProFiles is now reachable on the local network.":"ProFiles is restricted to this machine.","info"):ve("Failed to update LAN binding — the previous address is still active.","error")}catch(P){const re=P instanceof Error?P.message:"Failed to update LAN binding";ve(`Failed to update LAN binding: ${re}`,"error");const De=await ed();i(De)}},onCancel:()=>Be(null)}),y.jsx(S8,{isOpen:!!vs,file:vs,onConfirm:()=>{if(vs){const B=vs;Fa(null),wi(B)}},onDismiss:()=>Fa(null)})]})}class wq extends A.Component{constructor(){super(...arguments);yh(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,i){console.error("Application render error:",t,i.componentStack)}render(){return this.state.error?y.jsx("main",{className:"flex min-h-screen items-center justify-center bg-app p-6 text-ink",children:y.jsxs("section",{className:"w-full max-w-lg rounded-lg border border-line bg-surface p-6",children:[y.jsx("h1",{className:"text-base font-semibold",children:"ProFiles encountered an error"}),y.jsx("p",{className:"mt-2 text-sm text-ink-secondary",children:"The interface could not continue. Reload the application to try again."}),y.jsxs("details",{className:"mt-4 text-xs text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer",children:"Error details"}),y.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap",children:this.state.error.message})]}),y.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"btn btn-primary mt-5 px-4 py-2 text-sm font-semibold",children:"Reload application"})]})}):this.props.children}}yM.createRoot(document.getElementById("root")).render(y.jsx(fM.StrictMode,{children:y.jsx(wq,{children:y.jsx(vq,{})})})); diff --git a/src/profiles/web/dist/assets/index-DzeM--qU.js b/src/profiles/web/dist/assets/index-DzeM--qU.js new file mode 100644 index 0000000..9c868b1 --- /dev/null +++ b/src/profiles/web/dist/assets/index-DzeM--qU.js @@ -0,0 +1,448 @@ +var oM=Object.defineProperty;var aM=(n,e,t)=>e in n?oM(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gf=(n,e,t)=>aM(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(l){if(l.ep)return;l.ep=!0;const o=t(l);fetch(l.href,o)}})();function Zx(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Mg={exports:{}},mc={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var bk;function cM(){if(bk)return mc;bk=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function t(i,l,o){var a=null;if(o!==void 0&&(a=""+o),l.key!==void 0&&(a=""+l.key),"key"in l){o={};for(var u in l)u!=="key"&&(o[u]=l[u])}else o=l;return l=o.ref,{$$typeof:n,type:i,key:a,ref:l!==void 0?l:null,props:o}}return mc.Fragment=e,mc.jsx=t,mc.jsxs=t,mc}var vk;function uM(){return vk||(vk=1,Mg.exports=cM()),Mg.exports}var y=uM(),Dg={exports:{}},Ve={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var wk;function fM(){if(wk)return Ve;wk=1;var n=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),t=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),a=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),b=Symbol.for("react.view_transition"),v=Symbol.iterator;function w(j){return j===null||typeof j!="object"?null:(j=v&&j[v]||j["@@iterator"],typeof j=="function"?j:null)}var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function _(j,q,ue){this.props=j,this.context=q,this.refs=O,this.updater=ue||S}_.prototype.isReactComponent={},_.prototype.setState=function(j,q){if(typeof j!="object"&&typeof j!="function"&&j!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,j,q,"setState")},_.prototype.forceUpdate=function(j){this.updater.enqueueForceUpdate(this,j,"forceUpdate")};function M(){}M.prototype=_.prototype;function H(j,q,ue){this.props=j,this.context=q,this.refs=O,this.updater=ue||S}var B=H.prototype=new M;B.constructor=H,C(B,_.prototype),B.isPureReactComponent=!0;var D=Array.isArray;function R(){}var P={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function I(j,q,ue){var pe=ue.ref;return{$$typeof:n,type:j,key:q,ref:pe!==void 0?pe:null,props:ue}}function F(j,q){return I(j.type,q,j.props)}function A(j){return typeof j=="object"&&j!==null&&j.$$typeof===n}function ne(j){var q={"=":"=0",":":"=2"};return"$"+j.replace(/[=:]/g,function(ue){return q[ue]})}var ae=/\/+/g;function ie(j,q){return typeof j=="object"&&j!==null&&j.key!=null?ne(""+j.key):q.toString(36)}function $(j){switch(j.status){case"fulfilled":return j.value;case"rejected":throw j.reason;default:switch(typeof j.status=="string"?j.then(R,R):(j.status="pending",j.then(function(q){j.status==="pending"&&(j.status="fulfilled",j.value=q)},function(q){j.status==="pending"&&(j.status="rejected",j.reason=q)})),j.status){case"fulfilled":return j.value;case"rejected":throw j.reason}}throw j}function oe(j,q,ue,pe,De){var Te=typeof j;(Te==="undefined"||Te==="boolean")&&(j=null);var Pe=!1;if(j===null)Pe=!0;else switch(Te){case"bigint":case"string":case"number":Pe=!0;break;case"object":switch(j.$$typeof){case n:case e:Pe=!0;break;case m:return Pe=j._init,oe(Pe(j._payload),q,ue,pe,De)}}if(Pe)return De=De(j),Pe=pe===""?"."+ie(j,0):pe,D(De)?(ue="",Pe!=null&&(ue=Pe.replace(ae,"$&/")+"/"),oe(De,q,ue,"",function(Rt){return Rt})):De!=null&&(A(De)&&(De=F(De,ue+(De.key==null||j&&j.key===De.key?"":(""+De.key).replace(ae,"$&/")+"/")+Pe)),q.push(De)),1;Pe=0;var ve=pe===""?".":pe+":";if(D(j))for(var Ee=0;Ee>>1,N=$[Y];if(0>>1;Yl(z,Z))jl(q,z)?($[Y]=q,$[j]=Z,Y=j):($[Y]=z,$[ye]=Z,Y=ye);else if(jl(q,Z))$[Y]=q,$[j]=Z,Y=j;else break e}}return oe}function l($,oe){var Z=$.sortIndex-oe.sortIndex;return Z!==0?Z:$.id-oe.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;n.unstable_now=function(){return o.now()}}else{var a=Date,u=a.now();n.unstable_now=function(){return a.now()-u}}var f=[],d=[],m=1,g=null,b=3,v=!1,w=!1,S=!1,C=!1,O=typeof setTimeout=="function"?setTimeout:null,_=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function H($){for(var oe=t(d);oe!==null;){if(oe.callback===null)i(d);else if(oe.startTime<=$)i(d),oe.sortIndex=oe.expirationTime,e(f,oe);else break;oe=t(d)}}function B($){if(S=!1,H($),!w)if(t(f)!==null)w=!0,D||(D=!0,A());else{var oe=t(d);oe!==null&&ie(B,oe.startTime-$)}}var D=!1,R=-1,P=5,te=-1;function I(){return C?!0:!(n.unstable_now()-te$&&I());){var Y=g.callback;if(typeof Y=="function"){g.callback=null,b=g.priorityLevel;var N=Y(g.expirationTime<=$);if($=n.unstable_now(),typeof N=="function"){g.callback=N,H($),oe=!0;break t}g===t(f)&&i(f),H($)}else i(f);g=t(f)}if(g!==null)oe=!0;else{var he=t(d);he!==null&&ie(B,he.startTime-$),oe=!1}}break e}finally{g=null,b=Z,v=!1}oe=void 0}}finally{oe?A():D=!1}}}var A;if(typeof M=="function")A=function(){M(F)};else if(typeof MessageChannel<"u"){var ne=new MessageChannel,ae=ne.port2;ne.port1.onmessage=F,A=function(){ae.postMessage(null)}}else A=function(){O(F,0)};function ie($,oe){R=O(function(){$(n.unstable_now())},oe)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function($){$.callback=null},n.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<$?Math.floor(1e3/$):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function($){switch(b){case 1:case 2:case 3:var oe=3;break;default:oe=b}var Z=b;b=oe;try{return $()}finally{b=Z}},n.unstable_requestPaint=function(){C=!0},n.unstable_runWithPriority=function($,oe){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var Z=b;b=$;try{return oe()}finally{b=Z}},n.unstable_scheduleCallback=function($,oe,Z){var Y=n.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0Y?($.sortIndex=Z,e(d,$),t(f)===null&&$===t(d)&&(S?(_(R),R=-1):S=!0,ie(B,Z-Y))):($.sortIndex=N,e(f,$),w||v||(w=!0,D||(D=!0,A()))),$},n.unstable_shouldYield=I,n.unstable_wrapCallback=function($){var oe=b;return function(){var Z=b;b=oe;try{return $.apply(this,arguments)}finally{b=Z}}}})(_g)),_g}var Ck;function mM(){return Ck||(Ck=1,jg.exports=dM()),jg.exports}var Lg={exports:{}},wn={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ok;function pM(){if(Ok)return wn;Ok=1;var n=Jx();function e(m){var g="https://react.dev/errors/"+m;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Lg.exports=pM(),Lg.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Nk;function gM(){if(Nk)return pc;Nk=1;var n=mM(),e=Jx(),t=FC();function i(r){var s="https://react.dev/errors/"+r;if(1Ft||(r.current=Ut[Ft],Ut[Ft]=null,Ft--)}function $e(r,s){Ft++,Ut[Ft]=r.current,r.current=s}var Xt=zt(null),Nn=zt(null),en=zt(null),tn=zt(null);function Ce(r,s){switch($e(en,s),$e(Nn,r),$e(Xt,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?Aw(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=Aw(s),r=Ew(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}gt(Xt),$e(Xt,r)}function Fe(){gt(Xt),gt(Nn),gt(en)}function qe(r){var s=r.memoizedState;s!==null&&(zo._currentValue=s.memoizedState,$e(tn,r)),s=Xt.current;var c=Ew(s,r.type);s!==c&&($e(Nn,r),$e(Xt,c))}function at(r){Nn.current===r&&(gt(Xt),gt(Nn)),tn.current===r&&(gt(tn),zo._currentValue=Rt)}var ee,fe;function _e(r){if(ee===void 0)try{throw Error()}catch(c){var s=c.stack.trim().match(/\n( *(at )?)/);ee=s&&s[1]||"",fe=-1)":-1p||L[h]!==X[p]){var J=` +`+L[h].replace(" at new "," at ");return r.displayName&&J.includes("")&&(J=J.replace("",r.displayName)),J}while(1<=h&&0<=p);break}}}finally{ze=!1,Error.prepareStackTrace=c}return(c=r?r.displayName||r.name:"")?_e(c):""}function ce(r,s){switch(r.tag){case 26:case 27:case 5:return _e(r.type);case 16:return _e("Lazy");case 13:return r.child!==s&&s!==null?_e("Suspense Fallback"):_e("Suspense");case 19:return _e("SuspenseList");case 0:case 15:return Dt(r.type,!1);case 11:return Dt(r.type.render,!1);case 1:return Dt(r.type,!0);case 31:return _e("Activity");case 30:return _e("ViewTransition");default:return""}}function xe(r){try{var s="",c=null;do s+=ce(r,c),c=r,r=r.return;while(r);return s}catch(h){return` +Error generating stack: `+h.message+` +`+h.stack}}var Le=Object.prototype.hasOwnProperty,we=n.unstable_scheduleCallback,mt=n.unstable_cancelCallback,An=n.unstable_shouldYield,mn=n.unstable_requestPaint,Nt=n.unstable_now,ht=n.unstable_getCurrentPriorityLevel,Bi=n.unstable_ImmediatePriority,Ln=n.unstable_UserBlockingPriority,Er=n.unstable_NormalPriority,Jd=n.unstable_LowPriority,gu=n.unstable_IdlePriority,em=n.log,tm=n.unstable_setDisableYieldValue,Jl=null,zn=null;function Pi(r){if(typeof em=="function"&&tm(r),zn&&typeof zn.setStrictMode=="function")try{zn.setStrictMode(Jl,r)}catch{}}var on=Math.clz32?Math.clz32:nm,qs=Math.log,xu=Math.LN2;function nm(r){return r>>>=0,r===0?32:31-(qs(r)/xu|0)|0}var Qs=256,Xs=262144,$s=4194304;function Mr(r){var s=r&42;if(s!==0)return s;switch(r&-r){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return r&-r;case 262144:case 524288:case 1048576:case 2097152:return r&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return r&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return r}}function Gs(r,s,c){var h=r.pendingLanes;if(h===0)return 0;var p=0,x=r.suspendedLanes,k=r.pingedLanes;r=r.warmLanes;var T=h&134217727;return T!==0?(h=T&~x,h!==0?p=Mr(h):(k&=T,k!==0?p=Mr(k):c||(c=T&~r,c!==0&&(p=Mr(c))))):(T=h&~x,T!==0?p=Mr(T):k!==0?p=Mr(k):c||(c=h&~r,c!==0&&(p=Mr(c)))),p===0?0:s!==0&&s!==p&&(s&x)===0&&(x=p&-p,c=s&-s,x>=c||x===32&&(c&4194048)!==0)?s:p}function vi(r,s){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&s)===0}function ka(r,s){(s&8)!==0&&(s|=s&32);var c=r.entangledLanes;if(c!==0)for(r=r.entanglements,c&=s;0c;c++)s.push(r);return s}function es(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function rm(r,s,c,h,p,x){var k=r.pendingLanes;r.pendingLanes=c,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=c,r.entangledLanes&=c,r.errorRecoveryDisabledLanes&=c,r.shellSuspendCounter=0;var T=r.entanglements,L=r.expirationTimes,X=r.hiddenUpdates;for(c=k&~c;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),dm=!1;if(Rr)try{var Na={};Object.defineProperty(Na,"passive",{get:function(){dm=!0}}),window.addEventListener("test",Na,Na),window.removeEventListener("test",Na,Na)}catch{dm=!1}var ll=null,mm=null,Mu=null;function Cb(){if(Mu)return Mu;var r,s=mm,c=s.length,h,p="value"in ll?ll.value:ll.textContent,x=p.length;for(r=0;r=Ma),Mb=" ",Db=!1;function Rb(r,s){switch(r){case"keyup":return r5.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jb(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var io=!1;function s5(r,s){switch(r){case"compositionend":return jb(s);case"keypress":return s.which!==32?null:(Db=!0,Mb);case"textInput":return r=s.data,r===Mb&&Db?null:r;default:return null}}function o5(r,s){if(io)return r==="compositionend"||!bm&&Rb(r,s)?(r=Cb(),Mu=mm=ll=null,io=!1,r):null;switch(r){case"paste":return null;case"keypress":if(!(s.ctrlKey||s.altKey||s.metaKey)||s.ctrlKey&&s.altKey){if(s.char&&1"u")return null;try{return r.activeElement||r.body}catch{return r.body}}function Ub(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Fb(r,s){var c=Ub(r);r=0;for(var h;c;){if(c.nodeType===3){if(h=r+c.textContent.length,r<=s&&h>=s)return{node:c,offset:s-r};r=h}e:{for(;c;){if(c.nextSibling){c=c.nextSibling;break e}c=c.parentNode}c=void 0}c=Ub(c)}}function Vb(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?Vb(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function qb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=km(r.document);s instanceof r.HTMLIFrameElement;){try{var c=typeof s.contentWindow.location.href=="string"}catch{c=!1}if(c)r=s.contentWindow;else break;s=km(r.document)}return s}function Sm(r){var s=r&&r.nodeName&&r.nodeName.toLowerCase();return s&&(s==="input"&&(r.type==="text"||r.type==="search"||r.type==="tel"||r.type==="url"||r.type==="password")||s==="textarea"||r.contentEditable==="true")}var p5=Rr&&"documentMode"in document&&11>=document.documentMode,ro=null,Cm=null,_a=null,Om=!1;function Qb(r,s,c){var h=c.window===c?c.document:c.nodeType===9?c:c.ownerDocument;Om||ro==null||ro!==km(h)||(h=ro,"selectionStart"in h&&Sm(h)?h={start:h.selectionStart,end:h.selectionEnd}:(h=(h.ownerDocument&&h.ownerDocument.defaultView||window).getSelection(),h={anchorNode:h.anchorNode,anchorOffset:h.anchorOffset,focusNode:h.focusNode,focusOffset:h.focusOffset}),_a&&ja(_a,h)||(_a=h,h=zf(Cm,"onSelect"),0>=k,p-=k,tr=1<<32-on(s)+p|c<Ie?(Wt=Be,Be=null):Wt=Be.sibling;var st=V(Q,Be,G[Ie],le);if(st===null){Be===null&&(Be=Wt);break}r&&Be&&st.alternate===null&&s(Q,Be),U=x(st,U,Ie),lt===null?Me=st:lt.sibling=st,lt=st,Be=Wt}if(Ie===G.length)return c(Q,Be),Ze&&zr(Q,Ie),Me;if(Be===null){for(;IeIe?(Wt=Be,Be=null):Wt=Be.sibling;var Ml=V(Q,Be,st.value,le);if(Ml===null){Be===null&&(Be=Wt);break}r&&Be&&Ml.alternate===null&&s(Q,Be),U=x(Ml,U,Ie),lt===null?Me=Ml:lt.sibling=Ml,lt=Ml,Be=Wt}if(st.done)return c(Q,Be),Ze&&zr(Q,Ie),Me;if(Be===null){for(;!st.done;Ie++,st=G.next())st=se(Q,st.value,le),st!==null&&(U=x(st,U,Ie),lt===null?Me=st:lt.sibling=st,lt=st);return Ze&&zr(Q,Ie),Me}for(Be=h(Be);!st.done;Ie++,st=G.next())st=W(Be,Q,Ie,st.value,le),st!==null&&(r&&(Wt=st.alternate,Wt!==null&&Be.delete(Wt.key===null?Ie:Wt.key)),U=x(st,U,Ie),lt===null?Me=st:lt.sibling=st,lt=st);return r&&Be.forEach(function(sM){return s(Q,sM)}),Ze&&zr(Q,Ie),Me}function Ye(Q,U,G,le){if(typeof G=="object"&&G!==null&&G.type===F&&G.key===null&&G.props.ref===void 0&&(G=G.props.children),typeof G=="object"&&G!==null){switch(G.$$typeof){case te:e:{for(var Me=G.key;U!==null;){if(U.key===Me){if(Me=G.type,Me===F){if(U.tag===7){c(Q,U.sibling),le=p(U,G.props.children),fl(le,G),le.return=Q,Q=le;break e}}else if(U.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===N&&hs(Me)===U.type){c(Q,U.sibling),le=p(U,G.props),fl(le,G),le.return=Q,Q=le;break e}c(Q,U);break}else s(Q,U);U=U.sibling}G.type===F?(le=ls(G.props.children,Q.mode,le,G.key),fl(le,G),le.return=Q,Q=le):(le=Iu(G.type,G.key,G.props,null,Q.mode,le),fl(le,G),le.return=Q,Q=le)}return k(Q);case I:e:{for(Me=G.key;U!==null;){if(U.key===Me)if(U.tag===4&&U.stateNode.containerInfo===G.containerInfo&&U.stateNode.implementation===G.implementation){c(Q,U.sibling),le=p(U,G.children||[]),le.return=Q,Q=le;break e}else{c(Q,U);break}else s(Q,U);U=U.sibling}le=Rm(G,Q.mode,le),le.return=Q,Q=le}return k(Q);case N:return G=hs(G),Ye(Q,U,G,le)}if(Pe(G))return be(Q,U,G,le);if(pe(G)){if(Me=pe(G),typeof Me!="function")throw Error(i(150));return G=Me.call(G),Re(Q,U,G,le)}if(typeof G.then=="function")return Ye(Q,U,Ku(G),le);if(G.$$typeof===ie)return Ye(Q,U,Xu(Q,G),le);Wu(Q,G)}return typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint"?(G=""+G,U!==null&&U.tag===6?(c(Q,U.sibling),le=p(U,G),le.return=Q,Q=le):(c(Q,U),le=Dm(G,Q.mode,le),le.return=Q,Q=le),k(Q)):c(Q,U)}return function(Q,U,G,le){try{Ia=0;var Me=Ye(Q,U,G,le);return mo=null,Me}catch(Be){if(Be===ho||Be===Gu)throw Be;var lt=Xn(29,Be,null,Q.mode);return lt.lanes=le,lt.return=Q,lt}finally{}}}var ms=p1(!0),g1=p1(!1),hl=!1;function Fm(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Vm(r,s){r=r.updateQueue,s.updateQueue===r&&(s.updateQueue={baseState:r.baseState,firstBaseUpdate:r.firstBaseUpdate,lastBaseUpdate:r.lastBaseUpdate,shared:r.shared,callbacks:null})}function dl(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function ml(r,s,c){var h=r.updateQueue;if(h===null)return null;if(h=h.shared,(dt&2)!==0){var p=h.pending;return p===null?s.next=s:(s.next=p.next,p.next=s),h.pending=s,s=Hu(r),Jb(r,null,c),s}return Pu(r,h,s,c),Hu(r)}function Ua(r,s,c){if(s=s.updateQueue,s!==null&&(s=s.shared,(c&4194048)!==0)){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,vu(r,c)}}function qm(r,s){var c=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,c===h)){var p=null,x=null;if(c=c.firstBaseUpdate,c!==null){do{var k={lane:c.lane,tag:c.tag,payload:c.payload,callback:null,next:null};x===null?p=x=k:x=x.next=k,c=c.next}while(c!==null);x===null?p=x=s:x=x.next=s}else p=x=s;c={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:x,shared:h.shared,callbacks:h.callbacks},r.updateQueue=c;return}r=c.lastBaseUpdate,r===null?c.firstBaseUpdate=s:r.next=s,c.lastBaseUpdate=s}var Qm=!1;function Fa(){if(Qm){var r=fo;if(r!==null)throw r}}function Va(r,s,c,h){Qm=!1;var p=r.updateQueue;hl=!1;var x=p.firstBaseUpdate,k=p.lastBaseUpdate,T=p.shared.pending;if(T!==null){p.shared.pending=null;var L=T,X=L.next;L.next=null,k===null?x=X:k.next=X,k=L;var J=r.alternate;J!==null&&(J=J.updateQueue,T=J.lastBaseUpdate,T!==k&&(T===null?J.firstBaseUpdate=X:T.next=X,J.lastBaseUpdate=L))}if(x!==null){var se=p.baseState;k=0,J=X=L=null,T=x;do{var V=T.lane&-536870913,W=V!==T.lane;if(W?(rt&V)===V:(h&V)===V){V!==0&&V===us&&(Qm=!0),J!==null&&(J=J.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var be=r,Re=T;V=s;var Ye=c;switch(Re.tag){case 1:if(be=Re.payload,typeof be=="function"){se=be.call(Ye,se,V);break e}se=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Re.payload,V=typeof be=="function"?be.call(Ye,se,V):be,V==null)break e;se=R({},se,V);break e;case 2:hl=!0}}V=T.callback,V!==null&&(r.flags|=64,W&&(r.flags|=8192),W=p.callbacks,W===null?p.callbacks=[V]:W.push(V))}else W={lane:V,tag:T.tag,payload:T.payload,callback:T.callback,next:null},J===null?(X=J=W,L=se):J=J.next=W,k|=V;if(T=T.next,T===null){if(T=p.shared.pending,T===null)break;W=T,T=W.next,W.next=null,p.lastBaseUpdate=W,p.shared.pending=null}}while(!0);J===null&&(L=se),p.baseState=L,p.firstBaseUpdate=X,p.lastBaseUpdate=J,x===null&&(p.shared.lanes=0),wl|=k,r.lanes=k,r.memoizedState=se}}function x1(r,s){if(typeof r!="function")throw Error(i(191,r));r.call(s)}function y1(r,s){var c=r.callbacks;if(c!==null)for(r.callbacks=null,r=0;rx?x:8;var k=ve.T,T={};T.types=k!==null?k.types:null,ve.T=T,fp(r,!1,s,c);try{var L=p(),X=ve.S;if(X!==null&&X(T,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var J=T5(L,h);$a(r,s,J,hi(r))}else $a(r,s,h,hi(r))}catch(se){$a(r,s,{then:function(){},status:"rejected",reason:se},hi())}finally{Ee.p=x,k!==null&&T.types!==null&&(k.types=T.types),ve.T=k}}function R5(){}function cp(r,s,c,h){if(r.tag!==5)throw Error(i(476));var p=K1(r).queue;Y1(r,p,s,Rt,c===null?R5:function(){return W1(r),c(h)})}function K1(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:Rt,baseState:Rt,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:Rt},next:null};var c={};return s.next={memoizedState:c,baseState:c,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:c},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function W1(r){var s=K1(r);s.next===null&&(s=r.alternate.memoizedState),$a(r,s.next.queue,{},hi())}function up(){return gn(zo)}function Z1(){return Vt().memoizedState}function J1(){return Vt().memoizedState}function j5(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var c=hi();r=dl(c);var h=ml(s,r,c);h!==null&&(Kn(h,s,c),Ua(h,s,c)),s={cache:Pm()},r.payload=s;return}s=s.return}}function _5(r,s,c){var h=hi();c={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null},af(r)?tv(s,c):(c=Em(r,s,c,h),c!==null&&(Kn(c,r,h),nv(c,s,h)))}function ev(r,s,c){var h=hi();$a(r,s,c,h)}function $a(r,s,c,h){var p={lane:h,revertLane:0,gesture:null,action:c,hasEagerState:!1,eagerState:null,next:null};if(af(r))tv(s,p);else{var x=r.alternate;if(r.lanes===0&&(x===null||x.lanes===0)&&(x=s.lastRenderedReducer,x!==null))try{var k=s.lastRenderedState,T=x(k,c);if(p.hasEagerState=!0,p.eagerState=T,oi(T,k))return Pu(r,s,p,0),St===null&&Bu(),!1}catch{}finally{}if(c=Em(r,s,p,h),c!==null)return Kn(c,r,h),nv(c,s,h),!0}return!1}function fp(r,s,c,h){if(h={lane:2,revertLane:tg(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},af(r)){if(s)throw Error(i(479))}else s=Em(r,c,h,2),s!==null&&Kn(s,r,2)}function af(r){var s=r.alternate;return r===Ge||s!==null&&s===Ge}function tv(r,s){po=ef=!0;var c=r.pending;c===null?s.next=s:(s.next=c.next,c.next=s),r.pending=s}function nv(r,s,c){if((c&4194048)!==0){var h=s.lanes;h&=r.pendingLanes,c|=h,s.lanes=c,vu(r,c)}}var cf={readContext:gn,use:rf,useCallback:Bt,useContext:Bt,useEffect:Bt,useImperativeHandle:Bt,useLayoutEffect:Bt,useInsertionEffect:Bt,useMemo:Bt,useReducer:Bt,useRef:Bt,useState:Bt,useDebugValue:Bt,useDeferredValue:Bt,useTransition:Bt,useSyncExternalStore:Bt,useId:Bt,useHostTransitionStatus:Bt,useFormState:Bt,useActionState:Bt,useOptimistic:Bt,useMemoCache:Bt,useCacheRefresh:Bt,useEffectEvent:Bt},iv={readContext:gn,use:rf,useCallback:function(r,s){return Pn().memoizedState=[r,s===void 0?null:s],r},useContext:gn,useEffect:I1,useImperativeHandle:function(r,s,c){c=c!=null?c.concat([r]):null,sf(4194308,4,q1.bind(null,s,r),c)},useLayoutEffect:function(r,s){return sf(4194308,4,r,s)},useInsertionEffect:function(r,s){sf(4,2,r,s)},useMemo:function(r,s){var c=Pn();s=s===void 0?null:s;var h=r();if(ps){Pi(!0);try{r()}finally{Pi(!1)}}return c.memoizedState=[h,s],h},useReducer:function(r,s,c){var h=Pn();if(c!==void 0){var p=c(s);if(ps){Pi(!0);try{c(s)}finally{Pi(!1)}}}else p=s;return h.memoizedState=h.baseState=p,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:p},h.queue=r,r=r.dispatch=_5.bind(null,Ge,r),[h.memoizedState,r]},useRef:function(r){var s=Pn();return r={current:r},s.memoizedState=r},useState:function(r){r=rp(r);var s=r.queue,c=ev.bind(null,Ge,s);return s.dispatch=c,[r.memoizedState,c]},useDebugValue:op,useDeferredValue:function(r,s){var c=Pn();return ap(c,r,s)},useTransition:function(){var r=rp(!1);return r=Y1.bind(null,Ge,r.queue,!0,!1),Pn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,c){var h=Ge,p=Pn();if(Ze){if(c===void 0)throw Error(i(407));c=c()}else{if(c=s(),St===null)throw Error(i(349));(rt&127)!==0||C1(h,s,c)}p.memoizedState=c;var x={value:c,getSnapshot:s};return p.queue=x,I1(T1.bind(null,h,x,r),[r]),h.flags|=2048,xo(9,{destroy:void 0},O1.bind(null,h,x,c,s),null),c},useId:function(){var r=Pn(),s=St.identifierPrefix;if(Ze){var c=nr,h=tr;c=(h&~(1<<32-on(h)-1)).toString(32)+c,s="_"+s+"R_"+c,c=tf++,0<\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof h.is=="string"?k.createElement("select",{is:h.is}):k.createElement("select"),h.multiple?x.multiple=!0:h.size&&(x.size=h.size);break;default:x=typeof h.is=="string"?k.createElement(p,{is:h.is}):k.createElement(p)}}x[nn]=s,x[pn]=h;e:for(k=s.child;k!==null;){if(k.tag===5||k.tag===6)x.appendChild(k.stateNode);else if(k.tag!==4&&k.tag!==27&&k.child!==null){k.child.return=k,k=k.child;continue}if(k===s)break e;for(;k.sibling===null;){if(k.return===null||k.return===s)break e;k=k.return}k.sibling.return=k.return,k=k.sibling}s.stateNode=x;e:switch(vn(x,p,h),p){case"button":case"input":case"select":case"textarea":h=!!h.autoFocus;break e;case"img":h=!0;break e;default:h=!1}h&&Fr(s)}}return Et(s),s.subtreeFlags&=-33554433,Cp(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,c),null;case 6:if(r&&s.stateNode!=null)r.memoizedProps!==h&&Fr(s);else{if(typeof h!="string"&&s.stateNode===null)throw Error(i(166));if(r=en.current,uo(s)){if(r=s.stateNode,c=s.memoizedProps,h=null,p=an,p!==null)switch(p.tag){case 27:case 5:h=p.memoizedProps}r[nn]=s,r=!!(r.nodeValue===c||h!==null&&h.suppressHydrationWarning===!0||Tw(r.nodeValue,c)),r||cl(s,!0)}else r=sc(r).createTextNode(h),r[nn]=s,s.stateNode=r}return Et(s),null;case 31:if(c=s.memoizedState,r===null||r.memoizedState!==null){if(h=uo(s),c!==null){if(r===null){if(!h)throw Error(i(318));if(r=s.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(i(557));r[nn]=s}else ss(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Et(s),r=!1}else c=Lm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=c),r=!0;if(!r)return s.flags&256?(ai(s),s):(ai(s),null);if((s.flags&128)!==0)throw Error(i(558))}return Et(s),null;case 13:if(h=s.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(p=uo(s),h!==null&&h.dehydrated!==null){if(r===null){if(!p)throw Error(i(318));if(p=s.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(i(317));p[nn]=s}else ss(),(s.flags&128)===0&&(s.memoizedState=null),s.flags|=4;Et(s),p=!1}else p=Lm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return s.flags&256?(ai(s),s):(ai(s),null)}return ai(s),(s.flags&128)!==0?(s.lanes=c,s):(c=h!==null,r=r!==null&&r.memoizedState!==null,c&&(h=s.child,p=null,h.alternate!==null&&h.alternate.memoizedState!==null&&h.alternate.memoizedState.cachePool!==null&&(p=h.alternate.memoizedState.cachePool.pool),x=null,h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(x=h.memoizedState.cachePool.pool),x!==p&&(h.flags|=2048)),c!==r&&c&&(s.child.flags|=8192),pf(s,s.updateQueue),Et(s),null);case 4:return Fe(),r===null&&lg(s.stateNode.containerInfo),s.flags|=67108864,Et(s),null;case 10:return Pr(s.type),Et(s),null;case 19:if(Ym(s),h=s.memoizedState,h===null)return Et(s),null;if(p=(s.flags&128)!==0,x=h.rendering,x===null)if(p)Ya(h,!1);else{if(Pt!==0||r!==null&&(r.flags&128)!==0)for(r=s.child;r!==null;){if(x=Ju(r),x!==null){for(s.flags|=128,Ya(h,!1),r=x.updateQueue,s.updateQueue=r,pf(s,r),s.subtreeFlags=0,r=c,c=s.child;c!==null;)e1(c,r),c=c.sibling;return qa(s,yn.current&1|2),Ze&&zr(s,h.treeForkCount),s.child}r=r.sibling}h.tail!==null&&Nt()>Nf&&(s.flags|=128,p=!0,Ya(h,!1),s.lanes=4194304)}else{if(!p)if(r=Ju(x),r!==null){if(s.flags|=128,p=!0,r=r.updateQueue,s.updateQueue=r,pf(s,r),Ya(h,!0),h.tail===null&&h.tailMode!=="collapsed"&&h.tailMode!=="visible"&&!x.alternate&&!Ze)return Et(s),null}else 2*Nt()-h.renderingStartTime>Nf&&c!==536870912&&(s.flags|=128,p=!0,Ya(h,!1),s.lanes=4194304);h.isBackwards?(x.sibling=s.child,s.child=x):(r=h.last,r!==null?r.sibling=x:s.child=x,h.last=x)}if(h.tail!==null){r=h.tail;e:{for(c=r;c!==null;){if(c.alternate!==null){c=!1;break e}c=c.sibling}c=!0}return h.rendering=r,h.tail=r.sibling,h.renderingStartTime=Nt(),r.sibling=null,x=yn.current,x=p?x&1|2:x&1,h.tailMode==="visible"||h.tailMode==="collapsed"||!c||Ze?qa(s,x):(c=x,$e(xn,s),$e(yn,c),En===null&&(En=s)),Ze&&zr(s,h.treeForkCount),r}return Et(s),null;case 22:case 23:return ai(s),$m(),h=s.memoizedState!==null,r!==null?r.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(c&536870912)!==0&&(s.flags&128)===0&&(Et(s),s.subtreeFlags&6&&(s.flags|=8192)):Et(s),c=s.updateQueue,c!==null&&pf(s,c.retryQueue),c=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(c=r.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==c&&(s.flags|=2048),r!==null&>(fs),null;case 24:return c=null,r!==null&&(c=r.memoizedState.cache),s.memoizedState.cache!==c&&(s.flags|=2048),Pr(Gt),Et(s),null;case 25:return null;case 30:return s.flags|=33554432,Et(s),null}throw Error(i(156,s.tag))}function U5(r,s){switch(jm(s),s.tag){case 1:return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 3:return Pr(Gt),Fe(),r=s.flags,(r&65536)!==0&&(r&128)===0?(s.flags=r&-65537|128,s):null;case 26:case 27:case 5:return at(s),null;case 31:if(s.memoizedState!==null){if(ai(s),s.alternate===null)throw Error(i(340));ss()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 13:if(ai(s),r=s.memoizedState,r!==null&&r.dehydrated!==null){if(s.alternate===null)throw Error(i(340));ss()}return r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 19:return Ym(s),r=s.flags,r&65536?(s.flags=r&-65537|128,r=s.memoizedState,r!==null&&(r.rendering=null,r.tail=null),s.flags|=4,s):null;case 4:return Fe(),null;case 10:return Pr(s.type),null;case 22:case 23:return ai(s),$m(),r!==null&>(fs),r=s.flags,r&65536?(s.flags=r&-65537|128,s):null;case 24:return Pr(Gt),null;case 25:return null;default:return null}}function Av(r,s){switch(jm(s),s.tag){case 3:Pr(Gt),Fe();break;case 26:case 27:case 5:at(s);break;case 4:Fe();break;case 31:s.memoizedState!==null&&ai(s);break;case 13:ai(s);break;case 19:Ym(s);break;case 10:Pr(s.type);break;case 22:case 23:ai(s),$m(),r!==null&>(fs);break;case 24:Pr(Gt)}}function Ka(r,s){try{var c=s.updateQueue,h=c!==null?c.lastEffect:null;if(h!==null){var p=h.next;c=p;do{if((c.tag&r)===r){h=void 0;var x=c.create,k=c.inst;h=x(),k.destroy=h}c=c.next}while(c!==p)}}catch(T){yt(s,s.return,T)}}function yl(r,s,c){try{var h=s.updateQueue,p=h!==null?h.lastEffect:null;if(p!==null){var x=p.next;h=x;do{if((h.tag&r)===r){var k=h.inst,T=k.destroy;if(T!==void 0){k.destroy=void 0,p=s;var L=c,X=T;try{X()}catch(J){yt(p,L,J)}}}h=h.next}while(h!==x)}}catch(J){yt(s,s.return,J)}}function Ev(r){var s=r.updateQueue;if(s!==null){var c=r.stateNode;try{y1(s,c)}catch(h){yt(r,r.return,h)}}}function Mv(r,s,c){c.props=gs(r.type,r.memoizedProps),c.state=r.memoizedState;try{c.componentWillUnmount()}catch(h){yt(r,s,h)}}function ir(r,s){try{var c=r.ref;if(c!==null){switch(r.tag){case 26:case 27:case 5:var h=r.stateNode;break;case 30:var p=r.stateNode,x=jr(r.memoizedProps,p);(p.ref===null||p.ref.name!==x)&&(p.ref=Bw(x)),h=p.ref;break;case 7:if(r.stateNode===null){var k=new di(r);g(r.child,!1,D3,k,void 0,void 0),r.stateNode=k}h=r.stateNode;break;default:h=r.stateNode}typeof c=="function"?r.refCleanup=c(h):c.current=h}}catch(T){yt(r,s,T)}}function bn(r,s){var c=r.ref,h=r.refCleanup;if(c!==null)if(typeof h=="function")try{h()}catch(p){yt(r,s,p)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof c=="function")try{c(null)}catch(p){yt(r,s,p)}else c.current=null}function gf(r,s){if((r.tag===5||r.tag===27||r.tag===6)&&r.alternate===null&&s!==null)for(var c=0;c title"))),vn(h,s,c),h[nn]=r,de(h),s=h;break e;case"link":if(x=ek("link","href",p).get(s+(c.href||""))){for(k=0;kYe&&(k=Ye,Ye=Re,Re=k);var Q=Fb(T,Re),U=Fb(T,Ye);if(Q&&U&&(W.rangeCount!==1||W.anchorNode!==Q.node||W.anchorOffset!==Q.offset||W.focusNode!==U.node||W.focusOffset!==U.offset)){var G=se.createRange();G.setStart(Q.node,Q.offset),W.removeAllRanges(),Re>Ye?(W.addRange(G),W.extend(U.node,U.offset)):(G.setEnd(U.node,U.offset),W.addRange(G))}}}}for(se=[],W=T;W=W.parentNode;)W.nodeType===1&&se.push({element:W,left:W.scrollLeft,top:W.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;Tc?32:c,ve.T=null,c=Qp,Qp=null;var x=Vi,k=cr;if(Lt=0,vs=Vi=null,cr=0,(dt&6)!==0)throw Error(i(331));var T=dt;if(dt|=4,Jv(x.current),Kv(x,x.current,k,c),dt=T,ic(0,!1),zn&&typeof zn.onPostCommitFiberRoot=="function")try{zn.onPostCommitFiberRoot(Jl,x)}catch{}return!0}finally{Ee.p=p,ve.T=h,mw(r,s)}}function pw(r,s,c){s=Ci(c,s),s=mp(r.stateNode,s,2),r=ml(r,s,2),r!==null&&(es(r,2),ur(r))}function yt(r,s,c){if(r.tag===3)pw(r,r,c);else for(;s!==null;){if(s.tag===3){pw(s,r,c);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(kl===null||!kl.has(h))){r=Ci(c,r),c=fv(2),h=ml(s,c,2),h!==null&&(hv(c,h,s,r),es(h,2),ur(h));break}}s=s.return}}function Zp(r,s,c){var h=r.pingCache;if(h===null){h=r.pingCache=new Q5;var p=new Set;h.set(s,p)}else p=h.get(s),p===void 0&&(p=new Set,h.set(s,p));p.has(c)||(Fp=!0,p.add(c),r=J5.bind(null,r,s,c),s.then(r,r))}function J5(r,s,c){var h=r.pingCache;h!==null&&h.delete(s),r.pingedLanes|=r.suspendedLanes&c,r.warmLanes&=~c,St===r&&(rt&c)===c&&((Pt===4||Pt===3&&(rt&62914560)===rt&&300>Nt()-Tf)&&(dt&2)===0?Ao(r,0):Of|=c,So===rt&&(So=0)),ur(r)}function gw(r,s){s===0&&(s=yu()),r=rs(r,s),r!==null&&(es(r,s),ur(r))}function e3(r){var s=r.memoizedState,c=0;s!==null&&(c=s.retryLane),gw(r,c)}function t3(r,s){var c=0;switch(r.tag){case 31:case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(c=p.retryLane);break;case 19:h=r.stateNode;break;case 22:h=r.stateNode._retryCache;break;default:throw Error(i(314))}h!==null&&h.delete(s),gw(r,c)}function n3(r,s){return we(r,s)}var Mo=null,Do=null,Jp=!1,_f=!1,eg=!1,Cl=0;function ur(r){r!==Do&&r.next===null&&(Do===null?Mo=Do=r:Do=Do.next=r),_f=!0,Jp||(Jp=!0,r3())}function ic(r,s){if(!eg&&_f){eg=!0;do for(var c=!1,h=Mo;h!==null;){if(r!==0){var p=h.pendingLanes;if(p===0)var x=0;else{var k=h.suspendedLanes,T=h.pingedLanes;x=(1<<31-on(42|r)+1)-1,x&=p&~(k&~T),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(c=!0,vw(h,x))}else x=rt,x=Gs(h,h===St?x:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(x&3)===0||vi(h,x)||(c=!0,vw(h,x));h=h.next}while(c);eg=!1}}function i3(){xw()}function xw(){_f=Jp=!1;var r=0;Cl!==0&&p3()&&(r=Cl);for(var s=Nt(),c=null,h=Mo;h!==null;){var p=h.next,x=yw(h,s);x===0?(h.next=null,c===null?Mo=p:c.next=p,p===null&&(Do=c)):(c=h,(r!==0||(x&3)!==0)&&(_f=!0)),h=p}Lt!==0&&Lt!==5||ic(r),Cl!==0&&(Cl=0)}function yw(r,s){for(var c=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,x=r.pendingLanes&-62914561;0T)break;var J=L.transferSize,se=L.initiatorType;J&&Nw(se)&&(L=L.responseEnd,k+=J*(LHf){Re.length=be;break}G=new Promise(w3.bind(G)),Re.push(G)}}}if(0"u"?null:document;function Kw(r,s,c){var h=jo;if(h&&typeof s=="string"&&s){var p=ki(s);p='link[rel="'+r+'"][href="'+p+'"]',typeof c=="string"&&(p+='[crossorigin="'+c+'"]'),Yw.has(p)||(Yw.add(p),r={rel:r,crossOrigin:c,href:s},h.querySelector(p)===null&&(s=h.createElement("link"),vn(s,"link",r),de(s),h.head.appendChild(s)))}}function I3(r){qr.D(r),Kw("dns-prefetch",r,null)}function U3(r,s){qr.C(r,s),Kw("preconnect",r,s)}function F3(r,s,c){qr.L(r,s,c);var h=jo;if(h&&r&&s){var p='link[rel="preload"][as="'+ki(s)+'"]';s==="image"&&c&&c.imageSrcSet?(p+='[imagesrcset="'+ki(c.imageSrcSet)+'"]',typeof c.imageSizes=="string"&&(p+='[imagesizes="'+ki(c.imageSizes)+'"]')):p+='[href="'+ki(r)+'"]';var x=p;switch(s){case"style":x=_o(r);break;case"script":x=Lo(r)}if(!(Mi.has(x)||(r=R({rel:"preload",href:s==="image"&&c&&c.imageSrcSet?void 0:r,as:s},c),Mi.set(x,r),h.querySelector(p)!==null||s==="style"&&h.querySelector(ac(x))||s==="script"&&h.querySelector(cc(x))))){var k=h.createElement("link");vn(k,"link",r),s==="style"&&(k[Ys]=!0,k.onload=k.onerror=function(){Oe(k)}),de(k),h.head.appendChild(k)}}}function V3(r,s){qr.m(r,s);var c=jo;if(c&&r){var h=s&&typeof s.as=="string"?s.as:"script",p='link[rel="modulepreload"][as="'+ki(h)+'"][href="'+ki(r)+'"]',x=p;switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Lo(r)}if(!Mi.has(x)&&(r=R({rel:"modulepreload",href:r},s),Mi.set(x,r),c.querySelector(p)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(c.querySelector(cc(x)))return}h=c.createElement("link"),vn(h,"link",r),de(h),c.head.appendChild(h)}}}function q3(r,s,c){qr.S(r,s,c);var h=jo;if(h&&r){var p=K(h).hoistableStyles,x=_o(r);s=s||"default";var k=p.get(x);if(!k){var T={loading:0,preload:null};if(k=h.querySelector(ac(x)))T.loading=5;else{r=R({rel:"stylesheet",href:r,"data-precedence":s},c),(c=Mi.get(x))&&wg(r,c);var L=k=h.createElement("link");de(L),vn(L,"link",r),L._p=new Promise(function(X,J){L.onload=X,L.onerror=J}),L.addEventListener("load",function(){T.loading|=1}),L.addEventListener("error",function(){T.loading|=2}),T.loading|=4,Bf(k,s,h)}k={type:"stylesheet",instance:k,count:1,state:T},p.set(x,k)}}}function Q3(r,s){qr.X(r,s);var c=jo;if(c&&r){var h=K(c).hoistableScripts,p=Lo(r),x=h.get(p);x||(x=c.querySelector(cc(p)),x||(r=R({src:r,async:!0},s),(s=Mi.get(p))&&kg(r,s),x=c.createElement("script"),de(x),vn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function X3(r,s){qr.M(r,s);var c=jo;if(c&&r){var h=K(c).hoistableScripts,p=Lo(r),x=h.get(p);x||(x=c.querySelector(cc(p)),x||(r=R({src:r,async:!0,type:"module"},s),(s=Mi.get(p))&&kg(r,s),x=c.createElement("script"),de(x),vn(x,"link",r),c.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function Ww(r,s,c,h){var p=(p=en.current)?oc(p):null;if(!p)throw Error(i(446));switch(r){case"meta":case"title":return null;case"style":return typeof c.precedence=="string"&&typeof c.href=="string"?(c=_o(c.href),s=K(p).hoistableStyles,h=s.get(c),h||(h={type:"style",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(c.rel==="stylesheet"&&typeof c.href=="string"&&typeof c.precedence=="string"){r=_o(c.href);var x=K(p).hoistableStyles,k=x.get(r);if(k||(p=p.ownerDocument||p,k={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(r,k),(x=p.querySelector(ac(r)))?x._p||(k.instance=x,k.state.loading=5):(x=Mi.get(r),x||(x={rel:"preload",as:"style",href:c.href,crossOrigin:c.crossOrigin,integrity:c.integrity,media:c.media,hrefLang:c.hrefLang,referrerPolicy:c.referrerPolicy},Mi.set(r,x)),$3(p,r,x,k.state))),s&&h===null)throw Error(i(528,""));return k}if(s&&h!==null)throw Error(i(529,""));return null;case"script":return s=c.async,c=c.src,typeof c=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(c=Lo(c),s=K(p).hoistableScripts,h=s.get(c),h||(h={type:"script",instance:null,count:0,state:null},s.set(c,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function _o(r){return'href="'+ki(r)+'"'}function ac(r){return'link[rel="stylesheet"]['+r+"]"}function Zw(r){return R({},r,{"data-precedence":r.precedence,precedence:null})}function $3(r,s,c,h){if(s=r.querySelector('link[rel="preload"][as="style"]['+s+"]")){if(s[Ys]!==!0){h.loading=1;return}}else s=r.createElement("link"),s[Ys]=!0,s.onload=s.onerror=Oe.bind(null,s),vn(s,"link",c),de(s),r.head.appendChild(s);h.preload=s,s.addEventListener("load",function(){return h.loading|=1}),s.addEventListener("error",function(){return h.loading|=2})}function Lo(r){return'[src="'+ki(r)+'"]'}function cc(r){return"script[async]"+r}function Jw(r,s,c){if(s.count++,s.instance===null)switch(s.type){case"style":var h=r.querySelector('style[data-href~="'+ki(c.href)+'"]');if(h)return s.instance=h,de(h),h;var p=R({},c,{"data-href":c.href,"data-precedence":c.precedence,href:null,precedence:null});return h=(r.ownerDocument||r).createElement("style"),de(h),vn(h,"style",p),Bf(h,c.precedence,r),s.instance=h;case"stylesheet":p=_o(c.href);var x=r.querySelector(ac(p));if(x)return s.state.loading|=4,s.instance=x,de(x),x;h=Zw(c),(p=Mi.get(p))&&wg(h,p),x=(r.ownerDocument||r).createElement("link"),de(x);var k=x;return k._p=new Promise(function(T,L){k.onload=T,k.onerror=L}),vn(x,"link",h),s.state.loading|=4,Bf(x,c.precedence,r),s.instance=x;case"script":return x=Lo(c.src),(p=r.querySelector(cc(x)))?(s.instance=p,de(p),p):(h=c,(p=Mi.get(x))&&(h=R({},c),kg(h,p)),r=r.ownerDocument||r,p=r.createElement("script"),de(p),vn(p,"link",h),r.head.appendChild(p),s.instance=p);case"void":return null;default:throw Error(i(443,s.type))}else s.type==="stylesheet"&&(s.state.loading&4)===0&&(h=s.instance,s.state.loading|=4,Bf(h,c.precedence,r));return s.instance}function Bf(r,s,c){for(var h=c.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=h.length?h[h.length-1]:null,x=p,k=0;k title"):null)}function G3(r,s,c){if(c===1||s.itemProp!=null)return!1;switch(r){case"meta":case"title":return!0;case"style":if(typeof s.precedence!="string"||typeof s.href!="string"||s.href==="")break;return!0;case"link":if(typeof s.rel!="string"||typeof s.href!="string"||s.href===""||s.onLoad||s.onError)break;switch(s.rel){case"stylesheet":return r=s.disabled,typeof s.precedence=="string"&&r==null;default:return!0}case"script":if(s.async&&typeof s.async!="function"&&typeof s.async!="symbol"&&!s.onLoad&&!s.onError&&s.src&&typeof s.src=="string")return!0}return!1}function tk(r,s){return r==="img"&&s.src!=null&&s.src!==""&&s.onLoad==null&&s.loading!=="lazy"}function nk(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function ik(r){return(r.width||100)*(r.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function rk(r,s){typeof s.decode=="function"&&(r.imgCount++,s.complete||(r.imgBytes+=ik(s),r.suspenseyImages.push(s)),r=W3.bind(r),s.decode().then(r,r))}function Y3(r,s,c,h){if(c.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(c.state.loading&4)===0){if(c.instance===null){var p=_o(h.href),x=s.querySelector(ac(p));if(x){s=x._p,s!==null&&typeof s=="object"&&typeof s.then=="function"&&(r.count++,r=uc.bind(r),s.then(r,r)),c.state.loading|=4,c.instance=x,de(x);return}x=s.ownerDocument||s,h=Zw(h),(p=Mi.get(p))&&wg(h,p),x=x.createElement("link"),de(x);var k=x;k._p=new Promise(function(T,L){k.onload=T,k.onerror=L}),vn(x,"link",h),c.instance=x}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(c,s),(s=c.state.preload)&&(c.state.loading&3)===0&&(r.count++,c=uc.bind(r),s.addEventListener("load",c),s.addEventListener("error",c))}}var Hf=0;function K3(r,s){return r.stylesheets&&r.count===0&&Uf(r,r.stylesheets),0Hf?50:800)+s);return r.unsuspend=c,function(){r.unsuspend=null,clearTimeout(h),clearTimeout(p)}}:null}function lk(r){if(r.count===0&&(r.imgCount===0||!r.waitingForImages)){if(r.stylesheets)Uf(r,r.stylesheets);else if(r.unsuspend){var s=r.unsuspend;r.unsuspend=null,s()}}}function uc(){this.count--,lk(this)}function W3(){this.imgCount--,lk(this)}var If=null;function Uf(r,s){r.stylesheets=null,r.unsuspend!==null&&(r.count++,If=new Map,s.forEach(Z3,r),If=null,uc.call(r))}function Z3(r,s){if(!(s.state.loading&4)){var c=If.get(r);if(c)var h=c.get(null);else{c=new Map,If.set(r,c);for(var p=r.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}return n(),Rg.exports=gM(),Rg.exports}var yM=xM();const bM=Zx(yM);class ey extends Error{constructor(t,i,l){super(t);Gf(this,"status");Gf(this,"detail");this.name="ApiError",this.status=i,this.detail=l}}async function Tr(n,e){let t=e,i;try{const l=await n.json();typeof(l==null?void 0:l.detail)=="string"&&l.detail?(t=l.detail,i=l.detail):Array.isArray(l==null?void 0:l.detail)&&(i=l.detail)}catch{}return new ey(t,n.status,i)}async function vM(n){const e=await fetch(`/api/notifications?after=${n}`);if(!e.ok)throw new Error("Failed to fetch notifications");return e.json()}async function wM(){const n=await fetch("/api/actions/open-log",{method:"POST"});if(!n.ok)throw new Error("Failed to open log file");return n.json()}async function kM(n){const e=new URLSearchParams;e.set("limit",String(n.limit)),n!=null&&n.level&&e.set("level",n.level),n!=null&&n.search&&e.set("search",n.search);const t=await fetch(`/api/logs?${e.toString()}`);if(!t.ok)throw new Error("Failed to fetch log entries");return t.json()}async function Qh(){const n=await fetch("/api/system");if(!n.ok)throw new Error("Failed to fetch system info");return n.json()}async function SM(n){const e=await fetch("/api/system/bind",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:n})});if(!e.ok){let t="Failed to update LAN binding";try{const i=await e.json();i!=null&&i.detail&&(t=i.detail)}catch{}throw new Error(t)}return e.json()}async function CM(n,e=1e4){const t=Date.now()+e;let i=null;for(;Date.now()setTimeout(l,500))}return i}async function Ek(){const n=await fetch("/api/config");if(!n.ok)throw new Error("Failed to fetch app configuration");return n.json()}async function Mk(n){const e=await fetch("/api/config/select-directory",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw await Tr(e,"Failed to select directory");return e.json()}async function OM(n){const e=await fetch("/api/config/load",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({config_path:n})});if(!e.ok)throw new Error("Failed to load config file");return e.json()}async function VC(n,e){const t=await fetch("/api/config/load-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok){let i=`Failed to apply dropped config (${n})`;try{const l=await t.json();l!=null&&l.detail&&(i=l.detail)}catch{}throw new Error(i)}return t.json()}async function TM(){const n=await fetch("/api/config/reload",{method:"POST"});if(!n.ok){let e="Failed to reload configuration";try{const t=await n.json();t!=null&&t.detail&&(e=t.detail)}catch{}throw new Error(e)}return n.json()}async function NM(n){const e=await fetch("/api/config/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:n})});if(!e.ok)throw new Error("Failed to create config file");return e.json()}async function Dk(){const n=await fetch("/api/config/content");if(!n.ok)throw await Tr(n,"Failed to fetch config content");return n.json()}async function Rk(n,e){const t=await fetch("/api/config/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,content:e})});if(!t.ok)throw await Tr(t,"Failed to validate config content");return t.json()}async function AM(){const n=await fetch("/api/config/template",{method:"POST"});if(!n.ok)throw await Tr(n,"Failed to fetch config template");return n.json()}async function jk(n,e,t={}){const i=await fetch("/api/config/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,force:e,baseline_hash:t.baselineHash??null,overwrite_changes:t.overwriteChanges??!1})});if(!i.ok)throw await Tr(i,"Failed to save configuration");const l=await i.json();return{config:l.config,contentHash:l.content_hash??null}}async function EM(n){const e=await fetch("/api/config/save-as",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await Tr(e,"Failed to save configuration as");const t=await e.json();return{config:t.config,contentHash:t.content_hash??null}}async function MM(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}&include_hidden=true`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse config files");return t.json()}async function qC(n){const e=`/api/fs/browse?path=${encodeURIComponent(n)}`,t=await fetch(e);if(!t.ok)throw new Error("Failed to browse directory");return t.json()}async function _k(n,e){const t=await fetch("/api/scan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n),signal:e});if(!t.ok)throw await Tr(t,"Failed to execute scan");return t.json()}async function Lk(n){const e=new URLSearchParams;(n==null?void 0:n.offset)!=null&&e.set("offset",String(n.offset)),(n==null?void 0:n.limit)!=null&&e.set("limit",String(n.limit)),n!=null&&n.sort_by&&e.set("sort_by",n.sort_by),n!=null&&n.sort_dir&&e.set("sort_dir",n.sort_dir);const t=e.toString(),i=`/api/scan/results${t?`?${t}`:""}`,l=await fetch(i,{signal:n==null?void 0:n.signal});if(!l.ok)throw new Error("Failed to fetch scan results");return l.json()}async function DM(n){const e=await fetch("/api/actions/launch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw new Error("Failed to launch file");return e.json()}async function QC(n){const e=await fetch("/api/actions/reveal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to reveal file");return e.json()}async function j0(n){const e=await fetch("/api/actions/open-folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open folder");return e.json()}async function zk(n){const e=await fetch("/api/actions/open-terminal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n})});if(!e.ok)throw new Error("Failed to open terminal");return e.json()}async function Bk(n,e){const t=await fetch("/api/actions/hash",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n,algorithm:e})});if(!t.ok)throw new Error("Failed to compute hash");return t.json()}async function RM(){const n=await fetch("/api/actions/open-config",{method:"POST"});if(!n.ok)throw new Error("Failed to open config file");return n.json()}async function Pk(n){const e={file_path:n.file_path||n.filePath,content:n.content},t=await fetch("/api/actions/barcode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error("Failed to generate barcode");return t.json()}async function jM(n){const e=await fetch("/api/actions/barcode/decode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n.imageBase64,formats:n.formats})});if(!e.ok)throw e.status===503?new Error("Server-side barcode decoding is unavailable"):new Error(`Failed to decode frame (HTTP ${e.status})`);return e.json()}async function _M(n,e){const t=await fetch("/api/actions/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:n}),signal:e});if(!t.ok)throw new Error("Failed to fetch metadata");return t.json()}async function LM(n,e){const t=await fetch("/api/actions/export-csv",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:n,filename:e})});if(!t.ok)throw new Error("Failed to export CSV");return t.json()}async function zM(n,e){const t=await fetch("/api/actions/save-image",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({image_base64:n,filename:e})});if(!t.ok)throw new Error("Failed to save image");return t.json()}async function BM(n){const e=await fetch("/api/workflow/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await Tr(e,"Failed to start workflow session");return e.json()}async function PM(n,e){const t=await fetch(`/api/workflow/${n}/respond`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:e})});if(!t.ok)throw await Tr(t,"Failed to respond to workflow prompt");return t.json()}async function HM(n){const e=await fetch(`/api/workflow/${n}/abort`,{method:"POST"});if(!e.ok)throw await Tr(e,"Failed to abort workflow session");return e.json()}function zg(n){return n==="light"?"light":"dark"}function Yf(n,e,t){return e!=null&&e.includes(n)?n:(e==null?void 0:e[0])??t}/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const IM=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),XC=(...n)=>n.filter((e,t,i)=>!!e&&e.trim()!==""&&i.indexOf(e)===t).join(" ").trim();/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var UM={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const FM=E.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:l="",children:o,iconNode:a,...u},f)=>E.createElement("svg",{ref:f,...UM,width:e,height:e,stroke:n,strokeWidth:i?Number(t)*24/Number(e):t,className:XC("lucide",l),...u},[...a.map(([d,m])=>E.createElement(d,m)),...Array.isArray(o)?o:[o]]));/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const je=(n,e)=>{const t=E.forwardRef(({className:i,...l},o)=>E.createElement(FM,{ref:o,iconNode:e,className:XC(`lucide-${IM(n)}`,i),...l}));return t.displayName=`${n}`,t};/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const VM=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],qM=je("Activity",VM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const QM=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],$C=je("ArrowDown",QM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const XM=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],$M=je("ArrowLeftRight",XM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const GM=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],YM=je("ArrowRight",GM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const KM=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Hk=je("ArrowUpDown",KM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const WM=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],ZM=je("ArrowUp",WM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const JM=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],eD=je("Bug",JM);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tD=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],nD=je("Calendar",tD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iD=[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],GC=je("Camera",iD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rD=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Sr=je("Check",rD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lD=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],sD=je("ChevronDown",lD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oD=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ad=je("ChevronRight",oD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Ec=je("CircleAlert",aD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ik=je("CircleCheck",cD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const uD=[["path",{d:"M10.1 2.182a10 10 0 0 1 3.8 0",key:"5ilxe3"}],["path",{d:"M13.9 21.818a10 10 0 0 1-3.8 0",key:"11zvb9"}],["path",{d:"M17.609 3.721a10 10 0 0 1 2.69 2.7",key:"1iw5b2"}],["path",{d:"M2.182 13.9a10 10 0 0 1 0-3.8",key:"c0bmvh"}],["path",{d:"M20.279 17.609a10 10 0 0 1-2.7 2.69",key:"1ruxm7"}],["path",{d:"M21.818 10.1a10 10 0 0 1 0 3.8",key:"qkgqxc"}],["path",{d:"M3.721 6.391a10 10 0 0 1 2.7-2.69",key:"1mcia2"}],["path",{d:"M6.391 20.279a10 10 0 0 1-2.69-2.7",key:"1fvljs"}]],fD=je("CircleDashed",uD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],dD=je("CircleDot",hD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]],pD=je("CirclePause",mD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],xD=je("CirclePlay",gD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Uc=je("CircleX",yD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],vD=je("Clock",bD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wD=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Zn=je("Copy",wD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kD=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],YC=je("Download",kD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const SD=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],KC=je("ExternalLink",SD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const CD=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],OD=je("EyeOff",CD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const TD=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_0=je("Eye",TD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ND=[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]],AD=je("FastForward",ND);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ED=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],MD=je("FileCode2",ED);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const DD=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],L0=je("FileCode",DD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const RD=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m3.2 12.9-.9-.4",key:"1i3dj5"}],["path",{d:"m3.2 15.1-.9.4",key:"1fvgj0"}],["path",{d:"M4.677 21.5a2 2 0 0 0 1.313.5H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v2.5",key:"1yo3oz"}],["path",{d:"m4.9 11.2-.4-.9",key:"otmhb9"}],["path",{d:"m4.9 16.8-.4.9",key:"1b8z07"}],["path",{d:"m7.5 10.3-.4.9",key:"11k65u"}],["path",{d:"m7.5 17.7-.4-.9",key:"431x55"}],["path",{d:"m9.7 12.5-.9.4",key:"87sjan"}],["path",{d:"m9.7 15.5-.9-.4",key:"khqm91"}],["circle",{cx:"6",cy:"14",r:"3",key:"a1xfv6"}]],Qo=je("FileCog",RD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jD=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]],_D=je("FilePlus2",jD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const LD=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],sa=je("FileText",LD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zD=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],Bg=je("File",zD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const BD=[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]],PD=je("FlaskConical",BD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const HD=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Hl=je("FolderOpen",HD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ID=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],lu=je("Folder",ID);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const UD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],FD=je("Globe",UD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const VD=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Xo=je("Hash",VD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qD=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]],Ed=je("House",qD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const QD=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ty=je("Info",QD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const XD=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],WC=je("Keyboard",XD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $D=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],GD=je("Link2",$D);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const YD=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Yr=je("LoaderCircle",YD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const KD=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],WD=je("Lock",KD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ZD=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],JD=je("Moon",ZD);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const e4=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],t4=je("Network",e4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const n4=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Ul=je("Play",n4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const i4=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],r4=je("Plus",i4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const l4=[["rect",{width:"5",height:"5",x:"3",y:"3",rx:"1",key:"1tu5fj"}],["rect",{width:"5",height:"5",x:"16",y:"3",rx:"1",key:"1v8r4q"}],["rect",{width:"5",height:"5",x:"3",y:"16",rx:"1",key:"1x03jg"}],["path",{d:"M21 16h-3a2 2 0 0 0-2 2v3",key:"177gqh"}],["path",{d:"M21 21v.01",key:"ents32"}],["path",{d:"M12 7v3a2 2 0 0 1-2 2H7",key:"8crl2c"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M12 3h.01",key:"n36tog"}],["path",{d:"M12 16v.01",key:"133mhm"}],["path",{d:"M16 12h1",key:"1slzba"}],["path",{d:"M21 12v.01",key:"1lwtk9"}],["path",{d:"M12 21v-1",key:"1880an"}]],ny=je("QrCode",l4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const s4=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Md=je("RefreshCw",s4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const o4=[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]],a4=je("Rocket",o4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const c4=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],u4=je("RotateCcw",c4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const f4=[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]],h4=je("SaveAll",f4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const d4=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],ZC=je("Save",d4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m4=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],JC=je("Search",m4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const p4=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],g4=je("Settings",p4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const x4=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],y4=je("Sun",x4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const b4=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],eO=je("Terminal",b4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const v4=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],tO=je("Timer",v4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const w4=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],nO=je("Trash2",w4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const k4=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],iy=je("TriangleAlert",k4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const S4=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],C4=je("User",S4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const O4=[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]],iO=je("Webhook",O4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const T4=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],N4=je("Workflow",T4);/** + * @license lucide-react v0.477.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const A4=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],bi=je("X",A4);function E4({items:n,columnTemplate:e,resizePointerRef:t,resizeMovedRef:i}){return y.jsx("div",{className:"grid select-none items-center border-b border-l-2 border-l-transparent border-line/40 bg-surface/60 font-medium text-ink-muted shadow-sm backdrop-blur-md",role:"row","aria-rowindex":1,"data-file-list-header":!0,style:{gridTemplateColumns:e},children:n.map((l,o)=>{const a=!!(l.onSort&&l.sortKey),u=l.active?l.direction==="asc"?"ascending":"descending":"none";return y.jsxs("div",{role:"columnheader","data-column-key":l.sortKey,className:`group relative flex items-center gap-1.5 truncate px-3 py-2 ${a?"cursor-pointer hover:text-ink transition-colors":""} ${l.active?"text-ink":""}`,...a?{"aria-sort":u,tabIndex:0,onClick:l.onSort,onKeyDown:f=>{var d;(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),(d=l.onSort)==null||d.call(l))}}:{},children:[l.icon,y.jsx("span",{className:"truncate",children:l.label}),a?l.active?l.direction==="asc"?y.jsx(ZM,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx($C,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(Hk,{className:"ml-auto h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-40 hover:opacity-40"}):o>0&&y.jsx(Hk,{className:"ml-auto h-3 w-3 shrink-0 opacity-40"}),l.canResize&&l.onResizeBy&&y.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":`Resize ${l.label} column`,"aria-valuemin":$o,"aria-valuemax":Xh,"aria-valuenow":l.width??l.defaultWidth??Dh,"aria-valuetext":`${l.width??l.defaultWidth??Dh} pixels wide`,title:"Drag to resize; use arrow keys or click either side to adjust",tabIndex:0,onClick:f=>{var g;f.preventDefault(),f.stopPropagation();const d=i.current;if(i.current=!1,d)return;const m=f.currentTarget.getBoundingClientRect();(g=l.onResizeBy)==null||g.call(l,f.clientX{f.preventDefault(),f.stopPropagation();const d=f.currentTarget.parentElement;i.current=!1,t.current={pointerId:f.pointerId,startX:f.clientX,startWidth:l.width??(d==null?void 0:d.getBoundingClientRect().width)??l.defaultWidth??Dh,resizeTo:l.onResizeTo},f.currentTarget.setPointerCapture(f.pointerId)},onPointerMove:f=>{const d=t.current;if(!d||d.pointerId!==f.pointerId)return;const m=f.clientX-d.startX;Math.abs(m)>2&&(i.current=!0),d.resizeTo(d.startWidth+m)},onPointerUp:f=>{var d;((d=t.current)==null?void 0:d.pointerId)===f.pointerId&&(f.currentTarget.releasePointerCapture(f.pointerId),t.current=null,window.setTimeout(()=>{i.current=!1},0))},onPointerCancel:()=>{t.current=null,i.current=!1},onKeyDown:f=>{var d,m;f.stopPropagation(),f.key==="ArrowLeft"||f.key==="ArrowRight"?(f.preventDefault(),(d=l.onResizeBy)==null||d.call(l,f.key==="ArrowLeft"?-Wf:Wf)):(f.key==="Home"||f.key==="End")&&(f.preventDefault(),(m=l.onResizeTo)==null||m.call(l,f.key==="Home"?$o:Xh))},className:"absolute inset-y-0 right-0 z-10 w-3 cursor-col-resize touch-none border-r border-transparent transition-colors hover:border-indigo-400 focus-visible:border-indigo-400 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500"})]},o)})})}const Qi=28,Kf=12,Uk=500,$o=80,Xh=960,Dh=160,Wf=24,Fk=44,Zf={File:2,Path:3,FileName:1,Type:1,Version:1};function M4({files:n,totalCount:e,rawLoadedCount:t,onLoadMore:i,loadingMore:l=!1,scanning:o=!1,hasScanned:a=!1,activeDirectory:u="",recursive:f=!1,onDisableRecursive:d,onOpenDirectory:m,onLoadConfig:g,filterText:b,onClearFilter:v,prefilterNote:w,columnHeaders:S,columnNames:C,selectedIndex:O,onSelectIndex:_,onLaunch:M,onContextMenu:H,rowColors:B,sort:D,onSortChange:R}){const P=["File"],te=C.length>0?C:P,I=S.length>0?S:te,F=Array.from({length:Math.max(te.length,I.length)},(Ce,Fe)=>({key:te[Fe]??P[0],header:I[Fe]??te[Fe]??P[0]})),A=E.useRef(null),[ne,ae]=E.useState(0),[ie,$]=E.useState(600),[oe,Z]=E.useState(0),[Y,N]=E.useState({}),he=E.useRef(null),ye=E.useRef(!1),z=te.reduce((Ce,Fe)=>Ce+(Zf[Fe]??1),1),j=(Ce,Fe)=>{const qe=Math.min(Xh,Math.max($o,Math.round(Fe)));N(at=>({...at,[Ce]:qe}))},q=(Ce,Fe)=>{var ee;const qe=Array.from(((ee=A.current)==null?void 0:ee.querySelectorAll("[data-column-key]"))??[]).find(fe=>fe.dataset.columnKey===Ce),at=Y[Ce]??(qe==null?void 0:qe.getBoundingClientRect().width)??Dh;j(Ce,at+Fe)},ue=[`${Fk}px`,...te.map(Ce=>Y[Ce]?`${Y[Ce]}px`:`minmax(${$o}px, ${Zf[Ce]??1}fr)`)].join(" "),pe=E.useRef(!1),De=E.useRef(null),Te=n.length,Pe=t??Te,ve=e??Pe,Ee=Pe{const Ce=A.current;if(!Ce)return;const Fe=new ResizeObserver(qe=>{for(const at of qe)$(at.contentRect.height),Z(at.contentRect.width)});return Fe.observe(Ce),$(Ce.clientHeight||600),Z(Ce.clientWidth||0),()=>Fe.disconnect()},[]),E.useEffect(()=>{var fe;const Ce=A.current;if(!Ce||O<0||O>=Te)return;const Fe=((fe=Ce.querySelector("[data-file-list-header]"))==null?void 0:fe.offsetHeight)??0,qe=Fe+O*Qi,at=qe+Qi;let ee=Ce.scrollTop;qeCe.scrollTop+Ce.clientHeight&&(ee=at-Ce.clientHeight),ee!==Ce.scrollTop&&(Ce.scrollTop=ee,ae(ee))},[O,Te]),E.useEffect(()=>{const Ce=A.current;if(!Ce)return;const Fe=()=>{if(pe.current||!Ut||!i)return;const qe=Ce.scrollTop+Ce.clientHeight,at=Te*Qi;at-qeqe&&(pe.current=!0,window.setTimeout(()=>{pe.current=!1},200),i())};return Ce.addEventListener("scroll",Fe,{passive:!0}),window.addEventListener("scroll",Fe,{passive:!0}),()=>{Ce.removeEventListener("scroll",Fe),window.removeEventListener("scroll",Fe)}},[n,Ut,i,Te]),E.useEffect(()=>{if(pe.current||!Ut||!i)return;const Ce=Te*Qi,Fe=ne+ie;if(!(Ce-FeFe))return;const at=`${Te}:${Pe}:${ve}`;De.current=at,i()});const Ft=E.useCallback(Ce=>{ae(Ce.currentTarget.scrollTop)},[]),zt=Math.max(0,Math.floor(ne/Qi)-Kf),gt=Math.ceil(ie/Qi)+Kf*2,$e=Math.min(Te,zt+gt),Xt=zt*Qi,Nn=(Ce,Fe)=>{if(Fe)return{className:"bg-chip-indigo-bg border-l-4 border-chip-indigo-border text-ink",style:{}};for(const[qe,at]of B)if(Ce.toLowerCase().includes(qe.toLowerCase()))return{className:"hover:bg-elevated border-l-4 text-ink",style:{borderLeftColor:at,borderLeftWidth:"4px"}};return{className:"border-l-4 border-transparent text-ink-secondary hover:bg-elevated/60",style:{borderLeftColor:"transparent",borderLeftWidth:"4px"}}},en=(Ut?Te+gt:Te)*Qi,tn="btn btn-secondary px-3 py-1.5";return y.jsxs("div",{ref:A,onScroll:Ft,className:"flex-1 overflow-auto bg-app text-xs transition-colors duration-200 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 focus-visible:outline-offset-[-2px]","data-testid":"file-list","data-loaded-count":Pe,"aria-busy":o,role:"grid","aria-label":"Discovered files","aria-rowcount":Math.max(ve,Te===0?1:0)+1,"aria-colcount":te.length+1,"aria-activedescendant":Te>0?`file-row-${O}`:void 0,tabIndex:0,children:[y.jsx("div",{className:"sticky top-0 z-10",role:"presentation",children:y.jsx(E4,{columnTemplate:ue,resizePointerRef:he,resizeMovedRef:ye,items:[{label:"#",icon:y.jsx(L0,{className:"h-3.5 w-3.5"})},...F.map(({key:Ce,header:Fe})=>({label:Fe,weight:Zf[Ce]??1,width:Y[Ce],defaultWidth:Math.min(Xh,Math.max($o,Math.round((oe-Fk)*(Zf[Ce]??1)/z))),canResize:!0,onResizeBy:qe=>q(Ce,qe),onResizeTo:qe=>j(Ce,qe),sortKey:Ce,active:(D==null?void 0:D.column)===Ce,direction:D==null?void 0:D.direction,onSort:()=>{(D==null?void 0:D.column)!==Ce?R({column:Ce,direction:"asc"}):D.direction==="asc"?R({column:Ce,direction:"desc"}):R(null)}}))]})}),w&&Te>0&&y.jsxs("div",{role:"note","data-testid":"prefilter-note",className:"flex items-center gap-1.5 border-b border-line/40 bg-surface px-3 py-1 text-[11px] text-ink-faint",children:[y.jsx(ty,{className:"h-3 w-3 shrink-0 text-ink-faint","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 truncate",children:w})]}),Te===0?y.jsx("div",{role:"row","aria-rowindex":2,"data-testid":"file-list-empty",children:y.jsx("div",{role:"gridcell","aria-colspan":te.length+1,className:"p-8 text-center text-ink-faint",children:o?y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx(Yr,{className:"h-5 w-5 animate-spin text-chip-indigo-text motion-reduce:animate-none"}),y.jsx("span",{children:"Scanning files..."})]}):!u.trim()&&g?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"Select a directory first."}),y.jsx("button",{type:"button",onClick:g,className:tn,children:"Choose configuration"})]}):a?b.trim()?y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsxs("span",{children:["No files match “",b,"”."]}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[y.jsx("button",{type:"button",onClick:v,className:tn,children:"Clear filter"}),f&&d&&y.jsx("button",{type:"button",onClick:d,className:tn,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:tn,children:"Open directory"})]})]}):y.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y.jsx("span",{children:"No files found for the current directory and extension."}),y.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[f&&d&&y.jsx("button",{type:"button",onClick:d,className:tn,children:"Turn off recursive"}),m&&y.jsx("button",{type:"button",onClick:m,className:tn,children:"Open directory"})]})]}):y.jsx("span",{children:"Select a directory and scan to find files."})})}):y.jsxs("div",{className:"relative",style:{height:en},role:"rowgroup",children:[l&&y.jsx("div",{className:"pointer-events-none absolute left-1/2 top-2 z-20 -translate-x-1/2","aria-hidden":"true",children:y.jsx(Yr,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})}),y.jsx("div",{style:{transform:`translateY(${Xt}px)`},"data-testid":"file-list-window",role:"presentation",children:n.slice(zt,$e).map((Ce,Fe)=>{const qe=zt+Fe,at=qe===O,ee=Nn(Ce.filename,at);return y.jsxs("div",{id:`file-row-${qe}`,"data-row-index":qe,role:"row","aria-rowindex":qe+2,"aria-selected":at,onClick:()=>{var fe;_(qe),(fe=A.current)==null||fe.focus()},onDoubleClick:()=>M(Ce),onContextMenu:fe=>H(fe,Ce,qe),className:`grid cursor-pointer items-center transition-colors ${ee.className}`,style:{...ee.style,height:Qi,gridTemplateColumns:ue},children:[y.jsxs("div",{className:"flex items-center justify-end gap-1 px-3 font-mono text-ink-faint",children:[Ce.has_hook&&y.jsx("span",{title:Ce.hook_pattern?`Launch workflow: ${Ce.hook_pattern}`:"Launch workflow configured","aria-label":"Workflow hook attached",className:"inline-flex items-center text-status-warning-text hover:brightness-95",children:y.jsx(iO,{className:"h-3 w-3 shrink-0"})}),y.jsx("span",{className:"hidden sm:inline",children:qe+1})]}),te.map((fe,_e)=>{const ze=Ce.column_values[fe]||(fe==="File"?Ce.filename:"-");return y.jsx("div",{role:"gridcell","data-column-key":fe,className:"truncate px-3 font-mono",style:{minWidth:$o},title:fe==="Path"?Ce.path:ze,children:ze},_e)})]},Ce.path||qe)})}),Ee&&y.jsxs("div",{className:"pointer-events-none absolute bottom-2 left-1/2 -translate-x-1/2 rounded-full border border-line bg-surface-strong px-3 py-1 text-[11px] text-ink-muted shadow","data-testid":"file-list-paging",children:[l?y.jsx($M,{className:"mr-1.5 h-4 w-4 animate-spin motion-reduce:animate-none text-ink-muted"}):null,"(",Pe," of ",ve," loaded)"]})]})]})}const D4=800;function R4(n){const[e,t]=E.useState([]),[i,l]=E.useState(0),[o,a]=E.useState(!1),[u,f]=E.useState(!1),[d,m]=E.useState(null),[g,b]=E.useState(!1),v=E.useRef(0),w=E.useRef(null),S=E.useRef(null),C=E.useRef(n);E.useEffect(()=>{C.current=n}),E.useEffect(()=>()=>{var A;S.current&&(clearTimeout(S.current),S.current=null),(A=w.current)==null||A.abort()},[]);const O=()=>{var A;return(A=w.current)==null||A.abort(),w.current=new AbortController,++v.current},_=()=>{S.current&&(clearTimeout(S.current),S.current=null);const A=O();return b(!0),f(!1),A},M=A=>A===v.current,H=A=>{M(A)&&b(!1)},B=async(A,ne=d)=>{var ie;const ae=await Lk({offset:0,limit:Uk,sort_by:ne==null?void 0:ne.column,sort_dir:ne==null?void 0:ne.direction,signal:(ie=w.current)==null?void 0:ie.signal});return M(A)?(t(ae.items),l(ae.count),a(!0),ae):null},D=async(A,ne)=>{var ie;if(!M(A))return!1;const ae=await _k(ne,(ie=w.current)==null?void 0:ie.signal);return ae.warning&&M(A)&&C.current.showToast(ae.warning,"error"),!M(A)||!await B(A)?!1:(C.current.onFreshResults(),!0)},R=async(A,ne,ae)=>{var ie;if(!ne.directory)return{ok:!1};try{const $=await _k(ne,(ie=w.current)==null?void 0:ie.signal);$.warning&&M(A)&&C.current.showToast($.warning,"error");const oe=await B(A);return oe?(C.current.onFreshResults(),{ok:!0,firstPage:{items:oe.items,count:oe.count}}):{ok:!1}}catch($){if(M(A)){const oe=(ae==null?void 0:ae.errorPrefix)??"Scan failed";C.current.showToast(`${oe}: ${($==null?void 0:$.message)??String($)}`,"error")}return{ok:!1}}finally{H(A)}},P=async(A,ne)=>{if(!A.directory)return{ok:!1};const ae=_();return R(ae,A,ne)};return{files:e,totalCount:i,hasScanned:o,loadingMore:u,scanning:g,sort:d,beginScan:_,claimGeneration:O,isCurrentScan:M,finishScan:H,runScan:D,scanWith:P,scanWithGeneration:R,applySort:A=>{m(A),C.current.onFreshResults();const ne=_();B(ne,A).catch(ae=>{M(ne)&&C.current.showToast(`Sort failed: ${(ae==null?void 0:ae.message)??String(ae)}`,"error")}).finally(()=>H(ne))},handleLoadMore:async()=>{if(u||e.length>=i)return;const A=v.current;f(!0);try{const ne=await Lk({offset:e.length,limit:Uk,sort_by:d==null?void 0:d.column,sort_dir:d==null?void 0:d.direction});if(!M(A))return;const ae=new Set(e.map(ie=>ie.path||ie.filename));t(ie=>[...ie,...ne.items.filter($=>!ae.has($.path||$.filename))]),l(ne.count)}catch{C.current.showToast("Couldn't load more results — scroll to try again.","error")}finally{M(A)&&f(!1)}},scheduleDeferredRescan:()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{S.current=null,P(C.current.getScanParams())},D4)}}}function j4(){const[n,e]=E.useState(null),t=E.useRef(null);return{toastMessage:n,showToast:(o,a="info")=>{o&&(e({message:o,kind:a}),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>e(null),a==="error"?1e4:3500))},dismissToast:()=>{t.current&&clearTimeout(t.current),e(null)}}}const _4=4e3;function L4(n){const e=E.useRef(0),t=E.useRef(n);E.useEffect(()=>{t.current=n}),E.useEffect(()=>{const i=async()=>{let o=[];try{o=(await vM(e.current)).events}catch{return}for(const a of o){if(e.current=Math.max(e.current,a.id),a.config_applied)try{await t.current.onConfigApplied()}catch{}t.current.showToast(a.message)}},l=setInterval(()=>void i(),_4);return()=>clearInterval(l)},[])}const Vk=20;function z4(n){E.useEffect(()=>{const e=n,t=i=>{var o,a,u,f;if(i.key==="Escape"){e.onEscape();return}if(e.anyModalOpen)return;if(i.ctrlKey&&!i.shiftKey&&i.key.toLowerCase()==="l"){i.preventDefault(),(o=document.querySelector("[data-testid='file-list']"))==null||o.focus();return}const l=i.target;if(!(l instanceof HTMLElement&&l.closest("button, a, [role='menuitem'], [role='option'], [role='columnheader'], [role='separator']"))){if(l instanceof HTMLInputElement||l instanceof HTMLSelectElement){i.key==="Enter"&&e.onScan();return}if(i.key==="ContextMenu"||i.shiftKey&&i.key==="F10"){const d=e.visibleFiles[e.selectedIndex];if(!d)return;i.preventDefault();const m=document.querySelector(`[data-row-index="${e.selectedIndex}"]`),g=m==null?void 0:m.getBoundingClientRect();e.onContextMenu({x:g?g.left+24:24,y:g?g.top+g.height/2:24,file:d});return}if(i.key==="F5"){i.preventDefault(),e.onScan();return}if(i.ctrlKey&&i.key.toLowerCase()==="r"){i.preventDefault(),e.onReloadConfig();return}if(i.ctrlKey&&i.key.toLowerCase()==="d"){i.preventDefault(),(a=document.querySelector("#directory-combobox"))==null||a.focus();return}if(i.ctrlKey&&i.key.toLowerCase()==="e"){i.preventDefault(),(u=document.querySelector("#extension-combobox"))==null||u.focus();return}if(i.ctrlKey&&i.key.toLowerCase()==="f"){i.preventDefault(),(f=document.querySelector("#filter-combobox"))==null||f.focus();return}if(i.ctrlKey&&i.shiftKey&&i.key.toLowerCase()==="l"){i.preventDefault(),e.setShowLogViewer(d=>!d);return}if(i.ctrlKey&&i.key===","){i.preventDefault(),e.setShowConfigEditor(!0);return}if(i.ctrlKey&&i.shiftKey&&i.key.toLowerCase()==="t"){i.preventDefault(),e.onToggleTheme();return}if(i.ctrlKey&&!i.shiftKey&&i.key.toLowerCase()==="b"){i.preventDefault(),e.setBarcodeMode(d=>!d);return}if(i.ctrlKey&&i.shiftKey&&i.key.toLowerCase()==="b"){i.preventDefault(),e.setShowCameraScanner(d=>!d);return}if(i.ctrlKey&&!i.shiftKey&&i.key.toLowerCase()==="t"){i.preventDefault(),e.setShowTimerModal(!0);return}if(i.ctrlKey&&!i.shiftKey&&i.key.toLowerCase()==="h"){i.preventDefault(),e.onGoHome();return}if(i.key==="?"||i.ctrlKey&&i.key==="/"){i.preventDefault(),e.setShowShortcuts(d=>!d);return}if(i.key.toLowerCase()==="p"&&!i.ctrlKey&&!i.shiftKey&&!i.altKey){const d=e.visibleFiles[e.selectedIndex];d&&(i.preventDefault(),e.onProperties(d));return}i.key==="ArrowDown"?(i.preventDefault(),e.moveSelection((d,m)=>Math.min(d+1,Math.max(0,m-1)))):i.key==="ArrowUp"?(i.preventDefault(),e.moveSelection(d=>Math.max(d-1,0))):i.key==="Home"?(i.preventDefault(),e.moveSelection(d=>d===0?d:0)):i.key==="End"?(i.preventDefault(),e.moveSelection((d,m)=>{const g=Math.max(0,m-1);return d===g?d:g})):i.key==="PageUp"?(i.preventDefault(),e.moveSelection(d=>Math.max(d-Vk,0))):i.key==="PageDown"?(i.preventDefault(),e.moveSelection((d,m)=>Math.min(d+Vk,Math.max(0,m-1)))):i.key==="Enter"&&(i.preventDefault(),e.onExecute())}};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[n.anyModalOpen,n.visibleFiles,n.selectedIndex,n.activeDirectory,n.activeExtension,n.filterText,n.recursive,n.barcodeMode])}function B4(n){const[e,t]=E.useState(0),i=E.useRef(null),l=E.useRef(n);return E.useEffect(()=>{l.current=n}),E.useEffect(()=>(e>0&&(i.current=setInterval(()=>{l.current.scan()},e*1e3)),()=>{i.current&&(clearInterval(i.current),i.current=null)}),[e]),{autoRescanInterval:e,handleTimerSet:a=>{t(a),a>0?l.current.showToast(`Auto-rescan every ${a}s.`):l.current.showToast("Auto-rescan disabled.")}}}function P4(n){return n.scan===!0||n.filter!==void 0||n.ext!==void 0||n.recursive!==void 0||n.dir!==void 0}const H4=";",qk="=";function I4(n){const e=n.trim().toLowerCase();return e==="extension"||e==="file_ext"||e==="filetype"?"ext":e==="directory"||e==="path"||e==="folder"?"dir":e==="recurse"||e==="recursive_search"?"recursive":e==="filter_text"||e==="query"||e==="search"?"filter":e}function Qk(n){const e=n.trim();if(!e.includes(qk))return{values:{filter:e},isPlainFilter:!0};const t={};for(const i of e.split(H4)){const l=i.trim();if(!l)continue;const o=l.indexOf(qk);if(o===-1)continue;const a=I4(l.slice(0,o)),u=l.slice(o+1).trim();switch(a){case"filter":t.filter=u;break;case"ext":t.ext=u;break;case"recursive":t.recursive=Xk(u,!0);break;case"dir":t.dir=u;break;case"scan":t.scan=Xk(u,!1);break}}return{values:t,isPlainFilter:!1}}function Xk(n,e){const t=n.toLowerCase();return["0","false","no","off"].includes(t)?!1:["1","true","yes","on"].includes(t)?!0:e}function U4(n){const[e,t]=E.useState(!1),i=E.useRef(""),l=E.useRef(n);E.useEffect(()=>{l.current=n});const o=async f=>{n.onCameraClose(),n.showToast("Barcode detected!");const m=Qk(f).values,g=n.getScanParams(),b=m.dir!==void 0?m.dir:g.directory,v=m.ext!==void 0?m.ext:g.extension,w=m.filter!==void 0?m.filter:g.filter_text,S=m.recursive!==void 0?m.recursive:g.recursive;if(n.onApplyValues(m),b){const C=await n.scanWith({directory:b,extension:v,filter_text:w,recursive:S},{errorPrefix:"Scan error"});C.ok&&C.firstPage.count===1&&C.firstPage.items.length===1&&n.onSingleMatch(C.firstPage.items[0])}},a=()=>{t(f=>{const d=!f;return d?(i.current="",n.showToast("Barcode mode ON — scan a barcode now.")):(i.current="",n.showToast("Barcode mode OFF.")),d})},u=f=>{n.onApplyValues(f),P4(f)&&(t(!1),i.current="",setTimeout(()=>{l.current.scanWith(l.current.getScanParams(),{errorPrefix:"Scan failed"})},50))};return E.useEffect(()=>{if(!e)return;const f=n,d=m=>{const g=m.target;if(!(g instanceof HTMLElement&&(g.isContentEditable||g instanceof HTMLInputElement||g instanceof HTMLTextAreaElement||g instanceof HTMLSelectElement)))if(m.key==="Enter"){const v=i.current;if(!v){i.current="";return}m.preventDefault(),m.stopPropagation(),i.current="";const w=Qk(v);if(w.isPlainFilter)f.showToast(`Barcode filter: ${w.values.filter}`),f.setFilterText(w.values.filter||""),t(!1),setTimeout(()=>{l.current.scanWith(l.current.getScanParams(),{errorPrefix:"Scan failed"})},50);else{const S=w.values,C=Object.entries(S).map(([O,_])=>`${O}=${_}`).join(", ");f.showToast(`Barcode applied: ${C}`),u(S)}}else m.key==="Escape"?(t(!1),i.current="",f.showToast("Barcode mode cancelled.")):m.key.length===1&&!m.ctrlKey&&!m.metaKey&&!m.altKey&&(m.stopPropagation(),i.current+=m.key)};return document.addEventListener("keydown",d,!0),()=>document.removeEventListener("keydown",d,!0)},[e]),{barcodeMode:e,setBarcodeMode:t,handleBarcodeToggle:a,handleCameraDetected:o}}const rO="profiles-theme";function F4(){try{const n=localStorage.getItem(rO);return n==="dark"||n==="light"?n:"dark"}catch{return"dark"}}function V4(){const[n,e]=E.useState(F4),t=E.useRef(n);E.useEffect(()=>{t.current=n}),E.useEffect(()=>{document.documentElement.setAttribute("data-theme",n)},[n]);const i=(o,a)=>{if(e(o),a.persist)try{localStorage.setItem(rO,o)}catch{}};return{theme:n,applyTheme:i,toggleTheme:o=>{i(t.current==="dark"?"light":"dark",o)}}}const q4=[".profiles",".profiles.yaml",".profiles.yml",".yaml",".yml"];function Q4(n){const e=n.toLowerCase();return q4.some(t=>e.endsWith(t))}function X4(n){for(const e of n)if(Q4(e.name))return e;return null}function Rh(){return{depth:0,overlayVisible:!1}}function $k(n,e,t){switch(e){case"enter":return t?{depth:n.depth+1,overlayVisible:!0}:n;case"leave":{const i=Math.max(0,n.depth-1);return{depth:i,overlayVisible:n.depth>0&&i>0}}case"drop":return Rh()}}function $4(n){const[e,t]=E.useState(!1),i=E.useRef(Rh()),l=d=>{i.current=d,t(d.overlayVisible)},o=E.useRef(()=>{}),a=async d=>{try{const m=await d.text(),g=await VC(d.name,m);await n.onConfigLoaded(g),n.showToast(`Session config applied: ${d.name}`)}catch(m){n.showToast(m.message||"Failed to apply dropped configuration","error")}};return o.current=d=>{a(d)},E.useEffect(()=>{const d=n,m=S=>{var C;return Array.from(((C=S.dataTransfer)==null?void 0:C.types)??[]).includes("Files")},g=S=>{l($k(i.current,"enter",m(S)))},b=S=>{m(S)&&S.preventDefault()},v=S=>{l($k(i.current,"leave",m(S)))},w=S=>{var _;S.preventDefault(),l(Rh());const C=Array.from(((_=S.dataTransfer)==null?void 0:_.files)??[]),O=X4(C);if(!O){C.length>0&&d.showToast("Not a ProFiles configuration file.","error");return}o.current(O)};return window.addEventListener("dragenter",g),window.addEventListener("dragover",b),window.addEventListener("dragleave",v),window.addEventListener("drop",w),()=>{window.removeEventListener("dragenter",g),window.removeEventListener("dragover",b),window.removeEventListener("dragleave",v),window.removeEventListener("drop",w)}},[]),{dropOverlayVisible:e,resetDrop:()=>{l(Rh())},applyConfigFile:d=>{a(d)}}}function G4(n){if(n<60)return`${n}s`;const e=Math.floor(n/60),t=n%60;return`${e}m${t.toString().padStart(2,"0")}s`}function Y4(n){if(!n)return{label:"",cut:!1};const e=n.replace(/\\/g,"/").split("/").filter(Boolean);return e.length===0?{label:n,cut:!1}:{label:e[e.length-1],cut:e.length>1}}function K4({directory:n}){const[e,t]=E.useState(0);E.useEffect(()=>{t(0);const o=window.setInterval(()=>{t(a=>a+1)},1e3);return()=>window.clearInterval(o)},[]);const{label:i,cut:l}=Y4(n);return y.jsxs("div",{"data-testid":"scan-status-strip",className:"flex min-w-0 items-center gap-1.5 text-[11px] text-ink-muted",children:[y.jsx(Yr,{className:"h-3 w-3 shrink-0 animate-spin text-chip-indigo-text motion-reduce:animate-none","aria-hidden":"true"}),y.jsxs("span",{className:"min-w-0 truncate",children:["Scanning",n&&y.jsxs(y.Fragment,{children:[" ",y.jsxs("span",{className:"font-mono text-ink-secondary",title:n,children:[l?"…/":"",i]})]})," — ",y.jsx("span",{className:"font-mono tabular-nums text-ink-secondary",children:G4(e)})]})]})}function W4({onExecute:n,scanning:e,hasSelection:t,fileCount:i,totalCount:l,scanningDirectory:o="",toastMessage:a,onToastDismiss:u}){const f=(a==null?void 0:a.kind)==="error";return y.jsxs("div",{className:"relative flex items-center justify-between border-t border-line bg-surface-glass px-4 py-2.5 text-xs transition-colors duration-200",children:[a&&y.jsx("div",{role:"status","aria-live":f?"assertive":"polite","aria-atomic":"true",className:`animate-toast-in absolute left-1/2 top-1/2 z-[var(--z-toast)] max-w-[min(80vw,640px)] -translate-x-1/2 -translate-y-1/2 rounded-xl border px-4 py-2 text-xs font-medium glass-panel-strong ${f?"pointer-events-auto flex max-w-[min(70vw,560px)] items-center gap-2.5 border-status-danger-border text-left text-ink":"pointer-events-none max-w-[min(70vw,560px)] text-center text-ink"}`,children:f?y.jsxs(y.Fragment,{children:[y.jsx(Uc,{className:"h-3.5 w-3.5 shrink-0 text-status-danger-text/80","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 flex-1",children:a.message}),u&&y.jsx("button",{type:"button",onClick:u,"aria-label":"Dismiss error",className:"shrink-0 rounded-md p-0.5 text-status-danger-text/60 hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-status-danger-border transition-colors",children:y.jsx(bi,{className:"h-3.5 w-3.5"})})]}):a.message}),y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e&&y.jsx(K4,{directory:o}),l!==void 0&&l!==i&&y.jsxs("span",{"data-testid":"action-bar-count",className:"text-ink-muted",children:["Showing ",i," of ",l]})]}),y.jsxs("button",{onClick:n,disabled:!t||e,className:"flex shrink-0 items-center gap-2 rounded-xl border border-emerald-300/50 bg-gradient-to-b from-emerald-400/90 to-emerald-600/90 px-5 py-2 font-semibold text-white shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] transition-[filter,box-shadow,transform] hover:-translate-y-px hover:brightness-110 hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_12px_30px_-6px_rgb(16_185_129/0.7)] disabled:opacity-40 disabled:hover:translate-y-0 disabled:hover:brightness-100 disabled:hover:shadow-[inset_0_1px_0_rgb(255_255_255/0.35),0_8px_24px_-6px_rgb(16_185_129/0.55)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-400",children:[y.jsx(Ul,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:"Execute"}),y.jsx("kbd",{className:"rounded bg-emerald-800/60 px-1.5 py-0.5 text-[10px] text-emerald-200 shadow-[inset_0_1px_0_rgb(255_255_255/0.12)]",children:"↵"})]})]})}let z0=[],lO=[];(()=>{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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e>1;if(n=lO[i])e=i+1;else return!0;if(e==t)return!1}}function Gk(n){return n>=127462&&n<=127487}const Yk=8205;function J4(n,e,t=!0,i=!0){return(t?sO:eR)(n,e,i)}function sO(n,e,t){if(e==n.length)return e;e&&oO(n.charCodeAt(e))&&aO(n.charCodeAt(e-1))&&e--;let i=Pg(n,e);for(e+=Kk(i);e=0&&Gk(Pg(n,a));)o++,a-=2;if(o%2==0)break;e+=2}else break}return e}function eR(n,e,t){for(;e>1;){let i=sO(n,e-2,t);if(i=56320&&n<57344}function aO(n){return n>=55296&&n<56320}function Kk(n){return n<65536?1:2}class ot{lineAt(e){if(e<0||e>this.length)throw new 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 new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=oa(this,e,t);let l=[];return this.decompose(0,e,l,2),i.length&&i.decompose(0,i.length,l,3),this.decompose(t,this.length,l,1),xr.from(l,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=oa(this,e,t);let i=[];return this.decompose(e,t,i,0),xr.from(i,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),i=this.length-this.scanIdentical(e,-1),l=new Mc(this),o=new Mc(e);for(let a=t,u=t;;){if(l.next(a),o.next(a),a=0,l.lineBreak!=o.lineBreak||l.done!=o.done||l.value!=o.value)return!1;if(u+=l.value.length,l.done||u>=i)return!0}}iter(e=1){return new Mc(this,e)}iterRange(e,t=this.length){return new cO(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let l=this.line(e).from;i=this.iterRange(l,Math.max(l,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new uO(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?ot.empty:e.length<=32?new qt(e):xr.from(qt.split(e,[]))}}class qt extends ot{constructor(e,t=tR(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.text[o],u=l+a.length;if((t?i:u)>=e)return new nR(l,u,i,a);l=u+1,i++}}decompose(e,t,i,l){let o=e<=0&&t>=this.length?this:new qt(Wk(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let a=i.pop(),u=jh(o.text,a.text.slice(),0,o.length);if(u.length<=32)i.push(new qt(u,a.length+o.length));else{let f=u.length>>1;i.push(new qt(u.slice(0,f)),new qt(u.slice(f)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof qt))return super.replace(e,t,i);[e,t]=oa(this,e,t);let l=jh(this.text,jh(i.text,Wk(this.text,0,e)),t),o=this.length+i.length-(t-e);return l.length<=32?new qt(l,o):xr.from(qt.split(l,[]),o)}sliceString(e,t=this.length,i=` +`){[e,t]=oa(this,e,t);let l="";for(let o=0,a=0;o<=t&&ae&&a&&(l+=i),eo&&(l+=u.slice(Math.max(0,e-o),t-o)),o=f+1}return l}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],l=-1;for(let o of e)i.push(o),l+=o.length+1,i.length==32&&(t.push(new qt(i,l)),i=[],l=-1);return l>-1&&t.push(new qt(i,l)),t}}class xr extends ot{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,l){for(let o=0;;o++){let a=this.children[o],u=l+a.length,f=i+a.lines-1;if((t?f:u)>=e)return a.lineInner(e,t,i,l);l=u+1,i=f+1}}decompose(e,t,i,l){for(let o=0,a=0;a<=t&&o=a){let d=l&((a<=e?1:0)|(f>=t?2:0));a>=e&&f<=t&&!d?i.push(u):u.decompose(e-a,t-a,i,d)}a=f+1}}replace(e,t,i){if([e,t]=oa(this,e,t),i.lines=o&&t<=u){let f=a.replace(e-o,t-o,i),d=this.lines-a.lines+f.lines;if(f.lines>4&&f.lines>d>>6){let m=this.children.slice();return m[l]=f,new xr(m,this.length-(t-e)+i.length)}return super.replace(o,u,f)}o=u+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` +`){[e,t]=oa(this,e,t);let l="";for(let o=0,a=0;oe&&o&&(l+=i),ea&&(l+=u.sliceString(e-a,t-a,i)),a=f+1}return l}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof xr))return 0;let i=0,[l,o,a,u]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;l+=t,o+=t){if(l==a||o==u)return i;let f=this.children[l],d=e.children[o];if(f!=d)return i+f.scanIdentical(d,t);i+=f.length+1}}static from(e,t=e.reduce((i,l)=>i+l.length+1,-1)){let i=0;for(let v of e)i+=v.lines;if(i<32){let v=[];for(let w of e)w.flatten(v);return new qt(v,t)}let l=Math.max(32,i>>5),o=l<<1,a=l>>1,u=[],f=0,d=-1,m=[];function g(v){let w;if(v.lines>o&&v instanceof xr)for(let S of v.children)g(S);else v.lines>a&&(f>a||!f)?(b(),u.push(v)):v instanceof qt&&f&&(w=m[m.length-1])instanceof qt&&v.lines+w.lines<=32?(f+=v.lines,d+=v.length+1,m[m.length-1]=new qt(w.text.concat(v.text),w.length+1+v.length)):(f+v.lines>l&&b(),f+=v.lines,d+=v.length+1,m.push(v))}function b(){f!=0&&(u.push(m.length==1?m[0]:xr.from(m,d)),d=-1,f=m.length=0)}for(let v of e)g(v);return b(),u.length==1?u[0]:new xr(u,t)}}ot.empty=new qt([""],0);function tR(n){let e=-1;for(let t of n)e+=t.length+1;return e}function jh(n,e,t=0,i=1e9){for(let l=0,o=0,a=!0;o=t&&(f>i&&(u=u.slice(0,i-l)),l0?1:(e instanceof qt?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,l=this.nodes[i],o=this.offsets[i],a=o>>1,u=l instanceof qt?l.text.length:l.children.length;if(a==(t>0?u:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(l instanceof qt){let f=l.text[a+(t<0?-1:0)];if(this.offsets[i]+=t,f.length>Math.max(0,e))return this.value=e==0?f:t>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=l.children[a+(t<0?-1:0)];e>f.length?(e-=f.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(f),this.offsets.push(t>0?1:(f instanceof qt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class cO{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Mc(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}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 i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:l}=this.cursor.next(e);return this.pos+=(l.length+e)*t,this.value=l.length<=i?l:t<0?l.slice(l.length-i):l.slice(0,i),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!=""}}class uO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:l}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=l,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(ot.prototype[Symbol.iterator]=function(){return this.iter()},Mc.prototype[Symbol.iterator]=cO.prototype[Symbol.iterator]=uO.prototype[Symbol.iterator]=function(){return this});class nR{constructor(e,t,i,l){this.from=e,this.to=t,this.number=i,this.text=l}get length(){return this.to-this.from}}function oa(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}function hn(n,e,t=!0,i=!0){return J4(n,e,t,i)}function iR(n){return n>=56320&&n<57344}function rR(n){return n>=55296&&n<56320}function Jn(n,e){let t=n.charCodeAt(e);if(!rR(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return iR(i)?(t-55296<<10)+(i-56320)+65536:t}function ry(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function yr(n){return n<65536?1:2}const B0=/\r\n?|\n/;var Fn=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(Fn||(Fn={}));class Cr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return o+(e-l);o+=u}else{if(i!=Fn.Simple&&d>=e&&(i==Fn.TrackDel&&le||i==Fn.TrackBefore&&le))return null;if(d>e||d==e&&t<0&&!u)return e==l||t<0?o:o+f;o+=f}l=d}if(e>l)throw new RangeError(`Position ${e} is out of range for changeset of length ${l}`);return o}touchesRange(e,t=e){for(let i=0,l=0;i=0&&l<=t&&u>=e)return lt?"cover":!0;l=u}return!1}toString(){let e="";for(let t=0;t=0?":"+l:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Cr(e)}static create(e){return new Cr(e)}}class ln extends Cr{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return P0(this,(t,i,l,o,a)=>e=e.replace(l,l+(i-t),a),!1),e}mapDesc(e,t=!1){return H0(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let l=0,o=0;l=0){t[l]=u,t[l+1]=a;let f=l>>1;for(;i.length0&&zl(i,t,o.text),o.forward(m),u+=m}let d=e[a++];for(;u>1].toJSON()))}return e}static of(e,t,i){let l=[],o=[],a=0,u=null;function f(m=!1){if(!m&&!l.length)return;ab||g<0||b>t)throw new RangeError(`Invalid change range ${g} to ${b} (in doc of length ${t})`);let w=v?typeof v=="string"?ot.of(v.split(i||B0)):v:ot.empty,S=w.length;if(g==b&&S==0)return;ga&&Mn(l,g-a,-1),Mn(l,b-g,S),zl(o,l,w),a=b}}return d(e),f(!u),u}static empty(e){return new ln(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let l=0;lu&&typeof a!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)t.push(o[0],0);else{for(;i.length=0&&t<=0&&t==n[l+1]?n[l]+=e:l>=0&&e==0&&n[l]==0?n[l+1]+=t:i?(n[l]+=e,n[l+1]+=t):n.push(e,t)}function zl(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||a==n.sections.length||n.sections[a+1]<0);)u=n.sections[a++],f=n.sections[a++];e(l,d,o,m,g),l=d,o=m}}}function H0(n,e,t,i=!1){let l=[],o=i?[]:null,a=new Fc(n),u=new Fc(e);for(let f=-1;;){if(a.done&&u.len||u.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&u.ins==-1){let d=Math.min(a.len,u.len);Mn(l,d,-1),a.forward(d),u.forward(d)}else if(u.ins>=0&&(a.ins<0||f==a.i||a.off==0&&(u.len=0&&f=0){let d=0,m=a.len;for(;m;)if(u.ins==-1){let g=Math.min(m,u.len);d+=g,m-=g,u.forward(g)}else if(u.ins==0&&u.lenf||a.ins>=0&&a.len>f)&&(u||i.length>d),o.forward2(f),a.forward(f)}}}}class Fc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?ot.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?ot.empty:t[i].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)}}class _l{constructor(e,t,i,l){this.from=e,this.to=t,this.flags=i,this.goalColumn=l}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(e,t=-1){let i,l;return this.empty?i=l=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),l=e.mapPos(this.to,-1)),i==this.from&&l==this.to?this:new _l(i,l,this.flags,this.goalColumn)}extend(e,t=e,i=0){if(e<=this.anchor&&t>=this.anchor)return re.range(e,t,void 0,void 0,i);let l=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return re.range(this.anchor,l,void 0,void 0,i)}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 new RangeError("Invalid JSON representation for SelectionRange");return re.range(e.anchor,e.head)}static create(e,t,i,l){return new _l(e,t,i,l)}}class re{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:re.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;ie.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new re(e.ranges.map(t=>_l.fromJSON(t)),e.main)}static single(e,t=e){return new re([re.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,l=0;ll.from-o.from),t=e.indexOf(i);for(let l=1;lo.head?re.range(f,u):re.range(u,f))}}return new re(e,t)}}function hO(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let ly=0;class Ne{constructor(e,t,i,l,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=l,this.id=ly++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ne(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:sy),!!e.static,e.enables)}of(e){return new _h([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _h(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new _h(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function sy(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class _h{constructor(e,t,i,l){this.dependencies=e,this.facet=t,this.type=i,this.value=l,this.id=ly++}dynamicSlot(e){var t;let i=this.value,l=this.facet.compareInput,o=this.id,a=e[o]>>1,u=this.type==2,f=!1,d=!1,m=[];for(let g of this.dependencies)g=="doc"?f=!0:g=="selection"?d=!0:(((t=e[g.id])!==null&&t!==void 0?t:1)&1)==0&&m.push(e[g.id]);return{create(g){return g.values[a]=i(g),1},update(g,b){if(f&&b.docChanged||d&&(b.docChanged||b.selection)||I0(g,m)){let v=i(g);if(u?!Zk(v,g.values[a],l):!l(v,g.values[a]))return g.values[a]=v,1}return 0},reconfigure:(g,b)=>{let v,w=b.config.address[o];if(w!=null){let S=Gh(b,w);if(this.dependencies.every(C=>C instanceof Ne?b.facet(C)===g.facet(C):C instanceof Rn?b.field(C,!1)==g.field(C,!1):!0)||(u?Zk(v=i(g),S,l):l(v=i(g),S)))return g.values[a]=S,0}else v=i(g);return g.values[a]=v,1}}}get extension(){return this}}function Zk(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[f.id]),l=t.map(f=>f.type),o=i.filter(f=>!(f&1)),a=n[e.id]>>1;function u(f){let d=[];for(let m=0;mi===l),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Jf).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,l)=>{let o=i.values[t],a=this.updateF(o,l);return this.compareF(o,a)?0:(i.values[t]=a,1)},reconfigure:(i,l)=>{let o=i.facet(Jf),a=l.facet(Jf),u;return(u=o.find(f=>f.field==this))&&u!=a.find(f=>f.field==this)?(i.values[t]=u.create(i),1):l.config.address[this.id]!=null?(i.values[t]=l.field(this),0):(i.values[t]=this.create(i),1)}}}init(e){return[this,Jf.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function gc(n){return e=>new dO(e,n)}const Fs={highest:gc(Ns.highest),high:gc(Ns.high),default:gc(Ns.default),low:gc(Ns.low),lowest:gc(Ns.lowest)};class dO{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class Dd{of(e){return new U0(this,e)}reconfigure(e){return Dd.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class U0{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}}class $h{constructor(e,t,i,l,o,a){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=l,this.staticValues=o,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let l=[],o=Object.create(null),a=new Map;for(let b of sR(e,t,a))b instanceof Rn?l.push(b):(o[b.facet.id]||(o[b.facet.id]=[])).push(b);let u=Object.create(null),f=[],d=[];for(let b of l)u[b.id]=d.length<<1,d.push(v=>b.slot(v));let m=i==null?void 0:i.config.facets;for(let b in o){let v=o[b],w=v[0].facet,S=m&&m[b]||[];if(v.every(C=>C.type==0))if(u[w.id]=f.length<<1|1,sy(S,v))f.push(i.facet(w));else{let C=w.combine(v.map(O=>O.value));f.push(i&&w.compare(C,i.facet(w))?i.facet(w):C)}else{for(let C of v)C.type==0?(u[C.id]=f.length<<1|1,f.push(C.value)):(u[C.id]=d.length<<1,d.push(O=>C.dynamicSlot(O)));u[w.id]=d.length<<1,d.push(C=>lR(C,w,v))}}let g=d.map(b=>b(u));return new $h(e,a,g,u,f,o)}}function sR(n,e,t){let i=[[],[],[],[],[]],l=new Map;function o(a,u){let f=l.get(a);if(f!=null){if(f<=u)return;let d=i[f].indexOf(a);d>-1&&i[f].splice(d,1),a instanceof U0&&t.delete(a.compartment)}if(l.set(a,u),Array.isArray(a))for(let d of a)o(d,u);else if(a instanceof U0){if(t.has(a.compartment))throw new RangeError("Duplicate use of compartment in extensions");let d=e.get(a.compartment)||a.inner;t.set(a.compartment,d),o(d,u)}else if(a instanceof dO)o(a.inner,a.prec);else if(a instanceof Rn)i[u].push(a),a.provides&&o(a.provides,u);else if(a instanceof _h)i[u].push(a),a.facet.extensions&&o(a.facet.extensions,Ns.default);else{let d=a.extension;if(!d)throw new Error(`Unrecognized extension value in extension set (${a}).`);if(d==a)throw new Error(`Unrecognized extension value in extension set (${a}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(d,u)}}return o(n,Ns.default),i.reduce((a,u)=>a.concat(u))}function Dc(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let l=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|l}function Gh(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const mO=Ne.define(),F0=Ne.define({combine:n=>n.some(e=>e),static:!0}),pO=Ne.define({combine:n=>n.length?n[0]:void 0,static:!0}),gO=Ne.define(),xO=Ne.define(),yO=Ne.define(),bO=Ne.define({combine:n=>n.length?n[0]:!1});class Jr{constructor(e,t){this.type=e,this.value=t}static define(){return new oR}}class oR{of(e){return new Jr(this,e)}}class aR{constructor(e){this.map=e}of(e){return new Ke(this,e)}}class Ke{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new Ke(this.type,t)}is(e){return this.type==e}static define(e={}){return new aR(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let l of e){let o=l.map(t);o&&i.push(o)}return i}}Ke.reconfigure=Ke.define();Ke.appendConfig=Ke.define();class sn{constructor(e,t,i,l,o,a){this.startState=e,this.changes=t,this.selection=i,this.effects=l,this.annotations=o,this.scrollIntoView=a,this._doc=null,this._state=null,i&&hO(i,t.newLength),o.some(u=>u.type==sn.time)||(this.annotations=o.concat(sn.time.of(Date.now())))}static create(e,t,i,l,o,a){return new sn(e,t,i,l,o,a)}get newDoc(){return this._doc||(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(e){let t=this.annotation(sn.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}sn.time=Jr.define();sn.userEvent=Jr.define();sn.addToHistory=Jr.define();sn.remote=Jr.define();function cR(n,e){let t=[];for(let i=0,l=0;;){let o,a;if(i=n[i]))o=n[i++],a=n[i++];else if(l=0;l--){let o=i[l](n);o instanceof sn?n=o:Array.isArray(o)&&o.length==1&&o[0]instanceof sn?n=o[0]:n=wO(e,Zo(o),!1)}return n}function fR(n){let e=n.startState,t=e.facet(yO),i=n;for(let l=t.length-1;l>=0;l--){let o=t[l](n);o&&Object.keys(o).length&&(i=vO(i,V0(e,o,n.changes.newLength),!0))}return i==n?n:sn.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const hR=[];function Zo(n){return n==null?hR:Array.isArray(n)?n:[n]}var _t=(function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n})(_t||(_t={}));const dR=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let q0;try{q0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function mR(n){if(q0)return q0.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||dR.test(t)))return!0}return!1}function pR(n){return e=>{if(!/\S/.test(e))return _t.Space;if(mR(e))return _t.Word;for(let t=0;t-1)return _t.Word;return _t.Other}}class ut{constructor(e,t,i,l,o,a){this.config=e,this.doc=t,this.selection=i,this.values=l,this.status=e.statusTemplate.slice(),this.computeSlot=o,a&&(a._state=this);for(let u=0;ul.set(d,f)),t=null),l.set(u.value.compartment,u.value.extension)):u.is(Ke.reconfigure)?(t=null,i=u.value):u.is(Ke.appendConfig)&&(t=null,i=Zo(i).concat(u.value));let o;t?o=e.startState.values.slice():(t=$h.resolve(i,l,this),o=new ut(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(f,d)=>d.reconfigure(f,this),null).values);let a=e.startState.facet(F0)?e.newSelection:e.newSelection.asSingle();new ut(t,e.newDoc,a,o,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:re.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),l=this.changes(i.changes),o=[i.range],a=Zo(i.effects);for(let u=1;ua.spec.fromJSON(u,f)))}}return ut.create({doc:e.doc,selection:re.fromJSON(e.selection),extensions:t.extensions?l.concat([t.extensions]):l})}static create(e={}){let t=$h.resolve(e.extensions||[],new Map),i=e.doc instanceof ot?e.doc:ot.of((e.doc||"").split(t.staticFacet(ut.lineSeparator)||B0)),l=e.selection?e.selection instanceof re?e.selection:re.single(e.selection.anchor,e.selection.head):re.single(0);return hO(l,i.length),t.staticFacet(F0)||(l=l.asSingle()),new ut(t,i,l,t.dynamicSlots.map(()=>null),(o,a)=>a.create(o),null)}get tabSize(){return this.facet(ut.tabSize)}get lineBreak(){return this.facet(ut.lineSeparator)||` +`}get readOnly(){return this.facet(bO)}phrase(e,...t){for(let i of this.facet(ut.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,l)=>{if(l=="$")return"$";let o=+(l||1);return!o||o>t.length?i:t[o-1]})),e}languageDataAt(e,t,i=-1){let l=[];for(let o of this.facet(mO))for(let a of o(this,t,i))Object.prototype.hasOwnProperty.call(a,e)&&l.push(a[e]);return l}charCategorizer(e){let t=this.languageDataAt("wordChars",e);return pR(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:l}=this.doc.lineAt(e),o=this.charCategorizer(e),a=e-i,u=e-i;for(;a>0;){let f=hn(t,a,!1);if(o(t.slice(f,a))!=_t.Word)break;a=f}for(;un.length?n[0]:4});ut.lineSeparator=pO;ut.readOnly=bO;ut.phrases=Ne.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(l=>n[l]==e[l])}});ut.languageData=mO;ut.changeFilter=gO;ut.transactionFilter=xO;ut.transactionExtender=yO;Dd.reconfigure=Ke.define();function Nr(n,e,t={}){let i={};for(let l of n)for(let o of Object.keys(l)){let a=l[o],u=i[o];if(u===void 0)i[o]=a;else if(!(u===a||a===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](u,a);else throw new Error("Config merge conflict for field "+o)}for(let l in e)i[l]===void 0&&(i[l]=e[l]);return i}class Fl{eq(e){return this==e}range(e,t=e){return Q0.create(e,t,this)}}Fl.prototype.startSide=Fl.prototype.endSide=0;Fl.prototype.point=!1;Fl.prototype.mapMode=Fn.TrackDel;function oy(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let Q0=class kO{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new kO(e,t,i)}};function X0(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class ay{constructor(e,t,i,l){this.from=e,this.to=t,this.value=i,this.maxPoint=l}get length(){return Ho(this.to)}findIndex(e,t,i,l=0){let o=i?this.to:this.from;for(let a=l,u=o.length;;){if(a==u)return a;let f=a+u>>1,d=o[f]-e||(i?this.value[f].endSide:this.value[f].startSide)-t;if(f==a)return d>=0?a:u;d>=0?u=f:a=f+1}}between(e,t,i,l){for(let o=this.findIndex(t,-1e9,!0),a=this.findIndex(i,1e9,!1,o);oC||S==C&&b.startSide>0&&b.endSide<=0)continue;if(!((C-S||b.endSide-b.startSide)<0))if(d<0&&(d=S),b.point&&(m=Math.max(m,C-S)),(S-i||b.startSide-l)>=0)a.push(b),u.push(S-d),f.push(C-d),i=C,l=b.endSide;else{if(S==C)for(let O=a.length;O>0;O--){if((S-(f[O-1]+d)||b.startSide-a[O-1].endSide)>=0){a.splice(O,0,b),u.splice(O,0,S-d),f.splice(O,0,C-d);continue e}if((S-(u[O-1]+d)||b.endSide-a[O-1].startSide)>0)break}o(S,C,b)}}return{mapped:a.length?new ay(u,f,a,m):null,pos:d}}}class it{constructor(e,t,i,l){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=l}static create(e,t,i,l){return new it(e,t,i,l)}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(e){let{add:t=[],sort:i=!1,filterFrom:l=0,filterTo:o=this.length}=e,a=e.filter;if(t.length==0&&!a)return this;if(i&&(t=t.slice().sort(X0)),this.isEmpty)return t.length?it.of(t):this;let u=new SO(this,null,-1).goto(0),f=0,d=[],m=new Or;for(;u.value||f=0){let g=t[f++];m.addInner(g.from,g.to,g.value,!1)||d.push(g)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||ou.to||o{o||(o=new Or),o.addRange(f,d,m,!1)};for(let f=0;f=o&&e<=o+a.length&&a.between(o,e-o,t-o,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Vc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Vc.from(e).goto(t)}static compare(e,t,i,l,o=-1){let a=e.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),u=t.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),f=Jk(a,u,i),d=new xc(a,f,o),m=new xc(u,f,o);i.iterGaps((g,b,v)=>eS(d,g,m,b,v,l)),i.empty&&i.length==0&&eS(d,0,m,0,0,l)}static eq(e,t,i=0,l){l==null&&(l=999999999);let o=e.filter(m=>!m.isEmpty&&t.indexOf(m)<0),a=t.filter(m=>!m.isEmpty&&e.indexOf(m)<0);if(o.length!=a.length)return!1;if(!o.length)return!0;let u=Jk(o,a),f=new xc(o,u,0).goto(i),d=new xc(a,u,0).goto(i);for(;;){if(f.to!=d.to||!$0(f.active,d.active)||f.point&&(!d.point||!oy(f.point,d.point)))return!1;if(f.to>l)return!0;f.next(),d.next()}}static spans(e,t,i,l,o=-1){let a=new xc(e,null,o).goto(t),u=t,f=a.openStart;for(;;){let d=Math.min(a.to,i);if(a.point){let m=a.activeForPoint(a.to),g=a.pointFromu&&(l.span(u,d,a.active,f),f=a.openEnd(d));if(a.to>i)return f+(a.point&&a.to>i?1:0);u=a.to,a.next()}}static of(e,t=!1){let i=new Or;for(let l of e instanceof Q0?[e]:t?gR(e):e)i.add(l.from,l.to,l.value);return i.finish()}static join(e){if(!e.length)return it.empty;let t=Ho(e);for(let i=e.length-2;i>=0;i--)for(let l=e[i];l!=it.empty;l=l.nextLayer)t=new it(l.chunkPos,l.chunk,t,Math.max(l.maxPoint,t.maxPoint));return t}}it.empty=new it([],[],null,-1);function Ho(n){return n[n.length-1]}function gR(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(X0);e=i}return n}it.empty.nextLayer=it.empty;class Or{finishChunk(e){this.chunks.push(new ay(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(e,t,i){this.addRange(e,t,i,!0)}addRange(e,t,i,l){this.addInner(e,t,i,l)||(this.nextLayer||(this.nextLayer=new Or)).addRange(e,t,i,l)}addInner(e,t,i,l){let o=e-this.lastTo||i.startSide-this.last.endSide;if(l&&o<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return o<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=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.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 i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(it.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=it.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function Jk(n,e,t){let i=new Map;for(let o of n)for(let a=0;a=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&l.push(new SO(a,t,i,o));return l.length==1?l[0]:new Vc(l)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Hg(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Hg(this.heap,i);(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(),Hg(this.heap,0)}}}function Hg(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let l=n[i];if(i+1=0&&(l=n[i+1],i++),t.compare(l)<0)break;n[i]=t,n[e]=l,e=i}}class xc{constructor(e,t,i){this.minPoint=i,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=Vc.from(e,t,i)}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){eh(this.active,e),eh(this.activeTo,e),eh(this.activeRank,e),this.minActive=tS(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:l,rank:o}=this.cursor;for(;t0;)t++;th(this.active,t,i),th(this.activeTo,t,l),th(this.activeRank,t,o),e&&th(e,t,this.cursor.from),this.minActive=tS(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let i=this.openStart<0?[]:null;for(;;){let l=this.minActive;if(l>-1&&(this.activeTo[l]-this.cursor.from||this.active[l].endSide-this.cursor.startSide)<0){if(this.activeTo[l]>e){this.to=this.activeTo[l],this.endSide=this.active[l].endSide;break}this.removeActive(l),i&&eh(i,l)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let o=this.cursor.value;if(!o.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[l]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function eS(n,e,t,i,l,o){n.goto(e),t.goto(i);let a=i+l,u=i,f=i-e,d=!!o.boundChange;for(let m=!1;;){let g=n.to+f-t.to,b=g||n.endSide-t.endSide,v=b<0?n.to+f:t.to,w=Math.min(v,a);if(n.point||t.point?(n.point&&t.point&&oy(n.point,t.point)&&$0(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(u,w,n.point,t.point),m=!1):(m&&(o.boundChange(u),m=!1),w>u&&!$0(n.active,t.active)&&o.compareRange(u,w,n.active,t.active),d&&wa)break;u=v,b<=0&&n.next(),b>=0&&t.next()}}function $0(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function tS(n,e){let t=-1,i=1e9;for(let l=0;l=e)return l;if(l==n.length)break;o+=n.charCodeAt(l)==9?t-o%t:1,l=hn(n,l)}return i===!0?-1:n.length}const Y0="ͼ",nS=typeof Symbol>"u"?"__"+Y0:Symbol.for(Y0),K0=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),iS=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Vl{constructor(e,t){this.rules=[];let{finish:i}=t||{};function l(a){return/^@/.test(a)?[a]:a.split(/,\s*/)}function o(a,u,f,d){let m=[],g=/^@(\w+)\b/.exec(a[0]),b=g&&g[1]=="keyframes";if(g&&u==null)return f.push(a[0]+";");for(let v in u){let w=u[v];if(/&/.test(v))o(v.split(/,\s*/).map(S=>a.map(C=>S.replace(/&/,C))).reduce((S,C)=>S.concat(C)),w,f);else if(w&&typeof w=="object"){if(!g)throw new RangeError("The value of a property ("+v+") should be a primitive value.");o(l(v),w,m,b)}else w!=null&&m.push(v.replace(/_.*/,"").replace(/[A-Z]/g,S=>"-"+S.toLowerCase())+": "+w+";")}(m.length||b)&&f.push((i&&!g&&!d?a.map(i):a).join(", ")+" {"+m.join(" ")+"}")}for(let a in e)o(l(a),e[a],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=iS[nS]||1;return iS[nS]=e+1,Y0+e.toString(36)}static mount(e,t,i){let l=e[K0],o=i&&i.nonce;l?o&&l.setNonce(o):l=new xR(e,o),l.mount(Array.isArray(t)?t:[t],e)}}let rS=new Map;class xR{constructor(e,t){let i=e.ownerDocument||e,l=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let o=rS.get(i);if(o)return e[K0]=o;this.sheet=new l.CSSStyleSheet,rS.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[K0]=this}mount(e,t){let i=this.sheet,l=0,o=0,a=!1;for(let u=0;u-1&&(this.modules.splice(d,1),a=!0,o--,d=-1),d==-1){if(this.modules.splice(o++,0,f),a=!0,i)for(let m=0;m",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yR=typeof navigator<"u"&&/Mac/.test(navigator.platform),bR=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Sn=0;Sn<10;Sn++)ql[48+Sn]=ql[96+Sn]=String(Sn);for(var Sn=1;Sn<=24;Sn++)ql[Sn+111]="F"+Sn;for(var Sn=65;Sn<=90;Sn++)ql[Sn]=String.fromCharCode(Sn+32),qc[Sn]=String.fromCharCode(Sn);for(var Ig in ql)qc.hasOwnProperty(Ig)||(qc[Ig]=ql[Ig]);function vR(n){var e=yR&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bR&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?qc:ql)[n.keyCode]||n.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 wt(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var l=t[i];typeof l=="string"?n.setAttribute(i,l):l!=null&&(n[i]=l)}e++}for(;e2);var Se={mac:oS||/Mac/.test(Un.platform),windows:/Win/.test(Un.platform),linux:/Linux|X11/.test(Un.platform),ie:Rd,ie_version:OO?W0.documentMode||6:J0?+J0[1]:Z0?+Z0[1]:0,gecko:lS,gecko_version:lS?+(/Firefox\/(\d+)/.exec(Un.userAgent)||[0,0])[1]:0,chrome:!!Ug,chrome_version:Ug?+Ug[1]:0,ios:oS,android:/Android\b/.test(Un.userAgent),webkit:sS,webkit_version:sS?+(/\bAppleWebKit\/(\d+)/.exec(Un.userAgent)||[0,0])[1]:0,safari:ex,safari_version:ex?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Un.userAgent)||[0,0])[1]:0,tabSize:W0.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function cy(n,e){for(let t in n)t=="class"&&e.class?e.class+=" "+n.class:t=="style"&&e.style?e.style+=";"+n.style:e[t]=n[t];return e}const Yh=Object.create(null);function uy(n,e,t){if(n==e)return!0;n||(n=Yh),e||(e=Yh);let i=Object.keys(n),l=Object.keys(e);if(i.length-0!=l.length-0)return!1;for(let o of i)if(o!=t&&(l.indexOf(o)==-1||n[o]!==e[o]))return!1;return!0}function wR(n,e){for(let t=n.attributes.length-1;t>=0;t--){let i=n.attributes[t].name;e[i]==null&&n.removeAttribute(i)}for(let t in e){let i=e[t];t=="style"?n.style.cssText=i:n.getAttribute(t)!=i&&n.setAttribute(t,i)}}function aS(n,e,t){let i=!1;if(e)for(let l in e)t&&l in t||(i=!0,l=="style"?n.style.cssText="":n.removeAttribute(l));if(t)for(let l in t)e&&e[l]==t[l]||(i=!0,l=="style"?n.style.cssText=t[l]:n.setAttribute(l,t[l]));return i}function kR(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Ps(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,l;if(e.isBlockGap)i=-5e8,l=4e8;else{let{start:o,end:a}=TO(e,t);i=(o?t?-3e8:-1:5e8)-1,l=(a?t?2e8:1:-6e8)+1}return new Ps(e,i,l,t,e.widget||null,!0)}static line(e){return new ou(e)}static set(e,t=!1){return it.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Ue.none=it.empty;class su extends Ue{constructor(e){let{start:t,end:i}=TO(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?cy(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Yh}eq(e){return this==e||e instanceof su&&this.tagName==e.tagName&&uy(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}su.prototype.point=!1;class ou extends Ue{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ou&&this.spec.class==e.spec.class&&uy(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ou.prototype.mapMode=Fn.TrackBefore;ou.prototype.point=!0;class Ps extends Ue{constructor(e,t,i,l,o,a){super(t,i,o,e),this.block=l,this.isReplace=a,this.mapMode=l?t<=0?Fn.TrackBefore:Fn.TrackAfter:Fn.TrackDel}get type(){return this.startSide!=this.endSide?Tn.WidgetRange:this.startSide<=0?Tn.WidgetBefore:Tn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ps&&SR(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ps.prototype.point=!0;function TO(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function SR(n,e){return n==e||!!(n&&e&&n.compare(e))}function Jo(n,e,t,i=0){let l=t.length-1;l>=0&&t[l]+i>=n?t[l]=Math.max(t[l],e):t.push(n,e)}class Qc extends Fl{constructor(e,t,i){super(),this.tagName=e,this.attributes=t,this.rank=i}eq(e){return e==this||e instanceof Qc&&this.tagName==e.tagName&&uy(this.attributes,e.attributes)}static create(e){return new Qc(e.tagName,e.attributes||Yh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,t=!1){return it.of(e,t)}}Qc.prototype.startSide=Qc.prototype.endSide=-1;const dn=n=>n.nodeType==1,aa=n=>n.nodeType==3;function Xc(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function tx(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Rc(n,e){if(!e.anchorNode)return!1;try{return tx(n,e.anchorNode)}catch{return!1}}function Lh(n){return aa(n)?$c(n,0,n.nodeValue.length).getClientRects():dn(n)?n.getClientRects():[]}function jc(n,e,t,i){return t?cS(n,e,t,i,-1)||cS(n,e,t,i,1):!1}function Ql(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function Kh(n){return dn(n)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}function cS(n,e,t,i,l){for(;;){if(n==t&&e==i)return!0;if(e==(l<0?0:Kr(n))){if(n.nodeName=="DIV")return!1;let o=n.parentNode;if(!o||!dn(o))return!1;e=Ql(n)+(l<0?0:1),n=o}else if(dn(n)){if(n=n.childNodes[e+(l<0?-1:0)],dn(n)&&(n.nodeName=="IMG"||n.nodeName=="BR"||n.contentEditable=="false"))return!1;e=l<0?Kr(n):0}else return!1}}function Kr(n){return aa(n)?n.nodeValue.length:n.childNodes.length}function Wh(n,e){let{left:t,right:i}=n;if(t==i)return n;let l=e?t:i;return{left:l,right:l,top:n.top,bottom:n.bottom}}function CR(n){let e=n.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function NO(n,e){let t=e.width/n.offsetWidth,i=e.height/n.offsetHeight;return(t>.995&&t<1.005||!isFinite(t)||Math.abs(e.width-n.offsetWidth)<1)&&(t=1),(i>.995&&i<1.005||!isFinite(i)||Math.abs(e.height-n.offsetHeight)<1)&&(i=1),{scaleX:t,scaleY:i}}function OR(n,e,t,i,l,o,a,u){let f=n.ownerDocument,d=f.defaultView||window;for(let m=n,g=!1;m&&!g;)if(dn(m)){let b,v=m==f.body,w=1,S=1,C=!0,O=!0;if(v)b=CR(d);else{let H=getComputedStyle(m);if(/^(fixed|sticky)$/.test(H.position)&&(g=!0),(m.scrollHeight<=m.clientHeight||!/auto|scroll/.test(H.overflowY))&&(O=!1),(m.scrollWidth<=m.clientWidth||!/auto|scroll/.test(H.overflowX))&&(C=!1),!C&&!O){m=m.assignedSlot||m.parentNode;continue}let B=m.getBoundingClientRect();({scaleX:w,scaleY:S}=NO(m,B)),b={left:B.left,right:B.left+m.clientWidth*w,top:B.top,bottom:B.top+m.clientHeight*S}}let _=0,M=0;if(O)if(l=="nearest")e.top0&&e.bottom>b.bottom+M&&(M=e.bottom-b.bottom+a)):e.bottom>b.bottom-a&&(M=e.bottom-b.bottom+a,t<0&&e.top-M0&&e.right>b.right+_&&(_=e.right-b.right+o)):e.right>b.right-o&&(_=e.right-b.right+o,t<0&&e.leftb.bottom||e.leftb.right)&&(e={left:Math.max(e.left,b.left),right:Math.min(e.right,b.right),top:Math.max(e.top,b.top),bottom:Math.min(e.bottom,b.bottom)}),m=m.assignedSlot||m.parentNode}else if(m.nodeType==11)m=m.host;else break}function AO(n,e=!0){let t=n.ownerDocument,i=null,l=null;for(let o=n.parentNode;o&&!(o==t.body||(!e||i)&&l);)if(dn(o))!l&&o.scrollHeight>o.clientHeight&&/scroll|auto/.test(getComputedStyle(o).overflowY)&&(l=o),e&&!i&&o.scrollWidth>o.clientWidth&&/scroll|auto/.test(getComputedStyle(o).overflowX)&&(i=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:i,y:l}}class TR{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:i}=e;this.set(t,Math.min(e.anchorOffset,t?Kr(t):0),i,Math.min(e.focusOffset,i?Kr(i):0))}set(e,t,i,l){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=l}}function EO(n){let e=[];for(let t=n;t;t=t.nodeType==11?t.host:t.parentNode)dn(t)&&e.push({node:t,left:t.scrollLeft,top:t.scrollTop});return e}function MO(n,e=!0){for(let{node:t,left:i,top:l}of n)e&&t.scrollTop!=l&&(t.scrollTop=l),t.scrollLeft!=i&&(t.scrollLeft=i)}let Os=null;Se.safari&&Se.safari_version>=26&&(Os=!1);function DO(n){if(n.setActive)return n.setActive();if(Os)return n.focus(Os);let e=EO(n);n.focus(Os==null?{get preventScroll(){return Os={preventScroll:!0},!0}}:void 0),Os||(Os=!1,MO(e))}let uS;function $c(n,e,t=e){let i=uS||(uS=document.createRange());return i.setEnd(n,t),i.setStart(n,e),i}function ea(n,e,t,i){let l={key:e,code:e,keyCode:t,which:t,cancelable:!0};i&&({altKey:l.altKey,ctrlKey:l.ctrlKey,shiftKey:l.shiftKey,metaKey:l.metaKey}=i);let o=new KeyboardEvent("keydown",l);o.synthetic=!0,n.dispatchEvent(o);let a=new KeyboardEvent("keyup",l);return a.synthetic=!0,n.dispatchEvent(a),o.defaultPrevented||a.defaultPrevented}function NR(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function AR(n,e){let t=e.focusNode,i=e.focusOffset;if(!t||e.anchorNode!=t||e.anchorOffset!=i)return!1;for(i=Math.min(i,Kr(t));;)if(i){if(!dn(t))return!1;let l=t.childNodes[i-1];l.contentEditable=="false"?i--:(t=l,i=Kr(t))}else{if(t==n)return!0;i=Ql(t),t=t.parentNode}}function RO(n){return n instanceof Window?n.pageYOffset>Math.max(0,n.document.documentElement.scrollHeight-n.innerHeight-4):n.scrollTop>Math.max(1,n.scrollHeight-n.clientHeight-4)}function jO(n,e){for(let t=n,i=e;;){if(aa(t)&&i>0)return{node:t,offset:i};if(dn(t)&&i>0){if(t.contentEditable=="false")return null;t=t.childNodes[i-1],i=Kr(t)}else if(t.parentNode&&!Kh(t))i=Ql(t),t=t.parentNode;else return null}}function _O(n,e){for(let t=n,i=e;;){if(aa(t)&&i=t){if(u.level==i)return a;(o<0||(l!=0?l<0?u.fromt:e[o].level>u.level))&&(o=a)}}if(o<0)throw new RangeError("Index out of range");return o}}function BO(n,e){if(n.length!=e.length)return!1;for(let t=0;t=0;S-=3)if(fr[S+1]==-v){let C=fr[S+2],O=C&2?l:C&4?C&1?o:l:0;O&&(Ot[g]=Ot[fr[S]]=O),u=S;break}}else{if(fr.length==189)break;fr[u++]=g,fr[u++]=b,fr[u++]=f}else if((w=Ot[g])==2||w==1){let S=w==l;f=S?0:1;for(let C=u-3;C>=0;C-=3){let O=fr[C+2];if(O&2)break;if(S)fr[C+2]|=2;else{if(O&4)break;fr[C+2]|=4}}}}}function _R(n,e,t,i){for(let l=0,o=i;l<=t.length;l++){let a=l?t[l-1].to:n,u=lf;)w==C&&(w=t[--S].from,C=S?t[S-1].to:n),Ot[--w]=v;f=m}else o=d,f++}}}function ix(n,e,t,i,l,o,a){let u=i%2?2:1;if(i%2==l%2)for(let f=e,d=0;ff&&a.push(new vr(f,S.from,v));let C=S.direction==ca!=!(v%2);rx(n,C?i+1:i,l,S.inner,S.from,S.to,a),f=S.to}w=S.to}else{if(w==t||(m?Ot[w]!=u:Ot[w]==u))break;w++}b?ix(n,f,w,i+1,l,b,a):fe;){let m=!0,g=!1;if(!d||f>o[d-1].to){let S=Ot[f-1];S!=u&&(m=!1,g=S==16)}let b=!m&&u==1?[]:null,v=m?i:i+1,w=f;e:for(;;)if(d&&w==o[d-1].to){if(g)break e;let S=o[--d];if(!m)for(let C=S.from,O=d;;){if(C==e)break e;if(O&&o[O-1].to==C)C=o[--O].from;else{if(Ot[C-1]==u)break e;break}}if(b)b.push(S);else{S.toOt.length;)Ot[Ot.length]=256;let i=[],l=e==ca?0:1;return rx(n,l,l,t,0,n.length,i),i}function PO(n){return[new vr(0,n,0)]}let HO="";function zR(n,e,t,i,l){var o;if(!n.length)return null;let a=i.head-n.from,u;if(i.head==n.from&&i.assoc<0){if(!l)return null;a=e[u=0].side(!1,t)}else if(i.head==n.to&&i.assoc>0){if(l)return null;a=e[u=e.length-1].side(!0,t)}else u=vr.find(e,a,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc);let f=e[u],d=f.side(l,t);if(a==d){let b=u+=l?1:-1;if(b<0||b>=e.length)return null;f=e[u=b],a=f.side(!l,t),d=f.side(l,t)}let m=hn(n.text,a,f.forward(l,t));(mf.to)&&(m=d),HO=n.text.slice(Math.min(a,m),Math.max(a,m));let g=u==(l?e.length-1:0)?null:e[u+(l?1:-1)];if(m==d){if(!g)return l?re.cursor(n.to,1):re.cursor(n.from,-1);if(g.level+(l?0:1)n.some(e=>e)}),$O=Ne.define({combine:n=>n.some(e=>e)}),GO=Ne.define();class ta{constructor(e,t,i,l,o,a=!1){this.range=e,this.y=t,this.x=i,this.yMargin=l,this.xMargin=o,this.isSnapshot=a}map(e){return e.empty?this:new ta(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ta(re.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const nh=Ke.define({map:(n,e)=>n.map(e)}),YO=Ke.define();function ni(n,e,t){let i=n.facet(VO);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)||(t?console.error(t+":",e):console.error(e))}const $r=Ne.define({combine:n=>n.length?n[0]:!0});let PR=0;const Go=Ne.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let f=[];return a&&f.push(jd.of(d=>{let m=d.plugin(u);return m?a(m):Ue.none})),o&&f.push(o(u)),f})}static fromClass(e,t){return Qt.define((i,l)=>new e(i,l),t)}}class Fg{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.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(ni(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){ni(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){ni(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const KO=Ne.define(),my=Ne.define(),jd=Ne.define(),WO=Ne.define(),py=Ne.define(),au=Ne.define(),ZO=Ne.define();function fS(n,e){let t=n.state.facet(ZO);if(!t.length)return t;let i=t.map(o=>o instanceof Function?o(n):o),l=[];return it.spans(i,e.from,e.to,{point(){},span(o,a,u,f){let d=o-e.from,m=a-e.from,g=l;for(let b=u.length-1;b>=0;b--,f--){let v=u[b].spec.bidiIsolate,w;if(f>0&&g.length&&(w=g[g.length-1]).to==d&&w.direction==v)w.to=m,g=w.inner;else{let S={from:d,to:m,direction:v,inner:[]};g.push(S),g=S.inner}}}}),JO(e.text,l)}function JO(n,e){for(let t of e){if(t.direction==null){for(let i=t.from,l=0;i0;t--){let l=e[t-1];if(!(l.fromA>i.toA)){if(l.toAl.push(new Ri(o,a,u,f))),this.changedRanges=l}static create(e,t,i){return new Zh(e,t,i)}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}}const HR=[];class It{constructor(e,t,i=0){this.dom=e,this.length=t,this.flags=i,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return HR}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 t=this.domAttrs;t&&wR(this.dom,t)}}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 i=t;for(let l of this.children){if(l==e)return i;i+=l.length+l.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,i){return null}domPosFor(e,t){let i=Ql(this.dom),l=this.length?e>0:t>0;return new $i(this.parent.dom,i+(l?1:0),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 Ld)return e;return null}static get(e){return e.cmTile}}class _d extends It{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,i=null,l,o=(e==null?void 0:e.node)==t?e:null,a=0;for(let u of this.children){if(u.sync(e),a+=u.length+u.breakAfter,l=i?i.nextSibling:t.firstChild,o&&l!=u.dom&&(o.written=!0),u.dom.parentNode==t)for(;l&&l!=u.dom;)l=hS(l);else t.insertBefore(u.dom,l);i=u.dom}for(l=i?i.nextSibling:t.firstChild,o&&l&&(o.written=!0);l;)l=hS(l);this.length=a}}function hS(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Ld extends _d{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=It.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],i=this,l=0,o=0;;)if(l==i.children.length){if(!t.length)return;i=i.parent,i.breakAfter&&o++,l=t.pop()}else{let a=i.children[l++];if(a instanceof Gr)t.push(l),i=a,l=0;else{let u=o+a.length,f=e(a,o);if(f!==void 0)return f;o=u+a.breakAfter}}}resolveBlock(e,t){let i,l=-1,o,a=-1;if(this.blockTiles((u,f)=>{let d=f+u.length;if(e>=f&&e<=d){if(u.isWidget()&&t>=-1&&t<=1){if(u.flags&32)return!0;u.flags&16&&(i=void 0)}(fe||e==f&&(t>1?u.length:u.covers(-1)))&&(!o||!u.isWidget()&&o.isWidget())&&(o=u,a=e-f)}}),!i&&!o)throw new Error("No tile at position "+e);return i&&t<0||!o?{tile:i,offset:l}:{tile:o,offset:a}}}class Gr extends _d{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(e,t){let i=new Gr(t||document.createElement(e.tagName),e);return t||(i.flags|=4),i}}class ua extends _d{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(e,t,i){let l=new ua(t||document.createElement("div"),e);return(!t||!i)&&(l.flags|=4),l}get domAttrs(){return this.attrs}resolveInline(e,t,i=!1){let l=null,o=-1,a=null,u=-1;function f(m,g){for(let b=0,v=0;b=g&&(w.isComposite()?f(w,g-v):(!a||i&&a.isHidden&&(t>0&&!(a.flags&32)||i&&UR(a,w)))&&(S>g||w.flags&32&&t<=1)?(a=w,u=g-v):(v=-1)&&(l=w,o=g-v)),v=S}}f(this,e);let d=(t<0?l:a)||l||a;return d?{tile:d,offset:d==l?o:u}:null}coordsIn(e,t,i){let l=this.resolveInline(e,t,!0);return l?l.tile.coordsIn(Math.max(0,l.offset),t,i):IR(this)}domIn(e,t){let i=this.resolveInline(e,t);if(i){let{tile:l,offset:o}=i;if(this.dom.contains(l.dom))return l.isText()?new $i(l.dom,Math.min(l.dom.nodeValue.length,o)):l.domPosFor(o,l.flags&16?1:l.flags&32?-1:t);let a=i.tile.parent,u=!1;for(let f of a.children){if(u)return new $i(f.dom,0);f==i.tile&&(u=!0)}}return new $i(this.dom,0)}}function IR(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Lh(e);return t[t.length-1]||null}function UR(n,e){let t=n.coordsIn(0,1),i=e.coordsIn(0,1);return t&&i&&i.topl&&(e=l);let o=e,a=e,u=0;e==0&&t<0||e==l&&t>=0?Se.chrome||Se.gecko||(e?(o--,u=1):a=0)?0:f.length-1];return Se.safari&&!u&&d.width==0&&(d=Array.prototype.find.call(f,m=>m.width)||d),i==null?d:Wh(d,(u?u>0:t<0)==i)}static of(e,t){let i=new Ms(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Hs extends It{constructor(e,t,i,l){super(e,t,l),this.widget=i}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,i){let l=this.widget.coordsAt(this.dom,e,t);if(l)return l;if(i)return Wh(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let o=this.dom.getClientRects(),a=null;if(!o.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?o.length-1:0;a=o[f],!(e>0?f==0:f==o.length-1||a.top0==i)}}class FR{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,i){let{tile:l,index:o,beforeBreak:a,parents:u}=this;for(;e||t>0;)if(l.isComposite())if(a){if(!e)break;i&&i.break(),e--,a=!1}else if(o==l.children.length){if(!e&&!u.length)break;i&&i.leave(l),a=!!l.breakAfter,{tile:l,index:o}=u.pop(),o++}else{let f=l.children[o],d=f.breakAfter;(t>0?f.length<=e:f.length=0;u--){let f=t.marks[u],d=l.lastChild;if(d instanceof ti&&d.mark.eq(f.mark))d.dom!=f.dom&&d.setDOM(Vg(f.dom)),l=d;else{let{dom:m}=f;this.cache.reused.get(f)&&It.get(f.dom)&&(m=Vg(f.dom));let g=ti.of(f.mark,m);l.append(g),l=g}this.cache.reused.set(f,2)}let o=It.get(e.text);o&&this.cache.reused.set(o,2);let a=new Ms(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,l.append(a)}addInlineWidget(e,t,i){let l=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);l||this.flushBuffer();let o=this.ensureMarks(t,i);!l&&!(e.flags&16)&&o.append(this.getBuffer(1)),o.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,i){this.flushBuffer(),this.ensureMarks(t,i).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){var i;e||(e=tT);let l=ua.start(e,t||((i=this.cache.find(ua))===null||i===void 0?void 0:i.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=l)}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){var i;let l=this.curLine;for(let o=e.length-1;o>=0;o--){let a=e[o],u;if(t>0&&(u=l.lastChild)&&u instanceof ti&&u.mark.eq(a))l=u,t--;else{let f=ti.of(a,(i=this.cache.find(ti,d=>d.mark.eq(a)))===null||i===void 0?void 0:i.dom);l.append(f),l=f,t=0}}return l}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!dS(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Se.ios&&dS(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(qg,0,32)||new Hs(qg.toDOM(),0,qg,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){let t=e.rank*102+e.value.rank,i=new VR(e.from,e.to,e.value,t),l=this.wrappers.length;for(;l>0&&(this.wrappers[l-1].rank-i.rank||this.wrappers[l-1].to-i.to)<0;)l--;this.wrappers.splice(l,0,i)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let i of this.wrappers){let l=t.lastChild;if(i.froma.wrapper.eq(i.wrapper)))===null||e===void 0?void 0:e.dom);t.append(o),t=o}}return t}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),i=this.cache.find(Jh,void 0,1);return i&&(i.flags=t),i||new Jh(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class QR{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:l,lineBreak:o,done:a}=this.cursor.next(this.skipCount);if(this.skipCount=0,a)throw new Error("Ran out of text content when drawing inline views");this.text=l;let u=this.textOff=Math.min(e,l.length);return o?null:l.slice(0,u)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const ed=[Hs,ua,Ms,ti,Jh,Gr,Ld];for(let n=0;n[]),this.index=ed.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,i=this.buckets[t];i.length<6?i.push(e):i[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,i=2){let l=e.bucket,o=this.buckets[l],a=this.index[l];for(let u=0;u{if(this.cache.add(a),a.isComposite())return!1},enter:a=>this.cache.add(a),leave:()=>{},break:()=>{}}}run(e,t){let i=t&&this.getCompositionContext(t.text);for(let l=0,o=0,a=0;;){let u=al){let d=f-l;this.preserve(d,!a,!u),l=f,o+=d}if(!u)break;t&&u.fromA<=t.range.fromA&&u.toA>=t.range.toA?(this.forward(u.fromA,t.range.fromA,t.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let d=f>0||u{a.isLine()?this.builder.addLineStart(a.attrs,this.cache.maybeReuse(a)):(this.cache.add(a),a instanceof ti&&l.unshift(a.mark)),this.openWidget=!1},leave:a=>{a.isLine()?l.length&&(l.length=o=0):a instanceof ti&&(l.shift(),o=Math.min(o,l.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let i=null,l=this.builder,o=-1,a=it.spans(this.decorations,e,t,{point:(u,f,d,m,g,b)=>{if(d instanceof Ps){if(this.disallowBlockEffectsFor[b]){if(d.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(o=m.length,g>m.length)l.continueWidget(f-u);else{let v=d.widget||(d.block?fa.block:fa.inline),w=GR(d),S=this.cache.findWidget(v,f-u,w)||Hs.of(v,this.view,f-u,w);d.block?(d.startSide>0&&l.addLineStartIfNotCovered(i),l.addBlockWidget(S)):(l.ensureLine(i),l.addInlineWidget(S,m,g))}i=null}else i=YR(i,d);f>u&&this.text.skip(f-u)},span:(u,f,d,m)=>{for(let g=u;g-1&&(this.openWidget=a>o),this.openWidget||l.addLineStartIfNotCovered(i),this.openMarks=a}forward(e,t,i=1){t-e<=10?this.old.advance(t-e,i,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,i,this.reuseWalker))}getCompositionContext(e){let t=[],i=null;for(let l=e.parentNode;;l=l.parentNode){let o=It.get(l);if(l==this.view.contentDOM)break;o instanceof ti?t.push(o):o!=null&&o.isLine()?i=o:o instanceof Gr||(l.nodeName=="DIV"&&!i?i=new ua(l,tT):i||t.push(ti.of(new su({tagName:l.nodeName.toLowerCase(),attributes:kR(l)}),l)))}return i?{line:i,marks:t}:null}}function dS(n,e){let t=i=>{for(let l of i.children)if((e?l.isText():l.length)||t(l))return!0;return!1};return t(n)}function GR(n){let e=n.isReplace?(n.startSide<0?64:0)|(n.endSide>0?128:0):n.startSide>0?32:16;return n.block&&(e|=256),e}const tT={class:"cm-line"};function YR(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&cy(t,n),i&&(n.class+=" "+i)),n}function KR(n){let e=[];for(let t=n.parents.length;t>1;t--){let i=t==n.parents.length?n.tile:n.parents[t].tile;i instanceof ti&&e.push(i.mark)}return e}function Vg(n){let e=It.get(n);return e&&e.setDOM(n.cloneNode()),n}class fa extends el{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}}fa.inline=new fa("span");fa.block=new fa("div");const qg=new class extends el{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class mS{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Ue.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 Ld(e,e.contentDOM),this.updateInner([new Ri(0,0,0,e.state.doc.length)],null)}update(e){var t;let i=e.changedRanges;this.minWidth>0&&i.length&&(i.every(({fromA:m,toA:g})=>gthis.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 l=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?l=this.domChanged.newSel.head:!lj(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let o=l>-1?ZR(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){let{from:m,to:g}=this.hasComposition;i=new Ri(m,g,e.changes.mapPos(m,-1),e.changes.mapPos(g,1)).addToSet(i.slice())}this.hasComposition=o?{from:o.range.fromB,to:o.range.toB}:null,(Se.ie||Se.chrome)&&!o&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let a=this.decorations,u=this.blockWrappers;this.updateDeco();let f=tj(a,this.decorations,e.changes);f.length&&(i=Ri.extendWithRanges(i,f));let d=ij(u,this.blockWrappers,e.changes);return d.length&&(i=Ri.extendWithRanges(i,d)),o&&!i.some(m=>m.fromA<=o.range.fromA&&m.toA>=o.range.toA)&&(i=o.range.addToSet(i.slice())),this.tile.flags&2&&i.length==0?!1:(this.updateInner(i,o),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:i}=this.view;i.ignore(()=>{if(t||e.length){let a=this.tile,u=new $R(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&It.get(t.text)&&u.cache.reused.set(It.get(t.text),2),this.tile=u.run(e,t),sx(a,u.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 o=Se.chrome||Se.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(o),o&&(o.written||i.selectionRange.focusNode!=o.node||!this.tile.dom.contains(o.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let l=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Rc(i,this.view.observer.selectionRange)&&!(l&&i.contains(l));if(!(o||t||a))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,d,m;if(f.empty?m=d=this.inlineDOMNearPos(f.anchor,f.assoc||1):(m=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),d=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Se.gecko&&f.empty&&!this.hasComposition&&WR(d)){let b=document.createTextNode("");this.view.observer.ignore(()=>d.node.insertBefore(b,d.node.childNodes[d.offset]||null)),d=m=new $i(b,0),u=!0}let g=this.view.observer.selectionRange;(u||!g.focusNode||(!jc(d.node,d.offset,g.anchorNode,g.anchorOffset)||!jc(m.node,m.offset,g.focusNode,g.focusOffset))&&!this.suppressWidgetCursorChange(g,f))&&(this.view.observer.ignore(()=>{Se.android&&Se.chrome&&i.contains(g.focusNode)&&rj(g.focusNode,i)&&(i.blur(),i.focus({preventScroll:!0}));let b=Xc(this.view.root);if(b)if(f.empty){if(Se.gecko){let v=JR(d.node,d.offset);if(v&&v!=3){let w=(v==1?jO:_O)(d.node,d.offset);w&&(d=new $i(w.node,w.offset))}}b.collapse(d.node,d.offset),f.bidiLevel!=null&&b.caretBidiLevel!==void 0&&(b.caretBidiLevel=f.bidiLevel)}else if(b.extend){b.collapse(d.node,d.offset);try{b.extend(m.node,m.offset)}catch{}}else{let v=document.createRange();f.anchor>f.head&&([d,m]=[m,d]),v.setEnd(m.node,m.offset),v.setStart(d.node,d.offset),b.removeAllRanges(),b.addRange(v)}a&&this.view.root.activeElement==i&&(i.blur(),l&&l.focus())}),this.view.observer.setSelectionRange(d,m)),this.impreciseAnchor=d.precise?null:new $i(g.anchorNode,g.anchorOffset),this.impreciseHead=m.precise?null:new $i(g.focusNode,g.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&jc(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,i=Xc(e.root),{anchorNode:l,anchorOffset:o}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let u=a.posAtStart;if(t.head==u||t.head==u+a.length)return;let f=this.coordsAt(t.head,-1),d=this.coordsAt(t.head,1);if(!f||!d||f.bottom>d.top)return;let m=this.domAtPos(t.head+t.assoc,t.assoc);i.collapse(m.node,m.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let g=e.observer.selectionRange;e.docView.posFromDOM(g.anchorNode,g.anchorOffset)!=t.from&&i.collapse(l,o)}posFromDOM(e,t){let i=this.tile.nearest(e);if(!i)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let l=i.posAtStart;if(i.isComposite()){let o;if(e==i.dom)o=i.dom.childNodes[t];else{let a=Kr(e)==0?0:t==0?-1:1;for(;;){let u=e.parentNode;if(u==i.dom)break;a==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?a=-1:a=1),e=u}a<0?o=e:o=e.nextSibling}if(o==i.dom.firstChild)return l;for(;o&&!It.get(o);)o=o.nextSibling;if(!o)return l+i.length;for(let a=0,u=l;;a++){let f=i.children[a];if(f.dom==o)return u;u+=f.length+f.breakAfter}}else return i.isText()?e==i.dom?l+t:l+(t?i.length:0):l}domAtPos(e,t){let{tile:i,offset:l}=this.tile.resolveBlock(e,t);return i.isWidget()?i.domPosFor(l,t):i.domIn(l,t)}inlineDOMNearPos(e,t){let i,l=-1,o=!1,a,u=-1,f=!1;return this.tile.blockTiles((d,m)=>{if(d.isWidget()){if(d.flags&32&&m>=e)return!0;d.flags&16&&(o=!0)}else{let g=m+d.length;if(m<=e&&(i=d,l=e-m,o=g=e&&!a&&(a=d,u=e-m,f=m>e),m>e&&a)return!0}}),!i&&!a?this.domAtPos(e,t):(o&&a?i=null:f&&i&&(a=null),i&&t<0||!a?i.domIn(l,t):a.domIn(u,t))}coordsAt(e,t,i){let{tile:l,offset:o}=this.tile.resolveBlock(e,t);return l.isWidget()?l.widget instanceof Qg?null:l.coordsInWidget(o,t,!0):l.coordsIn(o,t,i)}lineAt(e,t){let{tile:i}=this.tile.resolveBlock(e,t);return i.isLine()?i:null}coordsForChar(e){let{tile:t,offset:i}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function l(o,a){if(o.isComposite())for(let u of o.children){if(u.length>=a){let f=l(u,a);if(f)return f}if(a-=u.length,a<0)break}else if(o.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==kt.LTR,d=0,m=(g,b,v)=>{for(let w=0;wl);w++){let S=g.children[w],C=b+S.length,O=S.dom.getBoundingClientRect(),{height:_}=O;if(v&&!w&&(d+=O.top-v.top),S instanceof Gr)C>i&&m(S,b,O);else if(b>=i&&(d>0&&t.push(-d),t.push(_+d),d=0,a)){let M=S.dom.lastChild,H=M?Lh(M):[];if(H.length){let B=H[H.length-1],D=f?B.right-O.left:O.right-B.left;D>u&&(u=D,this.minWidth=o,this.minWidthFrom=b,this.minWidthTo=C)}}v&&w==g.children.length-1&&(d+=v.bottom-O.bottom),b=C+S.breakAfter}};return m(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?kt.RTL:kt.LTR}measureTextSize(){let e=this.tile.blockTiles(a=>{if(a.isLine()&&a.children.length&&a.length<=20){let u=0,f;for(let d of a.children){if(!d.isText()||/[^ -~]/.test(d.text))return;let m=Lh(d.dom);if(m.length!=1)return;u+=m[0].width,f=m[0].height}if(u)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:u/a.length,textHeight:f}}});if(e)return e;let t=document.createElement("div"),i,l,o;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 a=Lh(t.firstChild)[0];i=t.getBoundingClientRect().height,l=a&&a.width?a.width/27:7,o=a&&a.height?a.height:i,t.remove()}),{lineHeight:i,charWidth:l,textHeight:o}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,l=0;;l++){let o=l==t.viewports.length?null:t.viewports[l],a=o?o.from-1:this.view.state.doc.length;if(a>i){let u=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Ue.replace({widget:new Qg(u),block:!0,inclusive:!0,isBlockGap:!0}).range(i,a))}if(!o)break;i=o.to+1}return Ue.set(e)}updateDeco(){let e=1,t=this.view.state.facet(jd).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,l=this.view.state.facet(py).map((o,a)=>{let u=typeof o=="function";return u&&(i=!0),u?o(this.view):o});for(l.length&&(this.dynamicDecorationMap[e++]=i,t.push(it.join(l))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof o=="function"?o(this.view):o)}scrollIntoView(e){if(e.isSnapshot){let d=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=d.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let d of this.view.state.facet(GO))try{if(d(this.view,e.range,e))return!0}catch(m){ni(this.view.state,m,"scroll handler")}let{range:t}=e,i=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),l;if(!i)return;!t.empty&&(l=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,l.left),top:Math.min(i.top,l.top),right:Math.max(i.right,l.right),bottom:Math.max(i.bottom,l.bottom)});let o=gy(this.view),a={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(OR(this.view.scrollDOM,a,t.head1&&(i.top>window.visualViewport.offsetTop+window.visualViewport.height||i.bottomi.isWidget()||i.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){sx(this.tile)}}function sx(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)sx(i,e)}}function WR(n){return dn(n.node)&&n.node.firstChild&&(n.offset==0||n.node.childNodes[n.offset-1].contentEditable=="false")&&(n.offset==n.node.childNodes.length||n.node.childNodes[n.offset].contentEditable=="false")}function nT(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=jO(t.focusNode,t.focusOffset),l=_O(t.focusNode,t.focusOffset),o=i||l;if(l&&i&&l.node!=i.node){let u=It.get(l.node);if(!u||u.isText()&&u.text!=l.node.nodeValue)o=l;else if(n.docView.lastCompositionAfterCursor){let f=It.get(i.node);!f||f.isText()&&f.text!=i.node.nodeValue||(o=l)}}if(n.docView.lastCompositionAfterCursor=o!=i,!o)return null;let a=e-o.offset;return{from:a,to:a+o.node.nodeValue.length,node:o.node}}function ZR(n,e,t){let i=nT(n,t);if(!i)return null;let{node:l,from:o,to:a}=i,u=l.nodeValue;if(/[\n\r]/.test(u)||n.state.doc.sliceString(i.from,i.to)!=u)return null;let f=e.invertedDesc;return{range:new Ri(f.mapPos(o),f.mapPos(a),o,a),text:l}}function JR(n,e){return dn(n)?(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class Qg extends el{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 sj(n,e,t=1){let i=n.charCategorizer(e),l=n.doc.lineAt(e),o=e-l.from;if(l.length==0)return re.cursor(e);o==0?t=1:o==l.length&&(t=-1);let a=o,u=o;t<0?a=hn(l.text,o,!1):u=hn(l.text,o);let f=i(l.text.slice(a,u));for(;a>0;){let d=hn(l.text,a,!1);if(i(l.text.slice(d,a))!=f)break;a=d}for(;un.defaultLineHeight*1.5){let u=n.viewState.heightOracle.textHeight,f=Math.floor((l-t.top-(n.defaultLineHeight-u)*.5)/u);o+=f*n.viewState.heightOracle.lineLength}let a=n.state.sliceDoc(t.from,t.to);return t.from+G0(a,o,n.state.tabSize)}function ox(n,e,t){let i=n.lineBlockAt(e);if(Array.isArray(i.type)){let l;for(let o of i.type){if(o.from>e)break;if(!(o.toe)return o;(!l||o.type==Tn.Text&&(l.type!=o.type||(t<0?o.frome)))&&(l=o)}}return l||i}return i}function aj(n,e,t,i){let l=ox(n,e.head,e.assoc||-1),o=!i||l.type!=Tn.Text||!(n.lineWrapping||l.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>l.from?e.head-1:e.head);if(o){let a=n.dom.getBoundingClientRect(),u=n.textDirectionAt(l.from),f=n.posAndSideAtCoords({x:t==(u==kt.LTR)?a.right-1:a.left+1,y:(o.top+o.bottom)/2});if(f)return re.cursor(f.pos,f.assoc)}return re.cursor(t?l.to:l.from,t?1:-1)}function pS(n,e,t,i){let l=n.state.doc.lineAt(e.head),o=n.bidiSpans(l),a=n.textDirectionAt(l.from);for(let u=e,f=null;;){let d=zR(l,o,a,u,t),m=HO;if(!d){if(l.number==(t?n.state.doc.lines:1))return u;m=` +`,l=n.state.doc.line(l.number+(t?1:-1)),o=n.bidiSpans(l),d=t?re.cursor(l.from,-1):re.cursor(l.to,1)}if(f){if(!f(m))return u}else{if(!i)return d;f=i(m)}u=d}}function cj(n,e,t){let i=n.state.charCategorizer(e),l=i(t);return o=>{let a=i(o);return l==_t.Space&&(l=a),l==a}}function uj(n,e,t,i){let l=e.head,o=t?1:-1;if(l==(t?n.state.doc.length:0))return re.cursor(l,e.assoc);let a=e.goalColumn,u,f=n.contentDOM.getBoundingClientRect(),d=n.coordsAtPos(l,e.assoc||((e.empty?t:e.head==e.from)?1:-1)),m=n.documentTop;if(d)a==null&&(a=d.left-f.left),u=o<0?d.top:d.bottom;else{let w=n.viewState.lineBlockAt(l);a==null&&(a=Math.min(f.right-f.left,n.defaultCharacterWidth*(l-w.from))),u=(o<0?w.top:w.bottom)+m}let g=f.left+a,b=n.viewState.heightOracle.textHeight>>1,v=i??b;for(let w=0;;w+=b){let S=u+(v+w)*o,C=ax(n,{x:g,y:S},!1,o);if(t?S>f.bottom:Su:_{if(e>o&&el(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:re.cursor(i,in.viewState.docHeight)return new br(n.state.doc.length,-1);if(d=n.elementAtHeight(f),i==null)break;if(d.type==Tn.Text){if(i<0?d.ton.viewport.to)break;let b=n.docView.coordsAt(i<0?d.from:d.to,i>0?-1:1);if(b&&(i<0?b.top<=f+o:b.bottom>=f+o))break}let g=n.viewState.heightOracle.textHeight/2;f=i>0?d.bottom+g:d.top-g}if(n.viewport.from>=d.to||n.viewport.to<=d.from){if(t)return null;if(d.type==Tn.Text){let g=oj(n,l,d,a,u);return new br(g,g==d.from?1:-1)}}if(d.type!=Tn.Text)return f<(d.top+d.bottom)/2?new br(d.from,1):new br(d.to,-1);let m=n.docView.lineAt(d.from,2);return(!m||m.length!=d.length)&&(m=n.docView.lineAt(d.from,-2)),new fj(n,a,u,n.textDirectionAt(d.from)).scanTile(m,d.from)}class fj{constructor(e,t,i,l){this.view=e,this.x=t,this.y=i,this.baseDir=l,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||i.length&&(i[0].level!=this.baseDir||i[0].to+l.from>1;t:if(a.has(S)){for(let _=1;_=o&&(M-=w),!a.has(M)){S=M;break t}}break e}a.add(S);let C=t(S),O=0;if(C)for(let _=0;_1))if(M.bottomthis.y)(!d||d.top>M.top)&&(d=M),O=-1;else{let H=M.left>this.x?this.x-M.left:M.right(w+w+S)/3)return this.y=f.bottom-1,this.scan(e,t,!0);if(d&&d.top<(w+S+S)/3)return this.y=d.top+1,this.scan(e,t,!0)}let v=(u?this.dirAt(e[m],1):this.baseDir)==kt.LTR;return{i:m,after:this.x>(b.left+b.right)/2==v}}scanText(e,t){let i=[];for(let o=0;o{let a=i[o]-t,u=i[o+1]-t;return $c(e.dom,a,u).getClientRects()});return l.after?new br(i[l.i+1],-1):new br(i[l.i],1)}scanTile(e,t){if(!e.length)return new br(t,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,t);if(u.isComposite())return this.scanTile(u,t)}let i=[t];for(let u=0,f=t;u{let f=e.children[u];return f.flags&48?null:(dn(f.dom)?f.dom:$c(f.dom,0,f.length)).getClientRects()}),o=e.children[l.i],a=i[l.i];return o.isText()?this.scanText(o,a):o.isComposite()?this.scanTile(o,a):l.after?new br(i[l.i+1],-1):new br(a,1)}}const Io="￿";class hj{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(ut.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Io}readRange(e,t){if(!e)return this;let i=e.parentNode;for(let l=e;;){this.findPointBefore(i,l);let o=this.text.length;this.readNode(l);let a=It.get(l),u=l.nextSibling;if(u==t){a!=null&&a.breakAfter&&!u&&i!=this.view.contentDOM&&this.lineBreak();break}let f=It.get(u);(a&&f?a.breakAfter:(a?a.breakAfter:Kh(l))||Kh(u)&&(l.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>o)&&!mj(u,t)&&this.lineBreak(),l=u}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,l=this.lineSeparator?null:/\r\n?|\n/g;;){let o=-1,a=1,u;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(u=l.exec(t))&&(o=u.index,a=u[0].length),this.append(t.slice(i,o<0?t.length:o)),o<0)break;if(this.lineBreak(),a>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=a-1);i=o+a}}readNode(e){let t=It.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let l=i.iter();!l.next().done;)l.lineBreak?this.lineBreak():this.append(l.value)}else aa(e)?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():dn(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(aa(e)?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+(dj(e,i.node,i.offset)?t:0))}}function dj(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:o,impreciseAnchor:a}=e.docView,u=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=rT(e.docView.tile,t,i,0))){let f=o||a?[]:xj(e),d=new hj(f,e);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=yj(f,this.bounds.from)}else{let f=e.observer.selectionRange,d=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!tx(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),m=a&&a.node==f.anchorNode&&a.offset==f.anchorOffset||!tx(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),g=e.viewport;if((Se.ios||Se.chrome)&&d!=m&&Math.min(d,m)<=u.main.from&&Math.max(d,m)>=u.main.to&&(g.from>0||g.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(re.range(m,d));else if(e.lineWrapping&&m==d&&!(u.main.empty&&u.main.head==d)&&e.inputState.lastTouchTime>Date.now()-100){let b=e.coordsAtPos(d,-1),v=0;b&&(v=e.inputState.lastTouchY<=b.bottom?-1:1),this.newSel=re.create([re.cursor(d,v)])}else this.newSel=re.single(m,d)}}}function rT(n,e,t,i){if(n.isComposite()){let l=-1,o=-1,a=-1,u=-1;for(let f=0,d=i,m=i;ft)return rT(g,e,t,d);if(b>=e&&l==-1&&(l=f,o=d),d>t&&g.dom.parentNode==n.dom){a=f,u=m;break}m=b,d=b+g.breakAfter}return{from:o,to:u<0?i+n.length:u,startDOM:(l?n.children[l-1].dom.nextSibling:null)||n.dom.firstChild,endDOM:a=0?n.children[a].dom:null}}else return n.isText()?{from:i,to:i+n.length,startDOM:n.dom,endDOM:n.dom.nextSibling}:null}function lT(n,e){let t,{newSel:i}=e,{state:l}=n,o=l.selection.main,a=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,d=o.from,m=null;(a===8||Se.android&&e.text.length=u&&o.to<=f&&(e.typeOver||g!=e.text)&&g.slice(0,o.from-u)==e.text.slice(0,o.from-u)&&g.slice(o.to-u)==e.text.slice(b=e.text.length-(g.length-(o.to-u)))?t={from:o.from,to:o.to,insert:ot.of(e.text.slice(o.from-u,b).split(Io))}:(v=sT(g,e.text,d-u,m))&&(Se.chrome&&a==13&&v.toB==v.from+2&&e.text.slice(v.from,v.toB)==Io+Io&&v.toB--,t={from:u+v.from,to:u+v.toA,insert:ot.of(e.text.slice(v.from,v.toB).split(Io))})}else i&&(!n.hasFocus&&l.facet($r)||cx(i,o))&&(i=null);if(!t&&!i)return!1;if((Se.mac||Se.android)&&t&&t.from==t.to&&t.from==o.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=re.single(i.main.anchor-1,i.main.head-1)),t={from:t.from,to:t.to,insert:ot.of([t.insert.toString().replace("."," ")])}):l.doc.lineAt(o.from).toDate.now()-50?t={from:o.from,to:o.to,insert:l.toText(n.inputState.insertingText)}:Se.chrome&&t&&t.from==t.to&&t.from==o.head&&t.insert.toString()==` + `&&n.lineWrapping&&(i&&(i=re.single(i.main.anchor-1,i.main.head-1)),t={from:o.from,to:o.to,insert:ot.of([" "])}),t)return xy(n,t,i,a);if(i&&!cx(i,o)){let u=!1,f="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(u=!0),f=n.inputState.lastSelectionOrigin,f=="select.pointer"&&(i=iT(l.facet(au).map(d=>d(n)),i))),n.dispatch({selection:i,scrollIntoView:u,userEvent:f}),!0}else return!1}function xy(n,e,t,i=-1){if(Se.ios&&n.inputState.flushIOSKey(e))return!0;let l=n.state.selection.main;if(Se.android&&(e.to==l.to&&(e.from==l.from||e.from==l.from-1&&n.state.sliceDoc(e.from,l.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&ea(n.contentDOM,"Enter",13)||(e.from==l.from-1&&e.to==l.to&&e.insert.length==0||i==8&&e.insert.lengthl.head)&&ea(n.contentDOM,"Backspace",8)||e.from==l.from&&e.to==l.to+1&&e.insert.length==0&&ea(n.contentDOM,"Delete",46)))return!0;let o=e.insert.toString();n.inputState.composing>=0&&n.inputState.composing++;let a,u=()=>a||(a=gj(n,e,t));return n.state.facet(qO).some(f=>f(n,e.from,e.to,o,u))||n.dispatch(u()),!0}function gj(n,e,t){let i,l=n.state,o=l.selection.main,a=-1;if(e.from==e.to&&e.fromo.to){let f=e.fromg(n)),d,f);e.from==m&&(a=m)}if(a>-1)i={changes:e,selection:re.cursor(e.from+e.insert.length,-1)};else if(e.from>=o.from&&e.to<=o.to&&e.to-e.from>=(o.to-o.from)/3&&(!t||t.main.empty&&t.main.from==e.from+e.insert.length)&&n.inputState.composing<0){let f=o.frome.to?l.sliceDoc(e.to,o.to):"";i=l.replaceSelection(n.state.toText(f+e.insert.sliceString(0,void 0,n.state.lineBreak)+d))}else{let f=l.changes(e),d=t&&t.main.to<=f.newLength?t.main:void 0;if(l.selection.ranges.length>1&&(n.inputState.composing>=0||n.inputState.compositionPendingChange)&&e.to<=o.to+10&&e.to>=o.to-10){let m=n.state.sliceDoc(e.from,e.to),g,b=t&&nT(n,t.main.head);if(b){let w=e.insert.length-(e.to-e.from);g={from:b.from,to:b.to-w}}else g=n.state.doc.lineAt(o.head);let v=o.to-e.to;i=l.changeByRange(w=>{if(w.from==o.from&&w.to==o.to)return{changes:f,range:d||w.map(f)};let S=w.to-v,C=S-m.length;if(n.state.sliceDoc(C,S)!=m||S>=g.from&&C<=g.to)return{range:w};let O=l.changes({from:C,to:S,insert:e.insert}),_=w.to-o.to;return{changes:O,range:d?re.range(Math.max(0,d.anchor+_),Math.max(0,d.head+_)):w.map(O)}})}else i={changes:f,selection:d&&l.selection.replaceRange(d)}}let u="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,u+=".compose",n.inputState.compositionFirstChange&&(u+=".start",n.inputState.compositionFirstChange=!1)),l.update(i,{userEvent:u,scrollIntoView:!0})}function sT(n,e,t,i){let l=Math.min(n.length,e.length),o=0;for(;o0&&u>0&&n.charCodeAt(a-1)==e.charCodeAt(u-1);)a--,u--;if(i=="end"){let f=Math.max(0,o-Math.min(a,u));t-=a+f-o}if(a=a?o-t:0;o-=f,u=o+(u-a),a=o}else if(u=u?o-t:0;o-=f,a=o+(a-u),u=o}return{from:o,toA:a,toB:u}}function xj(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}=n.observer.selectionRange;return t&&(e.push(new gS(t,i)),(l!=t||o!=i)&&e.push(new gS(l,o))),e}function yj(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t<0||i<0?null:t==i?re.create([re.cursor(i+e,-1)]):re.single(t+e,i+e)}function cx(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class bj{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,Se.safari&&e.contentDOM.addEventListener("input",()=>null),Se.gecko&&Lj(e.contentDOM.ownerDocument)}handleEvent(e){!Aj(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let i=this.handlers[e];if(i){for(let l of i.observers)l(this.view,t);for(let l of i.handlers){if(t.defaultPrevented)break;if(l(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=wj(e),i=this.handlers,l=this.view.contentDOM;for(let o in t)if(o!="scroll"){let a=!t[o].handlers.length,u=i[o];u&&a!=!u.handlers.length&&(l.removeEventListener(o,this.handleEvent),u=null),u||l.addEventListener(o,this.handleEvent,{passive:a})}for(let o in i)o!="scroll"&&!t[o]&&l.removeEventListener(o,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&&aT.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Se.android&&Se.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Se.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(oT.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||kj.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&Se.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&vj(this.view.win)&&(t.shiftKey=!1);let i=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==i&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key=="Enter"&&e&&e.from0?!0:Se.safari&&!Se.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 vj(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function xS(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(l){ni(t.state,l)}}}function wj(n){let e=Object.create(null);function t(i){return e[i]||(e[i]={observers:[],handlers:[]})}for(let i of n){let l=i.spec,o=l&&l.plugin.domEventHandlers,a=l&&l.plugin.domEventObservers;if(o)for(let u in o){let f=o[u];f&&t(u).handlers.push(xS(i.value,f))}if(a)for(let u in a){let f=a[u];f&&t(u).observers.push(xS(i.value,f))}}for(let i in Wi)t(i).handlers.push(Wi[i]);for(let i in qn)t(i).observers.push(qn[i]);return e}const oT=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],kj="dthko",aT=[16,17,18,20,91,92,224,225],ih=6;function rh(n){return Math.max(0,n)*.7+8}function Sj(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class Cj{constructor(e,t,i,l){this.view=e,this.startEvent=t,this.style=i,this.mustSelect=l,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=AO(e.contentDOM),this.atoms=e.state.facet(au).map(a=>a(e));let o=e.contentDOM.ownerDocument;o.addEventListener("mousemove",this.move=this.move.bind(this)),o.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ut.allowMultipleSelections)&&Oj(e,t),this.dragging=Nj(e,t)&&fT(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&&Sj(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,l=0,o=0,a=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=gy(this.view);e.clientX-f.left<=l+ih?t=-rh(l-e.clientX):e.clientX+f.right>=a-ih&&(t=rh(e.clientX-a)),e.clientY-f.top<=o+ih?i=-rh(o-e.clientY):e.clientY+f.bottom>=u-ih&&(i=rh(e.clientY-u)),this.setScrollSpeed(t,i)}up(e){this.dragging==null&&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,i=iT(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!i.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:i,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function Oj(n,e){let t=n.state.facet(IO);return t.length?t[0](e):Se.mac?e.metaKey:e.ctrlKey}function Tj(n,e){let t=n.state.facet(UO);return t.length?t[0](e):Se.mac?!e.altKey:!e.ctrlKey}function Nj(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=Xc(n.root);if(!i||i.rangeCount==0)return!0;let l=i.getRangeAt(0).getClientRects();for(let o=0;o=e.clientX&&a.top<=e.clientY&&a.bottom>=e.clientY)return!0}return!1}function Aj(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=It.get(t))&&i.isWidget()&&!i.isHidden&&i.widget.ignoreEvent(e))return!1;return!0}const Wi=Object.create(null),qn=Object.create(null),cT=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function Ej(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),uT(n,t.value)},50)}function zd(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function uT(n,e){e=zd(n.state,hy,e);let{state:t}=n,i,l=1,o=t.toText(e),a=o.lines==t.selection.ranges.length;if(ux!=null&&t.selection.ranges.every(f=>f.empty)&&ux==o.toString()){let f=-1;i=t.changeByRange(d=>{let m=t.doc.lineAt(d.from);if(m.from==f)return{range:d};f=m.from;let g=t.toText((a?o.line(l++).text:e)+t.lineBreak);return{changes:{from:m.from,insert:g},range:re.cursor(d.from+g.length,-1)}})}else a?i=t.changeByRange(f=>{let d=o.line(l++);return{changes:{from:f.from,to:f.to,insert:d.text},range:re.cursor(f.from+d.length,-1)}}):i=t.replaceSelection(o);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}qn.scroll=n=>{let e=n.inputState;e.lastScrollTop=n.scrollDOM.scrollTop,e.lastScrollLeft=n.scrollDOM.scrollLeft,Se.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};qn.wheel=qn.mousewheel=n=>{n.inputState.lastWheelEvent=Date.now()};Wi.keydown=(n,e)=>(n.inputState.setSelectionOrigin("select"),e.keyCode==27&&n.inputState.tabFocusMode!=0&&(n.inputState.tabFocusMode=Date.now()+2e3),!1);qn.touchstart=(n,e)=>{let t=n.inputState,i=e.targetTouches[0];t.touchActive=!0,t.lastTouchTime=Date.now(),i&&(t.lastTouchX=i.clientX,t.lastTouchY=i.clientY),t.setSelectionOrigin("select.pointer")};qn.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};qn.touchend=(n,e)=>{n.inputState.touchActive=!1};Wi.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return!1;let t=null;for(let i of n.state.facet(FO))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=Dj(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new Cj(n,e,t,i)),i&&n.observer.ignore(()=>{DO(n.contentDOM);let o=n.root.activeElement;o&&!o.contains(n.contentDOM)&&o.blur()});let l=n.inputState.mouseSelection;if(l)return l.start(e),l.dragging===!1}else n.inputState.setSelectionOrigin("select.pointer");return!1};function yS(n,e,t,i){if(i==1)return re.cursor(e,t);if(i==2)return sj(n.state,e,t);{let l=n.docView.lineAt(e,t),o=n.state.doc.lineAt(l?l.posAtEnd:e),a=l?l.posAtStart:o.from,u=l?l.posAtEnd:o.to;return uDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(vS+1)%3:1}function Dj(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=fT(e),l=n.state.selection;return{update(o){o.docChanged&&(t.pos=o.changes.mapPos(t.pos),l=l.map(o.changes))},get(o,a,u){let f=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),d,m=yS(n,f.pos,f.assoc,i);if(t.pos!=f.pos&&!a){let g=yS(n,t.pos,t.assoc,i),b=Math.min(g.from,m.from),v=Math.max(g.to,m.to);m=b1&&(d=Rj(l,f.pos))?d:u?l.addRange(m):re.create([m])}}}function Rj(n,e){for(let t=0;t=e)return re.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}Wi.dragstart=(n,e)=>{let{selection:{main:t}}=n.state;if(e.target.draggable){let l=n.docView.tile.nearest(e.target);if(l&&l.isWidget()){let o=l.posAtStart,a=o+l.length;(o>=t.to||a<=t.from)&&(t=re.undirectionalRange(o,a))}}let{inputState:i}=n;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=t,e.dataTransfer&&(e.dataTransfer.setData("Text",zd(n.state,dy,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Wi.dragend=n=>(n.inputState.draggedContent=null,!1);function kS(n,e,t,i){if(t=zd(n.state,hy,t),!t)return;let l=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,a=i&&o&&Tj(n,e)?{from:o.from,to:o.to}:null,u={from:l,insert:t},f=n.state.changes(a?[a,u]:u);n.focus(),n.dispatch({changes:f,selection:{anchor:f.mapPos(l,-1),head:f.mapPos(l,1)},userEvent:a?"move.drop":"input.drop"}),n.inputState.draggedContent=null}Wi.drop=(n,e)=>{if(!e.dataTransfer)return!1;if(n.state.readOnly)return!0;let t=e.dataTransfer.files;if(t&&t.length){let i=Array(t.length),l=0,o=()=>{++l==t.length&&kS(n,e,i.filter(a=>a!=null).join(n.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(i[a]=u.result),o()},u.readAsText(t[a])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return kS(n,e,i,!0),!0}return!1};Wi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=cT?null:e.clipboardData;return t?(uT(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(Ej(n),!1)};function jj(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function _j(n){let e=[],t=[],i=!1;for(let l of n.selection.ranges)l.empty||(e.push(n.sliceDoc(l.from,l.to)),t.push(l));if(!e.length){let l=-1;for(let{from:o}of n.selection.ranges){let a=n.doc.lineAt(o);a.number>l&&(e.push(a.text),t.push({from:a.from,to:Math.min(n.doc.length,a.to+1)})),l=a.number}i=!0}return{text:zd(n,dy,e.join(n.lineBreak)),ranges:t,linewise:i}}let ux=null;Wi.copy=Wi.cut=(n,e)=>{if(!Rc(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:l}=_j(n.state);if(!t&&!l)return!1;ux=l?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=cT?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(jj(n,t),!1)};const hT=Jr.define();function dT(n,e){let t=[];for(let i of n.facet(QO)){let l=i(n,e);l&&t.push(l)}return t.length?n.update({effects:t,annotations:hT.of(!0)}):null}function mT(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=dT(n.state,e);t?n.dispatch(t):n.update([])}},10)}qn.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),mT(n)};qn.blur=n=>{n.observer.clearSelectionRange(),mT(n)};qn.compositionstart=qn.compositionupdate=(n,e)=>{if(!n.observer.editContext&&(n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0)){let{main:t}=n.state.selection;!t.empty&&n.lineBlockAt(t.from).from!=n.lineBlockAt(t.to).from&&!n.state.readOnly&&n.dispatch({changes:n.state.selection.ranges.filter(i=>!i.empty).map(i=>({from:i.from,to:i.to})),userEvent:"input"}),n.inputState.composing=0}};qn.compositionend=n=>{n.observer.editContext||(n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,Se.chrome&&Se.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.hasComposition&&n.update([])},50))};qn.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};Wi.beforeinput=(n,e)=>{var t,i;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(n.inputState.insertingText=e.data,n.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&n.observer.editContext){let o=(t=e.dataTransfer)===null||t===void 0?void 0:t.getData("text/plain"),a=e.getTargetRanges();if(o&&a.length){let u=a[0],f=n.posAtDOM(u.startContainer,u.startOffset),d=n.posAtDOM(u.endContainer,u.endOffset);return xy(n,{from:f,to:d,insert:n.state.toText(o)},null),!0}}let l;if(Se.chrome&&Se.android&&(l=oT.find(o=>o.inputType==e.inputType))&&(n.observer.delayAndroidKey(l.key,l.keyCode),l.key=="Backspace"||l.key=="Delete")){let o=((i=window.visualViewport)===null||i===void 0?void 0:i.height)||0;setTimeout(()=>{var a;(((a=window.visualViewport)===null||a===void 0?void 0:a.height)||0)>o+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}return Se.ios&&e.inputType=="deleteContentForward"&&n.observer.flushSoon(),Se.safari&&e.inputType=="insertText"&&n.inputState.composing>=0&&setTimeout(()=>qn.compositionend(n,e),20),!1};const SS=new Set;function Lj(n){SS.has(n)||(SS.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const CS=["pre-wrap","normal","pre-line","break-spaces"];let ha=!1;function OS(){ha=!1}class zj{constructor(e){this.lineWrapping=e,this.doc=ot.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}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 CS.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,f=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=t,this.charWidth=i,this.textHeight=l,this.lineLength=o,f){this.heightSamples={};for(let d=0;d0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>zh&&(ha=!0),this.height=e)}replace(e,t,i){return Vn.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,l){let o=this,a=i.doc;for(let u=l.length-1;u>=0;u--){let{fromA:f,toA:d,fromB:m,toB:g}=l[u],b=o.lineAt(f,Mt.ByPosNoHeight,i.setDoc(t),0,0),v=b.to>=d?b:o.lineAt(d,Mt.ByPosNoHeight,i,0,0);for(g+=v.to-d,d=v.to;u>0&&b.from<=l[u-1].toA;)f=l[u-1].fromA,m=l[u-1].fromB,u--,fo*2){let u=e[t-1];u.break?e.splice(--t,1,u.left,null,u.right):e.splice(--t,1,u.left,u.right),i+=1+u.break,l-=u.size}else if(o>l*2){let u=e[i];u.break?e.splice(i,1,u.left,null,u.right):e.splice(i,1,u.left,u.right),i+=2+u.break,o-=u.size}else break;else if(l=o&&a(this.lineAt(0,Mt.ByPos,i,l,o))}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,i=!1,l){return l&&l.from<=t&&l.more&&this.setMeasuredHeight(l),this.outdated=!1,this}toString(){return`block(${this.length})`}}class xi extends pT{constructor(e,t,i){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=i}mainBlock(e,t){return new Xi(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,t,i){let l=i[0];return i.length==1&&(l instanceof xi||l instanceof kn&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof kn?l=new xi(l.length,this.height,this.spaceAbove):l.height=this.height,this.outdated||(l.outdated=!1),l):Vn.of(i)}updateHeight(e,t=0,i=!1,l){return l&&l.from<=t&&l.more?this.setMeasuredHeight(l):(i||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:""})`}}class kn extends Vn{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,l=e.doc.lineAt(t+this.length).number,o=l-i+1,a,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);a=f/o,this.length>o+1&&(u=(this.height-f)/(this.length-o-1))}else a=this.height/o;return{firstLine:i,lastLine:l,perLine:a,perChar:u}}blockAt(e,t,i,l){let{firstLine:o,lastLine:a,perLine:u,perChar:f}=this.heightMetrics(t,l);if(t.lineWrapping){let d=l+(e0){let o=i[i.length-1];o instanceof kn?i[i.length-1]=new kn(o.length+l):i.push(null,new kn(l-1))}if(e>0){let o=i[0];o instanceof kn?i[0]=new kn(e+o.length):i.unshift(new kn(e-1),null)}return Vn.of(i)}decomposeLeft(e,t){t.push(new kn(e-1),null)}decomposeRight(e,t){t.push(null,new kn(this.length-e-1))}updateHeight(e,t=0,i=!1,l){let o=t+this.length;if(l&&l.from<=t+this.length&&l.more){let a=[],u=Math.max(t,l.from),f=-1;for(l.from>t&&a.push(new kn(l.from-t-1).updateHeight(e,t));u<=o&&l.more;){let m=e.doc.lineAt(u).length;a.length&&a.push(null);let g=l.heights[l.index++],b=0;g<0&&(b=-g,g=l.heights[l.index++]),f==-1?f=g:Math.abs(g-f)>=zh&&(f=-2);let v=new xi(m,g,b);v.outdated=!1,a.push(v),u+=m+1}u<=o&&a.push(null,new kn(o-u).updateHeight(e,u));let d=Vn.of(a);return(f<0||Math.abs(d.height-this.height)>=zh||Math.abs(f-this.heightMetrics(e,t).perLine)>=zh)&&(ha=!0),td(this,d)}else(i||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class Hj extends Vn{constructor(e,t,i){super(e.length+(t?1:0)+i.length,e.height+i.height,(t?1:0)|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,l){let o=i+this.left.height;return eu))return d;let m=t==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?d.join(this.right.lineAt(u,m,i,a,u)):this.left.lineAt(u,m,i,l,o).join(d)}forEachLine(e,t,i,l,o,a){let u=l+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,t,i,u,f,a);else{let d=this.lineAt(f,Mt.ByPos,i,l,o);e=e&&d.from<=t&&a(d),t>d.to&&this.right.forEachLine(Math.max(e,d.to+1),t,i,u,f,a)}}replace(e,t,i){let l=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-l,t-l,i));let o=[];e>0&&this.decomposeLeft(e,o);let a=o.length;for(let u of i)o.push(u);if(e>0&&TS(o,a-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,l=i+this.break;if(e>=l)return this.right.decomposeRight(e-l,t);e2*t.size||t.size>2*e.size?Vn.of(this.break?[e,null,t]:[e,t]):(this.left=td(this.left,e),this.right=td(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,i=!1,l){let{left:o,right:a}=this,u=t+o.length+this.break,f=null;return l&&l.from<=t+o.length&&l.more?f=o=o.updateHeight(e,t,i,l):o.updateHeight(e,t,i),l&&l.from<=u+a.length&&l.more?f=a=a.updateHeight(e,u,i,l):a.updateHeight(e,u,i),f?this.balanced(o,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function TS(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof kn&&(i=n[e+1])instanceof kn&&n.splice(e-1,3,new kn(t.length+1+i.length))}const Ij=5;class yy{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 i=Math.min(t,this.lineEnd),l=this.nodes[this.nodes.length-1];l instanceof xi?l.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new xi(i-this.pos,-1,0)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=Ij)&&this.addLineDeco(l,o,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new xi(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let i=new kn(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof xi)return e;let t=new xi(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=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,i){let l=this.ensureLine();l.length+=i,l.collapsed+=i,l.widgetHeight=Math.max(l.widgetHeight,e),l.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof xi)&&!this.isCovered?this.nodes.push(new xi(0,-1,0)):(this.writtenTod.clientHeight||d.scrollWidth>d.clientWidth)&&m.overflow!="visible"){let g=d.getBoundingClientRect();o=Math.max(o,g.left),a=Math.min(a,g.right),u=Math.max(u,g.top),f=Math.min(d==n.parentNode?l.innerHeight:f,g.bottom)}d=m.position=="absolute"||m.position=="fixed"?d.offsetParent:d.parentNode}else if(d.nodeType==11)d=d.host;else break;return{left:o-t.left,right:Math.max(o,a)-t.left,top:u-(t.top+e),bottom:Math.max(u,f)-(t.top+e)}}function qj(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function Qj(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class $g{constructor(e,t,i,l){this.from=e,this.to=t,this.size=i,this.displaySize=l}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof l!="function"&&l.class=="cm-lineWrapping");this.heightOracle=new zj(i),this.stateDeco=AS(t),this.heightMap=Vn.empty().applyChanges(this.stateDeco,ot.empty,this.heightOracle.setDoc(t.doc),[new Ri(0,0,0,t.doc.length)]);for(let l=0;l<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());l++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Ue.set(this.lineGaps.map(l=>l.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let l=i?t.head:t.anchor;if(!e.some(({from:o,to:a})=>l>=o&&l<=a)){let{from:o,to:a}=this.lineBlockAt(l);e.push(new lh(o,a))}}return this.viewports=e.sort((i,l)=>i.from-l.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?fx:nd.get(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(Nc(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=AS(this.state);let l=e.changedRanges,o=Ri.extendWithRanges(l,Uj(i,this.stateDeco,e?e.changes:ln.empty(this.state.doc.length))),a=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);OS(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),o),(this.heightMap.height!=a||ha)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let f=o.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,t));let d=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(d||!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($O)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,i=window.getComputedStyle(t),l=this.heightOracle,o=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?kt.RTL:kt.LTR;let a=this.heightOracle.mustRefreshForWrapping(o)||this.mustMeasureContent==="refresh",u=t.getBoundingClientRect(),f=a||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let d=0,m=0;if(u.width&&u.height){let{scaleX:B,scaleY:D}=NO(t,u);(B>.005&&Math.abs(this.scaleX-B)>.005||D>.005&&Math.abs(this.scaleY-D)>.005)&&(this.scaleX=B,this.scaleY=D,d|=16,a=f=!0)}let g=(parseInt(i.paddingTop)||0)*this.scaleY,b=(parseInt(i.paddingBottom)||0)*this.scaleY;(this.paddingTop!=g||this.paddingBottom!=b)&&(this.paddingTop=g,this.paddingBottom=b,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(l.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let v=AO(this.view.contentDOM,!1).y;v!=this.scrollParent&&(this.scrollParent=v,this.scrollAnchorHeight=-1,this.scrollOffset=0);let w=this.getScrollOffset();this.scrollOffset!=w&&(this.scrollAnchorHeight=-1,this.scrollOffset=w),this.scrolledToBottom=RO(this.scrollParent||e.win);let S=(this.printing?Qj:Vj)(t,this.paddingTop),C=S.top-this.pixelViewport.top,O=S.bottom-this.pixelViewport.bottom;this.pixelViewport=S;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(f=!0)),!this.inView&&!this.scrollTarget&&!qj(e.dom))return 0;let M=u.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),f){let B=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(B)&&(a=!0),a||l.lineWrapping&&Math.abs(M-this.contentDOMWidth)>l.charWidth){let{lineHeight:D,charWidth:R,textHeight:P}=e.docView.measureTextSize();a=D>0&&l.refresh(o,D,R,P,Math.max(5,M/R),B),a&&(e.docView.minWidth=0,d|=16)}C>0&&O>0?m=Math.max(C,O):C<0&&O<0&&(m=Math.min(C,O)),OS();for(let D of this.viewports){let R=D.from==this.viewport.from?B:e.docView.measureVisibleLineHeights(D);this.heightMap=(a?Vn.empty().applyChanges(this.stateDeco,ot.empty,this.heightOracle,[new Ri(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,a,new Bj(D.from,R))}ha&&(d|=2)}let H=!this.viewportIsAppropriate(this.viewport,m)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return H&&(d&2&&(d|=this.updateScaler()),this.viewport=this.getViewport(m,this.scrollTarget),d|=this.updateForViewport()),(d&2||H)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),l=this.heightMap,o=this.heightOracle,{visibleTop:a,visibleBottom:u}=this,f=new lh(l.lineAt(a-i*1e3,Mt.ByHeight,o,0,0).from,l.lineAt(u+(1-i)*1e3,Mt.ByHeight,o,0,0).to);if(t){let{head:d}=t.range;if(df.to){let m=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),g=l.lineAt(d,Mt.ByPos,o,0,0),b;t.y=="center"?b=(g.top+g.bottom)/2-m/2:t.y=="start"||t.y=="nearest"&&d=u+Math.max(10,Math.min(i,250)))&&l>a-2*1e3&&o>1,a=l<<1;if(this.defaultTextDirection!=kt.LTR&&!i)return[];let u=[],f=(m,g,b,v)=>{if(g-mm&&OO.from>=b.from&&O.to<=b.to&&Math.abs(O.from-m)O.from<_&&O.to>_));if(!C){if(gM.from<=g&&M.to>=g)){let M=t.moveToLineBoundary(re.cursor(g),!1,!0).head;M>m&&(g=M)}let O=this.gapSize(b,m,g,v),_=i||O<2e6?O:2e6;C=new $g(m,g,O,_)}u.push(C)},d=m=>{if(m.length2e6)for(let D of e)D.from>=m.from&&D.fromm.from&&f(m.from,v,m,g),wt.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let i=[];it.spans(t,this.viewport.from,this.viewport.to,{span(o,a){i.push({from:o,to:a})},point(){}},20);let l=0;if(i.length!=this.visibleRanges.length)l=12;else for(let o=0;o=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Nc(this.heightMap.lineAt(e,Mt.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)||Nc(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Nc(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}}class lh{constructor(e,t){this.from=e,this.to=t}}function $j(n,e,t){let i=[],l=n,o=0;return it.spans(t,n,e,{span(){},point(a,u){a>l&&(i.push({from:l,to:a}),o+=a-l),l=u}},20),l=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let l=0;;l++){let{from:o,to:a}=e[l],u=a-o;if(i<=u)return o+i;i-=u}}function oh(n,e){let t=0;for(let{from:i,to:l}of n.ranges){if(e<=l){t+=e-i;break}t+=l-i}return t/n.total}function Gj(n,e){for(let t of n)if(e(t))return t}const fx={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function AS(n){let e=n.facet(jd).filter(i=>typeof i!="function"),t=n.facet(py).filter(i=>typeof i!="function");return t.length&&e.push(it.join(t)),e}class nd{constructor(e,t){this.scale=e,this.viewports=t}static get(e,t,i){let l=0,o=0,a=0,u=i.map(({from:d,to:m})=>{let g=t.lineAt(d,Mt.ByPos,e,0,0).top,b=t.lineAt(m,Mt.ByPos,e,0,0).bottom;return l+=b-g,{from:d,to:m,top:g,bottom:b,domTop:0,domBottom:0}});if(t.height-l<10)return fx;let f=(7e6-l)/(t.height-l);for(let d of u)d.domTop=a+(d.top-o)*f,a=d.domBottom=d.domTop+(d.bottom-d.top),o=d.bottom;return new nd(f,u)}toDOM(e){for(let t=0,i=0,l=0;;t++){let o=tt.from==e.viewports[i].from&&t.to==e.viewports[i].to):!1}}function Nc(n,e){if(e.scale==1)return n;let t=e.toDOM(n.top),i=e.toDOM(n.bottom);return new Xi(n.from,n.length,t,i-t,Array.isArray(n._content)?n._content.map(l=>Nc(l,e)):n._content)}const ah=Ne.define({combine:n=>n.join(" ")}),hx=Ne.define({combine:n=>n.indexOf(!0)>-1}),dx=Vl.newName(),gT=Vl.newName(),xT=Vl.newName(),yT={"&light":"."+gT,"&dark":"."+xT};function mx(n,e,t){return new Vl(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,l=>{if(l=="&")return n;if(!t||!t[l])throw new RangeError(`Unsupported selector: ${l}`);return t[l]}):n+" "+i}})}const Yj=mx("."+dx,{"&":{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:"baseline",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,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"}},yT),Kj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Gg=Se.ie&&Se.ie_version<=11;class Wj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new TR,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 i of t)this.queue.push(i);(Se.ie&&Se.ie_version<=11||Se.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Se.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Se.chrome&&Se.chrome_version<126)&&(this.editContext=new Jj(e),e.state.facet($r)&&(e.contentDOM.editContext=this.editContext.editContext)),Gg&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.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(t=>{t.length>0&&t[t.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(this.pendingRecords().length>0),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,i)=>t!=e[i]))){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:i}=this,l=this.selectionRange;if(i.state.facet($r)?i.root.activeElement!=this.dom:!Rc(this.dom,l))return;let o=l.anchorNode&&i.docView.tile.nearest(l.anchorNode);if(o&&o.isWidget()&&o.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Se.ie&&Se.ie_version<=11||Se.android&&Se.chrome)&&!i.state.selection.main.empty&&l.focusNode&&jc(l.focusNode,l.focusOffset,l.anchorNode,l.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Xc(e.root);if(!t)return!1;let i=Se.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Zj(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let l=Rc(this.dom,i);return l&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let o=this.delayedAndroidKey;o&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=o.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&o.force&&ea(this.dom,o.key,o.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(l)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{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,i=-1,l=!1;for(let o of e){let a=this.readMutation(o);a&&(a.typeOver&&(l=!0),t==-1?{from:t,to:i}=a:(t=Math.min(a.from,t),i=Math.max(a.to,i)))}return{from:t,to:i,typeOver:l}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),l=this.selectionChanged&&Rc(this.dom,this.selectionRange);if(e<0&&!l)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let o=new pj(this.view,e,t,i);return this.view.docView.domChanged={newSel:o.newSel?o.newSel.main:null},o}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,i=this.readChange();if(!i)return this.view.requestMeasure(),!1;let l=this.view.state,o=lT(this.view,i);return this.view.state==l&&(i.domChanged||t)&&this.view.update([]),o}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 i=ES(t,e.previousSibling||e.target.previousSibling,-1),l=ES(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:l?t.posBefore(l):t.posAtEnd,typeOver:!1}}else 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,i;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect();for(let l of this.scrollTargets)l.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 ES(n,e,t){for(;e;){let i=It.get(e);if(i&&i.parent==n)return i;let l=e.parentNode;e=l!=n.dom?l:t>0?e.nextSibling:e.previousSibling}return null}function MS(n,e){let t=e.startContainer,i=e.startOffset,l=e.endContainer,o=e.endOffset,a=n.docView.domAtPos(n.state.selection.main.anchor,1);return jc(a.node,a.offset,l,o)&&([t,i,l,o]=[l,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}}function Zj(n,e){if(e.getComposedRanges){let l=e.getComposedRanges(n.root)[0];if(l)return MS(n,l)}let t=null;function i(l){l.preventDefault(),l.stopImmediatePropagation(),t=l.getTargetRanges()[0]}return n.contentDOM.addEventListener("beforeinput",i,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",i,!0),t?MS(n,t):null}class Jj{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=i=>{let l=e.state.selection.main,{anchor:o,head:a}=l,u=this.toEditorPos(i.updateRangeStart),f=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:u,drifted:!1});let d=f-u>i.text.length;u==this.from&&othis.to&&(f=o);let m=sT(e.state.sliceDoc(u,f),i.text,(d?l.from:l.to)-u,d?"end":null);if(!m){let b=re.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));cx(b,l)||e.dispatch({selection:b,userEvent:"select"});return}let g={from:m.from+u,to:m.toA+u,insert:ot.of(i.text.slice(m.from,m.toB).split(` +`))};if((Se.mac||Se.android)&&g.from==a-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(g={from:u,to:f,insert:ot.of([i.text.replace("."," ")])}),this.pendingContextChange=g,!e.state.readOnly){let b=this.to-this.from+(g.to-g.from+g.insert.length);xy(e,g,re.single(this.toEditorPos(i.selectionStart,b),this.toEditorPos(i.selectionEnd,b)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),g.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let l=[],o=null;for(let a=this.toEditorPos(i.rangeStart),u=this.toEditorPos(i.rangeEnd);a{let l=[];for(let o of i.getTextFormats()){let a=o.underlineStyle,u=o.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(u)){let f=this.toEditorPos(o.rangeStart),d=this.toEditorPos(o.rangeEnd);if(f{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:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{let l=Xc(i.root);l&&l.rangeCount&&this.editContext.updateSelectionBounds(l.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,l=this.pendingContextChange;return e.changes.iterChanges((o,a,u,f,d)=>{if(i)return;let m=d.length-(a-o);if(l&&a>=l.to)if(l.from==o&&l.to==a&&l.insert.eq(d)){l=this.pendingContextChange=null,t+=m,this.to+=m;return}else l=null,this.revertPending(e.state);if(o+=t,a+=t,a<=this.from)this.from+=m,this.to+=m;else if(othis.to||this.to-this.from+d.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(a),d.toString()),this.to+=m}t+=m}),l&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(l=>!l.isUserEvent("input.type")&&l.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,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),l=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=l)&&this.editContext.updateSelection(i,l)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.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])}}class Ae{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={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,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:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(l=>l.forEach(o=>i(o,this)))||(l=>this.update(l)),this.dispatch=this.dispatch.bind(this),this._root=e.root||NR(e.parent)||document,this.viewState=new NS(this,e.state||ut.create(e)),e.scrollTo&&e.scrollTo.is(nh)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Go).map(l=>new Fg(l));for(let l of this.plugins)l.update(this);this.observer=new Wj(this),this.inputState=new bj(this),this.inputState.ensureHandlers(this.plugins),this.docView=new mS(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof sn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,l,o=this.state;for(let b of e){if(b.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=b.state}if(this.destroyed){this.viewState.state=o;return}let a=this.hasFocus,u=0,f=null;e.some(b=>b.annotation(hT))?(this.inputState.notifiedFocused=a,u=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,f=dT(o,a),f||(u=1));let d=this.observer.delayedAndroidKey,m=null;if(d?(this.observer.clearDelayedAndroidKey(),m=this.observer.readChange(),(m&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(m=null)):this.observer.clear(),o.facet(ut.phrases)!=this.state.facet(ut.phrases))return this.setState(o);l=Zh.create(this,o,e),l.flags|=u;let g=this.viewState.scrollTarget;try{this.updateState=2;for(let b of e){if(g&&(g=g.map(b.changes)),b.scrollIntoView){let{main:v}=b.state.selection,{x:w,y:S}=this.state.facet(Ae.cursorScrollMargin);g=new ta(v.empty?v:re.cursor(v.head,v.head>v.anchor?-1:1),"nearest","nearest",S,w)}for(let v of b.effects)v.is(nh)&&(g=v.value.clip(this.state))}this.viewState.update(l,g),this.bidiCache=id.update(this.bidiCache,l.changes),l.empty||(this.updatePlugins(l),this.inputState.update(l)),t=this.docView.update(l),this.state.facet(Tc)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(b=>b.isUserEvent("select.pointer")))}finally{this.updateState=0}if(l.startState.facet(ah)!=l.state.facet(ah)&&(this.viewState.mustMeasureContent=!0),(t||i||g||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!l.empty)for(let b of this.state.facet(lx))try{b(l)}catch(v){ni(this.state,v,"update listener")}(f||m)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),m&&!lT(this,m)&&d.force&&ea(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new 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 i of this.plugins)i.destroy(this);this.viewState=new NS(this,e),this.plugins=e.facet(Go).map(i=>new Fg(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new mS(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(Go),i=e.state.facet(Go);if(t!=i){let l=[];for(let o of i){let a=t.indexOf(o);if(a<0)l.push(new Fg(o));else{let u=this.plugins[a];u.mustUpdate=e,l.push(u)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=l,this.pluginMap.clear()}else for(let l of this.plugins)l.mustUpdate=e;for(let l=0;l-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,i=this.viewState.scrollParent,l=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:a,scaleY:u}=this.viewState;Math.abs(l-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(a<0){if(RO(i||this.win))o=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let w=this.viewState.scrollAnchorAt(l);o=w.from,a=w.top}u=this.viewState.scaleY}this.updateState=1;let d=this.viewState.measure();if(!d&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let m=[];d&4||([this.measureRequests,m]=[m,this.measureRequests]);let g=m.map(w=>{try{return w.read(this)}catch(S){return ni(this.state,S),DS}}),b=Zh.create(this,this.state,[]),v=!1;b.flags|=d,t?t.flags|=d:t=b,this.updateState=2,b.empty||(this.updatePlugins(b),this.inputState.update(b),this.updateAttrs(),v=this.docView.update(b),v&&this.docViewUpdate());for(let w=0;w1||S<-1)&&!(Se.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){l=l+S,i?o<0?i.scrollTop=i.scrollHeight:i.scrollTop+=S:this.win.scrollBy(0,S),a=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let f of this.state.facet(lx))f(t)}get themeClasses(){return dx+" "+(this.state.facet(hx)?xT:gT)+" "+this.state.facet(ah)}updateAttrs(){let e=RS(this,KO,{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:`${Se.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),RS(this,my,t);let i=this.observer.ignore(()=>{let l=aS(this.contentDOM,this.contentAttrs,t),o=aS(this.dom,this.editorAttrs,e);return l||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let l of i.effects)if(l.is(Ae.announce)){t&&(this.announceDOM.textContent="",this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=" "},200),t=!1);let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=l.value}}mountStyles(){this.styleModules=this.state.facet(Tc);let e=this.state.facet(Ae.cspNonce);Vl.mount(this.root,this.styleModules.concat(Yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new 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;ti.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,i){return Xg(this,e,pS(this,e,t,i))}moveByGroup(e,t){return Xg(this,e,pS(this,e,t,i=>cj(this,e.head,i)))}visualLineSide(e,t){return t?re.cursor(e.to,1):re.cursor(e.from,-1)}moveToLineBoundary(e,t,i=!0){return aj(this,e,t,i)}moveVertically(e,t,i){return Xg(this,e,uj(this,e,t,i))}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 i=ax(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),ax(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.state.doc.lineAt(e),l=this.bidiSpans(i),o=l[vr.find(l,e-i.from,-1,t)];return i.length&&(e==i.from&&t<0||e==i.to&&t>0)&&o.dir!=this.textDirectionAt(i.from)&&(e==i.to?(e=i.from+o.from,t=1):(e=i.from+o.to,t=-1)),this.docView.coordsAt(e,t,o.dir==kt.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(XO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>e_)return PO(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||BO(o.isolates,i=fS(this,e))))return o.order;i||(i=fS(this,e));let l=LR(e.text,t,i);return this.bidiCache.push(new id(e.from,e.to,t,i,!0,l)),l}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Se.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{DO(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.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,l,o,a;return nh.of(new ta(typeof e=="number"?re.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(l=t.x)!==null&&l!==void 0?l:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(a=t.xMargin)!==null&&a!==void 0?a:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return nh.of(new ta(re.cursor(i.from),"start","start",i.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 Qt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Qt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=Vl.newName(),l=[ah.of(i),Tc.of(mx(`.${i}`,e))];return t&&t.dark&&l.push(hx.of(!0)),l}static baseTheme(e){return Fs.lowest(Tc.of(mx("."+dx,e,yT)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),l=i&&It.get(i)||It.get(e);return((t=l==null?void 0:l.root)===null||t===void 0?void 0:t.view)||null}}Ae.styleModule=Tc;Ae.inputHandler=qO;Ae.clipboardInputFilter=hy;Ae.clipboardOutputFilter=dy;Ae.scrollHandler=GO;Ae.focusChangeEffect=QO;Ae.perLineTextDirection=XO;Ae.exceptionSink=VO;Ae.updateListener=lx;Ae.editable=$r;Ae.mouseSelectionStyle=FO;Ae.dragMovesSelection=UO;Ae.clickAddsSelectionRange=IO;Ae.decorations=jd;Ae.blockWrappers=WO;Ae.outerDecorations=py;Ae.atomicRanges=au;Ae.bidiIsolatedRanges=ZO;Ae.cursorScrollMargin=Ne.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});Ae.scrollMargins=eT;Ae.darkTheme=hx;Ae.cspNonce=Ne.define({combine:n=>n.length?n[0]:""});Ae.contentAttributes=my;Ae.editorAttributes=KO;Ae.lineWrapping=Ae.contentAttributes.of({class:"cm-lineWrapping"});Ae.announce=Ke.define();const e_=4096,DS={};class id{constructor(e,t,i,l,o,a){this.from=e,this.to=t,this.dir=i,this.isolates=l,this.fresh=o,this.order=a}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],l=e.length?e[e.length-1].dir:kt.LTR;for(let o=Math.max(0,e.length-10);o=0;l--){let o=i[l],a=typeof o=="function"?o(n):o;a&&cy(a,t)}return t}const t_=Se.mac?"mac":Se.windows?"win":Se.linux?"linux":"key";function n_(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let l,o,a,u;for(let f=0;fi.concat(l),[]))),t}function r_(n,e,t){return vT(bT(n.state),e,n,t)}let Ll=null;const l_=4e3;function s_(n,e=t_){let t=Object.create(null),i=Object.create(null),l=(a,u)=>{let f=i[a];if(f==null)i[a]=u;else if(f!=u)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},o=(a,u,f,d,m)=>{var g,b;let v=t[a]||(t[a]=Object.create(null)),w=u.split(/ (?!$)/).map(O=>n_(O,e));for(let O=1;O{let H=Ll={view:M,prefix:_,scope:a};return setTimeout(()=>{Ll==H&&(Ll=null)},l_),!0}]})}let S=w.join(" ");l(S,!1);let C=v[S]||(v[S]={preventDefault:!1,stopPropagation:!1,run:((b=(g=v._any)===null||g===void 0?void 0:g.run)===null||b===void 0?void 0:b.slice())||[]});f&&C.run.push(f),d&&(C.preventDefault=!0),m&&(C.stopPropagation=!0)};for(let a of n){let u=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let d of u){let m=t[d]||(t[d]=Object.create(null));m._any||(m._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:g}=a;for(let b in m)m[b].run.push(v=>g(v,px))}let f=a[e]||a.key;if(f)for(let d of u)o(d,f,a.run,a.preventDefault,a.stopPropagation),a.shift&&o(d,"Shift-"+f,a.shift,a.preventDefault,a.stopPropagation)}return t}let px=null;function vT(n,e,t,i){px=e;let l=vR(e),o=Jn(l,0),a=yr(o)==l.length&&l!=" ",u="",f=!1,d=!1,m=!1;Ll&&Ll.view==t&&Ll.scope==i&&(u=Ll.prefix+" ",aT.indexOf(e.keyCode)<0&&(d=!0,Ll=null));let g=new Set,b=C=>{if(C){for(let O of C.run)if(!g.has(O)&&(g.add(O),O(t)))return C.stopPropagation&&(m=!0),!0;C.preventDefault&&(C.stopPropagation&&(m=!0),d=!0)}return!1},v=n[i],w,S;return v&&(b(v[u+ch(l,e,!a)])?f=!0:a&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Se.windows&&e.ctrlKey&&e.altKey)&&!(Se.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(w=ql[e.keyCode])&&w!=l?(b(v[u+ch(w,e,!0)])||e.shiftKey&&(S=qc[e.keyCode])!=l&&S!=w&&b(v[u+ch(S,e,!1)]))&&(f=!0):a&&e.shiftKey&&b(v[u+ch(l,e,!0)])&&(f=!0),!f&&b(v._any)&&(f=!0)),d&&(f=!0),f&&m&&e.stopPropagation(),px=null,f}class _s{constructor(e,t,i,l,o){this.className=e,this.left=t,this.top=i,this.width=l,this.height=o}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(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(e,t,i){if(i.empty){let l=e.coordsAtPos(i.head,i.assoc||1);if(!l)return[];let o=wT(e);return[new _s(t,l.left-o.left,l.top-o.top,null,l.bottom-l.top)]}else return o_(e,t,i)}}function wT(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==kt.LTR?e.left:e.right-n.scrollDOM.clientWidth*n.scaleX)-n.scrollDOM.scrollLeft*n.scaleX,top:e.top-n.scrollDOM.scrollTop*n.scaleY}}function _S(n,e,t,i){let l=n.coordsAtPos(e,t*2);if(!l)return i;let o=n.dom.getBoundingClientRect(),a=(l.top+l.bottom)/2,u=n.posAtCoords({x:o.left+1,y:a}),f=n.posAtCoords({x:o.right-1,y:a});return u==null||f==null?i:{from:Math.max(i.from,Math.min(u,f)),to:Math.min(i.to,Math.max(u,f))}}function o_(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),l=Math.min(t.to,n.viewport.to),o=n.textDirection==kt.LTR,a=n.contentDOM,u=a.getBoundingClientRect(),f=wT(n),d=a.querySelector(".cm-line"),m=d&&window.getComputedStyle(d),g=u.left+(m?parseInt(m.paddingLeft)+Math.min(0,parseInt(m.textIndent)):0),b=u.right-(m?parseInt(m.paddingRight):0),v=ox(n,i,1),w=ox(n,l,-1),S=v.type==Tn.Text?v:null,C=w.type==Tn.Text?w:null;if(S&&(n.lineWrapping||v.widgetLineBreaks)&&(S=_S(n,i,1,S)),C&&(n.lineWrapping||w.widgetLineBreaks)&&(C=_S(n,l,-1,C)),S&&C&&S.from==C.from&&S.to==C.to)return _(M(t.from,t.to,S));{let B=S?M(t.from,null,S):H(v,!1),D=C?M(null,t.to,C):H(w,!0),R=[];return(S||v).to<(C||w).from-(S&&C?1:0)||v.widgetLineBreaks>1&&B.bottom+n.defaultLineHeight/2A&&ae.from=$)break;N>ie&&F(Math.max(Y,ie),B==null&&Y<=A,Math.min(N,$),D==null&&N>=ne,Z.dir)}if(ie=oe.to+1,ie>=$)break}return I.length==0&&F(A,B==null,ne,D==null,n.textDirection),{top:P,bottom:te,horizontal:I}}function H(B,D){let R=u.top+(D?B.top:B.bottom);return{top:R,bottom:R,horizontal:[]}}}function a_(n,e){return n.constructor==e.constructor&&n.eq(e)}class c_{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(Bh)!=e.state.facet(Bh)&&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,i=e.facet(Bh);for(;t!a_(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let l of e)l.update&&t&&l.constructor&&this.drawn[i].constructor&&l.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(l.draw(),t);for(;t;){let l=t.nextSibling;t.remove(),t=l}this.drawn=e,Se.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Bh=Ne.define();function kT(n){return[Qt.define(e=>new c_(e,n)),Bh.of(n)]}const gx=!Se.ios,da=Ne.define({combine(n){return Nr(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function u_(n={}){return[da.of(n),f_,h_,m_,$O.of(!0)]}function ST(n){return n.startState.facet(da)!=n.state.facet(da)}const f_=kT({above:!0,markers(n){let{state:e}=n,t=e.facet(da),i=[];for(let l of e.selection.ranges){let o=l==e.selection.main;if(l.empty||t.drawRangeCursor&&!(o&&Se.ios&&t.iosSelectionHandles)){let a=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=l.empty?l:re.cursor(l.head,l.assoc);for(let f of _s.forRange(n,a,u))i.push(f)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=ST(n);return t&&LS(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){LS(e.state,n)},class:"cm-cursorLayer"});function LS(n,e){e.style.animationDuration=n.facet(da).cursorBlinkRate+"ms"}const h_=kT({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let l of i)if(!l.empty&&(gx||l!=t))for(let o of _s.forRange(n,"cm-selectionBackground",l))e.push(o);if(Se.ios&&!t.empty&&n.state.facet(da).iosSelectionHandles){for(let l of _s.forRange(n,"cm-selectionHandle cm-selectionHandle-start",re.cursor(t.from,1)))e.push(l);for(let l of _s.forRange(n,"cm-selectionHandle cm-selectionHandle-end",re.cursor(t.to,1)))e.push(l)}return e},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||ST(n)},class:"cm-selectionLayer"}),d_=Se.gecko&&Se.gecko_version==153?"#ffffff01":"transparent",m_=Fs.highest(Ae.theme({".cm-line":{...gx?{"& ::selection, &::selection":{backgroundColor:`${d_} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...gx?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),CT=Ke.define({map(n,e){return n==null?null:e.mapPos(n)}}),Ac=Rn.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(CT)?i.value:t,n)}}),p_=Qt.fromClass(class{constructor(n){this.view=n,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(n){var e;let t=n.state.field(Ac);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(n.startState.field(Ac)!=t||n.docChanged||n.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:n}=this,e=n.state.field(Ac),t=e!=null&&n.coordsAtPos(e);if(!t)return null;let i=n.scrollDOM.getBoundingClientRect();return{left:t.left-i.left+n.scrollDOM.scrollLeft*n.scaleX,top:t.top-i.top+n.scrollDOM.scrollTop*n.scaleY,height:t.bottom-t.top}}drawCursor(n){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;n?(this.cursor.style.left=n.left/e+"px",this.cursor.style.top=n.top/t+"px",this.cursor.style.height=n.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(n){this.view.state.field(Ac)!=n&&this.view.dispatch({effects:CT.of(n)})}},{eventObservers:{dragover(n){this.setDropPos(this.view.posAtCoords({x:n.clientX,y:n.clientY}))},dragleave(n){(n.target==this.view.contentDOM||!this.view.contentDOM.contains(n.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function g_(){return[Ac,p_]}function zS(n,e,t,i,l){e.lastIndex=0;for(let o=n.iterRange(t,i),a=t,u;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;u=e.exec(o.value);)l(a+u.index,u)}function x_(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:l,to:o}of t)l=Math.max(n.state.doc.lineAt(l).from,l-e),o=Math.min(n.state.doc.lineAt(o).to,o+e),i.length&&i[i.length-1].to>=l?i[i.length-1].to=o:i.push({from:l,to:o});return i}class y_{constructor(e){const{regexp:t,decoration:i,decorate:l,boundary:o,maxLength:a=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,l)this.addMatch=(u,f,d,m)=>l(m,d,d+u[0].length,u,f);else if(typeof i=="function")this.addMatch=(u,f,d,m)=>{let g=i(u,f,d);g&&m(d,d+u[0].length,g)};else if(i)this.addMatch=(u,f,d,m)=>m(d,d+u[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=o,this.maxLength=a}createDeco(e){let t=new Or,i=t.add.bind(t);for(let{from:l,to:o}of x_(e,this.maxLength))zS(e.state.doc,this.regexp,l,o,(a,u)=>this.addMatch(u,e,a,i));return t.finish()}updateDeco(e,t){let i=1e9,l=-1;return e.docChanged&&e.changes.iterChanges((o,a,u,f)=>{f>=e.view.viewport.from&&u<=e.view.viewport.to&&(i=Math.min(u,i),l=Math.max(f,l))}),e.viewportMoved||l-i>1e3?this.createDeco(e.view):l>-1?this.updateRange(e.view,t.map(e.changes),i,l):t}updateRange(e,t,i,l){for(let o of e.visibleRanges){let a=Math.max(o.from,i),u=Math.min(o.to,l);if(u>=a){let f=e.state.doc.lineAt(a),d=f.tof.from;a--)if(this.boundary.test(f.text[a-1-f.from])){m=a;break}for(;ub.push(O.range(S,C));if(f==d)for(this.regexp.lastIndex=m-f.from;(v=this.regexp.exec(f.text))&&v.indexthis.addMatch(C,e,S,w));t=t.update({filterFrom:m,filterTo:g,filter:(S,C)=>Sg,add:b})}}return t}}const xx=/x/.unicode!=null?"gu":"g",b_=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,xx),v_={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"};let Yg=null;function w_(){var n;if(Yg==null&&typeof document<"u"&&document.body){let e=document.body.style;Yg=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Yg||!1}const Ph=Ne.define({combine(n){let e=Nr(n,{render:null,specialChars:b_,addSpecialChars:null});return(e.replaceTabs=!w_())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,xx)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,xx)),e}});function k_(n={}){return[Ph.of(n),S_()]}let BS=null;function S_(){return BS||(BS=Qt.fromClass(class{constructor(n){this.view=n,this.decorations=Ue.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(Ph)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new y_({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:l}=t.state,o=Jn(e[0],0);if(o==9){let a=l.lineAt(i),u=t.state.tabSize,f=xa(a.text,u,i-a.from);return Ue.replace({widget:new N_((u-f%u)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Ue.replace({widget:new T_(n,o)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(Ph);n.startState.facet(Ph)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const C_="•";function O_(n){return n>=32?C_:n==10?"␤":String.fromCharCode(9216+n)}class T_ extends el{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=O_(this.code),i=e.state.phrase("Control character")+" "+(v_[this.code]||"0x"+this.code.toString(16)),l=this.options.render&&this.options.render(this.code,i,t);if(l)return l;let o=document.createElement("span");return o.textContent=t,o.title=i,o.setAttribute("aria-label",i),o.className="cm-specialChar",o}ignoreEvent(){return!1}}class N_ extends el{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 A_(){return M_}const E_=Ue.line({class:"cm-activeLine"}),M_=Qt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.docChanged||n.selectionSet)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=-1,t=[];for(let i of n.state.selection.ranges){let l=n.lineBlockAt(i.head);l.from>e&&(t.push(E_.range(l.from)),e=l.from)}return Ue.set(t)}},{decorations:n=>n.decorations}),yx=2e3;function D_(n,e,t){let i=Math.min(e.line,t.line),l=Math.max(e.line,t.line),o=[];if(e.off>yx||t.off>yx||e.col<0||t.col<0){let a=Math.min(e.off,t.off),u=Math.max(e.off,t.off);for(let f=i;f<=l;f++){let d=n.doc.line(f);d.length<=u&&o.push(re.range(d.from+a,d.to+u))}}else{let a=Math.min(e.col,t.col),u=Math.max(e.col,t.col);for(let f=i;f<=l;f++){let d=n.doc.line(f),m=G0(d.text,a,n.tabSize,!0);if(m<0)o.push(re.cursor(d.to));else{let g=G0(d.text,u,n.tabSize);o.push(re.range(d.from+m,d.from+g))}}}return o}function R_(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function PS(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),l=t-i.from,o=l>yx?-1:l==i.length?R_(n,e.clientX):xa(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:o,off:l}}function j_(n,e){let t=PS(n,e),i=n.state.selection;return t?{update(l){if(l.docChanged){let o=l.changes.mapPos(l.startState.doc.line(t.line).from),a=l.state.doc.lineAt(o);t={line:a.number,col:t.col,off:Math.min(t.off,a.length)},i=i.map(l.changes)}},get(l,o,a){let u=PS(n,l);if(!u)return i;let f=D_(n.state,t,u);return f.length?a?re.create(f.concat(i.ranges)):re.create(f):i}}:null}function __(n){let e=(t=>t.altKey&&t.button==0);return Ae.mouseSelectionStyle.of((t,i)=>e(i)?j_(t,i):null)}const L_={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},z_={style:"cursor: crosshair"};function B_(n={}){let[e,t]=L_[n.key||"Alt"],i=Qt.fromClass(class{constructor(l){this.view=l,this.isDown=!1}set(l){this.isDown!=l&&(this.isDown=l,this.view.update([]))}},{eventObservers:{keydown(l){this.set(l.keyCode==e||t(l))},keyup(l){(l.keyCode==e||!t(l))&&this.set(!1)},mousemove(l){this.set(t(l))}}});return[i,Ae.contentAttributes.of(l=>{var o;return!((o=l.plugin(i))===null||o===void 0)&&o.isDown?z_:null})]}const uh="-10000px";class OT{constructor(e,t,i,l){this.facet=t,this.createTooltipView=i,this.removeTooltipView=l,this.input=e.state.facet(t),this.tooltips=this.input.filter(a=>a);let o=null;this.tooltipViews=this.tooltips.map(a=>o=i(a,o))}update(e,t){var i;let l=e.state.facet(this.facet),o=l.filter(f=>f);if(l===this.input){for(let f of this.tooltipViews)f.update&&f.update(e);return!1}let a=[],u=t?[]:null;for(let f=0;ft[d]=f),t.length=u.length),this.input=l,this.tooltips=o,this.tooltipViews=a,!0}}function TT(n){let e=n.dom.ownerDocument.documentElement,t=e.clientWidth,i=getComputedStyle(e);if(!/stable/.test(i.scrollbarGutter||""))return{left:0,right:t};let l=e.getBoundingClientRect(),o=n.win.scrollX;return{left:Math.max(0,l.left+o-parseFloat(i.marginLeft)),right:Math.min(t,l.right+o+parseFloat(i.marginRight))}}function P_(n){let{left:e,right:t}=TT(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const Kg=Ne.define({combine:n=>{var e,t,i;return{position:Se.ios?"absolute":((e=n.find(l=>l.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(l=>l.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(l=>l.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||P_}}}),HS=new WeakMap,vy=Qt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Kg);this.position=e.position,this.parent=e.parent,this.classes=n.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 OT(n,wy,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.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 n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Kg);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let l of this.manager.tooltipViews)l.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let l of this.manager.tooltipViews)this.container.appendChild(l.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let l=document.createElement("div");l.className="cm-tooltip-arrow",t.dom.appendChild(l)}return t.dom.style.position=this.position,t.dom.style.top=uh,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1,i=0;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(Se.safari){let u=a.getBoundingClientRect();t=Math.abs(u.top+1e4)>1||Math.abs(u.left)>1}else t=!!a.offsetParent&&a.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(n=a.width/this.parent.offsetWidth,e=a.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);else i=TT(this.view).left;let l=this.view.scrollDOM.getBoundingClientRect(),o=gy(this.view);return{visible:{left:l.left+o.left,top:l.top+o.top,right:l.right-o.right,bottom:l.bottom-o.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,u)=>{let f=this.manager.tooltipViews[u];return f.getCoords?f.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(Kg).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t,fixedLeft:i}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let u of this.manager.tooltipViews)u.dom.style.position="absolute"}let{visible:t,space:i,scaleX:l,scaleY:o}=n,a=[];for(let u=0;u=Math.min(t.bottom,i.bottom)||g.rightMath.min(t.right,i.right)+.1)){m.style.top=uh;continue}let v=f.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,w=v?7:0,S=b.right-b.left,C=(e=HS.get(d))!==null&&e!==void 0?e:b.bottom-b.top,O=d.offset||I_,_=this.view.textDirection==kt.LTR,M=b.width>i.right-i.left?_?i.left:i.right-b.width:_?Math.max(i.left,Math.min(g.left-(v?14:0)+O.x,i.right-S)):Math.min(Math.max(i.left,g.left-S+(v?14:0)-O.x),i.right-S),H=this.above[u];!f.strictSide&&(H?g.top-C-w-O.yi.bottom)&&H==i.bottom-g.bottom>g.top-i.top&&(H=this.above[u]=!H);let B=(H?g.top-i.top:i.bottom-g.bottom)-w;if(BM&&P.topD&&(D=H?P.top-C-2-w:P.bottom+w+2);if(this.position=="absolute"?(m.style.top=(D-n.parent.top)/o+"px",IS(m,(M-n.parent.left)/l)):(m.style.top=D/o+"px",IS(m,(M-n.fixedLeft)/l)),v){let P=g.left+(_?O.x:-O.x)-(M+14-7);v.style.left=P/l+"px"}d.overlap!==!0&&a.push({left:M,top:D,right:R,bottom:D+C}),m.classList.toggle("cm-tooltip-above",H),m.classList.toggle("cm-tooltip-below",!H),d.positioned&&d.positioned(n.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 n of this.manager.tooltipViews)n.dom.style.top=uh}},{eventObservers:{scroll(){this.maybeMeasure()}}});function IS(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const H_=Ae.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"}}}),I_={x:0,y:0},wy=Ne.define({enables:[vy,H_]}),rd=Ne.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Bd{static create(e){return new Bd(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new OT(e,rd,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}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===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let l=i[e];if(l!==void 0){if(t===void 0)t=l;else if(t!==l)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")}}const U_=wy.compute([rd],n=>{let e=n.facet(rd);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Bd.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),NT=Ne.define();class F_{constructor(e,t,i,l,o,a){this.view=e,this.source=t,this.field=i,this.locked=l,this.setHover=o,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;ea.bottom||t.xa.right+e.defaultCharacterWidth)return;let u=e.bidiSpans(e.state.doc.lineAt(l)).find(d=>d.from<=l&&d.to>=l),f=u&&u.dir==kt.RTL?-1:1;o=t.x{if(u&&!(Array.isArray(u)&&!u.length)){let f=Array.isArray(u)?u:[u];l&&this.locked.set(f,l),e.dispatch({effects:this.setHover.of(f)})}};if(o&&"then"in o){let u=this.pending={pos:t};o.then(f=>{this.pending==u&&(this.pending=null,a(f))},f=>ni(e.state,f,"hover tooltip"))}else a(o)}get tooltip(){let e=this.view.plugin(vy),t=e?e.manager.tooltips.findIndex(i=>i.create==Bd.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;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:l,tooltip:o}=this;if(l.length&&!this.locked.has(l)&&o&&!V_(o.dom,e)||this.pending){let{pos:a}=l[0]||this.pending,u=(i=(t=l[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:a;(a==u?this.view.posAtCoords(this.lastMove)!=a:!q_(this.view,a,u,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:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:l}=this;l.length&&!this.locked.has(l)&&!this.view.dom.contains(i.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)}}const fh=4;function V_(n,e){let{left:t,right:i,top:l,bottom:o}=n.getBoundingClientRect(),a;if(a=n.querySelector(".cm-tooltip-arrow")){let u=a.getBoundingClientRect();l=Math.min(u.top,l),o=Math.max(u.bottom,o)}return e.clientX>=t-fh&&e.clientX<=i+fh&&e.clientY>=l-fh&&e.clientY<=o+fh}function q_(n,e,t,i,l,o){let a=n.scrollDOM.getBoundingClientRect(),u=n.documentTop+n.documentPadding.top+n.contentHeight;if(a.left>i||a.rightl||Math.min(a.bottom,u)=e&&f<=t}function Q_(n,e={}){let t=Ke.define(),i=new WeakMap,l=Rn.define({create(){return[]},update(a,u){let f=i.get(a);if(a.length&&(e.hideOnChange&&(u.docChanged||u.selection)?a=[]:f&&f(u)?a=[]:e.hideOn&&(a=a.filter(d=>!e.hideOn(u,d)))),u.docChanged&&a.length){let d=[];for(let m of a){let g=u.changes.mapPos(m.pos,-1,Fn.TrackDel);if(g!=null){let b=Object.assign(Object.create(null),m);b.pos=g,b.end!=null&&(b.end=u.changes.mapPos(b.end)),d.push(b)}}a=d}for(let d of u.effects)d.is(t)&&(a=d.value,f=void 0),(d.is($_)&&!d.value||d.value==l)&&(a=[]);return a.length&&f&&i.set(a,f),a},provide:a=>rd.from(a)});const o=Qt.define(a=>new F_(a,n,l,i,t,e.hoverTime||300));return{active:l,extension:[l,o,NT.of(o),U_]}}function X_(n,e,t,i={}){var l;let o=n.state.facet(NT).map(a=>n.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=o.find(u=>u.field==i.tooltip.active);a&&(o=[a])}for(let a of o)a.activateHover(n,e,t,(l=i.until)!==null&&l!==void 0?l:(()=>!1))}function AT(n,e){let t=n.plugin(vy);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const $_=Ke.define(),US=Ne.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Pd(n,e){let t=n.plugin(ET),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const ET=Qt.fromClass(class{constructor(n){this.input=n.state.facet(Gc),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(US);this.top=new hh(n,!0,e.topContainer),this.bottom=new hh(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(US);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new hh(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new hh(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Gc);if(t!=this.input){let i=t.filter(f=>f),l=[],o=[],a=[],u=[];for(let f of i){let d=this.specs.indexOf(f),m;d<0?(m=f(n.view),u.push(m)):(m=this.panels[d],m.update&&m.update(n)),l.push(m),(m.top?o:a).push(m)}this.specs=i,this.panels=l,this.top.sync(o),this.bottom.sync(a);for(let f of u)f.dom.classList.add("cm-panel"),f.mount&&f.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>Ae.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class hh{constructor(e,t,i){this.view=e,this.top=t,this.container=i,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(),this.dom=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 t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=FS(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=FS(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 FS(n){let e=n.nextSibling;return n.remove(),e}const Gc=Ne.define({enables:ET});function G_(n,e){let t,i=new Promise(a=>t=a),l=a=>K_(a,e,t);n.state.field(Hh,!1)?n.dispatch({effects:MT.of(l)}):n.dispatch({effects:Ke.appendConfig.of(Hh.init(()=>[l]))});let o=DT.of(l);return{close:o,result:i.then(a=>((n.win.queueMicrotask||(f=>n.win.setTimeout(f,10)))(()=>{n.state.field(Hh).indexOf(l)>-1&&n.dispatch({effects:o})}),a))}}function Y_(n,e){let t=n.state.field(Hh,!1)||[];for(let i of t){let l=Pd(n,i);if(l&&l.dom.classList.contains(e))return l}return null}const Hh=Rn.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(MT)?n=[t.value].concat(n):t.is(DT)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>Gc.computeN([n],e=>e.field(n))}),MT=Ke.define(),DT=Ke.define();function K_(n,e,t){let i=e.content?e.content(n,()=>u(null)):null;if(!i){if(i=wt("form"),e.input){let f=wt("input",e.input);/^(text|password|number|email|tel|url)$/.test(f.type)&&f.classList.add("cm-textfield"),f.name||(f.name="input"),i.appendChild(wt("label",(e.label||"")+": ",f))}else i.appendChild(document.createTextNode(e.label||""));i.appendChild(document.createTextNode(" ")),i.appendChild(wt("button",{class:"cm-button",type:"submit"},e.submitLabel||"OK"))}let l=i.nodeName=="FORM"?[i]:i.querySelectorAll("form");for(let f=0;f{m.keyCode==27?(m.preventDefault(),u(null)):m.keyCode==13&&(m.preventDefault(),u(d))}),d.addEventListener("submit",m=>{m.preventDefault(),u(d)})}let o=wt("div",i,wt("button",{onclick:()=>u(null),"aria-label":n.state.phrase("close"),class:"cm-dialog-close",type:"button"},["×"]));e.class&&(o.className=e.class),o.classList.add("cm-dialog");let a=typeof e.focus=="string"?i.querySelector(e.focus):e.focus?i.querySelector("input")||i.querySelector("button"):null;function u(f){o.contains(o.ownerDocument.activeElement)&&n.focus(),t(f)}return{dom:o,top:e.top,mount:()=>{a&&("select"in a?a.select():"focus"in a&&a.focus())},destroy:()=>t(null)}}class Wr extends Fl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Wr.prototype.elementClass="";Wr.prototype.toDOM=void 0;Wr.prototype.mapMode=Fn.TrackBefore;Wr.prototype.startSide=Wr.prototype.endSide=-1;Wr.prototype.point=!0;const Ih=Ne.define(),W_=Ne.define(),Z_={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>it.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Lc=Ne.define();function J_(n){return[RT(),Lc.of({...Z_,...n})]}const VS=Ne.define({combine:n=>n.some(e=>e)});function RT(n){return[eL]}const eL=Qt.fromClass(class{constructor(n){this.view=n,this.domAfter=null,this.prevViewport=n.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=n.state.facet(Lc).map(e=>new QS(n,e)),this.fixed=!n.state.facet(VS);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),n.scrollDOM.insertBefore(this.dom,n.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(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}if(n.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(VS)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=it.iter(this.view.state.facet(Ih),this.view.viewport.from),i=[],l=this.gutters.map(o=>new tL(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(o.type)){let a=!0;for(let u of o.type)if(u.type==Tn.Text&&a){bx(t,i,u.from);for(let f of l)f.line(this.view,u,i);a=!1}else if(u.widget)for(let f of l)f.widget(this.view,u)}else if(o.type==Tn.Text){bx(t,i,o.from);for(let a of l)a.line(this.view,o,i)}else if(o.widget)for(let a of l)a.widget(this.view,o);for(let o of l)o.finish();n&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(n){let e=n.startState.facet(Lc),t=n.state.facet(Lc),i=n.docChanged||n.heightChanged||n.viewportChanged||!it.eq(n.startState.facet(Ih),n.state.facet(Ih),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let l of this.gutters)l.update(n)&&(i=!0);else{i=!0;let l=[];for(let o of t){let a=e.indexOf(o);a<0?l.push(new QS(this.view,o)):(this.gutters[a].update(n),l.push(this.gutters[a]))}for(let o of this.gutters)o.dom.remove(),l.indexOf(o)<0&&o.destroy();for(let o of l)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=l}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:n=>Ae.scrollMargins.of(e=>{let t=e.plugin(n);if(!t||t.gutters.length==0||!t.fixed)return null;let i=t.dom.offsetWidth*e.scaleX,l=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==kt.LTR?{left:i,right:l}:{right:i,left:l}})});function qS(n){return Array.isArray(n)?n:[n]}function bx(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class tL{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=it.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:l}=this,o=(t.top-this.height)/e.scaleY,a=t.height/e.scaleY;if(this.i==l.elements.length){let u=new jT(e,a,o,i);l.elements.push(u),l.dom.appendChild(u.dom)}else l.elements[this.i].update(e,a,o,i);this.height=t.bottom,this.i++}line(e,t,i){let l=[];bx(this.cursor,l,t.from),i.length&&(l=l.concat(i));let o=this.gutter.config.lineMarker(e,t,l);o&&l.unshift(o);let a=this.gutter;l.length==0&&!a.config.renderEmptyElements||this.addElement(e,t,l)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t),l=i?[i]:null;for(let o of e.state.facet(W_)){let a=o(e,t.widget,t);a&&(l||(l=[])).push(a)}l&&this.addElement(e,t,l)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class QS{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 i in t.domEventHandlers)this.dom.addEventListener(i,l=>{let o=l.target,a;if(o!=this.dom&&this.dom.contains(o)){for(;o.parentNode!=this.dom;)o=o.parentNode;let f=o.getBoundingClientRect();a=(f.top+f.bottom)/2}else a=l.clientY;let u=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,u,l)&&l.preventDefault()});this.markers=qS(t.markers(e)),t.initialSpacer&&(this.spacer=new jT(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=qS(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let l=this.config.updateSpacer(this.spacer.markers[0],e);l!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[l])}let i=e.view.viewport;return!it.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class jT{constructor(e,t,i,l){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,l)}update(e,t,i,l){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),nL(this.markers,l)||this.setMarkers(e,l)}setMarkers(e,t){let i="cm-gutterElement",l=this.dom.firstChild;for(let o=0,a=0;;){let u=a,f=oo(u,f,d)||a(u,f,d):a}return i}})}});class Wg extends Wr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Zg(n,e){return n.state.facet(Yo).formatNumber(e,n.state)}const lL=Lc.compute([Yo],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(iL)},lineMarker(e,t,i){return i.some(l=>l.toDOM)?null:new Wg(Zg(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let l of e.state.facet(rL)){let o=l(e,t,i);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(Yo)!=e.state.facet(Yo),initialSpacer(e){return new Wg(Zg(e,XS(e.state.doc.lines)))},updateSpacer(e,t){let i=Zg(t.view,XS(t.view.state.doc.lines));return i==e.number?e:new Wg(i)},domEventHandlers:n.facet(Yo).domEventHandlers,side:"before"}));function sL(n={}){return[Yo.of(n),RT(),lL]}function XS(n){let e=9;for(;e{let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.head).from;l>t&&(t=l,e.push(oL.range(l)))}return it.of(e)});function cL(){return aL}const _T=1024;let uL=0;class Jg{constructor(e,t){this.from=e,this.to=t}}class et{constructor(e={}){this.id=uL++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=ri.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}et.closedBy=new et({deserialize:n=>n.split(" ")});et.openedBy=new et({deserialize:n=>n.split(" ")});et.group=new et({deserialize:n=>n.split(" ")});et.isolate=new et({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});et.contextHash=new et({perNode:!0});et.lookAhead=new et({perNode:!0});et.mounted=new et({perNode:!0});class zc{constructor(e,t,i,l=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=l}static get(e){return e&&e.props&&e.props[et.mounted.id]}}const fL=Object.create(null);class ri{constructor(e,t,i,l=0){this.name=e,this.props=t,this.id=i,this.flags=l}static define(e){let t=e.props&&e.props.length?Object.create(null):fL,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new ri(e.name||"",t,e.id,i);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(l)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return l}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(et.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let l of i.split(" "))t[l]=e[i];return i=>{for(let l=i.prop(et.group),o=-1;o<(l?l.length:0);o++){let a=t[o<0?i.name:l[o]];if(a)return a}}}}ri.none=new ri("",Object.create(null),0,8);class ky{constructor(e){this.types=e;for(let t=0;t0;for(let f=this.cursor(a|Ht.IncludeAnonymous);;){let d=!1;if(f.from<=o&&f.to>=l&&(!u&&f.type.isAnonymous||t(f)!==!1)){if(f.firstChild())continue;d=!0}for(;d&&i&&(u||!f.type.isAnonymous)&&i(f),!f.nextSibling();){if(!f.parent())return;d=!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(e={}){return this.children.length<=8?this:Oy(ri.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,l)=>new Jt(this.type,t,i,l,this.propValues),e.makeTree||((t,i,l)=>new Jt(ri.none,t,i,l)))}static build(e){return pL(e)}}Jt.empty=new Jt(ri.none,[],[],0);class Sy{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 Sy(this.buffer,this.index)}}class Xl{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return ri.none}toString(){let e=[];for(let t=0;t0));f=a[f+3]);return u}slice(e,t,i){let l=this.buffer,o=new Uint16Array(t-e),a=0;for(let u=e,f=0;u=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Yc(n,e,t,i){for(var l;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?u.length:-1;e!=d;e+=t){let m=u[e],g=f[e]+a.from,b;if(!(!(o&Ht.EnterBracketed&&m instanceof Jt&&(b=zc.get(m))&&!b.overlay&&b.bracketed&&i>=g&&i<=g+m.length)&&!LT(l,i,g,g+m.length))){if(m instanceof Xl){if(o&Ht.ExcludeBuffers)continue;let v=m.findChild(0,m.buffer.length,t,i-g,l);if(v>-1)return new Bl(new hL(a,m,e,g),null,v)}else if(o&Ht.IncludeAnonymous||!m.type.isAnonymous||Cy(m)){let v;if(!(o&Ht.IgnoreMounts)&&(v=zc.get(m))&&!v.overlay)return new Li(v.tree,g,e,a);let w=new Li(m,g,e,a);return o&Ht.IncludeAnonymous||!w.type.isAnonymous?w:w.nextChild(t<0?m.children.length-1:0,t,i,l,o)}}}if(o&Ht.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+t:e=t<0?-1:a._parent._tree.children.length,a=a._parent,!a))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(e,t,i=0){let l;if(!(i&Ht.IgnoreOverlays)&&(l=zc.get(this._tree))&&l.overlay){let o=e-this.from,a=i&Ht.EnterBracketed&&l.bracketed;for(let{from:u,to:f}of l.overlay)if((t>0||a?u<=o:u=o:f>o))return new Li(l.tree,l.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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 GS(n,e,t,i){let l=n.cursor(),o=[];if(!l.firstChild())return o;if(t!=null){for(let a=!1;!a;)if(a=l.type.is(t),!l.nextSibling())return o}for(;;){if(i!=null&&l.type.is(i))return o;if(l.type.is(e)&&o.push(l.node),!l.nextSibling())return i==null?o:[]}}function vx(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class hL{constructor(e,t,i,l){this.parent=e,this.buffer=t,this.index=i,this.start=l}}class Bl extends zT{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,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new Bl(this.context,this,o)}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(e,t,i=0){if(i&Ht.ExcludeBuffers)return null;let{buffer:l}=this.context,o=l.findChild(this.index+4,l.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new Bl(this.context,this,o)}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:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Bl(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Bl(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,l=this.index+4,o=i.buffer[this.index+3];if(o>l){let a=i.buffer[this.index+1];e.push(i.slice(l,o,a)),t.push(0)}return new Jt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function BT(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||a.to=e){let u=new Li(a.tree,a.overlay[0].from+o.from,-1,o);(l||(l=[i])).push(Yc(u,e,t,!1))}}return l?BT(l):i}class wx{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&~Ht.EnterBracketed,e instanceof Li)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.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:i,buffer:l}=this.buffer;return this.type=t||l.set.types[l.buffer[e]],this.from=i+l.buffer[e+1],this.to=i+l.buffer[e+2],!0}yield(e){return e?e instanceof Li?(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,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:l}=this.buffer,o=l.findChild(this.index+4,l.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}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,i=this.mode){return this.buffer?i&Ht.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ht.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ht.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,i=this.stack.length-1;if(e<0){let l=i<0?0:this.stack[i]+4;if(this.index!=l)return this.yieldBuf(t.findChild(l,this.index,-1,0,4))}else{let l=t.buffer[this.index+3];if(l<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(l)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:l}=this;if(l){if(e>0){if(this.index-1)for(let o=t+e,a=e<0?-1:i._tree.children.length;o!=a;o+=e){let u=i._tree.children[o];if(this.mode&Ht.IncludeAnonymous||u instanceof Xl||!u.type.isAnonymous||Cy(u))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=0;){for(let a=e;a;a=a._parent)if(a.index==l){if(l==this.index)return a;t=a,i=o+1;break e}l=this.stack[--o]}for(let l=i;l=0;o--){if(o<0)return vx(this._tree,e,l);let a=i[t.buffer[this.stack[o]]];if(!a.isAnonymous){if(e[l]&&e[l]!=a.name)return!1;l--}}return!0}}function Cy(n){return n.children.some(e=>e instanceof Xl||!e.type.isAnonymous||Cy(e))}function pL(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:l=_T,reused:o=[],minRepeatType:a=i.types.length}=n,u=Array.isArray(t)?new Sy(t,t.length):t,f=i.types,d=0,m=0;function g(B,D,R,P,te,I){let{id:F,start:A,end:ne,size:ae}=u,ie=m,$=d;if(ae<0)if(u.next(),ae==-1){let he=o[F];R.push(he),P.push(A-B);return}else if(ae==-3){d=F;return}else if(ae==-4){m=F;return}else throw new RangeError(`Unrecognized record size: ${ae}`);let oe=f[F],Z,Y,N=A-B;if(ne-A<=l&&(Y=C(u.pos-D,te))){let he=new Uint16Array(Y.size-Y.skip),ye=u.pos-Y.size,z=he.length;for(;u.pos>ye;)z=O(Y.start,he,z);Z=new Xl(he,ne-Y.start,i),N=Y.start-B}else{let he=u.pos-ae;u.next();let ye=[],z=[],j=F>=a?F:-1,q=0,ue=ne,pe=ie;for(;u.pos>he;)j>=0&&u.id==j&&u.size>=0?(u.end<=ue-l&&(w(ye,z,A,q,u.end,ue,j,pe,$),q=ye.length,ue=u.end,pe=m),u.next()):I>2500?b(A,he,ye,z):(j>=0&&u.size==-1&&o[u.id].type==i.types[j]&&(q=0&&q>0&&q-1&&q>0){let De=v(oe,$);Z=Oy(oe,ye,z,0,ye.length,0,ne-A,De,De)}else Z=S(oe,ye,z,ne-A,ie-ne,$)}R.push(Z),P.push(N)}function b(B,D,R,P){let te=[],I=0,F=-1;for(;u.pos>D;){let{id:A,start:ne,end:ae,size:ie}=u;if(ie>4)u.next();else{if(F>-1&&ne=0;ae-=3)A[ie++]=te[ae],A[ie++]=te[ae+1]-ne,A[ie++]=te[ae+2]-ne,A[ie++]=ie;R.push(new Xl(A,te[2]-ne,i)),P.push(ne-B)}}function v(B,D){return(R,P,te)=>{let I=0,F=R.length-1,A,ne;if(F>=0&&(A=R[F])instanceof Jt){if(!F&&A.type==B&&A.length==te)return A;(ne=A.prop(et.lookAhead))&&(I=P[F]+A.length+ne-te)}return S(B,R,P,te,I,D)}}function w(B,D,R,P,te,I,F,A,ne){let ae=[],ie=[];for(;B.length>P;)ae.push(B.pop()),ie.push(D.pop()+R-te);B.push(S(i.types[F],ae,ie,I-te,A-I,ne)),D.push(te-R)}function S(B,D,R,P,te,I,F){if(I){let A=[et.contextHash,I];F=F?[A].concat(F):[A]}if(te>25){let A=[et.lookAhead,te];F=F?[A].concat(F):[A]}return new Jt(B,D,R,P,F)}function C(B,D){let R=u.fork(),P=0,te=0,I=0,F=R.end-l,A={size:0,start:0,skip:0};e:for(let ne=R.pos-B;R.pos>ne;){let ae=R.size;if(R.id==D&&ae>=0){A.size=P,A.start=te,A.skip=I,I+=4,P+=4,R.next();continue}let ie=R.pos-ae;if(ae<0||ie=a?4:0,oe=R.start;for(R.next();R.pos>ie;){if(R.size<0)if(R.size==-3||R.size==-4)$+=4;else break e;else R.id>=a&&($+=4);R.next()}te=oe,P+=ae,I+=$}return(D<0||P==B)&&(A.size=P,A.start=te,A.skip=I),A.size>4?A:void 0}function O(B,D,R){let{id:P,start:te,end:I,size:F}=u;if(u.next(),F>=0&&P4){let ne=u.pos-(F-4);for(;u.pos>ne;)R=O(B,D,R)}D[--R]=A,D[--R]=I-B,D[--R]=te-B,D[--R]=P}else F==-3?d=P:F==-4&&(m=P);return R}let _=[],M=[];for(;u.pos>0;)g(n.start||0,n.bufferStart||0,_,M,-1,0);let H=(e=n.length)!==null&&e!==void 0?e:_.length?M[0]+_[0].length:0;return new Jt(f[n.topID],_.reverse(),M.reverse(),H)}const YS=new WeakMap;function Uh(n,e){if(!n.isAnonymous||e instanceof Xl||e.type!=n)return 1;let t=YS.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof Jt)){t=1;break}t+=Uh(n,i)}YS.set(e,t)}return t}function Oy(n,e,t,i,l,o,a,u,f){let d=0;for(let w=i;w=m)break;D+=R}if(M==H+1){if(D>m){let R=w[H];v(R.children,R.positions,0,R.children.length,S[H]+_);continue}g.push(w[H])}else{let R=S[M-1]+w[M-1].length-B;g.push(Oy(n,w,S,H,M,B,R,null,f))}b.push(B+_-o)}}return v(e,t,i,l,0),(u||f)(g,b,a)}class Ls{constructor(e,t,i,l,o=!1,a=!1){this.from=e,this.to=t,this.tree=i,this.offset=l,this.open=(o?1:0)|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let l=[new Ls(0,e.length,e,0,!1,i)];for(let o of t)o.to>e.length&&l.push(o);return l}static applyChanges(e,t,i=128){if(!t.length)return e;let l=[],o=1,a=e.length?e[0]:null;for(let u=0,f=0,d=0;;u++){let m=u=i)for(;a&&a.from=b.from||g<=b.to||d){let v=Math.max(b.from,f)-d,w=Math.min(b.to,g)-d;b=v>=w?null:new Ls(v,w,b.tree,b.offset+d,u>0,!!m)}if(b&&l.push(b),a.to>g)break;a=onew Jg(l.from,l.to)):[new Jg(0,0)]:[new Jg(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let l=this.startParse(e,t,i);for(;;){let o=l.advance();if(o)return o}}}class gL{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 et({perNode:!0});let xL=0,Qr=class kx{constructor(e,t,i,l){this.name=e,this.set=t,this.base=i,this.modified=l,this.id=xL++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof kx&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let l=new kx(i,[],null,[]);if(l.set.push(l),t)for(let o of t.set)l.set.push(o);return l}static defineModifier(e){let t=new ld(e);return i=>i.modified.indexOf(t)>-1?i:ld.get(i.base||i,i.modified.concat(t).sort((l,o)=>l.id-o.id))}},yL=0;class ld{constructor(e){this.name=e,this.instances=[],this.id=yL++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(u=>u.base==e&&bL(t,u.modified));if(i)return i;let l=[],o=new Qr(e.name,l,e,t);for(let u of t)u.instances.push(o);let a=vL(t);for(let u of e.set)if(!u.modified.length)for(let f of a)l.push(ld.get(u,f));return o}}function bL(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function vL(n){let e=[[]];for(let t=0;ti.length-t.length)}function HT(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let l of t.split(" "))if(l){let o=[],a=2,u=l;for(let g=0;;){if(u=="..."&&g>0&&g+3==l.length){a=1;break}let b=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!b)throw new RangeError("Invalid path: "+l);if(o.push(b[0]=="*"?"":b[0][0]=='"'?JSON.parse(b[0]):b[0]),g+=b[0].length,g==l.length)break;let v=l[g++];if(g==l.length&&v=="!"){a=0;break}if(v!="/")throw new RangeError("Invalid path: "+l);u=l.slice(g)}let f=o.length-1,d=o[f];if(!d)throw new RangeError("Invalid path: "+l);let m=new Kc(i,a,f>0?o.slice(0,f):null);e[d]=m.sort(e[d])}}return IT.add(e)}const IT=new et({combine(n,e){let t,i,l;for(;n||e;){if(!n||e&&n.depth<=e.depth?(l=e,e=e.next):(l=n,n=n.next),t&&t.mode==l.mode&&!l.context&&!t.context)continue;let o=new Kc(l.tags,l.mode,l.context);t?t.next=o:i=o,t=o}return i}});class Kc{constructor(e,t,i,l){this.tags=e,this.mode=t,this.context=i,this.next=l}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let a=l;for(let u of o)for(let f of u.set){let d=t[f.id];if(d){a=a?a+" "+d:d;break}}return a},scope:i}}function wL(n,e){let t=null;for(let i of n){let l=i.style(e);l&&(t=t?t+" "+l:l)}return t}function kL(n,e,t,i=0,l=n.length){let o=new SL(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,l,"",o.highlighters),o.flush(l)}class SL{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,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,i,l,o){let{type:a,from:u,to:f}=e;if(u>=i||f<=t)return;a.isTop&&(o=this.highlighters.filter(v=>!v.scope||v.scope(a)));let d=l,m=CL(e)||Kc.empty,g=wL(o,m.tags);if(g&&(d&&(d+=" "),d+=g,m.mode==1&&(l+=(l?" ":"")+g)),this.startSpan(Math.max(t,u),d),m.opaque)return;let b=e.tree&&e.tree.prop(et.mounted);if(b&&b.overlay){let v=e.node.enter(b.overlay[0].from+u,1),w=this.highlighters.filter(C=>!C.scope||C.scope(b.tree.type)),S=e.firstChild();for(let C=0,O=u;;C++){let _=C=M||!e.nextSibling())););if(!_||M>i)break;O=_.to+u,O>t&&(this.highlightRange(v.cursor(),Math.max(t,_.from+u),Math.min(i,O),"",w),this.startSpan(Math.min(i,O),d))}S&&e.parent()}else if(e.firstChild()){b&&(l="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,l,o),this.startSpan(Math.min(i,e.to),d)}while(e.nextSibling());e.parent()}}}function CL(n){let e=n.type.prop(IT);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const ke=Qr.define,mh=ke(),Rl=ke(),KS=ke(Rl),WS=ke(Rl),jl=ke(),ph=ke(jl),e0=ke(jl),mr=ke(),ks=ke(mr),hr=ke(),dr=ke(),Sx=ke(),yc=ke(Sx),gh=ke(),me={comment:mh,lineComment:ke(mh),blockComment:ke(mh),docComment:ke(mh),name:Rl,variableName:ke(Rl),typeName:KS,tagName:ke(KS),propertyName:WS,attributeName:ke(WS),className:ke(Rl),labelName:ke(Rl),namespace:ke(Rl),macroName:ke(Rl),literal:jl,string:ph,docString:ke(ph),character:ke(ph),attributeValue:ke(ph),number:e0,integer:ke(e0),float:ke(e0),bool:ke(jl),regexp:ke(jl),escape:ke(jl),color:ke(jl),url:ke(jl),keyword:hr,self:ke(hr),null:ke(hr),atom:ke(hr),unit:ke(hr),modifier:ke(hr),operatorKeyword:ke(hr),controlKeyword:ke(hr),definitionKeyword:ke(hr),moduleKeyword:ke(hr),operator:dr,derefOperator:ke(dr),arithmeticOperator:ke(dr),logicOperator:ke(dr),bitwiseOperator:ke(dr),compareOperator:ke(dr),updateOperator:ke(dr),definitionOperator:ke(dr),typeOperator:ke(dr),controlOperator:ke(dr),punctuation:Sx,separator:ke(Sx),bracket:yc,angleBracket:ke(yc),squareBracket:ke(yc),paren:ke(yc),brace:ke(yc),content:mr,heading:ks,heading1:ke(ks),heading2:ke(ks),heading3:ke(ks),heading4:ke(ks),heading5:ke(ks),heading6:ke(ks),contentSeparator:ke(mr),list:ke(mr),quote:ke(mr),emphasis:ke(mr),strong:ke(mr),link:ke(mr),monospace:ke(mr),strikethrough:ke(mr),inserted:ke(),deleted:ke(),changed:ke(),invalid:ke(),meta:gh,documentMeta:ke(gh),annotation:ke(gh),processingInstruction:ke(gh),definition:Qr.defineModifier("definition"),constant:Qr.defineModifier("constant"),function:Qr.defineModifier("function"),standard:Qr.defineModifier("standard"),local:Qr.defineModifier("local"),special:Qr.defineModifier("special")};for(let n in me){let e=me[n];e instanceof Qr&&(e.name=n)}UT([{tag:me.link,class:"tok-link"},{tag:me.heading,class:"tok-heading"},{tag:me.emphasis,class:"tok-emphasis"},{tag:me.strong,class:"tok-strong"},{tag:me.keyword,class:"tok-keyword"},{tag:me.atom,class:"tok-atom"},{tag:me.bool,class:"tok-bool"},{tag:me.url,class:"tok-url"},{tag:me.labelName,class:"tok-labelName"},{tag:me.inserted,class:"tok-inserted"},{tag:me.deleted,class:"tok-deleted"},{tag:me.literal,class:"tok-literal"},{tag:me.string,class:"tok-string"},{tag:me.number,class:"tok-number"},{tag:[me.regexp,me.escape,me.special(me.string)],class:"tok-string2"},{tag:me.variableName,class:"tok-variableName"},{tag:me.local(me.variableName),class:"tok-variableName tok-local"},{tag:me.definition(me.variableName),class:"tok-variableName tok-definition"},{tag:me.special(me.variableName),class:"tok-variableName2"},{tag:me.definition(me.propertyName),class:"tok-propertyName tok-definition"},{tag:me.typeName,class:"tok-typeName"},{tag:me.namespace,class:"tok-namespace"},{tag:me.className,class:"tok-className"},{tag:me.macroName,class:"tok-macroName"},{tag:me.propertyName,class:"tok-propertyName"},{tag:me.operator,class:"tok-operator"},{tag:me.comment,class:"tok-comment"},{tag:me.meta,class:"tok-meta"},{tag:me.invalid,class:"tok-invalid"},{tag:me.punctuation,class:"tok-punctuation"}]);var t0;const Ko=new et;function OL(n){return Ne.define({combine:n?e=>e.concat(n):void 0})}const TL=new et;class Gi{constructor(e,t,i=[],l=""){this.data=e,this.name=l,ut.prototype.hasOwnProperty("tree")||Object.defineProperty(ut.prototype,"tree",{get(){return Dn(this)}}),this.parser=t,this.extension=[$l.of(this),ut.languageData.of((o,a,u)=>{let f=ZS(o,a,u),d=f.type.prop(Ko);if(!d)return[];let m=o.facet(d),g=f.type.prop(TL);if(g){let b=f.resolve(a-f.from,u);for(let v of g)if(v.test(b,o)){let w=o.facet(v.facet);return v.type=="replace"?w:w.concat(m)}}return m})].concat(i)}isActiveAt(e,t,i=-1){return ZS(e,t,i).type.prop(Ko)==this.data}findRegions(e){let t=e.facet($l);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],l=(o,a)=>{if(o.prop(Ko)==this.data){i.push({from:a,to:a+o.length});return}let u=o.prop(et.mounted);if(u){if(u.tree.prop(Ko)==this.data){if(u.overlay)for(let f of u.overlay)i.push({from:f.from+a,to:f.to+a});else i.push({from:a,to:a+o.length});return}else if(u.overlay){let f=i.length;if(l(u.tree,u.overlay[0].from+a),i.length>f)return}}for(let f=0;fi.isTop?t:void 0)]}),e.name)}configure(e,t){return new sd(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Dn(n){let e=n.field(Gi.state,!1);return e?e.tree:Jt.empty}class NL{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 i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let bc=null;class od{constructor(e,t,i=[],l,o,a,u,f){this.parser=e,this.state=t,this.fragments=i,this.tree=l,this.treeLen=o,this.viewport=a,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new od(e,t,[],Jt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new NL(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Jt.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let l=Date.now()+e;e=()=>Date.now()>l}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=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(Ls.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=bc;bc=this;try{return e()}finally{bc=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=JS(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:l,treeLen:o,viewport:a,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((d,m,g,b)=>f.push({fromA:d,toA:m,fromB:g,toB:b})),i=Ls.applyChanges(i,f),l=Jt.empty,o=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){u=[];for(let d of this.skipped){let m=e.mapPos(d.from,1),g=e.mapPos(d.to,-1);me.from&&(this.fragments=JS(this.fragments,l,o),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends PT{createParse(t,i,l){let o=l[0].from,a=l[l.length-1].to;return{parsedPos:o,advance(){let f=bc;if(f){for(let d of l)f.tempSkipped.push(d);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=a,new Jt(ri.none,[],[],a-o)},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 bc}}function JS(n,e,t){return Ls.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class ma{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new ma(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=od.create(e.facet($l).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ma(i)}}Gi.state=Rn.define({create:ma.init,update(n,e){for(let t of e.effects)if(t.is(Gi.setState))return t.value;return e.startState.facet($l)!=e.state.facet($l)?ma.init(e.state):n.apply(e)}});let FT=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(FT=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const n0=typeof navigator<"u"&&(!((t0=navigator.scheduling)===null||t0===void 0)&&t0.isInputPending)?()=>navigator.scheduling.isInputPending():null,AL=Qt.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(Gi.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(Gi.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=FT(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndl+1e3,f=o.context.work(()=>n0&&n0()||Date.now()>a,l+(u?0:1e5));this.chunkBudget-=Date.now()-t,(f||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:Gi.setState.of(new ma(o.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>ni(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),$l=Ne.define({combine(n){return n.length?n[0]:null},enables:n=>[Gi.state,AL,Ae.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class EL{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const ML=Ne.define(),Ty=Ne.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function ad(n){let e=n.facet(Ty);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Wc(n,e){let t="",i=n.tabSize,l=n.facet(Ty)[0];if(l==" "){for(;e>=i;)t+=" ",e-=i;l=" "}for(let o=0;o=e?DL(n,t,e):null}class Hd{constructor(e,t={}){this.state=e,this.options=t,this.unit=ad(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:l,simulateDoubleBreak:o}=this.options;return l!=null&&l>=i.from&&l<=i.to?o&&l==e?{text:"",from:e}:(t<0?l-1&&(o+=a-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return xa(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:l}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let a=o(l);if(a>-1)return a}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const VT=new et;function DL(n,e,t){let i=e.resolveStack(t),l=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(l!=i.node){let o=[];for(let a=l;a&&!(a.fromi.node.to||a.from==i.node.from&&a.type==i.node.type);a=a.parent)o.push(a);for(let a=o.length-1;a>=0;a--)i={node:o[a],next:i}}return qT(i,n,t)}function qT(n,e,t){for(let i=n;i;i=i.next){let l=jL(i.node);if(l)return l(Ay.create(e,t,i))}return 0}function RL(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function jL(n){let e=n.type.prop(VT);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(et.closedBy))){let l=n.lastChild,o=l&&i.indexOf(l.name)>-1;return a=>QT(a,!0,1,void 0,o&&!RL(a)?l.from:void 0)}return n.parent==null?_L:null}function _L(){return 0}class Ay extends Hd{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new Ay(e,t,i)}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 i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(LL(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return qT(this.context.next,this.base,this.pos)}}function LL(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function zL(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let l=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),a=l==null||l<=o.from?o.to:Math.min(o.to,l);for(let u=t.to;;){let f=e.childAfter(u);if(!f||f==i)return null;if(!f.type.isSkipped){if(f.from>=a)return null;let d=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+d}}u=f.to}}function e2({closing:n,align:e=!0,units:t=1}){return i=>QT(i,e,t,n)}function QT(n,e,t,i,l){let o=n.textAfter,a=o.match(/^\s*/)[0].length,u=i&&o.slice(a,a+i.length)==i||l==n.pos+a,f=e?zL(n):null;return f?u?n.column(f.from):n.column(f.to):n.baseIndent+(u?0:n.unit*t)}const BL=200;function PL(){return ut.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,l=t.lineAt(i);if(i>l.from+BL)return n;let o=t.sliceString(l.from,i);if(!e.some(d=>d.test(o)))return n;let{state:a}=n,u=-1,f=[];for(let{head:d}of a.selection.ranges){let m=a.doc.lineAt(d);if(m.from==u)continue;u=m.from;let g=Ny(a,m.from);if(g==null)continue;let b=/^\s*/.exec(m.text)[0],v=Wc(a,g);b!=v&&f.push({from:m.from,to:m.from+b.length,insert:v})}return f.length?[n,{changes:f,sequential:!0}]:n})}const HL=Ne.define(),XT=new et;function IL(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(o&&u.from=e&&d.to>t&&(o=d)}}return o}function FL(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function cd(n,e,t){for(let i of n.facet(HL)){let l=i(n,e,t);if(l)return l}return UL(n,e,t)}function $T(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const Id=Ke.define({map:$T}),cu=Ke.define({map:$T});function GT(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const Is=Rn.define({create(){return Ue.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,l)=>n=t2(n,i,l)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(Id)&&!VL(n,i.value.from,i.value.to)?t.push(i.value):i.is(cu)&&(n=n.update({filter:(l,o)=>i.value.from!=l||i.value.to!=o,filterFrom:i.value.from,filterTo:i.value.to}));if(t.length){let{preparePlaceholder:i}=e.state.facet(WT),l=t.map(o=>(i?Ue.replace({widget:new KL(i(e.state,o))}):n2).range(o.from,o.to));n=n.update({add:l})}return e.selection&&(n=t2(n,e.selection.main.head)),n},provide:n=>Ae.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,l)=>{t.push(i,l)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{le&&(i=!0)}),i?n.update({filterFrom:e,filterTo:t,filter:(l,o)=>l>=t||o<=e}):n}function ud(n,e,t){var i;let l=null;return(i=n.field(Is,!1))===null||i===void 0||i.between(e,t,(o,a)=>{(!l||l.from>o)&&(l={from:o,to:a})}),l}function VL(n,e,t){let i=!1;return n.between(e,e,(l,o)=>{l==e&&o==t&&(i=!0)}),i}function YT(n,e){return n.field(Is,!1)?e:e.concat(Ke.appendConfig.of(ZT()))}const qL=n=>{for(let e of GT(n)){let t=cd(n.state,e.from,e.to);if(t)return n.dispatch({effects:YT(n.state,[Id.of(t),KT(n,t)])}),!0}return!1},QL=n=>{if(!n.state.field(Is,!1))return!1;let e=[];for(let t of GT(n)){let i=ud(n.state,t.from,t.to);i&&e.push(cu.of(i),KT(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function KT(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,l=n.state.doc.lineAt(e.to).number;return Ae.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${l}.`)}const XL=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(Is,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,l)=>{t.push(cu.of({from:i,to:l}))}),n.dispatch({effects:t}),!0},GL=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:qL},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:QL},{key:"Ctrl-Alt-[",run:XL},{key:"Ctrl-Alt-]",run:$L}],YL={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},WT=Ne.define({combine(n){return Nr(n,YL)}});function ZT(n){return[Is,JL]}function JT(n,e){let{state:t}=n,i=t.facet(WT),l=a=>{let u=n.lineBlockAt(n.posAtDOM(a.target)),f=ud(n.state,u.from,u.to);f&&n.dispatch({effects:cu.of(f)}),a.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(n,l,e);let o=document.createElement("span");return o.textContent=i.placeholderText,o.setAttribute("aria-label",t.phrase("folded code")),o.title=t.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=l,o}const n2=Ue.replace({widget:new class extends el{toDOM(n){return JT(n,null)}}});class KL extends el{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return JT(e,this.value)}}const WL={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class i0 extends Wr{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 ZL(n={}){let e={...WL,...n},t=new i0(e,!0),i=new i0(e,!1),l=Qt.fromClass(class{constructor(a){this.from=a.viewport.from,this.markers=this.buildMarkers(a)}update(a){(a.docChanged||a.viewportChanged||a.startState.facet($l)!=a.state.facet($l)||a.startState.field(Is,!1)!=a.state.field(Is,!1)||Dn(a.startState)!=Dn(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let u=new Or;for(let f of a.viewportLineBlocks){let d=ud(a.state,f.from,f.to)?i:cd(a.state,f.from,f.to)?t:null;d&&u.add(f.from,f.from,d)}return u.finish()}}),{domEventHandlers:o}=e;return[l,J_({class:"cm-foldGutter",markers(a){var u;return((u=a.plugin(l))===null||u===void 0?void 0:u.markers)||it.empty},initialSpacer(){return new i0(e,!1)},domEventHandlers:{...o,click:(a,u,f)=>{if(o.click&&o.click(a,u,f))return!0;let d=ud(a.state,u.from,u.to);if(d)return a.dispatch({effects:cu.of(d)}),!0;let m=cd(a.state,u.from,u.to);return m?(a.dispatch({effects:Id.of(m)}),!0):!1}}}),ZT()]}const JL=Ae.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"}});class uu{constructor(e,t){this.specs=e;let i;function l(u){let f=Vl.newName();return(i||(i=Object.create(null)))["."+f]=u,f}const o=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,a=t.scope;this.scope=a instanceof Gi?u=>u.prop(Ko)==a.data:a?u=>u==a:void 0,this.style=UT(e.map(u=>({tag:u.tag,class:u.class||l(Object.assign({},u,{tag:null}))})),{all:o}).style,this.module=i?new Vl(i):null,this.themeType=t.themeType}static define(e,t){return new uu(e,t||{})}}const Cx=Ne.define(),eN=Ne.define({combine(n){return n.length?[n[0]]:null}});function r0(n){let e=n.facet(Cx);return e.length?e:n.facet(eN)}function tN(n,e){let t=[tz],i;return n instanceof uu&&(n.module&&t.push(Ae.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(eN.of(n)):i?t.push(Cx.computeN([Ae.darkTheme],l=>l.facet(Ae.darkTheme)==(i=="dark")?[n]:[])):t.push(Cx.of(n)),t}class ez{constructor(e){this.markCache=Object.create(null),this.tree=Dn(e.state),this.decorations=this.buildDeco(e,r0(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Dn(e.state),i=r0(e.state),l=i!=r0(e.startState),{viewport:o}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||l)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return Ue.none;let i=new Or;for(let{from:l,to:o}of e.visibleRanges)kL(this.tree,t,(a,u,f)=>{i.add(a,u,this.markCache[f]||(this.markCache[f]=Ue.mark({class:f})))},l,o);return i.finish()}}const tz=Fs.high(Qt.fromClass(ez,{decorations:n=>n.decorations})),nz=uu.define([{tag:me.meta,color:"#404740"},{tag:me.link,textDecoration:"underline"},{tag:me.heading,textDecoration:"underline",fontWeight:"bold"},{tag:me.emphasis,fontStyle:"italic"},{tag:me.strong,fontWeight:"bold"},{tag:me.strikethrough,textDecoration:"line-through"},{tag:me.keyword,color:"#708"},{tag:[me.atom,me.bool,me.url,me.contentSeparator,me.labelName],color:"#219"},{tag:[me.literal,me.inserted],color:"#164"},{tag:[me.string,me.deleted],color:"#a11"},{tag:[me.regexp,me.escape,me.special(me.string)],color:"#e40"},{tag:me.definition(me.variableName),color:"#00f"},{tag:me.local(me.variableName),color:"#30a"},{tag:[me.typeName,me.namespace],color:"#085"},{tag:me.className,color:"#167"},{tag:[me.special(me.variableName),me.macroName],color:"#256"},{tag:me.definition(me.propertyName),color:"#00c"},{tag:me.comment,color:"#940"},{tag:me.invalid,color:"#f00"}]),iz=Ae.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),nN=1e4,iN="()[]{}",rN=Ne.define({combine(n){return Nr(n,{afterCursor:!0,brackets:iN,maxScanDistance:nN,renderMatch:sz})}}),rz=Ue.mark({class:"cm-matchingBracket"}),lz=Ue.mark({class:"cm-nonmatchingBracket"});function sz(n){let e=[],t=n.matched?rz:lz;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function i2(n){let e=[],t=n.facet(rN);for(let i of n.selection.ranges){if(!i.empty)continue;let l=wr(n,i.head,-1,t)||i.head>0&&wr(n,i.head-1,1,t)||t.afterCursor&&(wr(n,i.head,1,t)||i.headn.decorations}),az=[oz,iz];function cz(n={}){return[rN.of(n),az]}const uz=new et;function Ox(n,e,t){let i=n.prop(e<0?et.openedBy:et.closedBy);if(i)return i;if(n.name.length==1){let l=t.indexOf(n.name);if(l>-1&&l%2==(e<0?1:0))return[t[l+e]]}return null}function Tx(n){let e=n.type.prop(uz);return e?e(n.node):n}function wr(n,e,t,i={}){let l=i.maxScanDistance||nN,o=i.brackets||iN,a=Dn(n),u=a.resolveInner(e,t);for(let f=u;f;f=f.parent){let d=Ox(f.type,t,o);if(d&&f.from0?e>=m.from&&em.from&&e<=m.to))return fz(n,e,t,f,m,d,o)}}return hz(n,e,t,a,u.type,l,o)}function fz(n,e,t,i,l,o,a){let u=i.parent,f={from:l.from,to:l.to},d=0,m=u==null?void 0:u.cursor();if(m&&(t<0?m.childBefore(i.from):m.childAfter(i.to)))do if(t<0?m.to<=i.from:m.from>=i.to){if(d==0&&o.indexOf(m.type.name)>-1&&m.from0)return null;let d={from:t<0?e-1:e,to:t>0?e+1:e},m=n.doc.iterRange(e,t>0?n.doc.length:0),g=0;for(let b=0;!m.next().done&&b<=o;){let v=m.value;t<0&&(b+=v.length);let w=e+b*t;for(let S=t>0?0:v.length-1,C=t>0?v.length:-1;S!=C;S+=t){let O=a.indexOf(v[S]);if(!(O<0||i.resolveInner(w+S,1).type!=l))if(O%2==0==t>0)g++;else{if(g==1)return{start:d,end:{from:w+S,to:w+S+1},matched:O>>1==f>>1};g--}}t>0&&(b+=v.length)}return m.done?{start:d,matched:!1}:null}const dz=Object.create(null),r2=[ri.none],l2=[],s2=Object.create(null),mz=Object.create(null);for(let[n,e]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"]])mz[n]=pz(dz,e);function l0(n,e){l2.indexOf(n)>-1||(l2.push(n),console.warn(e))}function pz(n,e){let t=[];for(let u of e.split(" ")){let f=[];for(let d of u.split(".")){let m=n[d]||me[d];m?typeof m=="function"?f.length?f=f.map(m):l0(d,`Modifier ${d} used at start of tag`):f.length?l0(d,`Tag ${d} used as modifier`):f=Array.isArray(m)?m:[m]:l0(d,`Unknown highlighting tag ${d}`)}for(let d of f)t.push(d)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),l=i+" "+t.map(u=>u.id),o=s2[l];if(o)return o.id;let a=s2[l]=ri.define({id:r2.length,name:i,props:[HT({[i]:t})]});return r2.push(a),a.id}kt.RTL,kt.LTR;const gz=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=My(n.state,t.from);return i.line?xz(n):i.block?bz(n):!1};function Ey(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let l=n(e,t);return l?(i(t.update(l)),!0):!1}}const xz=Ey(kz,0),yz=Ey(lN,0),bz=Ey((n,e)=>lN(n,e,wz(e)),0);function My(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const vc=50;function vz(n,{open:e,close:t},i,l){let o=n.sliceDoc(i-vc,i),a=n.sliceDoc(l,l+vc),u=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(a)[0].length,d=o.length-u;if(o.slice(d-e.length,d)==e&&a.slice(f,f+t.length)==t)return{open:{pos:i-u,margin:u&&1},close:{pos:l+f,margin:f&&1}};let m,g;l-i<=2*vc?m=g=n.sliceDoc(i,l):(m=n.sliceDoc(i,i+vc),g=n.sliceDoc(l-vc,l));let b=/^\s*/.exec(m)[0].length,v=/\s*$/.exec(g)[0].length,w=g.length-v-t.length;return m.slice(b,b+e.length)==e&&g.slice(w,w+t.length)==t?{open:{pos:i+b+e.length,margin:/\s/.test(m.charAt(b+e.length))?1:0},close:{pos:l-v-t.length,margin:/\s/.test(g.charAt(w-1))?1:0}}:null}function wz(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),l=t.to<=i.to?i:n.doc.lineAt(t.to);l.from>i.from&&l.from==t.to&&(l=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=l.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:l.to})}return e}function lN(n,e,t=e.selection.ranges){let i=t.map(o=>My(e,o.from).block);if(!i.every(o=>o))return null;let l=t.map((o,a)=>vz(e,i[a],o.from,o.to));if(n!=2&&!l.every(o=>o))return{changes:e.changes(t.map((o,a)=>l[a]?[]:[{from:o.from,insert:i[a].open+" "},{from:o.to,insert:" "+i[a].close}]))};if(n!=1&&l.some(o=>o)){let o=[];for(let a=0,u;al&&(o==a||a>g.from)){l=g.from;let b=/^\s*/.exec(g.text)[0].length,v=b==g.length,w=g.text.slice(b,b+d.length)==d?b:-1;bo.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:u,token:f,indent:d,empty:m,single:g}of i)(g||!m)&&o.push({from:u.from+d,insert:f+" "});let a=e.changes(o);return{changes:a,selection:e.selection.map(a,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:a,comment:u,token:f}of i)if(u>=0){let d=a.from+u,m=d+f.length;a.text[m-a.from]==" "&&m++,o.push({from:d,to:m})}return{changes:o}}return null}const Nx=Jr.define(),Sz=Jr.define(),Cz=Ne.define(),sN=Ne.define({combine(n){return Nr(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,l)=>e(i,l)||t(i,l)})}}),oN=Rn.define({create(){return kr.empty},update(n,e){let t=e.state.facet(sN),i=e.annotation(Nx);if(i){let f=ii.fromTransaction(e,i.selection),d=i.side,m=d==0?n.undone:n.done;return f?m=fd(m,m.length,t.minDepth,f):m=uN(m,e.startState.selection),new kr(d==0?i.rest:m,d==0?m:i.rest)}let l=e.annotation(Sz);if((l=="full"||l=="before")&&(n=n.isolate()),e.annotation(sn.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let o=ii.fromTransaction(e),a=e.annotation(sn.time),u=e.annotation(sn.userEvent);return o?n=n.addChanges(o,a,u,t,e):e.selection&&(n=n.addSelection(e.startState.selection,a,u,t.newGroupDelay)),(l=="full"||l=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new kr(n.done.map(ii.fromJSON),n.undone.map(ii.fromJSON))}});function Oz(n={}){return[oN,sN.of(n),Ae.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?aN:e.inputType=="historyRedo"?Ax:null;return i?(e.preventDefault(),i(t)):!1}})]}function Ud(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let l=t.field(oN,!1);if(!l)return!1;let o=l.pop(n,t,e);return o?(i(o),!0):!1}}const aN=Ud(0,!1),Ax=Ud(1,!1),Tz=Ud(0,!0),Nz=Ud(1,!0);class ii{constructor(e,t,i,l,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=l,this.selectionsAfter=o}setSelAfter(e){return new ii(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(l=>l.toJSON())}}static fromJSON(e){return new ii(e.changes&&ln.fromJSON(e.changes),[],e.mapped&&Cr.fromJSON(e.mapped),e.startSelection&&re.fromJSON(e.startSelection),e.selectionsAfter.map(re.fromJSON))}static fromTransaction(e,t){let i=ji;for(let l of e.startState.facet(Cz)){let o=l(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new ii(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ji)}static selection(e){return new ii(void 0,ji,void 0,void 0,e)}}function fd(n,e,t,i){let l=e+1>t+20?e-t-1:0,o=n.slice(l,e);return o.push(i),o}function Az(n,e){let t=[],i=!1;return n.iterChangedRanges((l,o)=>t.push(l,o)),e.iterChangedRanges((l,o,a,u)=>{for(let f=0;f=d&&a<=m&&(i=!0)}}),i}function Ez(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function cN(n,e){return n.length?e.length?n.concat(e):n:e}const ji=[],Mz=200;function uN(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Mz));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),fd(n,n.length-1,1e9,t.setSelAfter(i)))}else return[ii.selection([e])]}function Dz(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function s0(n,e){if(!n.length)return n;let t=n.length,i=ji;for(;t;){let l=Rz(n[t-1],e,i);if(l.changes&&!l.changes.empty||l.effects.length){let o=n.slice(0,t);return o[t-1]=l,o}else e=l.mapped,t--,i=l.selectionsAfter}return i.length?[ii.selection(i)]:ji}function Rz(n,e,t){let i=cN(n.selectionsAfter.length?n.selectionsAfter.map(u=>u.map(e)):ji,t);if(!n.changes)return ii.selection(i);let l=n.changes.map(e),o=e.mapDesc(n.changes,!0),a=n.mapped?n.mapped.composeDesc(o):o;return new ii(l,Ke.mapEffects(n.effects,e),a,n.startSelection.map(o),i)}const jz=/^(input\.type|delete)($|\.)/;class kr{constructor(e,t,i=0,l=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=l}isolate(){return this.prevTime?new kr(this.done,this.undone):this}addChanges(e,t,i,l,o){let a=this.done,u=a[a.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!i||jz.test(i))&&(!u.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):Fd(t,e))}function jn(n){return n.textDirectionAt(n.state.selection.main.head)==kt.LTR}const hN=n=>fN(n,!jn(n)),dN=n=>fN(n,jn(n));function mN(n,e){return Ji(n,t=>t.empty?n.moveByGroup(t,e):Fd(t,e))}const Lz=n=>mN(n,!jn(n)),zz=n=>mN(n,jn(n));function Bz(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Vd(n,e,t){let i=Dn(n).resolveInner(e.head),l=t?et.closedBy:et.openedBy;for(let f=e.head;;){let d=t?i.childAfter(f):i.childBefore(f);if(!d)break;Bz(n,d,l)?i=d:f=t?d.to:d.from}let o=i.type.prop(l),a,u;return o&&(a=t?wr(n,i.from,1):wr(n,i.to,-1))&&a.matched?u=t?a.end.to:a.end.from:u=t?i.to:i.from,re.cursor(u,t?-1:1)}const Pz=n=>Ji(n,e=>Vd(n.state,e,!jn(n))),Hz=n=>Ji(n,e=>Vd(n.state,e,jn(n)));function pN(n,e){return Ji(n,t=>{if(!t.empty)return Fd(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const gN=n=>pN(n,!1),xN=n=>pN(n,!0);function yN(n){let e=n.scrollDOM.clientHeighta.empty?n.moveVertically(a,e,t.height):Fd(a,e));if(l.eq(i.selection))return!1;let o;if(t.selfScroll){let a=n.coordsAtPos(i.selection.main.head),u=n.scrollDOM.getBoundingClientRect(),f=u.top+t.marginTop,d=u.bottom-t.marginBottom;a&&a.top>f&&a.bottombN(n,!1),Ex=n=>bN(n,!0);function Kl(n,e,t){let i=n.lineBlockAt(e.head),l=n.moveToLineBoundary(e,t);if(l.head==e.head&&l.head!=(t?i.to:i.from)&&(l=n.moveToLineBoundary(e,t,!1)),!t&&l.head==i.from&&i.length){let o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(l=re.cursor(i.from+o))}return l}const Iz=n=>Ji(n,e=>Kl(n,e,!0)),Uz=n=>Ji(n,e=>Kl(n,e,!1)),Fz=n=>Ji(n,e=>Kl(n,e,!jn(n))),Vz=n=>Ji(n,e=>Kl(n,e,jn(n))),qz=n=>Ji(n,e=>n.moveToLineBoundary(e,!1,!1)),Qz=n=>Ji(n,e=>n.moveToLineBoundary(e,!0,!1));function Xz(n,e,t){let i=!1,l=ya(n.selection,o=>{let a=wr(n,o.head,-1)||wr(n,o.head,1)||o.head>0&&wr(n,o.head-1,1)||o.headXz(n,e);function zi(n,e,t){let i=ya(n.state.selection,l=>{l.undirectional&&l.head>=l.anchor!=e&&(l=re.range(l.head,l.anchor));let o=t(l);return re.range(l.anchor,o.head,o.goalColumn,o.bidiLevel||void 0,o.assoc)});return i.eq(n.state.selection)?!1:(n.dispatch(Zi(n.state,i)),!0)}function vN(n,e){return zi(n,e,t=>n.moveByChar(t,e))}const wN=n=>vN(n,!jn(n)),kN=n=>vN(n,jn(n));function SN(n,e){return zi(n,e,t=>n.moveByGroup(t,e))}const Gz=n=>SN(n,!jn(n)),Yz=n=>SN(n,jn(n)),Kz=n=>{let e=!jn(n);return zi(n,e,t=>Vd(n.state,t,e))},Wz=n=>{let e=jn(n);return zi(n,e,t=>Vd(n.state,t,e))};function CN(n,e){return zi(n,e,t=>n.moveVertically(t,e))}const ON=n=>CN(n,!1),TN=n=>CN(n,!0);function NN(n,e){return zi(n,e,t=>n.moveVertically(t,e,yN(n).height))}const a2=n=>NN(n,!1),c2=n=>NN(n,!0),Zz=n=>zi(n,!0,e=>Kl(n,e,!0)),Jz=n=>zi(n,!1,e=>Kl(n,e,!1)),e6=n=>{let e=!jn(n);return zi(n,e,t=>Kl(n,t,e))},t6=n=>{let e=jn(n);return zi(n,e,t=>Kl(n,t,e))},n6=n=>zi(n,!1,e=>re.cursor(n.lineBlockAt(e.head).from)),i6=n=>zi(n,!0,e=>re.cursor(n.lineBlockAt(e.head).to)),u2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:0})),!0),f2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:n.doc.length})),!0),h2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:n.selection.main.anchor,head:0})),!0),d2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),r6=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),l6=({state:n,dispatch:e})=>{let t=qd(n).map(({from:i,to:l})=>re.undirectionalRange(i,Math.min(l+1,n.doc.length)));return e(n.update({selection:re.create(t),userEvent:"select"})),!0},s6=({state:n,dispatch:e})=>{let t=ya(n.selection,i=>{let l=Dn(n),o=l.resolveStack(i.from,1);if(i.empty){let a=l.resolveStack(i.from,-1);a.node.from>=o.node.from&&a.node.to<=o.node.to&&(o=a)}for(let a=o;a;a=a.next){let{node:u}=a;if((u.from=i.to||u.to>i.to&&u.from<=i.from)&&a.next)return re.undirectionalRange(u.from,u.to)}return i});return t.eq(n.selection)?!1:(e(Zi(n,t)),!0)};function AN(n,e){let{state:t}=n,i=t.selection,l=t.selection.ranges.slice();for(let o of t.selection.ranges){let a=t.doc.lineAt(o.head);if(e?a.to0)for(let u=o;;){let f=n.moveVertically(u,e);if(f.heada.to){l.some(d=>d.head==f.head)||l.push(f);break}else{if(f.head==u.head)break;u=f}}}return l.length==i.ranges.length?!1:(n.dispatch(Zi(t,re.create(l,l.length-1))),!0)}const o6=n=>AN(n,!1),a6=n=>AN(n,!0),c6=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=re.create([t.main]):t.main.empty||(i=re.create([re.cursor(t.main.head)])),i?(e(Zi(n,i)),!0):!1};function fu(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,l=i.changeByRange(o=>{let{from:a,to:u}=o;if(a==u){let f=e(o);fa&&(t="delete.forward",f=xh(n,f,!0)),a=Math.min(a,f),u=Math.max(u,f)}else a=xh(n,a,!1),u=xh(n,u,!0);return a==u?{range:o}:{changes:{from:a,to:u},range:re.cursor(a,al(n)))i.between(e,e,(l,o)=>{le&&(e=t?o:l)});return e}const EN=(n,e,t)=>fu(n,i=>{let l=i.from,{state:o}=n,a=o.doc.lineAt(l),u,f;if(t&&!e&&l>a.from&&lEN(n,!1,!0),MN=n=>EN(n,!0,!1),DN=(n,e)=>fu(n,t=>{let i=t.head,{state:l}=n,o=l.doc.lineAt(i),a=l.charCategorizer(i);for(let u=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?l.doc.lines:1)&&(i+=e?1:-1);break}let f=hn(o.text,i-o.from,e)+o.from,d=o.text.slice(Math.min(i,f)-o.from,Math.max(i,f)-o.from),m=a(d);if(u!=null&&m!=u)break;(d!=" "||i!=t.head)&&(u=m),i=f}return i}),RN=n=>DN(n,!1),u6=n=>DN(n,!0),f6=n=>fu(n,e=>{let t=n.lineBlockAt(e.head).to;return e.headfu(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),d6=n=>fu(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:ot.of(["",""])},range:re.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},p6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let l=i.from,o=n.doc.lineAt(l),a=l==o.from?l-1:hn(o.text,l-o.from,!1)+o.from,u=l==o.to?l+1:hn(o.text,l-o.from,!0)+o.from;return{changes:{from:a,to:u,insert:n.doc.slice(l,u).append(n.doc.slice(a,l))},range:re.cursor(u)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function qd(n){let e=[],t=-1;for(let i of n.selection.ranges){let l=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=l.number){let a=e[e.length-1];a.to=o.to,a.ranges.push(i)}else e.push({from:l.from,to:o.to,ranges:[i]});t=o.number+1}return e}function jN(n,e,t){if(n.readOnly)return!1;let i=[],l=[];for(let o of qd(n)){if(t?o.to==n.doc.length:o.from==0)continue;let a=n.doc.lineAt(t?o.to+1:o.from-1),u=a.length+1;if(t){i.push({from:o.to,to:a.to},{from:o.from,insert:a.text+n.lineBreak});for(let f of o.ranges)l.push(re.range(Math.min(n.doc.length,f.anchor+u),Math.min(n.doc.length,f.head+u)))}else{i.push({from:a.from,to:o.from},{from:o.to,insert:n.lineBreak+a.text});for(let f of o.ranges)l.push(re.range(f.anchor-u,f.head-u))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:re.create(l,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const g6=({state:n,dispatch:e})=>jN(n,e,!1),x6=({state:n,dispatch:e})=>jN(n,e,!0);function _N(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of qd(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.to)});let l=n.changes(i);return e(n.update({changes:l,selection:n.selection.map(l,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const y6=({state:n,dispatch:e})=>_N(n,e,!1),b6=({state:n,dispatch:e})=>_N(n,e,!0),v6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(qd(e).map(({from:l,to:o})=>(l>0?l--:o{let o;if(n.lineWrapping){let a=n.lineBlockAt(l.head),u=n.coordsAtPos(l.head,l.assoc||1);u&&(o=a.bottom+n.documentTop-u.bottom+n.defaultLineHeight/2)}return n.moveVertically(l,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function w6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Dn(n).resolveInner(e),i=t.childBefore(e),l=t.childAfter(e),o;return i&&l&&i.to<=e&&l.from>=e&&(o=i.type.prop(et.closedBy))&&o.indexOf(l.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(l.from).from&&!/\S/.test(n.sliceDoc(i.to,l.from))?{from:i.to,to:l.from}:null}const m2=LN(!1),k6=LN(!0);function LN(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(l=>{let{from:o,to:a}=l,u=e.doc.lineAt(o),f=!n&&o==a&&w6(e,o);n&&(o=a=(a<=u.to?u:e.doc.lineAt(a)).to);let d=new Hd(e,{simulateBreak:o,simulateDoubleBreak:!!f}),m=Ny(d,o);for(m==null&&(m=xa(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));au.from&&o{let l=[];for(let a=i.from;a<=i.to;){let u=n.doc.lineAt(a);u.number>t&&(i.empty||i.to>u.from)&&(e(u,l,i),t=u.number),a=u.to+1}let o=n.changes(l);return{changes:l,range:re.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}const S6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Hd(n,{overrideIndentation:o=>{let a=t[o];return a??-1}}),l=Dy(n,(o,a,u)=>{let f=Ny(i,o.from);if(f==null)return;/\S/.test(o.text)||(f=0);let d=/^\s*/.exec(o.text)[0],m=Wc(n,f);(d!=m||u.fromn.readOnly?!1:(e(n.update(Dy(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Ty)})}),{userEvent:"input.indent"})),!0),O6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Dy(n,(t,i)=>{let l=/^\s*/.exec(t.text)[0];if(!l)return;let o=xa(l,n.tabSize),a=0,u=Wc(n,Math.max(0,o-ad(n)));for(;a(n.setTabFocusMode(),!0),N6=[{key:"Ctrl-b",run:hN,shift:wN,preventDefault:!0},{key:"Ctrl-f",run:dN,shift:kN},{key:"Ctrl-p",run:gN,shift:ON},{key:"Ctrl-n",run:xN,shift:TN},{key:"Ctrl-a",run:qz,shift:n6},{key:"Ctrl-e",run:Qz,shift:i6},{key:"Ctrl-d",run:MN},{key:"Ctrl-h",run:Mx},{key:"Ctrl-k",run:f6},{key:"Ctrl-Alt-h",run:RN},{key:"Ctrl-o",run:m6},{key:"Ctrl-t",run:p6},{key:"Ctrl-v",run:Ex}],A6=[{key:"ArrowLeft",run:hN,shift:wN,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Lz,shift:Gz,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Fz,shift:e6,preventDefault:!0},{key:"ArrowRight",run:dN,shift:kN,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:zz,shift:Yz,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Vz,shift:t6,preventDefault:!0},{key:"ArrowUp",run:gN,shift:ON,preventDefault:!0},{mac:"Cmd-ArrowUp",run:u2,shift:h2},{mac:"Ctrl-ArrowUp",run:o2,shift:a2},{key:"ArrowDown",run:xN,shift:TN,preventDefault:!0},{mac:"Cmd-ArrowDown",run:f2,shift:d2},{mac:"Ctrl-ArrowDown",run:Ex,shift:c2},{key:"PageUp",run:o2,shift:a2},{key:"PageDown",run:Ex,shift:c2},{key:"Home",run:Uz,shift:Jz,preventDefault:!0},{key:"Mod-Home",run:u2,shift:h2},{key:"End",run:Iz,shift:Zz,preventDefault:!0},{key:"Mod-End",run:f2,shift:d2},{key:"Enter",run:m2,shift:m2},{key:"Mod-a",run:r6},{key:"Backspace",run:Mx,shift:Mx,preventDefault:!0},{key:"Delete",run:MN,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:RN,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:u6,preventDefault:!0},{mac:"Mod-Backspace",run:h6,preventDefault:!0},{mac:"Mod-Delete",run:d6,preventDefault:!0}].concat(N6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),E6=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Pz,shift:Kz},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Hz,shift:Wz},{key:"Alt-ArrowUp",run:g6},{key:"Shift-Alt-ArrowUp",run:y6},{key:"Alt-ArrowDown",run:x6},{key:"Shift-Alt-ArrowDown",run:b6},{key:"Mod-Alt-ArrowUp",run:o6},{key:"Mod-Alt-ArrowDown",run:a6},{key:"Escape",run:c6},{key:"Mod-Enter",run:k6},{key:"Alt-l",mac:"Ctrl-l",run:l6},{key:"Mod-i",run:s6,preventDefault:!0},{key:"Mod-[",run:O6},{key:"Mod-]",run:C6},{key:"Mod-Alt-\\",run:S6},{key:"Shift-Mod-k",run:v6},{key:"Shift-Mod-\\",run:$z},{key:"Mod-/",run:gz},{key:"Alt-A",mac:"Ctrl-A",run:yz},{key:"Ctrl-m",mac:"Shift-Alt-m",run:T6}].concat(A6),p2=typeof String.prototype.normalize=="function"?n=>n.normalize("NFKD"):n=>n;class pa{constructor(e,t,i=0,l=e.length,o,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(i,l),this.bufferStart=i,this.normalize=o?u=>o(p2(u)):p2,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 Jn(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=ry(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=yr(e);let l=this.normalize(t);if(l.length)for(let o=0,a=i,u=!0;;o++){let f=l.charCodeAt(o),d=this.match(f,a,u,this.bufferPos+this.bufferStart,o==l.length-1);if(d)return this.value=d,this;if(o==l.length-1)break;u&&othis.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 i=this.curLineStart+t.index,l=i+t[0].length;if(this.matchPos=hd(this.text,l+(i==l?1:0)),i==this.curLineStart+this.curLine.length&&this.nextLine(),(ithis.value.to)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=i||l.to<=t){let u=new na(t,e.sliceString(t,i));return o0.set(e,u),u}if(l.from==t&&l.to==i)return l;let{text:o,from:a}=l;return a>t&&(o=e.sliceString(t,a)+o,a=t),l.to=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 i=this.flat.from+t.index,l=i+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(i,l,t)))return this.value={from:i,to:l,precise:!0,match:t},this.matchPos=hd(this.text,l+(i==l?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=na.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(BN.prototype[Symbol.iterator]=PN.prototype[Symbol.iterator]=function(){return this});function M6(n){try{return new RegExp(n,Ry),!0}catch{return!1}}function hd(n,e){if(e>=n.length)return e;let t=n.lineAt(e),i;for(;e=56320&&i<57344;)e++;return e}const D6=n=>{let e=Y_(n,"cm-goto-line");if(e){let a=e.dom.querySelector("input[type=text]");return a&&a.select(),!0}let{state:t}=n,i=String(t.doc.lineAt(n.state.selection.main.head).number),{close:l,result:o}=G_(n,{class:"cm-goto-line",label:t.phrase("Go to line"),input:{type:"text",name:"line",value:i},focus:!0,submitLabel:t.phrase("go")});return o.then(a=>{let u=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!u){n.dispatch({effects:l});return}let f=t.doc.lineAt(t.selection.main.head),[,d,m,g,b]=u,v=g?+g.slice(1):0,w=m?+m:f.number;if(m&&b){let O=w/100;d&&(O=O*(d=="-"?-1:1)+f.number/t.doc.lines),w=Math.round(t.doc.lines*O)}else m&&d&&(w=w*(d=="-"?-1:1)+f.number);let S=t.doc.line(Math.max(1,Math.min(t.doc.lines,w))),C=re.cursor(S.from+Math.max(0,Math.min(v,S.length)));n.dispatch({effects:[l,Ae.scrollIntoView(C.from,{y:"center"})],selection:C})}),!0},R6={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},j6=Ne.define({combine(n){return Nr(n,R6,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function _6(n){return[H6,P6]}const L6=Ue.mark({class:"cm-selectionMatch"}),z6=Ue.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function g2(n,e,t,i){return(t==0||n(e.sliceDoc(t-1,t))!=_t.Word)&&(i==e.doc.length||n(e.sliceDoc(i,i+1))!=_t.Word)}function B6(n,e,t,i){return n(e.sliceDoc(t,t+1))==_t.Word&&n(e.sliceDoc(i-1,i))==_t.Word}const P6=Qt.fromClass(class{constructor(n){this.decorations=this.getDeco(n)}update(n){(n.selectionSet||n.docChanged||n.viewportChanged)&&(this.decorations=this.getDeco(n.view))}getDeco(n){let e=n.state.facet(j6),{state:t}=n,i=t.selection;if(i.ranges.length>1)return Ue.none;let l=i.main,o,a=null;if(l.empty){if(!e.highlightWordAroundCursor)return Ue.none;let f=t.wordAt(l.head);if(!f)return Ue.none;a=t.charCategorizer(l.head),o=t.sliceDoc(f.from,f.to)}else{let f=l.to-l.from;if(f200)return Ue.none;if(e.wholeWords){if(o=t.sliceDoc(l.from,l.to),a=t.charCategorizer(l.head),!(g2(a,t,l.from,l.to)&&B6(a,t,l.from,l.to)))return Ue.none}else if(o=t.sliceDoc(l.from,l.to),!o)return Ue.none}let u=[];for(let f of n.visibleRanges){let d=new pa(t.doc,o,f.from,f.to);for(;!d.next().done;){let{from:m,to:g}=d.value;if((!a||g2(a,t,m,g))&&(l.empty&&m<=l.from&&g>=l.to?u.push(z6.range(m,g)):(m>=l.to||g<=l.from)&&u.push(L6.range(m,g)),u.length>e.maxMatches))return Ue.none}}return Ue.set(u)}},{decorations:n=>n.decorations}),H6=Ae.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),I6=({state:n,dispatch:e})=>{let{selection:t}=n,i=re.create(t.ranges.map(l=>n.wordAt(l.head)||re.cursor(l.head)),t.mainIndex);return i.eq(t)?!1:(e(n.update({selection:i})),!0)};function U6(n,e){let{main:t,ranges:i}=n.selection,l=n.wordAt(t.head),o=l&&l.from==t.from&&l.to==t.to;for(let a=!1,u=new pa(n.doc,e,i[i.length-1].to);;)if(u.next(),u.done){if(a)return null;u=new pa(n.doc,e,0,Math.max(0,i[i.length-1].from-1)),a=!0}else{if(a&&i.some(f=>f.from==u.value.from))continue;if(o){let f=n.wordAt(u.value.from);if(!f||f.from!=u.value.from||f.to!=u.value.to)continue}return u.value}}const F6=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(o=>o.from===o.to))return I6({state:n,dispatch:e});let i=n.sliceDoc(t[0].from,t[0].to);if(n.selection.ranges.some(o=>n.sliceDoc(o.from,o.to)!=i))return!1;let l=U6(n,i);return l?(e(n.update({selection:n.selection.addRange(re.range(l.from,l.to),!1),effects:Ae.scrollIntoView(l.to)})),!0):!1},ba=Ne.define({combine(n){return Nr(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new nB(e),scrollToMatch:e=>Ae.scrollIntoView(e)})}});class HN{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||M6(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,(t,i)=>i=="n"?` +`:i=="r"?"\r":i=="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 G6(this):new Q6(this)}getCursor(e,t=0,i){let l=e.doc?e:ut.create({doc:e});return i==null&&(i=l.doc.length),this.regexp?Fo(this,l,t,i):Uo(this,l,t,i)}}class IN{constructor(e){this.spec=e}}function V6(n,e,t){return(i,l,o,a)=>{if(t&&!t(i,l,o,a))return!1;let u=i>=a&&l<=a+o.length?o.slice(i-a,l-a):e.doc.sliceString(i,l);return n(u,e,i,l)}}function Uo(n,e,t,i){let l;return n.wholeWord&&(l=q6(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(l=V6(n.test,e,l)),new pa(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:o=>o.toLowerCase(),l)}function q6(n,e){return(t,i,l,o)=>((o>t||o+l.length=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=Uo(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(i+this.spec.unquoted.length,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}function X6(n,e,t){return(i,l,o)=>(!t||t(i,l,o))&&n(o[0],e,i,l)}function Fo(n,e,t,i){let l;return n.wholeWord&&(l=$6(e.charCategorizer(e.selection.main.head))),n.test&&(l=X6(n.test,e,l)),new BN(e.doc,n.search,{ignoreCase:!n.caseSensitive,test:l},t,i)}function dd(n,e){return n.slice(hn(n,e,!1),e)}function md(n,e){return n.slice(e,hn(n,e))}function $6(n){return(e,t,i)=>!i[0].length||(n(dd(i.input,i.index))!=_t.Word||n(md(i.input,i.index))!=_t.Word)&&(n(md(i.input,i.index+i[0].length))!=_t.Word||n(dd(i.input,i.index+i[0].length))!=_t.Word)}class G6 extends IN{nextMatch(e,t,i){let l=Fo(this.spec,e,i,e.doc.length).next();return l.done&&(l=Fo(this.spec,e,0,t).next()),l.done?null:l.value}prevMatchInRange(e,t,i){for(let l=1;;l++){let o=Math.max(t,i-l*1e4),a=Fo(this.spec,e,o,i),u=null;for(;!a.next().done;)u=a.value;if(u&&(o==t||u.from>o+10))return u;if(o==t)return null}}prevMatch(e,t,i){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,i,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,i)=>{if(i=="&")return e.match[0];if(i=="$")return"$";for(let l=i.length;l>0;l--){let o=+i.slice(0,l);if(o>0&&o=t)return null;l.push(i.value)}return l}highlight(e,t,i,l){let o=Fo(this.spec,e,Math.max(0,t-250),Math.min(i+250,e.doc.length));for(;!o.next().done;)l(o.value.from,o.value.to)}}const Zc=Ke.define(),jy=Ke.define(),Il=Rn.define({create(n){return new a0(Dx(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Zc)?n=new a0(t.value.create(),n.panel):t.is(jy)&&(n=new a0(n.query,t.value?_y:null));return n},provide:n=>Gc.from(n,e=>e.panel)});class a0{constructor(e,t){this.query=e,this.panel=t}}const Y6=Ue.mark({class:"cm-searchMatch"}),K6=Ue.mark({class:"cm-searchMatch cm-searchMatch-selected"}),W6=Qt.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Il))}update(n){let e=n.state.field(Il);(e!=n.startState.field(Il)||n.docChanged||n.selectionSet||n.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:n,panel:e}){if(!e||!n.spec.valid)return Ue.none;let{view:t}=this,i=new Or;for(let l=0,o=t.visibleRanges,a=o.length;lo[l+1].from-500;)f=o[++l].to;n.highlight(t.state,u,f,(d,m)=>{let g=t.state.selection.ranges.some(b=>b.from==d&&b.to==m);i.add(d,m,g?K6:Y6)})}return i.finish()}},{decorations:n=>n.decorations});function hu(n){return e=>{let t=e.state.field(Il,!1);return t&&t.query.spec.valid?n(e,t):VN(e)}}const pd=hu((n,{query:e})=>{let{to:t}=n.state.selection.main,i=e.nextMatch(n.state,t,t);if(!i)return!1;let l=re.single(i.from,i.to),o=n.state.facet(ba);return n.dispatch({selection:l,effects:[Ly(n,i),o.scrollToMatch(l.main,n)],userEvent:"select.search"}),FN(n),!0}),gd=hu((n,{query:e})=>{let{state:t}=n,{from:i}=t.selection.main,l=e.prevMatch(t,i,i);if(!l)return!1;let o=re.single(l.from,l.to),a=n.state.facet(ba);return n.dispatch({selection:o,effects:[Ly(n,l),a.scrollToMatch(o.main,n)],userEvent:"select.search"}),FN(n),!0}),Z6=hu((n,{query:e})=>{let t=e.matchAll(n.state,1e3);return!t||!t.length?!1:(n.dispatch({selection:re.create(t.map(i=>re.range(i.from,i.to))),userEvent:"select.search.matches"}),!0)}),J6=({state:n,dispatch:e})=>{let t=n.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:i,to:l}=t.main,o=[],a=0;for(let u=new pa(n.doc,n.sliceDoc(i,l));!u.next().done;){if(o.length>1e3)return!1;u.value.from==i&&(a=o.length),o.push(re.range(u.value.from,u.value.to))}return e(n.update({selection:re.create(o,a),userEvent:"select.search.matches"})),!0},x2=hu((n,{query:e})=>{let{state:t}=n,{from:i,to:l}=t.selection.main;if(t.readOnly)return!1;let o=e.nextMatch(t,i,i);if(!o)return!1;let a=o,u=[],f,d,m=[];a.precise?a.from==i&&a.to==l&&(d=t.toText(e.getReplacement(a)),u.push({from:a.from,to:a.to,insert:d}),a=e.nextMatch(t,a.from,a.to),m.push(Ae.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(i).number)+"."))):a=e.nextMatch(t,a.from,a.to);let g=n.state.changes(u);return a&&(f=re.single(a.from,a.to).map(g),m.push(Ly(n,a)),m.push(t.facet(ba).scrollToMatch(f.main,n))),n.dispatch({changes:g,selection:f,effects:m,userEvent:"input.replace"}),!0}),eB=hu((n,{query:e})=>{if(n.state.readOnly)return!1;let t=[];for(let l of e.matchAll(n.state,1e9)){let{from:o,to:a,precise:u}=l;u&&t.push({from:o,to:a,insert:e.getReplacement(l)})}if(!t.length)return!1;let i=n.state.phrase("replaced $ matches",t.length)+".";return n.dispatch({changes:t,effects:Ae.announce.of(i),userEvent:"input.replace.all"}),!0});function _y(n){return n.state.facet(ba).createPanel(n)}function Dx(n,e){var t,i,l,o,a;let u=n.selection.main,f=u.empty||u.to>u.from+100?"":n.sliceDoc(u.from,u.to);if(e&&!f)return e;let d=n.facet(ba);return new HN({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:d.literal)?f:f.replace(/\n/g,"\\n"),caseSensitive:(i=e==null?void 0:e.caseSensitive)!==null&&i!==void 0?i:d.caseSensitive,literal:(l=e==null?void 0:e.literal)!==null&&l!==void 0?l:d.literal,regexp:(o=e==null?void 0:e.regexp)!==null&&o!==void 0?o:d.regexp,wholeWord:(a=e==null?void 0:e.wholeWord)!==null&&a!==void 0?a:d.wholeWord})}function UN(n){let e=Pd(n,_y);return e&&e.dom.querySelector("[main-field]")}function FN(n){let e=UN(n);e&&e==n.root.activeElement&&e.select()}const VN=n=>{let e=n.state.field(Il,!1);if(e&&e.panel){let t=UN(n);if(t&&t!=n.root.activeElement){let i=Dx(n.state,e.query.spec);i.valid&&n.dispatch({effects:Zc.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[jy.of(!0),e?Zc.of(Dx(n.state,e.query.spec)):Ke.appendConfig.of(rB)]});return!0},qN=n=>{let e=n.state.field(Il,!1);if(!e||!e.panel)return!1;let t=Pd(n,_y);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:jy.of(!1)}),!0},tB=[{key:"Mod-f",run:VN,scope:"editor search-panel"},{key:"F3",run:pd,shift:gd,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:pd,shift:gd,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:qN,scope:"editor search-panel"},{key:"Mod-Shift-l",run:J6},{key:"Mod-Alt-g",run:D6},{key:"Mod-d",run:F6,preventDefault:!0}];class nB{constructor(e){this.view=e;let t=this.query=e.state.field(Il).query.spec;this.commit=this.commit.bind(this),this.searchField=wt("input",{value:t.search,placeholder:mi(e,"Find"),"aria-label":mi(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=wt("input",{value:t.replace,placeholder:mi(e,"Replace"),"aria-label":mi(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=wt("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=wt("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=wt("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function i(l,o,a){return wt("button",{class:"cm-button",name:l,onclick:o,type:"button"},a)}this.dom=wt("div",{onkeydown:l=>this.keydown(l),class:"cm-search"},[this.searchField,i("next",()=>pd(e),[mi(e,"next")]),i("prev",()=>gd(e),[mi(e,"previous")]),i("select",()=>Z6(e),[mi(e,"all")]),wt("label",null,[this.caseField,mi(e,"match case")]),wt("label",null,[this.reField,mi(e,"regexp")]),wt("label",null,[this.wordField,mi(e,"by word")]),...e.state.readOnly?[]:[wt("br"),this.replaceField,i("replace",()=>x2(e),[mi(e,"replace")]),i("replaceAll",()=>eB(e),[mi(e,"replace all")])],wt("button",{name:"close",onclick:()=>qN(e),"aria-label":mi(e,"close"),type:"button"},["×"])])}commit(){let e=new HN({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:Zc.of(e)}))}keydown(e){r_(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?gd:pd)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),x2(this.view))}update(e){for(let t of e.transactions)for(let i of t.effects)i.is(Zc)&&!i.value.eq(this.query)&&this.setQuery(i.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(ba).top}}function mi(n,e){return n.state.phrase(e)}const yh=30,bh=/[\s\.,:;?!]/;function Ly(n,{from:e,to:t}){let i=n.state.doc.lineAt(e),l=n.state.doc.lineAt(t).to,o=Math.max(i.from,e-yh),a=Math.min(l,t+yh),u=n.state.sliceDoc(o,a);if(o!=i.from){for(let f=0;fu.length-yh;f--)if(!bh.test(u[f-1])&&bh.test(u[f])){u=u.slice(0,f);break}}return Ae.announce.of(`${n.state.phrase("current match")}. ${u} ${n.state.phrase("on line")} ${i.number}.`)}const iB=Ae.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"}}),rB=[Il,Fs.low(W6),iB];class QN{constructor(e,t,i,l){this.state=e,this.pos=t,this.explicit=i,this.view=l,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Dn(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),i=Math.max(t.from,this.pos-250),l=t.text.slice(i-t.from,this.pos-t.from),o=l.search(XN(e,!1));return o<0?null:{from:i+o,to:this.pos,text:l.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}}function y2(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function lB(n){let e=Object.create(null),t=Object.create(null);for(let{label:l}of n){e[l[0]]=!0;for(let o=1;otypeof l=="string"?{label:l}:l),[t,i]=e.every(l=>/^\w+$/.test(l.label))?[/\w*$/,/\w+$/]:lB(e);return l=>{let o=l.matchBefore(i);return o||l.explicit?{from:o?o.from:l.pos,options:e,validFor:t}:null}}class b2{constructor(e,t,i,l){this.completion=e,this.source=t,this.match=i,this.score=l}}function zs(n){return n.selection.main.from}function XN(n,e){var t;let{source:i}=n,l=e&&i[0]!="^",o=i[i.length-1]!="$";return!l&&!o?n:new RegExp(`${l?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const $N=Jr.define();function oB(n,e,t,i){let{main:l}=n.selection,o=t-l.from,a=i-l.from;return{...n.changeByRange(u=>{if(u!=l&&t!=i&&n.sliceDoc(u.from+o,u.from+a)!=n.sliceDoc(t,i))return{range:u};let f=n.toText(e);return{changes:{from:u.from+o,to:i==l.from?u.to:u.from+a,insert:f},range:re.cursor(u.from+o+f.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const v2=new WeakMap;function aB(n){if(!Array.isArray(n))return n;let e=v2.get(n);return e||v2.set(n,e=sB(n)),e}const xd=Ke.define(),Jc=Ke.define();class cB{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=48&&B<=57||B>=97&&B<=122?2:B>=65&&B<=90?1:0:(D=ry(B))!=D.toLowerCase()?1:D!=D.toUpperCase()?2:0;(!_||R==1&&C||H==0&&R!=0)&&(t[g]==B||i[g]==B&&(b=!0)?a[g++]=_:a.length&&(O=!1)),H=R,_+=yr(B)}return g==f&&a[0]==0&&O?this.result(-100+(b?-200:0),a,e):v==f&&w==0?this.ret(-200-e.length+(S==e.length?0:-100),[0,S]):u>-1?this.ret(-700-e.length,[u,u+this.pattern.length]):v==f?this.ret(-900-e.length,[w,S]):g==f?this.result(-100+(b?-200:0)+-700+(O?0:-1100),a,e):t.length==2?null:this.result((l[0]?-700:0)+-200+-1100,l,e)}result(e,t,i){let l=[],o=0;for(let a of t){let u=a+(this.astral?yr(Jn(i,a)):1);o&&l[o-1]==a?l[o-1]=u:(l[o++]=a,l[o++]=u)}return this.ret(e-i.length,l)}}class uB{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:fB,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)=>i=>w2(e(i),t(i)),optionClass:(e,t)=>i=>w2(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function w2(n,e){return n?e?n+" "+e:n:e}function fB(n,e,t,i,l,o){let a=n.textDirection==kt.RTL,u=a,f=!1,d="top",m,g,b=e.left-l.left,v=l.right-e.right,w=i.right-i.left,S=i.bottom-i.top;if(u&&b=S||_>e.top?m=t.bottom-e.top:(d="bottom",m=e.bottom-t.top)}let C=(e.bottom-e.top)/o.offsetHeight,O=(e.right-e.left)/o.offsetWidth;return{style:`${d}: ${m/C}px; max-width: ${g/O}px`,class:"cm-completionInfo-"+(f?a?"left-narrow":"right-narrow":u?"left":"right")}}const zy=Ke.define();function hB(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(l=>"cm-completionIcon-"+l)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,l,o){let a=document.createElement("span");a.className="cm-completionLabel";let u=t.displayLabel||t.label,f=0;for(let d=0;df&&a.appendChild(document.createTextNode(u.slice(f,m)));let b=a.appendChild(document.createElement("span"));b.appendChild(document.createTextNode(u.slice(m,g))),b.className="cm-completionMatchedText",f=g}return ft.position-i.position).map(t=>t.render)}function c0(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let l=Math.floor(e/t);return{from:l*t,to:(l+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}class dB{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:f=>this.placeInfo(f),key:this},this.space=null,this.currentClass="";let l=e.state.field(t),{options:o,selected:a}=l.open,u=e.state.facet(fn);this.optionContent=hB(u),this.optionClass=u.optionClass,this.tooltipClass=u.tooltipClass,this.range=c0(o.length,a,u.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",f=>{let{options:d}=e.state.field(t).open;for(let m=f.target,g;m&&m!=this.dom;m=m.parentNode)if(m.nodeName=="LI"&&(g=/-(\d+)$/.exec(m.id))&&+g[1]this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;m!=null&&(e.dispatch({effects:zy.of(m)}),f.preventDefault())}}),this.dom.addEventListener("focusout",f=>{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(fn).closeOnBlur&&f.relatedTarget!=e.contentDOM&&e.dispatch({effects:Jc.of(null)})}),this.showOptions(o,l.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){var t;let i=e.state.field(this.stateField),l=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=l){let{options:o,selected:a,disabled:u}=i.open;(!l.open||l.open.options!=o)&&(this.range=c0(o.length,a,e.state.facet(fn).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),u!=((t=l.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!u)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);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.to)&&(this.range=c0(t.options.length,t.selected,this.view.state.facet(fn).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:l}=t.options[t.selected],{info:o}=l;if(!o)return;let a=typeof o=="string"?document.createTextNode(o):o(l);if(!a)return;"then"in a?a.then(u=>{u&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(u,l)}).catch(u=>ni(this.view.state,u,"completion info")):(this.addInfoPane(a,l),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:l,destroy:o}=e;i.appendChild(l),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,l=this.range.from;i;i=i.nextSibling,l++)i.nodeName!="LI"||!i.id?l--:l==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&pB(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),l=e.getBoundingClientRect(),o=this.space;if(!o){let a=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:a.clientWidth,bottom:a.clientHeight}}return l.top>Math.min(o.bottom,t.bottom)-10||l.bottom{a.target==l&&a.preventDefault()});let o=null;for(let a=i.from;ai.from||i.from==0))if(o=b,typeof d!="string"&&d.header)l.appendChild(d.header(d));else{let v=l.appendChild(document.createElement("completion-section"));v.textContent=b}}const m=l.appendChild(document.createElement("li"));m.id=t+"-"+a,m.setAttribute("role","option");let g=this.optionClass(u);g&&(m.className=g);for(let b of this.optionContent){let v=b(u,this.view.state,this.view,f);v&&m.appendChild(v)}}return i.from&&l.classList.add("cm-completionListIncompleteTop"),i.tonew dB(t,n,e)}function pB(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),l=t.height/n.offsetHeight;i.topt.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/l)}function k2(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function gB(n,e){let t=[],i=null,l=null,o=m=>{t.push(m);let{section:g}=m.completion;if(g){i||(i=[]);let b=typeof g=="string"?g:g.name;i.some(v=>v.name==b)||i.push(typeof g=="string"?{name:b}:g)}},a=e.facet(fn);for(let m of n)if(m.hasResult()){let g=m.result.getMatch;if(m.result.filter===!1)for(let b of m.result.options)o(new b2(b,m.source,g?g(b):[],1e9-t.length));else{let b=e.sliceDoc(m.from,m.to),v,w=a.filterStrict?new uB(b):new cB(b);for(let S of m.result.options)if(v=w.match(S.label)){let C=S.displayLabel?g?g(S,v.matched):[]:v.matched,O=v.score+(S.boost||0);if(o(new b2(S,m.source,C,O)),typeof S.section=="object"&&S.section.rank==="dynamic"){let{name:_}=S.section;l||(l=Object.create(null)),l[_]=Math.max(O,l[_]||-1e9)}}}}if(i){let m=Object.create(null),g=0,b=(v,w)=>(v.rank==="dynamic"&&w.rank==="dynamic"?l[w.name]-l[v.name]:0)||(typeof v.rank=="number"?v.rank:1e9)-(typeof w.rank=="number"?w.rank:1e9)||(v.nameb.score-g.score||d(g.completion,b.completion))){let g=m.completion;!f||f.label!=g.label||f.detail!=g.detail||f.type!=null&&g.type!=null&&f.type!=g.type||f.apply!=g.apply||f.boost!=g.boost?u.push(m):k2(m.completion)>k2(f)&&(u[u.length-1]=m),f=m.completion}return u}class Wo{constructor(e,t,i,l,o,a){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=l,this.selected=o,this.disabled=a}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Wo(this.options,S2(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,l,o,a){if(l&&!a&&e.some(d=>d.isPending))return l.setDisabled();let u=gB(e,t);if(!u.length)return l&&e.some(d=>d.isPending)?l.setDisabled():null;let f=t.facet(fn).selectOnOpen?0:-1;if(l&&l.selected!=f&&l.selected!=-1){let d=l.options[l.selected].completion;for(let m=0;mm.hasResult()?Math.min(d,m.from):d,1e8),create:kB,above:o.aboveCursor},l?l.timestamp:Date.now(),f,!1)}map(e){return new Wo(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Wo(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class yd{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new yd(vB,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(fn),o=(i.override||t.languageDataAt("autocomplete",zs(t)).map(aB)).map(f=>(this.active.find(m=>m.source==f)||new _i(f,this.active.some(m=>m.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((f,d)=>f==this.active[d])&&(o=this.active);let a=this.open,u=e.effects.some(f=>f.is(By));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||o.some(f=>f.hasResult()&&e.changes.touchesRange(f.from,f.to))||!xB(o,this.active)||u?a=Wo.build(o,t,this.id,a,i,u):a&&a.disabled&&!o.some(f=>f.isPending)&&(a=null),!a&&o.every(f=>!f.isPending)&&o.some(f=>f.hasResult())&&(o=o.map(f=>f.hasResult()?new _i(f.source,0):f));for(let f of e.effects)f.is(zy)&&(a=a&&a.setSelected(f.value,this.id));return o==this.active&&a==this.open?this:new yd(o,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?yB:bB}}function xB(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const vB=[];function GN(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation($N);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}class _i{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=GN(e,t),l=this;(i&8||i&16&&this.touches(e))&&(l=new _i(l.source,0)),i&4&&l.state==0&&(l=new _i(this.source,1)),l=l.updateFor(e,i);for(let o of e.effects)if(o.is(xd))l=new _i(l.source,1,o.value);else if(o.is(Jc))l=new _i(l.source,0);else if(o.is(By))for(let a of o.value)a.source==l.source&&(l=a);return l}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(zs(e.state))}}class ia extends _i{constructor(e,t,i,l,o,a){super(e,3,t),this.limit=i,this.result=l,this.from=o,this.to=a}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let l=this.result;l.map&&!e.changes.empty&&(l=l.map(l,e.changes));let o=e.changes.mapPos(this.from),a=e.changes.mapPos(this.to,1),u=zs(e.state);if(u>a||!l||t&2&&(zs(e.startState)==this.from||ut.map(e))}}),ei=Rn.define({create(){return yd.start()},update(n,e){return n.update(e)},provide:n=>[wy.from(n,e=>e.tooltip),Ae.contentAttributes.from(n,e=>e.attrs)]});function Py(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(ei).active.find(l=>l.source==e.source);return i instanceof ia?(typeof t=="string"?n.dispatch({...oB(n.state,t,i.from,i.to),annotations:$N.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const kB=mB(ei,Py);function vh(n,e="option"){return t=>{let i=t.state.field(ei,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+l*(n?1:-1):n?0:a-1;return u<0?u=e=="page"?0:a-1:u>=a&&(u=e=="page"?a-1:0),t.dispatch({effects:zy.of(u)}),!0}}const SB=n=>{let e=n.state.field(ei,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampn.state.field(ei,!1)?(n.dispatch({effects:xd.of(!0)}),!0):!1,CB=n=>{let e=n.state.field(ei,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Jc.of(null)}),!0)};class OB{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const TB=50,NB=1e3,AB=Qt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(ei).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(ei),t=n.state.facet(fn);if(!n.selectionSet&&!n.docChanged&&n.startState.field(ei)==e)return;let i=n.transactions.some(o=>{let a=GN(o,t);return a&8||(o.selection||o.docChanged)&&!(a&3)});for(let o=0;oTB&&Date.now()-a.time>NB){for(let u of a.context.abortListeners)try{u()}catch(f){ni(this.view.state,f)}a.context.abortListeners=null,this.running.splice(o--,1)}else a.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(a=>a.is(xd)))&&(this.pendingStart=!0);let l=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(a=>a.active.source==o.source))?setTimeout(()=>this.startUpdate(),l):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(ei);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(fn).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=zs(e),i=new QN(e,t,n.explicit,this.view),l=new OB(n,i);this.running.push(l),Promise.resolve(n.source(i)).then(o=>{l.context.aborted||(l.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Jc.of(null)}),ni(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(fn).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(fn),i=this.view.state.field(ei);for(let l=0;lu.source==o.active.source);if(a&&a.isPending)if(o.done==null){let u=new _i(o.active.source,0);for(let f of o.updates)u=u.update(f,t);u.isPending||e.push(u)}else this.startQuery(a)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:By.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(ei,!1);if(e&&e.tooltip&&this.view.state.facet(fn).closeOnBlur){let t=e.open&&AT(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Jc.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:xd.of(!1)}),20),this.composing=0}}}),EB=typeof navigator=="object"&&/Win/.test(navigator.platform),MB=Fs.highest(Ae.domEventHandlers({keydown(n,e){let t=e.state.field(ei,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||!n.key||n.key.length>1||n.ctrlKey&&!(EB&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],l=t.active.find(a=>a.source==i.source),o=i.completion.commitCharacters||l.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&Py(e,i),!1}})),DB=Ae.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"}}}),eu={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ds=Ke.define({map(n,e){let t=e.mapPos(n,-1,Fn.TrackAfter);return t??void 0}}),Hy=new class extends Fl{};Hy.startSide=1;Hy.endSide=-1;const YN=Rn.define({create(){return it.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Ds)&&(n=n.update({add:[Hy.range(t.value,t.value+1)]}));return n}});function RB(){return[_B,YN]}const f0="()[]{}<>«»»«[]{}";function KN(n){for(let e=0;e{if((jB?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let l=n.state.selection.main;if(i.length>2||i.length==2&&yr(Jn(i,0))==1||e!=l.from||t!=l.to)return!1;let o=BB(n.state,i);return o?(n.dispatch(o),!0):!1}),LB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=WN(n,n.selection.main.head).brackets||eu.brackets,l=null,o=n.changeByRange(a=>{if(a.empty){let u=PB(n.doc,a.head);for(let f of i)if(f==u&&Qd(n.doc,a.head)==KN(Jn(f,0)))return{changes:{from:a.head-f.length,to:a.head+f.length},range:re.cursor(a.head-f.length)}}return{range:l=a}});return l||e(n.update(o,{scrollIntoView:!0,userEvent:"delete.backward"})),!l},zB=[{key:"Backspace",run:LB}];function BB(n,e){let t=WN(n,n.selection.main.head),i=t.brackets||eu.brackets;for(let l of i){let o=KN(Jn(l,0));if(e==l)return o==l?UB(n,l,i.indexOf(l+l+l)>-1,t):HB(n,l,o,t.before||eu.before);if(e==o&&ZN(n,n.selection.main.from))return IB(n,l,o)}return null}function ZN(n,e){let t=!1;return n.field(YN).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Qd(n,e){let t=n.sliceString(e,e+2);return t.slice(0,yr(Jn(t,0)))}function PB(n,e){let t=n.sliceString(e-2,e);return yr(Jn(t,0))==t.length?t:t.slice(1)}function HB(n,e,t,i){let l=null,o=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:t,from:a.to}],effects:Ds.of(a.to+e.length),range:re.range(a.anchor+e.length,a.head+e.length)};let u=Qd(n.doc,a.head);return!u||/\s/.test(u)||i.indexOf(u)>-1?{changes:{insert:e+t,from:a.head},effects:Ds.of(a.head+e.length),range:re.cursor(a.head+e.length)}:{range:l=a}});return l?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function IB(n,e,t){let i=null,l=n.changeByRange(o=>o.empty&&Qd(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:re.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(l,{scrollIntoView:!0,userEvent:"input.type"})}function UB(n,e,t,i){let l=i.stringPrefixes||eu.stringPrefixes,o=null,a=n.changeByRange(u=>{if(!u.empty)return{changes:[{insert:e,from:u.from},{insert:e,from:u.to}],effects:Ds.of(u.to+e.length),range:re.range(u.anchor+e.length,u.head+e.length)};let f=u.head,d=Qd(n.doc,f),m;if(d==e){if(C2(n,f))return{changes:{insert:e+e,from:f},effects:Ds.of(f+e.length),range:re.cursor(f+e.length)};if(ZN(n,f)){let b=t&&n.sliceDoc(f,f+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:f,to:f+b.length,insert:b},range:re.cursor(f+b.length)}}}else{if(t&&n.sliceDoc(f-2*e.length,f)==e+e&&(m=O2(n,f-2*e.length,l))>-1&&C2(n,m))return{changes:{insert:e+e+e+e,from:f},effects:Ds.of(f+e.length),range:re.cursor(f+e.length)};if(n.charCategorizer(f)(d)!=_t.Word&&O2(n,f,l)>-1&&!FB(n,f,e,l))return{changes:{insert:e+e,from:f},effects:Ds.of(f+e.length),range:re.cursor(f+e.length)}}return{range:o=u}});return o?null:n.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function C2(n,e){let t=Dn(n).resolveInner(e+1);return t.parent&&t.from==e}function FB(n,e,t,i){let l=Dn(n).resolveInner(e,-1),o=i.reduce((a,u)=>Math.max(a,u.length),0);for(let a=0;a<5;a++){let u=n.sliceDoc(l.from,Math.min(l.to,l.from+t.length+o)),f=u.indexOf(t);if(!f||f>-1&&i.indexOf(u.slice(0,f))>-1){let m=l.firstChild;for(;m&&m.from==l.from&&m.to-m.from>t.length+f;){if(n.sliceDoc(m.to-t.length,m.to)==t)return!1;m=m.firstChild}return!0}let d=l.to==e&&l.parent;if(!d)break;l=d}return!1}function O2(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=_t.Word)return e;for(let l of t){let o=e-l.length;if(n.sliceDoc(o,e)==l&&i(n.sliceDoc(o-1,o))!=_t.Word)return o}return-1}function VB(n={}){return[MB,ei,fn.of(n),AB,qB,DB]}const JN=[{key:"Ctrl-Space",run:u0},{mac:"Alt-`",run:u0},{mac:"Alt-i",run:u0},{key:"Escape",run:CB},{key:"ArrowDown",run:vh(!0)},{key:"ArrowUp",run:vh(!1)},{key:"PageDown",run:vh(!0,"page")},{key:"PageUp",run:vh(!1,"page")},{key:"Enter",run:SB}],qB=Fs.highest(by.computeN([fn],n=>n.facet(fn).defaultKeymap?[JN]:[]));class T2{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}}class As{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let l=i.facet(tu).markerFilter;l&&(e=l(e,i));let o=e.slice().sort((v,w)=>v.from-w.from||v.to-w.to),a=new Or,u=[],f=0,d=i.doc.iter(),m=0,g=i.doc.length;for(let v=0;;){let w=v==o.length?null:o[v];if(!w&&!u.length)break;let S,C;if(u.length)S=f,C=u.reduce((M,H)=>Math.min(M,H.to),w&&w.from>S?w.from:1e8);else{if(S=w.from,S>g)break;C=w.to,u.push(w),v++}for(;vM.from||M.to==S))u.push(M),v++,C=Math.min(M.to,C);else{C=Math.min(M.from,C);break}}C=Math.min(C,g);let O=!1;if(u.some(M=>M.from==S&&(M.to==C||C==g))&&(O=S==C,!O&&C-S<10)){let M=S-(m+d.value.length);M>0&&(d.next(M),m=S);for(let H=S;;){if(H>=C){O=!0;break}if(!d.lineBreak&&m+d.value.length>H)break;H=m+d.value.length,m+=d.value.length,d.next()}}let _=i9(u);if(O)a.add(S,S,Ue.widget({widget:new JB(_),diagnostics:u.slice()}));else{let M=u.reduce((H,B)=>B.markClass?H+" "+B.markClass:H,"");a.add(S,C,Ue.mark({class:"cm-lintRange cm-lintRange-"+_+M,diagnostics:u.slice(),inclusiveEnd:u.some(H=>H.to>C)}))}if(f=C,f==g)break;for(let M=0;M{if(!(e&&a.diagnostics.indexOf(e)<0))if(!i)i=new T2(l,o,e||a.diagnostics[0]);else{if(a.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new T2(i.from,o,i.diagnostic)}}),i}function QB(n,e){let t=e.pos,i=e.end||t,l=n.state.facet(tu).hideOn(n,t,i);if(l!=null)return l;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(a=>a.is(eA))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function XB(n,e){return n.field(yi,!1)?e:e.concat(Ke.appendConfig.of(r9))}const eA=Ke.define(),Iy=Ke.define(),tA=Ke.define(),yi=Rn.define({create(){return new As(Ue.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,l=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);i=Gl(t,n.selected.diagnostic,o)||Gl(t,null,o)}!t.size&&l&&e.state.facet(tu).autoPanel&&(l=null),n=new As(t,l,i)}for(let t of e.effects)if(t.is(eA)){let i=e.state.facet(tu).autoPanel?t.value.length?nu.open:null:n.panel;n=As.init(t.value,i,e.state)}else t.is(Iy)?n=new As(n.diagnostics,t.value?nu.open:null,n.selected):t.is(tA)&&(n=new As(n.diagnostics,n.panel,t.value));return n},provide:n=>[Gc.from(n,e=>e.panel),Ae.decorations.from(n,e=>e.diagnostics)]}),$B=Ue.mark({class:"cm-lintRange cm-lintRange-active"});function GB(n,e,t){let{diagnostics:i}=n.state.field(yi),l,o=-1,a=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(f,d,{spec:m})=>{if(e>=f&&e<=d&&(f==d||(e>f||t>0)&&(eiA(n,t,!1)))}const KB=n=>{let e=n.state.field(yi,!1);(!e||!e.panel)&&n.dispatch({effects:XB(n.state,[Iy.of(!0)])});let t=Pd(n,nu.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},N2=n=>{let e=n.state.field(yi,!1);return!e||!e.panel?!1:(n.dispatch({effects:Iy.of(!1)}),!0)},WB=n=>{let e=n.state.field(yi,!1);if(!e)return!1;let t=n.state.selection.main,i=Gl(e.diagnostics,null,t.to+1);return!i&&(i=Gl(e.diagnostics,null,0),!i||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),X_(n,i.from,1,{tooltip:rA,until:l=>l.docChanged||l.newSelection.main.headi.to}),!0)},ZB=[{key:"Mod-Shift-m",run:KB,preventDefault:!0},{key:"F8",run:WB}],tu=Ne.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Nr(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:A2,tooltipFilter:A2,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,l,o)=>e(i,l,o)||t(i,l,o):e:t,autoPanel:(e,t)=>e||t})}}});function A2(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function nA(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;io.toLowerCase()==l.toLowerCase())){e.push(l);continue e}}e.push("")}return e}function iA(n,e,t){var i;let l=t?nA(e.actions):[];return wt("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},wt("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,a)=>{let u=!1,f=v=>{if(v.preventDefault(),u)return;u=!0;let w=Gl(n.state.field(yi).diagnostics,e);w&&o.apply(n,w.from,w.to)},{name:d}=o,m=l[a]?d.indexOf(l[a]):-1,g=m<0?d:[d.slice(0,m),wt("u",d.slice(m,m+1)),d.slice(m+1)],b=o.markClass?" "+o.markClass:"";return wt("button",{type:"button",class:"cm-diagnosticAction"+b,onclick:f,onmousedown:f,"aria-label":` Action: ${d}${m<0?"":` (access key "${l[a]})"`}.`},g)}),e.source&&wt("div",{class:"cm-diagnosticSource"},e.source))}class JB extends el{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return wt("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class E2{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=iA(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class nu{constructor(e){this.view=e,this.items=[];let t=l=>{if(!(l.ctrlKey||l.altKey||l.metaKey)){if(l.keyCode==27)N2(this.view),this.view.focus();else if(l.keyCode==38||l.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(l.keyCode==40||l.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(l.keyCode==36)this.moveSelection(0);else if(l.keyCode==35)this.moveSelection(this.items.length-1);else if(l.keyCode==13)this.view.focus();else if(l.keyCode>=65&&l.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],a=nA(o.actions);for(let u=0;u{for(let o=0;oN2(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(yi).selected;if(!e)return-1;for(let t=0;t{for(let m of d.diagnostics){if(a.has(m))continue;a.add(m);let g=-1,b;for(let v=i;vi&&(this.items.splice(i,g-i),l=!0)),t&&b.diagnostic==t.diagnostic?b.dom.hasAttribute("aria-selected")||(b.dom.setAttribute("aria-selected","true"),o=b):b.dom.hasAttribute("aria-selected")&&b.dom.removeAttribute("aria-selected"),i++}});i({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:u,panel:f})=>{let d=f.height/this.list.offsetHeight;u.topf.bottom&&(this.list.scrollTop+=(u.bottom-f.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),l&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(yi),i=Gl(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:tA.of(i)})}static open(e){return new nu(e)}}function e9(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function wh(n){return e9(``,'width="6" height="3"')}const t9=Ae.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:wh("#f11")},".cm-lintRange-warning":{backgroundImage:wh("orange")},".cm-lintRange-info":{backgroundImage:wh("#999")},".cm-lintRange-hint":{backgroundImage:wh("#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 n9(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function i9(n){let e="hint",t=1;for(let i of n){let l=n9(i.severity);l>t&&(t=l,e=i.severity)}return e}const rA=Q_(GB,{hideOn:QB}),r9=[yi,Ae.decorations.compute([yi],n=>{let{selected:e,panel:t}=n.field(yi);return!e||!t||e.from==e.to?Ue.none:Ue.set([$B.range(e.from,e.to)])}),rA,t9],l9=[sL(),cL(),k_(),Oz(),ZL(),u_(),g_(),ut.allowMultipleSelections.of(!0),PL(),tN(nz,{fallback:!0}),cz(),RB(),VB(),__(),B_(),A_(),_6(),by.of([...zB,...E6,...tB,..._z,...GL,...JN,...ZB])];var M2={};class bd{constructor(e,t,i,l,o,a,u,f,d,m=0,g){this.p=e,this.stack=t,this.state=i,this.reducePos=l,this.pos=o,this.score=a,this.buffer=u,this.bufferBase=f,this.curContext=d,this.lookAhead=m,this.parent=g}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let l=e.parser.context;return new bd(e,[],t,i,i,0,[],0,l?new D2(l,l.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){var t;let i=e>>19,l=e&65535,{parser:o}=this.p,a=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[l])===null||t===void 0)&&t.isAnonymous)&&(d==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=m):this.p.lastBigReductionSizef;)this.stack.pop();this.reduceContext(l,d)}storeNode(e,t,i,l=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[a-4]==0&&this.buffer[a-1]>-1){if(t==i)return;if(this.buffer[a-2]>=t){this.buffer[a-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,l);else{let a=this.buffer.length;if(a>0&&(this.buffer[a-4]!=0||this.buffer[a-1]<0)){let u=!1;for(let f=a;f>0&&this.buffer[f-2]>i;f-=4)if(this.buffer[f-1]>=0){u=!0;break}if(u)for(;a>0&&this.buffer[a-2]>i;)this.buffer[a]=this.buffer[a-4],this.buffer[a+1]=this.buffer[a-3],this.buffer[a+2]=this.buffer[a-2],this.buffer[a+3]=this.buffer[a-1],a-=4,l>4&&(l-=4)}this.buffer[a]=e,this.buffer[a+1]=t,this.buffer[a+2]=i,this.buffer[a+3]=l}}shift(e,t,i,l){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:a}=this.p;this.pos=l;let u=a.stateFlag(o,1);!u&&(l>i||t<=a.maxNode)&&(this.reducePos=l),this.pushState(o,u?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=a.maxNode&&this.buffer.push(t,i,l,4)}else this.pos=l,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,l,4)}apply(e,t,i,l){e&65536?this.reduce(e):this.shift(e,t,i,l)}useNode(e,t,i){let l=this.p.reused.length-1;(l<0||this.p.reused[l]!=e)&&(this.p.reused.push(e),l++);let o=this.reducePos=this.pos=i+e.length;this.pushState(t,i),this.buffer.push(l,i,o,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),l=e.bufferBase+t;for(;e&&l==e.bufferBase;)e=e.parent;return new bd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,l,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new s9(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}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 l=[];for(let o=0,a;of&1&&u==a)||l.push(t[o],a)}t=l}let i=[];for(let l=0;l>19,l=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],l,!1)<0){let a=this.findForcedReduction();if(a==null)return!1;t=a}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=[],i=(l,o)=>{if(!t.includes(l))return t.push(l),e.allActions(l,a=>{if(!(a&393216))if(a&65536){let u=(a>>19)-o;if(u>1){let f=a&65535,d=this.stack.length-u*3;if(d>=0&&e.getGoto(this.stack[d],f,!1)>=0)return u<<19|65536|f}}else{let u=i(a,o+1);if(u!=null)return u}})};return i(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;t0&&this.emitLookAhead()}}class D2{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class s9{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let l=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=l}}class vd{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new vd(e,t,t-e.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 vd(this.stack,this.pos,this.index)}}function kh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,l=0;i=92&&a--,a>=34&&a--;let f=a-32;if(f>=46&&(f-=46,u=!0),o+=f,u)break;o*=46}t?t[l++]=o:t=new e(o)}return t}class Fh{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const R2=new Fh;class o9{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=R2,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 i=this.range,l=this.rangeIndex,o=this.pos+e;for(;oi.to:o>=i.to;){if(l==this.ranges.length-1)return null;let a=this.ranges[++l];o+=a.from-i.to,i=a}return o}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,l;if(t>=0&&t=this.chunk2Pos&&iu.to&&(this.chunk2=this.chunk2.slice(0,u.to-i)),l=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),l}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=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=R2,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&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 i="";for(let l of this.ranges){if(l.from>=t)break;l.to>e&&(i+=this.input.read(Math.max(l.from,e),Math.min(l.to,t)))}return i}}class ra{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;a9(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}ra.prototype.contextual=ra.prototype.fallback=ra.prototype.extend=!1;ra.prototype.fallback=ra.prototype.extend=!1;class Xd{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function a9(n,e,t,i,l,o){let a=0,u=1<0){let w=n[v];if(f.allows(w)&&(e.token.value==-1||e.token.value==w||c9(w,e.token.value,l,o))){e.acceptToken(w);break}}let m=e.next,g=0,b=n[a+2];if(e.next<0&&b>g&&n[d+b*3-3]==65535){a=n[d+b*3-1];continue e}for(;g>1,w=d+v+(v<<1),S=n[w],C=n[w+1]||65536;if(m=C)g=v+1;else{a=n[w+2],e.advance();continue e}}break}}function j2(n,e,t){for(let i=e,l;(l=n[i])!=65535;i++)if(l==t)return i-e;return-1}function c9(n,e,t,i){let l=j2(t,i,e);return l<0||j2(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class u9{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?_2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?_2(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(ee)return this.nextStart=a,null;if(o instanceof Jt){let u=a>this.lastRepeatPos&&o.type.id>=this.minRepeat;if(a==e||u){let f=a+o.length,d;if(a>=this.safeFrom&&f<=this.safeTo&&(!(d=o.prop(et.lookAhead))||f+d=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+o.length}}}class f9{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Fh)}getActions(e){let t=0,i=null,{parser:l}=e.p,{tokenizers:o}=l,a=l.stateSlot(e.state,3),u=e.curContext?e.curContext.hash:0,f=0;for(let d=0;dg.end+25&&(f=Math.max(g.lookAhead,f)),g.value!=0)){let b=t;if(g.extended>-1&&(t=this.addActions(e,g.extended,g.end,t)),t=this.addActions(e,g.value,g.end,t),!m.extend&&(i=g,t>b))break}}for(;this.actions.length>t;)this.actions.pop();return f&&e.setLookAhead(f),!i&&e.pos==this.stream.end&&(i=new Fh,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Fh,{pos:i,p:l}=e;return t.start=i,t.end=Math.min(i+1,l.stream.end),t.value=i==l.stream.end?l.parser.eofTerm:0,t}updateCachedToken(e,t,i){let l=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(l,e),i),e.value>-1){let{parser:o}=i.p;for(let a=0;a=0&&i.p.parser.dialect.allows(u>>1)){(u&1)==0?e.value=u>>1:e.extended=u>>1;break}}}else e.value=0,e.end=this.stream.clipPos(l+1)}putAction(e,t,i,l){for(let o=0;oe.bufferLength*4?new u9(i,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],l,o;if(this.bigReductionCount>300&&e.length==1){let[a]=e;for(;a.forceReduce()&&a.stack.length&&a.stack[a.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)i.push(u);else{if(this.advanceStack(u,i,e))continue;{l||(l=[],o=[]),l.push(u);let f=this.tokens.getMainToken(u);o.push(f.value,f.end)}}break}}if(!i.length){let a=l&&p9(l);if(a)return pi&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw pi&&l&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&l){let a=this.stoppedAt!=null&&l[0].pos>this.stoppedAt?l[0]:this.runRecovery(l,o,i);if(a)return pi&&console.log("Force-finish "+this.stackID(a)),this.stackToTree(a.forceAll())}if(this.recovering){let a=this.recovering==1?1:this.recovering*3;if(i.length>a)for(i.sort((u,f)=>f.score-u.score);i.length>a;)i.pop();i.some(u=>u.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&d.buffer.length>500)if((u.score-d.score||u.buffer.length-d.buffer.length)>0)i.splice(f--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,u)=>u.score-a.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let a=1;a-1&&i.length&&(!o||(i.prop(et.contextHash)||0)==a))return e.useNode(i,u,t),i;if(i.children.length==0||i.positions[0]>0)break;let f=i.children[0];if(f instanceof Jt&&(!l||f.type.id>=this.parser.minRepeatTerm))i=f;else break}return null}advanceStack(e,t,i){let l=e.pos,{parser:o}=this,a=pi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&l>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let d=e.reducePos0)return e.reduce(u),pi&&console.log(a+this.stackID(e)+` (via always-reduce ${o.getName(u&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let f=this.tokens.getActions(e);for(let d=0;dl?t.push(w):i.push(w)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return L2(e,t),!0}}runRecovery(e,t,i){let l=null,o=!1;for(let a=0;a ":"";if(u.deadEnd&&(o||(o=!0,u.restart(),pi&&console.log(m+this.stackID(u)+" (restarted)"),this.advanceFully(u,i))))continue;let g=u.split(),b=m;for(let v=0;v<10&&g.forceReduce()&&(pi&&console.log(b+this.stackID(g)+" (via force-reduce)"),!this.advanceFully(g,i));v++)pi&&(b=this.stackID(g)+" -> ");for(let v of u.recoverByInsert(f))pi&&console.log(m+this.stackID(v)+" (via recover-insert)"),this.advanceFully(v,i);this.stream.end>u.pos?(d==u.pos&&(d++,f=0),u.recoverByDelete(f,d),pi&&console.log(m+this.stackID(u)+` (via recover-delete ${this.parser.getName(f)})`),L2(u,i)):(!l||l.scoren;class m9{constructor(e){this.start=e.start,this.shift=e.shift||d0,this.reduce=e.reduce||d0,this.reuse=e.reuse||d0,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class wd extends PT{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let u=0;ue.topRules[u][1]),l=[];for(let u=0;u=0)o(m,f,u[d++]);else{let g=u[d+-m];for(let b=-m;b>0;b--)o(u[d++],f,g);d++}}}this.nodeSet=new ky(t.map((u,f)=>ri.define({name:f>=this.minRepeatTerm?void 0:u,id:f,props:l[f],top:i.indexOf(f)>-1,error:f==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(f)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=_T;let a=kh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let u=0;utypeof u=="number"?new ra(a,u):u),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,i){let l=new h9(this,e,t,i);for(let o of this.wrappers)l=o(l,e,t,i);return l}getGoto(e,t,i=!1){let l=this.goto;if(t>=l[0])return-1;for(let o=l[t+1];;){let a=l[o++],u=a&1,f=l[o++];if(u&&i)return f;for(let d=o+(a>>1);o0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),l=i?t(i):void 0;for(let o=this.stateSlot(e,1);l==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=Xr(this.data,o+2);else break;l=t(Xr(this.data,o+1))}return l}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Xr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let l=this.data[i+1];t.some((o,a)=>a&1&&o==l)||t.push(this.data[i],l)}}return t}configure(e){let t=Object.assign(Object.create(wd.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let l=e.tokenizers.find(o=>o.from==i);return l?l.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,l)=>{let o=e.specializers.find(u=>u.from==i.external);if(!o)return i;let a=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[l]=z2(a),a})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}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),i=t.map(()=>!1);if(e)for(let o of e.split(" ")){let a=t.indexOf(o);a>=0&&(i[a]=!0)}let l=null;for(let o=0;oi)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const Vo=63,B2=64,g9=1,x9=2,lA=3,y9=4,sA=5,b9=6,v9=7,oA=65,w9=66,k9=8,S9=9,C9=10,O9=11,T9=12,aA=13,N9=19,A9=20,E9=29,M9=33,D9=34,R9=47,j9=0,Uy=1,Rx=2,iu=3,jx=4;class Es{constructor(e,t,i){this.parent=e,this.depth=t,this.type=i,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+i}}Es.top=new Es(null,-1,j9);function Bc(n,e){for(let t=0,i=e-n.pos-1;;i--,t++){let l=n.peek(i);if(Zr(l)||l==-1)return t}}function _x(n){return n==32||n==9}function Zr(n){return n==10||n==13}function cA(n){return _x(n)||Zr(n)}function Rs(n){return n<0||cA(n)}const _9=new m9({start:Es.top,reduce(n,e){return n.type==iu&&(e==A9||e==D9)?n.parent:n},shift(n,e,t,i){if(e==lA)return new Es(n,Bc(i,i.pos),Uy);if(e==oA||e==sA)return new Es(n,Bc(i,i.pos),Rx);if(e==Vo)return n.parent;if(e==N9||e==M9)return new Es(n,0,iu);if(e==aA&&n.type==jx)return n.parent;if(e==R9){let l=/[1-9]/.exec(i.read(i.pos,t.pos));if(l)return new Es(n,n.depth+ +l[0],jx)}return n},hash(n){return n.hash}});function ga(n,e,t=0){return n.peek(t)==e&&n.peek(t+1)==e&&n.peek(t+2)==e&&Rs(n.peek(t+3))}const L9=new Xd((n,e)=>{if(n.next==-1&&e.canShift(B2))return n.acceptToken(B2);let t=n.peek(-1);if((Zr(t)||t<0)&&e.context.type!=iu){if(ga(n,45))if(e.canShift(Vo))n.acceptToken(Vo);else return n.acceptToken(g9,3);if(ga(n,46))if(e.canShift(Vo))n.acceptToken(Vo);else return n.acceptToken(x9,3);let i=0;for(;n.next==32;)i++,n.advance();(i{if(e.context.type==iu){n.next==63&&(n.advance(),Rs(n.next)&&n.acceptToken(v9));return}if(n.next==45)n.advance(),Rs(n.next)&&n.acceptToken(e.context.type==Uy&&e.context.depth==Bc(n,n.pos-1)?y9:lA);else if(n.next==63)n.advance(),Rs(n.next)&&n.acceptToken(e.context.type==Rx&&e.context.depth==Bc(n,n.pos-1)?b9:sA);else{let t=n.pos;for(;;)if(_x(n.next)){if(n.pos==t)return;n.advance()}else if(n.next==33)uA(n);else if(n.next==38)Lx(n);else if(n.next==42){Lx(n);break}else if(n.next==39||n.next==34){if(Fy(n,!0))break;return}else if(n.next==91||n.next==123){if(!P9(n))return;break}else{fA(n,!0,!1,0);break}for(;_x(n.next);)n.advance();if(n.next==58){if(n.pos==t&&e.canShift(E9))return;let i=n.peek(1);Rs(i)&&n.acceptTokenTo(e.context.type==Rx&&e.context.depth==Bc(n,t)?w9:oA,t)}}},{contextual:!0});function B9(n){return n>32&&n<127&&n!=34&&n!=37&&n!=44&&n!=60&&n!=62&&n!=92&&n!=94&&n!=96&&n!=123&&n!=124&&n!=125}function P2(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function H2(n,e){return n.next==37?(n.advance(),P2(n.next)&&n.advance(),P2(n.next)&&n.advance(),!0):B9(n.next)||e&&n.next==44?(n.advance(),!0):!1}function uA(n){if(n.advance(),n.next==60){for(n.advance();;)if(!H2(n,!0)){n.next==62&&n.advance();break}}else for(;H2(n,!1););}function Lx(n){for(n.advance();!Rs(n.next)&&kd(n.next)!="f";)n.advance()}function Fy(n,e){let t=n.next,i=!1,l=n.pos;for(n.advance();;){let o=n.next;if(o<0)break;if(n.advance(),o==t)if(o==39)if(n.next==39)n.advance();else break;else break;else if(o==92&&t==34)n.next>=0&&n.advance();else if(Zr(o)){if(e)return!1;i=!0}else if(e&&n.pos>=l+1024)return!1}return!i}function P9(n){for(let e=[],t=n.pos+1024;;)if(n.next==91||n.next==123)e.push(n.next),n.advance();else if(n.next==39||n.next==34){if(!Fy(n,!0))return!1}else if(n.next==93||n.next==125){if(e[e.length-1]!=n.next-2)return!1;if(e.pop(),n.advance(),!e.length)return!0}else{if(n.next<0||n.pos>t||Zr(n.next))return!1;n.advance()}}const H9="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function kd(n){return n<33?"u":n>125?"s":H9[n-33]}function m0(n,e){let t=kd(n);return t!="u"&&!(e&&t=="f")}function fA(n,e,t,i){if(kd(n.next)=="s"||(n.next==63||n.next==58||n.next==45)&&m0(n.peek(1),t))n.advance();else return!1;let l=n.pos;for(;;){let o=n.next,a=0,u=i+1;for(;cA(o);){if(Zr(o)){if(e)return!1;u=0}else u++;o=n.peek(++a)}if(!(o>=0&&(o==58?m0(n.peek(a+1),t):o==35?n.peek(a-1)!=32:m0(o,t)))||!t&&u<=i||u==0&&!t&&(ga(n,45,a)||ga(n,46,a)))break;if(e&&kd(o)=="f")return!1;for(let d=a;d>=0;d--)n.advance();if(e&&n.pos>l+1024)return!1}return!0}const I9=new Xd((n,e)=>{if(n.next==33)uA(n),n.acceptToken(T9);else if(n.next==38||n.next==42){let t=n.next==38?C9:O9;Lx(n),n.acceptToken(t)}else n.next==39||n.next==34?(Fy(n,!1),n.acceptToken(S9)):fA(n,!1,e.context.type==iu,e.context.depth)&&n.acceptToken(k9)}),U9=new Xd((n,e)=>{let t=e.context.type==jx?e.context.depth:-1,i=n.pos;e:for(;;){let l=0,o=n.next;for(;o==32;)o=n.peek(++l);if(!l&&(ga(n,45,l)||ga(n,46,l))||!Zr(o)&&(t<0&&(t=Math.max(e.context.depth+1,l)),lYAN>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:_9,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[F9],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:[L9,z9,I9,U9,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),q9=sd.define({name:"yaml",parser:V9.configure({props:[VT.add({Stream:n=>{for(let e=n.node.resolve(n.pos,-1);e&&e.to>=n.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.fromn.pos)return null}}return null},FlowMapping:e2({closing:"}"}),FlowSequence:e2({closing:"]"})}),XT.add({"FlowMapping FlowSequence":IL,"Item Pair BlockLiteral":(n,e)=>({from:e.doc.lineAt(n.from).to,to:n.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Q9(){return new EL(q9)}const I2='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], video[tabindex], [tabindex]:not([tabindex="-1"])';function Wl({isOpen:n,onClose:e,dialogRef:t,initialFocusRef:i}){return E.useEffect(()=>{if(!n)return;const l=document.activeElement instanceof HTMLElement?document.activeElement:null,o=requestAnimationFrame(()=>{var f;const u=(i==null?void 0:i.current)??((f=t.current)==null?void 0:f.querySelector(I2))??t.current;u==null||u.focus()}),a=u=>{if(u.key!=="Tab")return;const f=t.current;if(!f)return;const d=Array.from(f.querySelectorAll(I2));if(!d.length)return;const m=d[0],g=d[d.length-1],b=document.activeElement;if(!(b instanceof Node&&f.contains(b))){u.preventDefault(),(u.shiftKey?g:m).focus();return}u.shiftKey&&(b===m||b===f)?(u.preventDefault(),g.focus()):!u.shiftKey&&(b===g||b===f)&&(u.preventDefault(),m.focus())};return window.addEventListener("keydown",a,!0),()=>{cancelAnimationFrame(o),l==null||l.focus(),window.removeEventListener("keydown",a,!0)}},[n]),l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),e())}}function js({isOpen:n,title:e,message:t,confirmLabel:i="Confirm",cancelLabel:l="Cancel",danger:o=!1,onConfirm:a,onCancel:u}){const f=E.useRef(null),d=E.useRef(null),m=Wl({isOpen:n,onClose:u,dialogRef:f,initialFocusRef:d});return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:u,children:y.jsxs("div",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-dialog-title",onKeyDown:m,onClick:g=>g.stopPropagation(),className:"animate-modal-in w-[400px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-3 flex items-center gap-2.5",children:[y.jsx("span",{className:`grid h-9 w-9 shrink-0 place-items-center rounded-lg ${o?"bg-status-danger-bg text-status-danger-text":"bg-chip-indigo-bg text-chip-indigo-text"}`,children:y.jsx(iy,{className:"h-5 w-5"})}),y.jsx("h2",{id:"confirm-dialog-title",className:"text-sm font-semibold text-ink",children:e})]}),y.jsx("div",{className:"mb-5 whitespace-pre-line text-xs text-ink-secondary",children:t}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{ref:d,type:"button",onClick:u,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:l}),y.jsx("button",{type:"button",onClick:a,className:`min-h-9 rounded-lg border px-4 text-sm font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${o?"border-status-danger-border bg-status-danger-bg/30 text-status-danger-text hover:bg-status-danger-bg/60":"btn-primary border-transparent bg-indigo-600 text-white hover:bg-indigo-500"}`,children:i})]})]})}):null}var X9=FC();const gr=8,Pl=8,$9=400,U2={top:"bottom",bottom:"top",left:"right",right:"left"},G9={top:"-bottom-1 left-1/2 -translate-x-1/2",bottom:"-top-1 left-1/2 -translate-x-1/2",left:"-right-1 top-1/2 -translate-y-1/2",right:"-left-1 top-1/2 -translate-y-1/2"},Y9={top:"border-b border-r",bottom:"border-t border-l",left:"border-t border-r",right:"border-b border-l"},F2=(n,e,t)=>{switch(n){case"top":return e.top-Pl-t.h>=gr;case"bottom":return e.bottom+Pl+t.h<=window.innerHeight-gr;case"left":return e.left-Pl-t.w>=gr;default:return e.right+Pl+t.w<=window.innerWidth-gr}},K9=(n,e,t)=>{if(n==="top"||n==="bottom"){const a=e.left+e.width/2-t.w/2,u=window.innerWidth-t.w-gr;return{x:Math.min(Math.max(a,gr),Math.max(gr,u))-a,y:0}}const i=e.top+e.height/2-t.h/2,l=window.innerHeight-t.h-gr;return{x:0,y:Math.min(Math.max(i,gr),Math.max(gr,l))-i}},Xe=({text:n,children:e,block:t=!0,placement:i="top",suppress:l=!1})=>{const o=E.useRef(null),a=E.useRef(null),u=E.useId(),f=E.useRef(null),[d,m]=E.useState(!1),[g,b]=E.useState(i),[v,w]=E.useState({x:0,y:0}),[S,C]=E.useState({left:-9999,top:-9999}),O=()=>{f.current!==null&&(window.clearTimeout(f.current),f.current=null)};E.useEffect(()=>{l&&(O(),m(!1))},[l]),E.useEffect(()=>()=>O(),[]);const _=E.useCallback(()=>{const D=o.current,R=a.current;if(!D||!R)return;const P=D.getBoundingClientRect(),te={w:R.offsetWidth,h:R.offsetHeight},I=F2(i,P,te)?i:F2(U2[i],P,te)?U2[i]:i,F=K9(I,P,te);b(I),w(F);const A=P.left+P.width/2,ne=P.top+P.height/2;C(I==="top"?{left:A,top:P.top-Pl-te.h}:I==="bottom"?{left:A,top:P.bottom+Pl}:I==="left"?{left:P.left-Pl-te.w,top:ne}:{left:P.right+Pl,top:ne})},[i]);E.useEffect(()=>{if(!d)return;const D=()=>m(!1);return window.addEventListener("resize",D),window.addEventListener("scroll",D,!0),()=>{window.removeEventListener("resize",D),window.removeEventListener("scroll",D,!0)}},[d]);const M=D=>{if(l)return;O();const R=()=>{_(),m(!0)};D?R():f.current=window.setTimeout(R,$9)},H=()=>{O(),m(!1)};E.useEffect(()=>{if(!d)return;const D=R=>{R.key==="Escape"&&m(!1)};return document.addEventListener("keydown",D,!0),()=>document.removeEventListener("keydown",D,!0)},[d]),E.useEffect(()=>{if(!d)return;const D=()=>!!document.querySelector('[role="dialog"][aria-modal="true"], dialog[open]');if(D()){m(!1);return}const R=new MutationObserver(()=>{D()&&m(!1)});return R.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","open","class"]}),()=>R.disconnect()},[d]);const B={onMouseEnter:()=>M(!1),onMouseLeave:H,onFocus:()=>M(!0),onBlur:H,"aria-describedby":u};return y.jsxs("div",{ref:o,className:`group relative ${t?"flex min-w-0 flex-1 items-center":"inline-flex shrink-0 items-center"}`,onMouseEnter:()=>M(!1),onMouseLeave:H,onFocus:()=>M(!0),onBlur:H,children:[E.cloneElement(e,B),X9.createPortal(y.jsxs("span",{ref:a,id:u,role:"tooltip",className:`pointer-events-none invisible fixed z-[var(--z-tooltip)] w-max max-w-[calc(100vw-16px)] rounded-md border border-line bg-elevated px-2 py-1 text-left text-[11px] leading-relaxed text-ink shadow-lg ${d?"visible opacity-100":"opacity-0"}`,style:{left:S.left,top:S.top,transform:g==="top"||g==="bottom"?`translateX(calc(-50% + ${v.x}px))`:`translateY(calc(-50% + ${v.y}px))`},children:[n,y.jsx("span",{className:`absolute h-2 w-2 rotate-45 border-line bg-elevated ${G9[g]} ${Y9[g]}`,style:g==="top"||g==="bottom"?{left:`calc(50% - ${v.x}px)`}:void 0})]}),document.body)]})},W9=[".profiles",".profiles.yaml"];function Z9(n){const e=n.trim();if(!e)return null;const t=e.toLowerCase(),i=W9.find(l=>t.endsWith(l));if(i!==void 0){const l=e.slice(0,e.length-i.length);return!l.trim()||l!==l.trimEnd()?null:e}return t.includes(".")?null:`${e}.profiles`}function J9({open:n,onCancel:e,onConfirm:t}){const[i,l]=E.useState(null),[o,a]=E.useState(""),[u,f]=E.useState(""),[d,m]=E.useState(null),[g,b]=E.useState(!1),[v,w]=E.useState(null),[S,C]=E.useState(null),O=E.useRef(null),_=E.useRef(null),M=E.useRef(null),H=E.useCallback(async P=>{b(!0),w(null);try{const te=await qC(P);l(te),a(te.current_path)}catch(te){w(te instanceof Error?te.message:String(te))}finally{b(!1)}},[]);E.useEffect(()=>{if(!n)return;f(""),m(null),C(null),H(o);const P=requestAnimationFrame(()=>{var te;return(te=_.current)==null?void 0:te.focus()});return()=>cancelAnimationFrame(P)},[n]);const B=Wl({isOpen:n,onClose:e,dialogRef:O,initialFocusRef:_});function D(){if(!i)return;const P=Z9(u);if(P===null){m("Not a ProFiles configuration file. Allowed extensions: .profiles, .profiles.yaml");return}m(null);const te=o.trim()||i.current_path;if(o.trim()===i.current_path&&i.items.some(A=>!A.is_dir&&A.name===P)){C({filename:P,directory:te});return}t({filename:P,directory:te,overwrite:!1})}if(!n)return null;const R=(i==null?void 0:i.items.filter(P=>P.is_dir))??[];return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:O,role:"dialog","aria-modal":"true","aria-labelledby":"save-as-dialog-title",onKeyDown:B,onClick:P=>P.stopPropagation(),className:"animate-modal-in flex max-h-[calc(100dvh-2rem)] w-[min(94vw,560px)] flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",children:[y.jsx("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-8 w-8 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(ZC,{className:"h-4 w-4 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"save-as-dialog-title",className:"text-sm font-semibold text-ink",children:"Save configuration as"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(i==null?void 0:i.current_path)||"…"})]})]})}),y.jsxs("div",{className:"border-b border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:M,id:"save-as-path",type:"text",value:o,onChange:P=>a(P.target.value),onKeyDown:P=>{P.key==="Enter"&&H(o.trim())},placeholder:"/path/to/directory",className:"h-9 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>void H(o.trim()),className:"inline-flex h-9 shrink-0 items-center rounded-lg border border-line bg-elevated px-3 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Xe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void H(""),"aria-label":"Home directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ed,{className:"h-4 w-4"})})}),(i==null?void 0:i.parent_path)&&y.jsx(Xe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void H(i.parent_path),"aria-label":"Parent directory",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ad,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-24 flex-1 overflow-y-auto px-2 py-2 sm:px-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(Yr,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>void H(o||(i==null?void 0:i.current_path)||""),className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[R.map(P=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>void H(P.path),className:"flex min-h-9 w-full items-center gap-2.5 rounded-lg px-3 py-1.5 text-left text-sm text-ink-secondary transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400",children:[y.jsx(lu,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:P.name})]})},P.path)),R.length===0&&y.jsxs("li",{className:"flex min-h-16 flex-col items-center justify-center gap-2 text-center text-sm text-ink-muted",children:[y.jsx(Hl,{className:"h-6 w-6 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"shrink-0 border-t border-line px-5 py-3",children:[y.jsx("label",{htmlFor:"save-as-filename",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"File name"}),y.jsx("input",{ref:_,id:"save-as-filename",type:"text",value:u,onChange:P=>{f(P.target.value),m(null)},onKeyDown:P=>{P.key==="Enter"&&u.trim()&&D()},placeholder:"machine.profiles",className:"h-9 w-full rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),d&&y.jsx("p",{role:"alert","data-testid":"save-as-error",className:"mt-1.5 text-xs text-status-danger-text",children:d}),y.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:e,className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:D,disabled:!u.trim()||!i||g,title:"Save the configuration to the selected folder",className:"btn btn-primary min-h-9 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Sr,{className:"h-4 w-4"}),"Save"]})]})]})]})}),y.jsx(js,{isOpen:S!==null,title:"Replace configuration?",message:`A configuration named "${S==null?void 0:S.filename}" already exists in this folder. +Saving will replace it.`,confirmLabel:"Replace",cancelLabel:"Keep existing",danger:!0,onConfirm:()=>{const P=S;C(null),P&&t({...P,overwrite:!0})},onCancel:()=>C(null)})]})}const e8=800,t8=Ae.theme({"&":{height:"100%",fontSize:"12.5px",color:"var(--app-text-primary)",backgroundColor:"var(--app-editor-bg)"},".cm-scroller":{fontFamily:"'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",lineHeight:"1.6"},".cm-content":{caretColor:"var(--color-indigo-500, #6366f1)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--color-indigo-500, #6366f1)"},"&.cm-focused":{outline:"none"},".cm-selectionBackground, &.cm-focused .cm-selectionBackground":{backgroundColor:"var(--app-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--app-editor-active-line)"},".cm-matchingBracket":{color:"inherit",backgroundColor:"var(--app-editor-selection)",outline:"1px solid var(--app-editor-border)"},".cm-nonmatchingBracket":{color:"inherit",outline:"1px solid var(--status-danger-border, #fb7185)"},".cm-gutters":{backgroundColor:"var(--app-editor-gutter-bg)",color:"var(--app-text-faint)",border:"none",borderRight:"1px solid var(--app-editor-border)"},".cm-activeLineGutter":{backgroundColor:"var(--app-editor-active-line)",color:"var(--app-text-secondary)"},".cm-panels":{backgroundColor:"var(--app-editor-bg)",color:"var(--app-text-primary)"},".cm-tooltip":{border:"1px solid var(--app-border)",backgroundColor:"var(--app-glass-panel-strong)",color:"var(--app-text-primary)"}}),n8=uu.define([{tag:me.lineComment,color:"var(--app-editor-syntax-comment)"},{tag:[me.propertyName,me.definition(me.propertyName)],color:"var(--app-editor-syntax-key)"},{tag:[me.string,me.special(me.string)],color:"var(--app-editor-syntax-string)"},{tag:me.content,color:"var(--app-editor-syntax-string)"},{tag:[me.keyword,me.typeName],color:"var(--app-editor-syntax-keyword)"},{tag:me.labelName,color:"var(--app-editor-syntax-label)"}]);function p0(n){return n.replace(/\r\n?/g,` +`)}function Sh(n,e){return n!==null&&n.state.doc.toString()!==e}function i8(n){return n instanceof ey&&Array.isArray(n.detail)?{text:n.message,issues:n.detail}:{text:n instanceof Error?n.message:String(n),issues:[]}}function r8({open:n,onClose:e,onApplied:t,onLoadConfig:i,reloadKey:l=0}){const[o,a]=E.useState({status:"loading"}),[u,f]=E.useState(!1),[d,m]=E.useState(!1),[g,b]=E.useState(null),[v,w]=E.useState([]),[S,C]=E.useState({kind:"unknown"}),[O,_]=E.useState(!1),[M,H]=E.useState({line:1,col:1}),[B,D]=E.useState(null),[R,P]=E.useState(null),[te,I]=E.useState(null),[F,A]=E.useState(null),ne=E.useRef(null),ae=E.useRef(null),ie=E.useRef(null),$=E.useRef(null),oe=E.useRef(""),Z=E.useRef(null),Y=E.useRef(0),N=E.useRef(new Map),he=E.useRef(null),ye=E.useRef(null),z=E.useRef(!1),j=E.useRef(()=>{}),q=E.useRef(()=>{});z.current=R!==null||te!==null||F!==null;const ue=Wl({isOpen:n,onClose:Te,dialogRef:ne});E.useEffect(()=>{if(!n){oe.current="",Z.current=null,ie.current=null,a({status:"loading"}),f(!1),m(!1),b(null),w([]),C({kind:"unknown"}),_(!1),H({line:1,col:1}),D(null),P(null),I(null),A(null),he.current!==null&&(clearTimeout(he.current),he.current=null),ye.current=null,Y.current+=1,N.current.clear();return}let ce=!1;return Dk().then(xe=>{if(ce)return;const Le=p0(xe.content);oe.current=Le,Z.current=xe.content_hash??null,ye.current=Le,a({status:"ready",data:{...xe,content:Le}})}).catch(xe=>{ce||(oe.current="",a({status:"error",message:xe instanceof Error?xe.message:String(xe)}))}),()=>{ce=!0}},[n,l]);const pe=E.useCallback(()=>{he.current!==null&&(clearTimeout(he.current),he.current=null)},[]),De=E.useCallback(ce=>{z.current||ce!==ye.current&&(pe(),he.current=window.setTimeout(()=>{if(he.current=null,N.current.has("test")){q.current(ce);return}j.current()},e8))},[pe]);E.useEffect(()=>{if(!n||o.status!=="ready")return;const ce=ae.current;if(!ce)return;const xe=new Ae({doc:o.data.content,extensions:[l9,Q9(),tN(n8),t8,Ae.updateListener.of(Le=>{if(Le.selectionSet||Le.docChanged){const we=Le.state.selection.main.head,mt=Le.state.doc.lineAt(we);H({line:mt.number,col:we-mt.from+1})}Le.docChanged&&(f(Sh(Le.view,oe.current)),b(null),w([]),C({kind:"unknown"}),_(!1),De(Le.state.doc.toString()))})],parent:ce});return ie.current=xe,()=>{xe.destroy(),ie.current=null,pe()}},[n,o]);function Te(){if(Sh(ie.current,oe.current)){m(!0);return}e()}const Pe=E.useCallback(()=>{RM().catch(ce=>{console.error("Failed to open config file in OS editor:",ce)})},[]);function ve(){var ce;return((ce=ie.current)==null?void 0:ce.state.doc.toString())??oe.current}const Ee=E.useCallback(async(ce,xe)=>{if(N.current.has(ce))return;const Le=++Y.current;N.current.set(ce,Le);try{await xe(Le)}finally{N.current.get(ce)===Le&&N.current.delete(ce)}},[]),Rt=E.useCallback(()=>Ee("new",async ce=>{b(null),w([]);try{const xe=await AM();if(ce!==Y.current)return;const Le=p0(xe.content);oe.current=Le,Z.current=null,f(!1),a(we=>we.status==="ready"?{status:"ready",data:{...we.data,filename:xe.filename,content:Le,config_path:null}}:we),b({kind:"ok",text:"New configuration template loaded."})}catch(xe){if(ce!==Y.current)return;b({kind:"error",text:xe instanceof Error?xe.message:String(xe)})}}),[Ee]),Ut=E.useCallback(()=>Ee("revert",async ce=>{b(null),w([]);try{const xe=await Dk();if(ce!==Y.current)return;const Le=p0(xe.content);oe.current=Le,Z.current=xe.content_hash??null,f(!1),a({status:"ready",data:{...xe,content:Le}}),b({kind:"ok",text:"Configuration reloaded from disk."})}catch(xe){if(ce!==Y.current)return;b({kind:"error",text:xe instanceof Error?xe.message:String(xe)})}}),[Ee]);function Ft(){if(Sh(ie.current,oe.current)){D("new");return}Rt()}function zt(){if(Sh(ie.current,oe.current)){D("revert");return}Ut()}const gt=E.useCallback(()=>Ee("test",async ce=>{if(o.status!=="ready")return;pe();const xe=ve();ye.current=xe,C({kind:"validating"});try{const Le=await Rk(o.data.filename,xe);if(ce!==Y.current)return;w(Le.issues),Le.valid?(C({kind:"valid"}),b({kind:"ok",text:"Configuration is valid."})):(C({kind:"invalid",count:Le.issues.length}),_(!0),b({kind:"error",text:`Validation failed with ${Le.issues.length} issue${Le.issues.length===1?"":"s"}.`}))}catch(Le){if(ce!==Y.current)return;w([]),C({kind:"unknown"}),b({kind:"error",text:Le instanceof Error?Le.message:String(Le)})}}),[o,Ee]);j.current=()=>void gt(),q.current=De;const $e=E.useCallback(()=>Ee("apply",async ce=>{if(o.status==="ready")try{const xe=await VC(o.data.filename,ve());if(ce!==Y.current)return;b({kind:"ok",text:"Configuration applied (session trial)."}),t==null||t(xe)}catch(xe){if(ce!==Y.current)return;b({kind:"error",text:xe instanceof Error?xe.message:String(xe)})}}),[o,t,Ee]),Xt=E.useCallback(ce=>new Promise(xe=>{P({issues:ce,resolve:Le=>{P(null),xe(Le)}})}),[]),Nn=E.useCallback(()=>new Promise(ce=>{I({resolve:xe=>{I(null),ce(xe)}})}),[]),en=E.useCallback(()=>new Promise(ce=>{A({resolve:xe=>{A(null),ce(xe)}})}),[]),tn=E.useCallback((ce,xe,Le)=>{if(oe.current=xe,Z.current=Le,f(!1),w([]),C({kind:"unknown"}),P(null),I(null),ce.config_path){const we=ce.config_path.split(/[\\/]/).pop()||ce.title||"configuration";a(mt=>mt.status!=="ready"||!(mt.data.filename!==we||mt.data.config_path!==ce.config_path||mt.data.session_trial)?mt:{status:"ready",data:{...mt.data,filename:we,config_path:ce.config_path,session_trial:!1,content:xe}})}t==null||t(ce)},[t]),Ce=E.useCallback(ce=>{const xe=i8(ce);P(null),I(null),w(xe.issues),xe.issues.length>0?(C({kind:"invalid",count:xe.issues.length}),_(!0)):C({kind:"unknown"}),b({kind:"error",text:xe.text})},[]),Fe=E.useCallback((ce,xe)=>Ee(ce,async Le=>{if(o.status!=="ready")return;const we=ve();b(null),w([]),C({kind:"validating"});try{const mt=await Rk(xe,we);if(Le!==Y.current)return;let An=!1;if(mt.valid)C({kind:"valid"});else{if(C({kind:"invalid",count:mt.issues.length}),w(mt.issues),_(!0),An=await Xt(mt.issues),Le!==Y.current)return;if(!An){b({kind:"error",text:"Save cancelled — fix the listed issues, or force-save anyway."});return}}if(ce==="save-as"){const mn=await Nn();if(Le!==Y.current||mn===null)return;const Nt=await EM({content:we,filename:mn.filename,directory:mn.directory,force:An,overwrite:mn.overwrite});if(Le!==Y.current)return;tn(Nt.config,we,Nt.contentHash),b({kind:"ok",text:`Configuration saved as ${mn.filename}.`})}else{let mn;try{mn=await jk(we,An,{baselineHash:Z.current})}catch(Nt){if(!(Nt instanceof ey)||Nt.status!==409)throw Nt;const ht=await en();if(Le!==Y.current)return;if(!ht){Ut();return}mn=await jk(we,An,{baselineHash:Z.current,overwriteChanges:!0})}if(Le!==Y.current)return;tn(mn.config,we,mn.contentHash),b({kind:"ok",text:`Configuration saved to ${xe}.`})}}catch(mt){if(Le!==Y.current)return;Ce(mt)}}),[Xt,Nn,en,o,tn,Ce,Ut,Ee]),qe=E.useCallback(()=>Fe("save",o.status==="ready"?o.data.filename:""),[o,Fe]),at=E.useCallback(()=>Fe("save-as",o.status==="ready"?o.data.filename:""),[o,Fe]),ee=E.useRef(()=>{});if(ee.current=()=>{o.status==="ready"&&(R!==null||te!==null||F!==null||d||B!==null||(o.data.config_path!==null?qe():$e()))},E.useEffect(()=>{if(!n)return;const ce=xe=>{(xe.metaKey||xe.ctrlKey)&&!xe.altKey&&!xe.shiftKey&&xe.key.toLowerCase()==="s"&&(xe.preventDefault(),xe.stopPropagation(),ee.current())};return window.addEventListener("keydown",ce,!0),()=>window.removeEventListener("keydown",ce,!0)},[n]),!n)return null;const fe=o.status==="ready"?o.data.filename:"",_e=o.status==="ready"?o.data.session_trial:!1,ze=o.status!=="ready",Dt=o.status==="ready"&&o.data.config_path!==null;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:ne,role:"dialog","aria-modal":"true","aria-labelledby":"config-editor-title",onKeyDown:ue,onMouseDown:ce=>{$.current=ce.target===ce.currentTarget?{x:ce.clientX,y:ce.clientY}:null},onClick:ce=>{const xe=$.current;$.current=null,!(!xe||ce.target!==ce.currentTarget)&&Te()},className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",children:y.jsxs("div",{className:"animate-modal-in flex h-[90vh] w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-frame-line glass-panel",onClick:ce=>ce.stopPropagation(),children:[y.jsxs("div",{"data-testid":"editor-header",className:"flex shrink-0 items-center justify-between gap-3 border-b border-line px-5 py-3",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(MD,{className:"h-4 w-4"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"config-editor-title",className:"text-sm font-semibold text-ink",children:"Configuration Editor"}),y.jsxs("p",{className:"truncate text-xs text-ink-muted",children:[fe||"…",_e?" • session trial (not anchored to disk)":""]})]})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsxs("button",{type:"button",onClick:Ft,disabled:ze,title:"Load the starter configuration template",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(_D,{className:"h-3.5 w-3.5"}),"New"]}),y.jsxs("button",{type:"button",onClick:()=>void gt(),disabled:ze,title:"Validate the editor content in memory",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(PD,{className:"h-3.5 w-3.5"}),"Test"]}),y.jsxs("button",{type:"button",onClick:zt,disabled:ze,title:"Discard edits and reload the file from disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(u4,{className:"h-3.5 w-3.5"}),"Revert"]}),Dt&&y.jsxs("button",{type:"button",onClick:()=>void qe(),disabled:ze,title:"Save to the configuration file on disk (Ctrl/Cmd+S)",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(ZC,{className:"h-3.5 w-3.5"}),"Save"]}),y.jsxs("button",{type:"button",onClick:()=>void at(),disabled:ze,title:"Save the configuration to a new file — also anchors a session trial onto disk",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(h4,{className:"h-3.5 w-3.5"}),"Save As"]}),y.jsxs("button",{type:"button",onClick:()=>void $e(),disabled:ze,title:"Trial the editor content as the session configuration",className:"btn btn-primary px-2.5 py-1.5 font-semibold",children:[y.jsx(Ul,{className:"h-3.5 w-3.5"}),"Apply"]}),i&&y.jsxs("button",{type:"button",onClick:i,title:"Load a different .profiles file",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(Qo,{className:"h-3.5 w-3.5"}),"Load config file…"]}),Dt&&y.jsxs("button",{type:"button",onClick:Pe,title:"Open the configuration file with the OS default editor",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-2.5 py-1.5 text-xs font-medium text-ink-secondary hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:[y.jsx(KC,{className:"h-3.5 w-3.5"}),"Open in OS"]}),y.jsx("button",{type:"button",onClick:Te,"aria-label":"Close editor",className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(bi,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex min-h-0 flex-1 gap-2 p-3 sm:p-4",children:[y.jsx("div",{"data-testid":"editor-card",className:"min-w-0 flex-1 overflow-hidden rounded-lg border border-[var(--app-editor-border)] bg-[var(--app-editor-bg)]",children:o.status==="loading"?y.jsx("div",{className:"flex h-full items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):o.status==="error"?y.jsx("div",{className:"flex h-full items-center justify-center p-6",children:y.jsx("div",{className:"max-w-md rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:o.message})}):y.jsx("div",{ref:ae,className:"h-full"})}),o.status==="ready"&&O&&y.jsxs("aside",{"data-testid":"problems-panel","aria-live":"polite",className:"flex w-[280px] shrink-0 flex-col overflow-hidden rounded-lg border border-line bg-surface",children:[y.jsxs("div",{className:"flex shrink-0 items-center justify-between border-b border-line px-3 py-1.5",children:[y.jsx("span",{className:"text-xs font-semibold text-ink-secondary",children:"Problems"}),y.jsx("button",{type:"button",onClick:()=>_(!1),"aria-label":"Close problems",className:"rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(bi,{className:"h-3.5 w-3.5"})})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:v.length===0?y.jsx("p",{className:"px-2 py-1 text-xs text-ink-faint",children:"No problems detected."}):y.jsx("ul",{"data-testid":"editor-issues",className:"space-y-1",children:v.map((ce,xe)=>y.jsxs("li",{tabIndex:0,className:`flex items-start gap-2 rounded-md border px-2.5 py-1.5 text-xs ${ce.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":ce.severity==="warning"?"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text":"border-line bg-surface text-ink-secondary"}`,children:[ce.severity==="error"?y.jsx(Uc,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):ce.severity==="warning"?y.jsx(iy,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):y.jsx(ty,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),y.jsx("span",{className:"min-w-0",children:ce.message})]},`${ce.severity}-${xe}`))})})]})]}),o.status==="ready"&&y.jsxs("footer",{"data-testid":"editor-footer",className:"flex shrink-0 items-center justify-between gap-3 border-t border-line px-5 py-1.5 text-xs",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[y.jsxs("button",{type:"button","data-testid":"validity-chip",onClick:()=>_(ce=>!ce),title:"Toggle the problems panel","aria-pressed":O,className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-bold focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 ${S.kind==="valid"?"border-status-success-border bg-status-success-bg text-status-success-text":S.kind==="invalid"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-line bg-surface text-ink-muted"}`,children:[S.kind==="valid"?y.jsx(Sr,{className:"h-3 w-3"}):S.kind==="invalid"?y.jsx(Uc,{className:"h-3 w-3"}):S.kind==="validating"?y.jsx(Yr,{className:"h-3 w-3 animate-spin"}):y.jsx(fD,{className:"h-3 w-3"}),S.kind==="valid"?"Valid":S.kind==="invalid"?`${S.count} issue${S.count===1?"":"s"}`:S.kind==="validating"?"Validating…":"Not validated"]}),u&&y.jsxs("span",{role:"status",className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-chip-amber-border bg-chip-amber-bg px-2 py-0.5 text-[10px] font-bold text-chip-amber-text",children:[y.jsx(dD,{className:"h-3 w-3"}),"Unsaved changes"]}),g!==null&&y.jsx("div",{"data-testid":"editor-status","aria-live":"polite",className:`min-w-0 truncate rounded-md border px-2 py-0.5 font-medium ${g.kind==="ok"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:g.text})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-3 text-ink-muted",children:[y.jsxs("span",{className:"font-mono",children:["Ln ",M.line,", Col ",M.col]}),y.jsx("span",{className:"text-ink-faint",children:"YAML"}),y.jsx("span",{className:"max-w-[220px] truncate font-mono",children:fe})]})]})]})}),y.jsx(js,{isOpen:d,title:"Discard changes?",message:`The editor contains unsaved changes. +Closing now will discard them.`,confirmLabel:"Discard",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{m(!1),e()},onCancel:()=>m(!1)}),y.jsx(js,{isOpen:B!==null,title:"Replace current edits?",message:B==="revert"?`The editor contains unsaved changes. +Reverting will discard them and reload the file from disk.`:`The editor contains unsaved changes. +Loading the starter template will discard them.`,confirmLabel:"Replace",cancelLabel:"Keep editing",danger:!0,onConfirm:()=>{const ce=B;D(null),ce==="new"?Rt():ce==="revert"&&Ut()},onCancel:()=>D(null)}),y.jsx(js,{isOpen:R!==null,title:"Save with validation issues?",danger:!0,message:y.jsxs(y.Fragment,{children:[y.jsx("p",{children:"Saving will write these issues to disk; the file may fail to load until they are fixed."}),y.jsx("ul",{className:"mt-2 space-y-1",children:R==null?void 0:R.issues.map((ce,xe)=>y.jsx("li",{className:`rounded-md border px-3 py-1.5 text-xs ${ce.severity==="error"?"border-status-danger-border bg-status-danger-bg text-status-danger-text":"border-chip-amber-border bg-chip-amber-bg text-chip-amber-text"}`,children:ce.message},`${ce.severity}-${xe}`))})]}),confirmLabel:"Force save anyway",cancelLabel:"Go back and fix",onConfirm:()=>R==null?void 0:R.resolve(!0),onCancel:()=>R==null?void 0:R.resolve(!1)}),y.jsx(js,{isOpen:F!==null,title:"File changed on disk",danger:!0,message:`The configuration file was modified outside this editor since it was loaded. + +Reload disk version: discard your edits and load the file as it is on disk. +Overwrite anyway: save your edits and replace the file's current content.`,confirmLabel:"Overwrite anyway",cancelLabel:"Reload disk version",onConfirm:()=>F==null?void 0:F.resolve(!0),onCancel:()=>F==null?void 0:F.resolve(!1)}),y.jsx(J9,{open:te!==null,onCancel:()=>te==null?void 0:te.resolve(null),onConfirm:ce=>te==null?void 0:te.resolve(ce)})]})}function l8({position:n,onClose:e,onLaunch:t,onLaunchWithArgs:i,onReveal:l,onOpenFolder:o,onOpenTerminal:a,onScanDirectory:u,onFilterFolder:f,onFilterExtension:d,onCopyPath:m,onCopyFilename:g,onCopyUri:b,onComputeHash:v,onVerifyHash:w,onProperties:S,onClearFile:C,onGenerateBarcode:O,showToast:_}){const[M,H]=E.useState(!1),[B,D]=E.useState(""),R=E.useRef(null),P=E.useRef(null),te=E.useRef(null),[I,F]=E.useState(null);if(E.useEffect(()=>{var Y;M&&((Y=P.current)==null||Y.showModal())},[M]),E.useLayoutEffect(()=>{if(!n){F(null);return}const Y=()=>{const N=R.current;if(!N)return;const he=N.getBoundingClientRect(),ye=8;F({left:Math.max(ye,Math.min(n.x,window.innerWidth-he.width-ye)),top:Math.max(ye,Math.min(n.y,window.innerHeight-he.height-ye))})};return Y(),window.addEventListener("resize",Y),()=>window.removeEventListener("resize",Y)},[n]),E.useEffect(()=>{if(!n)return;te.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const Y=window.requestAnimationFrame(()=>{var N,he;(he=(N=R.current)==null?void 0:N.querySelector("[role='menuitem']"))==null||he.focus()});return()=>{var N;window.cancelAnimationFrame(Y),(N=te.current)==null||N.focus()}},[n]),!n)return null;const{file:A,x:ne,y:ae}=n,ie=()=>{i(A,B),H(!1),e()},$=Y=>{const N=Y.lastIndexOf(".");return N!==-1?Y.slice(N):""},oe=Y=>{const N=Math.max(Y.lastIndexOf("/"),Y.lastIndexOf("\\"));return N!==-1?Y.slice(0,N):Y},Z=Y=>{const N=Math.max(Y.lastIndexOf("/"),Y.lastIndexOf("\\"));return N!==-1?Y.slice(0,N):""};return y.jsxs(y.Fragment,{children:[y.jsx("div",{className:"fixed inset-0 z-[calc(var(--z-context-menu)-1)]",onClick:e,onContextMenu:Y=>{Y.preventDefault(),e()},"aria-hidden":"true"}),y.jsxs("div",{ref:R,role:"menu","aria-label":`Actions for ${A.filename}`,tabIndex:0,onKeyDown:Y=>{var ye,z,j,q;["Escape","ArrowDown","ArrowUp","Home","End"].includes(Y.key)&&Y.stopPropagation();const N=Array.from(((ye=R.current)==null?void 0:ye.querySelectorAll("[role='menuitem']"))??[]),he=N.indexOf(document.activeElement);if(Y.key==="Escape")Y.preventDefault(),e();else if(Y.key==="ArrowDown"||Y.key==="ArrowUp"){Y.preventDefault();const ue=Y.key==="ArrowDown"?1:-1;(z=N[(he+ue+N.length)%N.length])==null||z.focus()}else Y.key==="Home"?(Y.preventDefault(),(j=N[0])==null||j.focus()):Y.key==="End"&&(Y.preventDefault(),(q=N.at(-1))==null||q.focus())},className:"animate-modal-in fixed z-[var(--z-context-menu)] max-h-[calc(100dvh-16px)] w-56 max-w-[calc(100vw-16px)] overflow-y-auto rounded-lg border border-line bg-surface-glass py-1 text-xs text-ink shadow-2xl backdrop-blur-md",style:I??{left:ne,top:ae,visibility:"hidden"},children:[y.jsx("div",{className:"border-b border-line px-3 py-2 font-medium text-ink-muted truncate",children:A.filename}),y.jsxs("button",{role:"menuitem",onClick:()=>{t(A),e()},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${A.filename}`,children:[y.jsx(Ul,{className:"h-3.5 w-3.5 fill-current text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Launch"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{H(!0)},className:"flex w-full items-center gap-2 px-3 py-3 min-h-[44px] hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Launch ${A.filename} with arguments`,children:[y.jsx(Ul,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Launch with arguments..."})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{l(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Reveal ${A.filename} in file manager`,children:[y.jsx(_0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Reveal in File Manager"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{o(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open folder containing ${A.filename}`,children:[y.jsx(Hl,{className:"h-3.5 w-3.5 text-chip-amber-text group-hover:text-white"}),y.jsx("span",{children:"Open Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{a(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Open terminal in directory containing ${A.filename}`,children:[y.jsx(eO,{className:"h-3.5 w-3.5 text-status-success-text group-hover:text-white"}),y.jsx("span",{children:"Open Terminal in Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{O(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Generate QR Code",children:[y.jsx(ny,{className:"h-3.5 w-3.5 text-chip-fuchsia-text group-hover:text-white"}),y.jsx("span",{children:"Generate QR Code"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{const Y=oe(A.path);u(Y),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Scan to Directory",children:[y.jsx(Hl,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Scan to Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const Y=Z(A.rel_path);Y&&f(Y),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view to folder ${A.filename} is in`,children:[y.jsx(L0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter to Folder"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{const Y=$(A.filename);Y&&d(Y),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Filter view by extension ${$(A.filename)}`,children:[y.jsx(L0,{className:"h-3.5 w-3.5 text-chip-indigo-text group-hover:text-white"}),y.jsx("span",{children:"Filter by Extension"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(A,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy full path of ${A.filename}`,children:[y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Full Path"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{m(A,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy path of ${A.filename} with forward slashes`,children:[y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Path (Forward Slashes)"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(A,!1),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${A.filename}`,children:[y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{g(A,!0),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy filename of ${A.filename} without extension`,children:[y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Filename (no ext)"})]}),y.jsxs("button",{role:"menuitem",onClick:async()=>{const Y=oe(A.path);e();try{await navigator.clipboard.writeText(Y),_==null||_(`Copied: ${Y}`)}catch(N){_==null||_(`Copy failed: ${(N==null?void 0:N.message)??N}`,"error")}},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":"Copy Directory",children:[y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy Directory"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{b(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Copy URI of ${A.filename}`,children:[y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted group-hover:text-white"}),y.jsx("span",{className:"truncate",children:"Copy URI"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(A,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute MD5 hash of ${A.filename}`,children:[y.jsx(Xo,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{v(A,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Compute SHA256 hash of ${A.filename}`,children:[y.jsx(Xo,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Compute SHA256 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(A,"md5"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify MD5 hash of ${A.filename}`,children:[y.jsx(Xo,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify MD5 Hash"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{w(A,"sha256"),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Verify SHA256 hash of ${A.filename}`,children:[y.jsx(Xo,{className:"h-3.5 w-3.5 text-chip-purple-text group-hover:text-white"}),y.jsx("span",{children:"Verify SHA256 Hash"})]}),y.jsx("div",{className:"my-1 border-t border-line"}),y.jsxs("button",{role:"menuitem",onClick:()=>{S(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`View properties of ${A.filename}`,children:[y.jsx(_0,{className:"h-3.5 w-3.5 text-chip-sky-text group-hover:text-white"}),y.jsx("span",{children:"Properties"})]}),y.jsxs("button",{role:"menuitem",onClick:()=>{C(A),e()},className:"flex w-full items-center gap-2 px-3 py-1.5 hover:bg-indigo-600 hover:text-white focus:outline-none focus:ring-2 focus:ring-indigo-500 active:scale-95 transition-transform group","aria-label":`Remove ${A.filename} from list`,children:[y.jsx(nO,{className:"h-3.5 w-3.5 text-status-danger-text group-hover:text-white"}),y.jsx("span",{children:"Delete"})]})]}),M&&y.jsx("dialog",{ref:P,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 rounded-xl","aria-labelledby":"args-modal-title",onClick:Y=>{Y.target===P.current&&H(!1)},onCancel:Y=>{Y.preventDefault(),H(!1)},children:y.jsxs("div",{className:"animate-modal-in w-96 rounded-xl border border-frame-line glass-panel p-4",children:[y.jsx("h3",{id:"args-modal-title",className:"mb-2 text-sm font-semibold text-ink",children:"Launch with Arguments"}),y.jsx("p",{className:"mb-3 text-xs text-ink-muted truncate",children:A.filename}),y.jsx("input",{type:"text",autoFocus:!0,placeholder:"Arguments (e.g. --verbose --port 80)",value:B,onChange:Y=>D(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&ie(),Y.key==="Escape"&&H(!1)},className:"mb-4 w-full rounded-md border border-line bg-elevated px-3 py-2 text-xs text-ink outline-none focus:border-indigo-500 focus:ring-2 focus:ring-indigo-500","aria-label":"Command line arguments"}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{onClick:()=>H(!1),className:"rounded-md px-3 py-1.5 text-xs text-ink-muted hover:bg-elevated hover:text-ink focus:outline-none focus:ring-2 focus:ring-indigo-500","aria-label":"Cancel launch",children:"Cancel"}),y.jsx("button",{onClick:ie,className:"btn btn-primary px-3 py-1.5","aria-label":`Launch ${A.filename} with arguments`,children:"Launch"})]})]})})]})}function s8({isOpen:n,initialPath:e,onClose:t,onSelect:i}){const[l,o]=E.useState(null),[a,u]=E.useState(null),[f,d]=E.useState(""),[m,g]=E.useState(!1),[b,v]=E.useState(null),w=E.useRef(null),S=E.useRef(null),C=E.useRef(null);E.useEffect(()=>{var B;if(!n){(B=C.current)==null||B.focus();return}C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v(null),O(e||"");const H=requestAnimationFrame(()=>{var D;return(D=S.current)==null?void 0:D.focus()});return()=>{var D;cancelAnimationFrame(H),(D=C.current)==null||D.focus()}},[n]);const O=async H=>{g(!0),v(null);try{const B=await fetch(`/api/fs/browse?path=${encodeURIComponent(H)}`);if(!B.ok)throw new Error("Failed to browse directory");const D=await B.json();o(D),u(D.current_path),d(D.current_path)}catch(B){v(B.message||"Navigation failed")}finally{g(!1)}},_=()=>{const H=f.trim()||a;H&&(i(H),t())},M=H=>{var P;if(H.key==="Escape"){H.preventDefault(),t();return}if(H.key!=="Tab")return;const B=(P=w.current)==null?void 0:P.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(B!=null&&B.length))return;const D=B[0],R=B[B.length-1];H.shiftKey&&document.activeElement===D?(H.preventDefault(),R.focus()):!H.shiftKey&&document.activeElement===R&&(H.preventDefault(),D.focus())};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:t,children:y.jsxs("div",{ref:w,role:"dialog","aria-modal":"true","aria-labelledby":"directory-picker-title",onKeyDown:M,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:H=>H.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(Hl,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"directory-picker-title",className:"text-sm font-semibold text-ink",children:"Select a directory"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(l==null?void 0:l.current_path)||""})]})]}),y.jsx(Xe,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:t,"aria-label":"Close directory picker",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(bi,{className:"h-4 w-4"})})})]}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"directory-picker-path",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Location"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:S,id:"directory-picker-path",type:"text",value:f,onChange:H=>d(H.target.value),onKeyDown:H=>{H.key==="Enter"&&O(f.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>O(f.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Xe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>O(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ed,{className:"h-4 w-4"})})}),(l==null?void 0:l.parent_path)&&y.jsx(Xe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>O(l.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ad,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":m,children:m?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(Yr,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading directories…"})]}):b?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:b}),y.jsx("button",{type:"button",onClick:()=>O(f||(l==null?void 0:l.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-0.5",children:[l==null?void 0:l.items.filter(H=>H.is_dir).map(H=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>O(H.path),onDoubleClick:()=>{d(H.path),i(H.path),t()},className:`flex min-h-10 w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${a===H.path?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(lu,{className:"h-5 w-5 shrink-0 text-chip-indigo-text"}),y.jsx("span",{className:"truncate",children:H.name})]}),a===H.path&&y.jsx(Sr,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},H.path)),(l==null?void 0:l.items.filter(H=>H.is_dir).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(Hl,{className:"h-7 w-7 text-ink-faint"}),"No subdirectories found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected folder"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:a||f,children:a||f||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:t,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsxs("button",{type:"button",onClick:_,disabled:!f.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Hl,{className:"h-4 w-4"}),"Select folder"]})]})]})]})}):null}function o8({visible:n,onFileSelected:e}){const t=E.useRef(null);return n?y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-drop-overlay)] flex items-center justify-center bg-black/65 backdrop-blur-sm",onClick:()=>{var i;return(i=t.current)==null?void 0:i.click()},"data-testid":"drop-config-overlay",children:[y.jsx("input",{ref:t,type:"file",accept:".profiles,.profiles.yaml,.profiles.yml,.yaml,.yml",className:"hidden",onChange:i=>{var o;const l=(o=i.target.files)==null?void 0:o[0];l&&e(l),i.target.value=""}}),y.jsxs("div",{className:"rounded-xl border-2 border-dashed border-chip-indigo-border bg-surface px-8 py-6 text-center shadow-2xl",children:[y.jsx("span",{className:"mx-auto mb-3 grid h-9 w-9 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(Qo,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsx("p",{className:"text-sm font-semibold text-ink",children:"Drop configuration file"}),y.jsx("p",{className:"mt-1 text-xs text-ink-muted",children:".profiles, .profiles.yaml, .yml, .yaml — session-only preview"})]})]}):null}function zx({id:n,ariaLabel:e,value:t,options:i,onChange:l,placeholder:o,className:a="",inputClassName:u="",optionLabel:f=g=>g,onOpenChange:d,commitOn:m="change"}){const g=E.useId(),b=E.useRef(null),[v,w]=E.useState(!1),[S,C]=E.useState(""),[O,_]=E.useState(-1),[M,H]=E.useState(null),B=i.filter(F=>f(F).toLocaleLowerCase().includes(S.toLocaleLowerCase())),D=O>=0&&B[O]?`${g}-option-${O}`:void 0;E.useEffect(()=>{const F=A=>{var ne;(ne=b.current)!=null&&ne.contains(A.target)||w(!1)};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[]),E.useEffect(()=>{d==null||d(v)},[v,d]),E.useEffect(()=>{var F;O<0||(F=document.getElementById(`${g}-option-${O}`))==null||F.scrollIntoView({block:"nearest"})},[O,g]);const R=()=>{C(""),_(-1),w(!0)},P=F=>{H(null),l(F)},te=F=>{P(F),C(""),_(-1),w(!1)},I=F=>{if(F.key==="ArrowDown"){if(F.preventDefault(),!v){R(),_(0);return}_(A=>Math.min(A+1,B.length-1))}else if(F.key==="ArrowUp"){if(F.preventDefault(),!v){R(),_(B.length-1);return}_(A=>A<=0?B.length-1:A-1)}else F.key==="Enter"&&v&&B[O]!==void 0?(F.preventDefault(),F.stopPropagation(),te(B[O])):F.key==="Enter"&&m==="deferred"&&M!==null&&M!==t?(F.preventDefault(),F.stopPropagation(),P(M)):F.key==="Escape"&&w(!1)};return y.jsxs("div",{ref:b,onBlur:F=>{var A;(A=b.current)!=null&&A.contains(F.relatedTarget)||(w(!1),m==="deferred"&&M!==null&&M!==t&&P(M))},className:`relative flex min-w-0 ${a}`,children:[y.jsx("input",{id:n,type:"text",role:"combobox","aria-label":e,"aria-autocomplete":"list","aria-expanded":v,"aria-controls":g,"aria-activedescendant":D,value:m==="deferred"&&M!==null?M:t,placeholder:o,onChange:F=>{const A=F.target.value;C(A),_(-1),w(!0),m==="deferred"?H(A):l(A)},onKeyDown:I,className:`min-w-0 flex-1 rounded-l-md border border-line bg-elevated px-3 py-1.5 text-ink outline-none transition-colors hover:bg-surface-strong focus:border-indigo-500 ${u}`}),y.jsx("button",{type:"button","aria-label":`Show ${e.toLowerCase()} options`,"aria-expanded":v,title:`Show ${e.toLowerCase()} options`,onMouseDown:F=>F.preventDefault(),onClick:()=>v?w(!1):R(),className:"shrink-0 rounded-r-md border border-l-0 border-line bg-elevated px-2 text-ink-muted hover:bg-surface-strong hover:text-ink focus-visible:z-10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-indigo-500 transition-colors",children:y.jsx(sD,{className:`h-3.5 w-3.5 transition-transform ${v?"rotate-180":""}`})}),v&&y.jsx("ul",{id:g,role:"listbox","aria-label":`${e} options`,className:"absolute left-0 top-full z-[var(--z-combobox-list)] mt-1 max-h-60 w-full min-w-48 overflow-y-auto rounded-md border border-line bg-surface py-1 text-ink shadow-xl",children:B.length>0?B.map((F,A)=>{const ne=f(F),ae=A===O,ie=F===t;return y.jsx("li",{id:`${g}-option-${A}`,role:"option","aria-selected":ie,title:ne||void 0,onMouseEnter:()=>_(A),onMouseDown:$=>$.preventDefault(),onClick:()=>te(F),className:`cursor-pointer truncate px-3 py-1.5 ${ae?"bg-elevated text-ink":"text-ink-secondary"} ${ie?"font-semibold":""}`,children:ne||"(No filter)"},`${F}-${A}`)}):y.jsx("li",{className:"px-3 py-1.5 text-ink-muted",children:"No matching presets"})})]})}function a8(n){const e=n.match(/^(.*?)\.(?:dev|post)\d+/);if(e)return e[1];const t=n.indexOf("+");return t>-1?n.slice(0,t):n}function c8({title:n,release:e,directories:t,activeDirectory:i,onDirectoryChange:l,onBrowseDirectory:o,onGoToParentDirectory:a,onGoToHomeDirectory:u,onOpenActiveDirectory:f,onOpenTerminal:d}){const[m,g]=E.useState(!1),b=e||"0.0.0-dev",[v,w]=E.useState(!1),S=E.useRef(null),C=async()=>{try{await navigator.clipboard.writeText(b),w(!0),S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>w(!1),1500)}catch{}};return E.useEffect(()=>()=>{S.current!==null&&window.clearTimeout(S.current)},[]),y.jsxs("header",{className:"relative z-30 flex flex-wrap items-center gap-3 border-b border-line bg-app/90 px-5 py-2 text-xs backdrop-blur-xl shadow-xs transition-all duration-200",children:[y.jsx("div",{className:"flex shrink-0 items-center gap-3",children:y.jsxs("div",{className:"flex items-center gap-3.5",children:[y.jsxs("div",{className:"relative flex h-9 w-9 items-center justify-center rounded-xl border border-chip-indigo-border shadow-xs",children:[y.jsx("img",{src:"/profiles-128.png",alt:"ProFiles logo",className:"h-9 w-9 rounded-xl object-cover"}),y.jsx("span",{className:"absolute -bottom-0.5 -right-0.5 flex h-2.5 w-2.5 items-center justify-center rounded-full bg-emerald-500 ring-2 ring-app"})]}),y.jsxs("div",{children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("h1",{className:"text-sm font-bold tracking-tight text-ink font-heading",children:"ProFiles"}),n&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"/"}),y.jsx("span",{className:"text-xs font-medium text-chip-indigo-text bg-chip-indigo-bg px-2 py-0.5 rounded-md border border-chip-indigo-border/50",children:n})]})]}),y.jsxs("p",{className:"text-[11px] font-medium text-ink-muted tracking-wide mt-0.5",children:["Crafted by ",y.jsx("span",{className:"text-ink font-semibold",children:"Florent ALBANY"})," •"," ",y.jsx(Xe,{text:v?"Copied!":`v${b}`,block:!1,placement:"bottom",children:y.jsxs("button",{type:"button",onClick:()=>void C(),"aria-label":`Copy full version ${b}`,className:"cursor-pointer font-mono text-chip-indigo-text hover:text-chip-indigo-text/80",children:["v",a8(b)]})})]})]})]})}),y.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[y.jsxs("label",{className:"flex shrink-0 items-center gap-1.5 font-medium text-ink-secondary text-xs",children:[y.jsx(lu,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),y.jsx("span",{children:"Directory:"})]}),y.jsx(Xe,{text:"Select or type a directory path to scan files from.",suppress:m,children:y.jsx(zx,{id:"directory-combobox",ariaLabel:"Directory",value:i,options:t,onChange:l,commitOn:"deferred",onOpenChange:g,placeholder:"/path/to/directory",className:"w-full",inputClassName:"font-mono"})}),f&&y.jsx(Xe,{text:"Open the active directory in the OS file manager",block:!1,children:y.jsx("button",{type:"button",onClick:f,"aria-label":"Open active directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(YM,{className:"h-3.5 w-3.5"})})}),a&&y.jsx(Xe,{text:"Go to parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:a,"aria-label":"Go to parent directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Ad,{className:"h-3.5 w-3.5 rotate-180"})})}),o&&y.jsx(Xe,{text:"Browse for a folder on this system",block:!1,children:y.jsx("button",{type:"button",onClick:o,"aria-label":"Browse directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Hl,{className:"h-3.5 w-3.5"})})}),d&&y.jsx(Xe,{text:"Open the active directory in a terminal",block:!1,children:y.jsx("button",{type:"button",onClick:()=>d(i),"aria-label":"Open directory in terminal",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(eO,{className:"h-3.5 w-3.5"})})}),u&&y.jsx(Xe,{text:"Set directory to your home folder",block:!1,children:y.jsx("button",{type:"button",onClick:u,"aria-label":"Go to home directory",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(Ed,{className:"h-3.5 w-3.5"})})})]})]})}function u8({message:n,onRetry:e,retrying:t=!1}){return y.jsx("div",{className:"flex flex-1 items-center justify-center p-8",role:"alert","data-testid":"init-error-panel",children:y.jsxs("div",{className:"w-full max-w-sm rounded-xl border border-line bg-surface p-6 text-center shadow-xl",children:[y.jsx("div",{className:"mx-auto mb-3 flex h-10 w-10 items-center justify-center rounded-full border border-status-danger-border bg-status-danger-bg",children:y.jsx(Ec,{className:"h-5 w-5 text-status-danger-text/80"})}),y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Couldn't load the app"}),y.jsx("p",{className:"mt-1 break-words text-xs text-ink-secondary",children:n}),y.jsxs("button",{type:"button",onClick:e,disabled:t,className:"btn btn-primary mx-auto mt-4 px-3.5 py-1.5 font-semibold shadow-sm",children:[y.jsx(Md,{className:`h-3.5 w-3.5 ${t?"animate-spin motion-reduce:animate-none":""}`}),y.jsx("span",{children:t?"Retrying...":"Retry"})]})]})})}function V2({url:n,label:e,className:t="",onCopied:i,onCopyError:l}){const o=async()=>{try{await navigator.clipboard.writeText(n),i==null||i(n)}catch{l==null||l(n)}};return y.jsxs("span",{className:`flex items-center justify-between gap-2 ${t}`.trim(),children:[y.jsx("code",{className:"truncate font-mono text-[11px] text-ink",children:n}),y.jsx("button",{type:"button",onClick:o,"aria-label":e??`Copy ${n}`,title:e??"Copy",className:"focus-ring shrink-0 rounded p-1 text-ink-faint transition-colors hover:bg-elevated hover:text-ink",children:y.jsx(Zn,{className:"h-3.5 w-3.5"})})]})}function f8({pending:n,systemInfo:e,showToast:t,onConfirmed:i,onCancel:l}){return y.jsx(js,{isOpen:n!==null,title:n?"Enable LAN access?":"Restrict to this machine?",message:n?y.jsxs("span",{className:"block",children:["ProFiles will be reachable by anyone on this network:",y.jsx(V2,{url:`http://${e==null?void 0:e.hostname}:${window.location.port}`,label:"Copy hostname URL",className:"mt-1.5",onCopied:()=>t("URL copied to clipboard."),onCopyError:()=>t("Failed to copy URL.","error")}),y.jsx(V2,{url:`http://${e==null?void 0:e.ip}:${window.location.port}`,label:"Copy IP URL",className:"mt-1.5",onCopied:()=>t("URL copied to clipboard."),onCopyError:()=>t("Failed to copy URL.","error")})]}):"ProFiles will be reachable only on this machine.",confirmLabel:n?"Enable LAN":"Restrict",onConfirm:async()=>{const o=n;l();try{await SM(o),t(o?"Updating LAN binding…":"Restricting ProFiles to this machine…","info");const a=await CM(o);a&&i(a),(a==null?void 0:a.lan_enabled)===o?t(o?"ProFiles is now reachable on the local network.":"ProFiles is restricted to this machine.","info"):t("Failed to update LAN binding — the previous address is still active.","error")}catch(a){const u=a instanceof Error?a.message:"Failed to update LAN binding";t(`Failed to update LAN binding: ${u}`,"error");const f=await Qh();i(f)}},onCancel:l})}const q2=/"([^"]*)"|(\S+)/g,Q2=/"([^"]*)"/g,h8="Unmatched quote";function d8(n){const e=[];let t;for(q2.lastIndex=0;(t=q2.exec(n))!==null;){const a=t[1]!==void 0?t[1]:t[2];a&&a.trim()&&e.push(a)}let i="",l=0;Q2.lastIndex=0;let o;for(;(o=Q2.exec(n))!==null;)i+=n.slice(l,o.index),l=o.index+o[0].length;return i+=n.slice(l),{terms:e,error:i.includes('"')?h8:null}}function hA(n){const e=n.trim();if(!e)return{error:null,groups:[]};const{terms:t,error:i}=d8(e);if(t.length===0)return{error:i,groups:[]};const l=[];let o={includes:[],excludes:[]};for(const a of t){if(a.toUpperCase()==="OR"){l.push(o),o={includes:[],excludes:[]};continue}a==="-"||a==="+"||(a.startsWith("-")&&a.length>1?o.excludes.push(a.slice(1)):a.startsWith("+")&&a.length>1?o.includes.push(a.slice(1)):o.includes.push(a))}return l.push(o),{error:i,groups:l}}const m8=256,Ss=new Map;function X2(n){return n.toLowerCase()}function p8(n){const e=Ss.get(n);if(e)return Ss.delete(n),Ss.set(n,e),e;const{groups:t}=hA(n),i={groups:t.map(l=>({includes:l.includes.map(X2),excludes:l.excludes.map(X2)}))};if(Ss.size>=m8){const l=Ss.keys().next().value;l!==void 0&&Ss.delete(l)}return Ss.set(n,i),i}function g8(n,e){return e.includes.every(t=>n.includes(t))&&!e.excludes.some(t=>n.includes(t))}function x8(n,e){const{groups:t}=p8(e);if(t.length===0)return!0;const i=n.toLowerCase();return t.some(l=>g8(i,l))}function y8({query:n,visible:e}){if(!e)return null;const t=hA(n);return t.error?y.jsx("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-status-danger-border bg-surface-strong px-3 py-2 text-[11px] leading-5 text-status-danger-text/90 shadow-xl",children:t.error}):t.groups.length===0?null:y.jsxs("div",{"data-testid":"filter-syntax-helper",className:"pointer-events-none absolute left-0 right-0 top-full z-[var(--z-syntax-helper)] mt-1 rounded-md border border-line bg-surface-strong px-3 py-2 text-[11px] leading-5 text-ink-secondary shadow-xl",children:[y.jsx("span",{className:"mr-1.5 align-[1px] text-[10px] uppercase tracking-wide text-ink-muted",children:"reads as"}),t.groups.map((i,l)=>y.jsxs("span",{"data-testid":"filter-syntax-group",children:[l>0&&y.jsx("span",{className:"mx-1 font-mono text-chip-indigo-text",children:"OR"}),i.includes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"font-mono text-chip-indigo-text",children:o})]},`i-${a}`)),i.includes.length>0&&i.excludes.length>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),i.excludes.map((o,a)=>y.jsxs("span",{children:[a>0&&y.jsx("span",{className:"text-ink-muted",children:" · "}),y.jsx("span",{className:"text-ink-muted",children:"✕ "}),y.jsx("span",{className:"font-mono text-status-danger-text/70 line-through",children:o})]},`x-${a}`))]},l))]})}const $2=y.jsxs("span",{className:"flex flex-col gap-1 whitespace-nowrap text-left",children:[y.jsx("span",{className:"font-semibold",children:"Supported operators"}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a b"})," — AND (both terms)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"a OR b"})," — either term"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"-a"})," — NOT (exclude)"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:"+a"})," — force include"]}),y.jsxs("span",{children:[y.jsx("code",{className:"font-mono text-chip-indigo-text",children:'"a b"'})," — exact phrase"]})]});function b8({extensions:n,activeExtension:e,onExtensionChange:t,filterOptions:i,filterText:l,onFilterTextChange:o,recursive:a,onRecursiveChange:u,onScan:f,scanning:d,barcodeMode:m,onBarcodeToggle:g,onCameraBarcodeClick:b,autoRescanActive:v,onTimerClick:w}){const[S,C]=E.useState(!1),[O,_]=E.useState(!1),[M,H]=E.useState(!1);return y.jsxs("div",{className:"flex w-full flex-wrap items-center gap-3 border-b border-line bg-surface-glass p-3 text-xs",children:[y.jsx(Xe,{text:$2,suppress:O,children:y.jsxs("div",{className:"relative min-w-0 flex-1 basis-64",onFocusCapture:B=>{B.target.tagName==="INPUT"&&C(!0)},onBlurCapture:B=>{B.target.tagName==="INPUT"&&C(!1)},children:[y.jsx(JC,{className:"pointer-events-none absolute left-3 top-1/2 z-10 h-4 w-4 -translate-y-1/2 text-ink-secondary"}),y.jsx(zx,{id:"filter-combobox",ariaLabel:"File filter",value:l,options:i||[],onChange:o,onOpenChange:_,placeholder:"Filter files: keyword, a OR b, -tag, exact phrase...",className:"w-full",inputClassName:"pl-9 pr-3",optionLabel:B=>B||"(No filter)"}),y.jsx(y8,{query:l,visible:S&&!O&&l.trim().length>0})]})}),y.jsx(Xe,{text:$2,block:!1,suppress:M,children:y.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[y.jsx("span",{className:"text-ink-muted",children:"Ext:"}),y.jsx(zx,{id:"extension-combobox",ariaLabel:"Extension filter",value:e,options:n,onChange:t,commitOn:"deferred",onOpenChange:H,placeholder:".py OR .toml",className:"w-44",inputClassName:"font-mono px-2.5"})]})}),y.jsx(Xe,{text:"Include subdirectories when scanning",block:!1,children:y.jsxs("label",{className:"flex shrink-0 cursor-pointer select-none items-center gap-1.5 text-ink-secondary",children:[y.jsx("input",{type:"checkbox",checked:a,onChange:B=>u(B.target.checked),className:"rounded border-line text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-1 focus-visible:ring-offset-app"}),y.jsx("span",{children:"Recursive"})]})}),y.jsx(Xe,{text:"Run the scan with the current criteria (Enter)",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"btn btn-primary shrink-0 px-3.5 py-1.5 font-semibold shadow-sm",children:[d?y.jsx(Md,{className:"h-3.5 w-3.5 animate-spin motion-reduce:animate-none"}):y.jsx(Ul,{className:"h-3.5 w-3.5 fill-current"}),y.jsx("span",{children:d?"Scanning...":"Scan"})]})}),y.jsx(Xe,{text:v?"Auto-rescan is active. Click to configure.":"Configure periodic auto-rescan (hot-folder mode)",block:!1,children:y.jsx("button",{type:"button",onClick:w,"aria-label":"Configure timer / auto-rescan",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${v?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(tO,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`})})}),y.jsx(Xe,{text:"Toggle barcode scanner mode (USB HID). When active, scan a barcode to auto-fill controls and trigger a scan.",block:!1,children:y.jsx("button",{type:"button",onClick:g,"aria-label":m?"Disable barcode mode":"Enable barcode mode",className:`flex shrink-0 items-center justify-center rounded-md border p-1.5 text-ink-secondary hover:border-indigo-500 hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 transition-colors ${m?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated"}`,children:y.jsx(ny,{className:`h-3.5 w-3.5 ${m?"animate-pulse":""}`})})}),b&&y.jsx(Xe,{text:"Scan barcode or QR code using webcam / camera (Ctrl + Shift + B)",block:!1,children:y.jsx("button",{type:"button",onClick:b,"aria-label":"Scan barcode with camera",className:"btn btn-secondary shrink-0 p-1.5",children:y.jsx(GC,{className:"h-3.5 w-3.5"})})})]})}const v8=2e3,w8=500,k8=[{value:null,label:"ALL"},{value:"DEBUG",label:"DEBUG"},{value:"INFO",label:"INFO"},{value:"WARNING",label:"WARNING"},{value:"ERROR",label:"ERROR"},{value:"CRITICAL",label:"CRITICAL"}],G2={DEBUG:{icon:eD,className:"text-chip-sky-text"},INFO:{icon:ty,className:"text-status-success-text"},WARNING:{icon:iy,className:"text-status-warning-text"},ERROR:{icon:Uc,className:"text-status-danger-text"},CRITICAL:{icon:Uc,className:"text-status-danger-text"},UNKNOWN:{icon:sa,className:"text-ink-faint"}};function S8({isOpen:n,onClose:e,onOpenExternally:t}){const[i,l]=E.useState([]),[o,a]=E.useState("profiles.log"),[u,f]=E.useState(0),[d,m]=E.useState(null),[g,b]=E.useState(""),[v,w]=E.useState(!1),[S,C]=E.useState(!0),[O,_]=E.useState(null),[M,H]=E.useState(!0),B=E.useRef(null),D=E.useRef(null),R=E.useRef(null),P=E.useRef(null),te=E.useRef(S),I=E.useRef({level:d,search:g}),F=E.useRef(0),A=E.useRef(!0);te.current=S,I.current={level:d,search:g};const ne=E.useCallback(async()=>{const Z=++F.current,{level:Y,search:N}=I.current;w(!0);try{const he=await kM({limit:w8,level:Y,search:N});if(F.current!==Z)return;l(he.entries),a(he.path),f(he.size_bytes),_(null)}catch(he){if(F.current!==Z)return;_((he==null?void 0:he.message)||"Failed to read the log file")}finally{F.current===Z&&w(!1)}},[]);E.useEffect(()=>{n&&ne()},[n,ne]),E.useEffect(()=>{if(!n||!S)return;const Z=window.setInterval(()=>{ne()},v8);return()=>window.clearInterval(Z)},[n,S,ne]),E.useEffect(()=>{if(!n){A.current=!0;return}if(A.current){A.current=!1;return}const Z=window.setTimeout(()=>void ne(),250);return()=>window.clearTimeout(Z)},[n,d,g,ne]),E.useEffect(()=>{if(!M)return;const Z=R.current;Z&&(Z.scrollTop=Z.scrollHeight)},[i,M]),E.useEffect(()=>{if(!n)return;const Z=document.activeElement instanceof HTMLElement?document.activeElement:null,Y=requestAnimationFrame(()=>{var N;return(N=D.current)==null?void 0:N.focus()});return()=>{cancelAnimationFrame(Y),Z==null||Z.focus()}},[n]);const ae=Z=>{var ye;if(Z.key==="Escape"){Z.preventDefault(),e();return}if(Z.key!=="Tab")return;const Y=(ye=B.current)==null?void 0:ye.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(Y!=null&&Y.length))return;const N=Y[0],he=Y[Y.length-1];Z.shiftKey&&document.activeElement===N?(Z.preventDefault(),he.focus()):!Z.shiftKey&&document.activeElement===he&&(Z.preventDefault(),N.focus())},ie=()=>{const Z=R.current;if(!Z)return;const Y=Z.scrollHeight-Z.scrollTop-Z.clientHeight<24;H(Y)},$=async()=>{try{await navigator.clipboard.writeText(i.map(Z=>Z.raw).join(` +`))}catch{}},oe=E.useMemo(()=>{const Z=new Map;for(const Y of i)Z.set(Y.level,(Z.get(Y.level)??0)+1);return Z},[i]);return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:e,children:y.jsxs("div",{ref:B,role:"dialog","aria-modal":"true","aria-labelledby":"log-viewer-title",onKeyDown:ae,className:"animate-modal-in flex h-[min(84dvh,760px)] w-[clamp(560px,85vw,1500px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:Z=>Z.stopPropagation(),children:[y.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-line px-5 py-4 sm:px-6",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[y.jsx("span",{className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(sa,{className:"h-5 w-5 text-chip-indigo-text","aria-hidden":"true"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"log-viewer-title",className:"text-base font-semibold text-ink",children:"Application logs"}),y.jsxs("p",{className:"truncate font-mono text-xs text-ink-muted",children:[o,y.jsxs("span",{className:"text-ink-faint",children:[" · ",Y2(u)]})]})]})]}),y.jsxs("div",{className:"relative min-w-[220px] flex-1",children:[y.jsx(JC,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-ink-faint","aria-hidden":"true"}),y.jsx("input",{ref:P,type:"search",value:g,onChange:Z=>b(Z.target.value),placeholder:"Filter log lines…","aria-label":"Filter log lines",className:"w-full rounded-lg border border-line bg-elevated py-1.5 pl-8 pr-2.5 font-mono text-xs text-ink placeholder:text-ink-faint focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400"})]}),y.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[y.jsx(Xe,{text:S?"Pause live tail":"Resume live tail",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>C(Z=>!Z),"aria-pressed":S,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${S?"border-status-success-border bg-status-success-bg text-status-success-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx("span",{className:`h-2 w-2 rounded-full ${S?"bg-emerald-400":"bg-ink-faint"}`,"aria-hidden":"true"}),S?"Live":"Paused"]})}),y.jsx(Xe,{text:"Refresh now",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void ne(),disabled:v,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Md,{className:`h-4 w-4 ${v?"animate-spin":""}`,"aria-hidden":"true"})})}),y.jsx(Xe,{text:"Copy visible lines",block:!1,children:y.jsx("button",{type:"button",onClick:()=>void $(),disabled:i.length===0,className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Zn,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx(Xe,{text:"Open log file in the default application",block:!1,children:y.jsx("button",{type:"button",onClick:()=>{t==null||t(),e()},className:"rounded-lg border border-line bg-elevated p-2 text-ink-muted hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(KC,{className:"h-4 w-4","aria-hidden":"true"})})}),y.jsx(Xe,{text:"Close",block:!1,children:y.jsx("button",{ref:D,type:"button",onClick:e,className:"rounded-lg p-2 text-ink-muted hover:bg-hover-surface hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(bi,{className:"h-4 w-4","aria-hidden":"true"})})})]})]}),y.jsxs("div",{ref:R,onScroll:ie,className:"min-h-0 flex-1 overflow-y-auto overscroll-contain bg-app px-2 py-2 font-mono text-xs leading-relaxed sm:px-3",children:[y.jsxs("div",{className:"sticky top-0 z-10 mb-1 flex items-center gap-2 rounded-md border border-line/40 bg-surface/60 px-2 py-1 text-[10px] font-bold uppercase tracking-wider text-ink-muted shadow-sm backdrop-blur-md",role:"row",children:[y.jsx("span",{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink/70",children:"Time"}),y.jsx("span",{className:"w-[52px] shrink-0 text-ink/70",children:"Level"}),y.jsx("span",{className:"w-[150px] shrink-0 text-ink/70",children:"Source"}),y.jsx("span",{className:"min-w-0 flex-1 text-ink/70",children:"Message"})]}),O&&y.jsx("p",{role:"alert",className:"px-3 py-6 text-center text-xs text-status-danger-text",children:O}),!O&&i.length===0&&!v&&y.jsx("p",{className:"px-3 py-6 text-center text-xs text-ink-faint",children:"No log entries match the current filters."}),y.jsx("ul",{className:"space-y-0.5",children:i.map((Z,Y)=>{const N=G2[Z.level]??G2.UNKNOWN,he=N.icon,ye=Z.level==="ERROR"||Z.level==="CRITICAL";return y.jsxs("li",{className:`group flex items-start gap-2 rounded px-2 py-1 ${ye?"bg-status-danger-bg/40":"hover:bg-elevated/50"}`,children:[y.jsx("span",{className:N.className,children:y.jsx(he,{className:"mt-0.5 h-3.5 w-3.5","aria-hidden":"true"})}),y.jsx("span",{className:"w-[138px] shrink-0 text-ink-faint",children:Z.timestamp}),y.jsx("span",{className:`w-[52px] shrink-0 text-[10px] font-semibold ${N.className}`,children:Z.level}),y.jsx("span",{className:"w-[150px] shrink-0 truncate text-ink-faint",title:Z.source,children:Z.source}),y.jsx("span",{className:"min-w-0 flex-1 break-words text-ink-secondary",children:Z.message})]},`${Y}-${Z.raw}`)})})]}),y.jsx("div",{className:"border-t border-line/60 bg-elevated/50 px-5 py-2.5 text-[11px] text-ink-faint shadow-sm backdrop-blur-md sm:px-6",children:y.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[y.jsx("span",{className:"mr-auto min-w-0 max-w-full basis-full truncate sm:basis-auto",role:"status","aria-atomic":"true",children:v&&i.length===0?"Loading log entries…":`${i.length} of ${Y2(u)} shown`}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("div",{className:"flex overflow-hidden rounded-lg border border-line/60 text-[11px] backdrop-blur-sm",role:"group","aria-label":"Filter by log level",children:k8.map(Z=>{const Y=d===Z.value,N=Z.value?oe.get(Z.value)??0:i.length;return y.jsxs("button",{type:"button",onClick:()=>m(Z.value),"aria-pressed":Y,title:Z.value?`Show ${Z.value} and above`:"Show all levels",className:`flex items-center gap-1 px-2.5 py-1 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${Y?"bg-indigo-600 text-white":"text-ink-muted hover:bg-elevated hover:text-ink"}`,children:[Z.label,y.jsx("span",{className:Y?"text-chip-indigo-text":"text-ink-faint",children:N})]},Z.label)})}),y.jsx(Xe,{text:"Scroll to the newest entry",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>H(!0),"aria-pressed":M,className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400 ${M?"border-chip-indigo-border bg-chip-indigo-bg text-chip-indigo-text":"border-line bg-elevated text-ink-muted hover:text-ink"}`,children:[y.jsx($C,{className:"h-3.5 w-3.5","aria-hidden":"true"}),y.jsx("span",{className:"hidden sm:inline",children:"Follow tail"})]})})]}),y.jsxs("span",{className:"hidden items-center gap-1.5 lg:flex",children:[y.jsx("span",{className:"hidden sm:inline",children:"Ctrl + Shift + L"}),y.jsx("span",{children:"toggles this viewer"})]})]})})]})}):null}function Y2(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function C8({isOpen:n,onClose:e}){const t=E.useRef(null),i=Wl({isOpen:n,onClose:e,dialogRef:t});if(!n)return null;const l=[{key:"F5",desc:"Refresh / re-scan file list"},{key:"Ctrl + R",desc:"Reload configuration & scan"},{key:"Enter",desc:"Execute / launch selected file"},{key:"P",desc:"Open properties for selected file"},{key:"↑ / ↓",desc:"Navigate file list"},{key:"Home / End",desc:"Jump to first / last file"},{key:"PageUp / PageDown",desc:"Page through the file list"},{key:"Ctrl + D",desc:"Focus Directory field"},{key:"Ctrl + E",desc:"Focus Extension field"},{key:"Ctrl + F",desc:"Focus Filter / Search field"},{key:"Ctrl + L",desc:"Focus File List"},{key:"Ctrl + Shift + L",desc:"Open the log viewer"},{key:"Ctrl + ,",desc:"Open the config editor"},{key:"Ctrl + Shift + T",desc:"Toggle theme (Dark / Light)"},{key:"Ctrl + B",desc:"Toggle barcode scanner mode"},{key:"Ctrl + Shift + B",desc:"Open webcam / camera barcode scanner"},{key:"Ctrl + T",desc:"Open auto-rescan timer modal"},{key:"Ctrl + H",desc:"Set directory to home folder"},{key:"? or Ctrl + /",desc:"Show keyboard shortcuts"},{key:"Y / S / N",desc:"Answer workflow guard: Yes / Skip / No (prompt open)"},{key:"Enter",desc:"Confirm active workflow prompt (prompt open)"},{key:"Escape",desc:"Close dialogs / context menu"}];return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:t,role:"dialog","aria-modal":"true","aria-label":"Keyboard Shortcuts",onKeyDown:i,className:"animate-modal-in w-[450px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(WC,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Keyboard Shortcuts"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(bi,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"max-h-[60vh] space-y-2 overflow-y-auto pr-1 text-xs",children:l.map(({key:o,desc:a})=>y.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-elevated/50 px-3 py-2",children:[y.jsx("span",{className:"text-ink-secondary",children:a}),y.jsx("kbd",{className:"rounded bg-app px-2 py-0.5 font-mono text-[11px] font-semibold text-chip-indigo-text border border-line",children:o})]},o))}),y.jsx("div",{className:"mt-5 flex justify-end",children:y.jsx("button",{onClick:e,className:"btn btn-primary rounded-lg px-4 py-2 font-semibold",children:"Close"})})]})})}function O8({isOpen:n,mode:e,activeConfigPath:t,onClose:i,onLoaded:l}){const[o,a]=E.useState(null),[u,f]=E.useState(""),[d,m]=E.useState(null),[g,b]=E.useState(!1),[v,w]=E.useState(null),S=E.useRef(null),C=E.useRef(null),O=E.useRef(null),_=e==="create";E.useEffect(()=>{var F;if(!n){(F=O.current)==null||F.focus();return}O.current=document.activeElement instanceof HTMLElement?document.activeElement:null,w(null);const R=t??"",P=Math.max(R.lastIndexOf("/"),R.lastIndexOf("\\")),te=P>0?R.slice(0,P):"";M(te);const I=requestAnimationFrame(()=>{var A;return(A=C.current)==null?void 0:A.focus()});return()=>{var A;cancelAnimationFrame(I),(A=O.current)==null||A.focus()}},[n,t]);const M=async R=>{b(!0),w(null);try{const P=await MM(R);a(P),f(P.current_path),t&&P.items.some(te=>te.path===t)?m(t):m(null)}catch(P){w(P.message||"Navigation failed")}finally{b(!1)}},H=R=>{var F;if(R.key==="Escape"){R.preventDefault(),i();return}if(R.key!=="Tab")return;const P=(F=S.current)==null?void 0:F.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(P!=null&&P.length))return;const te=P[0],I=P[P.length-1];R.shiftKey&&document.activeElement===te?(R.preventDefault(),I.focus()):!R.shiftKey&&document.activeElement===I&&(R.preventDefault(),te.focus())},B=async()=>{var P;const R=d||(((P=o==null?void 0:o.items.find(te=>te.is_config))==null?void 0:P.path)??null);if(!R){w("Select a configuration file to load.");return}try{b(!0);const te=await OM(R);l(te),i()}catch(te){w(te.message||"Unable to load configuration")}finally{b(!1)}},D=async()=>{const R=(u||(o==null?void 0:o.current_path)||"").trim();if(!R){w("Choose a directory before creating a configuration.");return}try{b(!0);const P=await NM(R);l(P),i()}catch(P){w(P.message||"Unable to create configuration")}finally{b(!1)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/65 p-3 backdrop-blur-sm sm:p-6",onClick:i,children:y.jsxs("div",{ref:S,role:"dialog","aria-modal":"true","aria-labelledby":"load-config-title",onKeyDown:H,className:"animate-modal-in flex h-[min(84dvh,760px)] max-h-[calc(100dvh-1.5rem)] w-[min(94vw,960px)] min-h-0 flex-col overflow-hidden rounded-xl border border-frame-line glass-panel sm:rounded-2xl",onClick:R=>R.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line px-4 py-3 sm:px-5",children:[y.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg bg-chip-indigo-bg",children:y.jsx(Qo,{className:"h-5 w-5 text-chip-indigo-text"})}),y.jsxs("div",{className:"min-w-0",children:[y.jsx("h2",{id:"load-config-title",className:"text-sm font-semibold text-ink",children:_?"Create configuration":"Load configuration"}),y.jsx("p",{className:"truncate font-mono text-xs text-ink-muted",children:(o==null?void 0:o.current_path)||""})]})]}),y.jsx(Xe,{text:"Close",block:!1,children:y.jsx("button",{type:"button",onClick:i,"aria-label":"Close configuration modal",className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg text-ink-muted transition-colors hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(bi,{className:"h-4 w-4"})})})]}),_&&y.jsx("div",{className:"border-b border-line bg-chip-indigo-bg/20 px-4 py-3 text-xs text-ink-secondary",children:"No configuration file was found. Create one here?"}),y.jsxs("div",{className:"border-b border-line px-4 py-3 sm:px-5",children:[y.jsx("label",{htmlFor:"config-path-input",className:"mb-1.5 block text-xs font-medium text-ink-secondary",children:"Configuration directory"}),y.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[y.jsx("input",{ref:C,id:"config-path-input",type:"text",value:u,onChange:R=>f(R.target.value),onKeyDown:R=>{R.key==="Enter"&&M(u.trim())},placeholder:"/path/to/directory",className:"h-10 min-w-0 flex-1 rounded-lg border border-line bg-elevated px-2.5 font-mono text-sm text-ink outline-none placeholder:text-ink-faint transition-colors hover:bg-surface-strong focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-indigo-500/30"}),y.jsx("button",{type:"button",onClick:()=>M(u.trim()),className:"inline-flex h-10 shrink-0 items-center gap-1.5 rounded-lg border border-line bg-elevated px-3.5 text-sm font-medium text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Go"}),y.jsx(Xe,{text:"Home directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>M(""),"aria-label":"Home directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ed,{className:"h-4 w-4"})})}),(o==null?void 0:o.parent_path)&&y.jsx(Xe,{text:"Parent directory",block:!1,children:y.jsx("button",{type:"button",onClick:()=>M(o.parent_path),"aria-label":"Parent directory",className:"grid h-10 w-10 shrink-0 place-items-center rounded-lg border border-line bg-elevated text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:y.jsx(Ad,{className:"h-4 w-4 rotate-180"})})})]})]}),y.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-2 py-2 sm:px-3 sm:py-3","aria-busy":g,children:g?y.jsxs("div",{className:"flex h-full items-center justify-center gap-2.5 text-sm text-ink-muted",children:[y.jsx(Yr,{className:"h-5 w-5 animate-spin text-chip-indigo-text"}),y.jsx("span",{role:"status",children:"Loading configuration files…"})]}):v?y.jsxs("div",{role:"alert",className:"flex h-full flex-col items-center justify-center gap-2.5 text-center",children:[y.jsx("p",{className:"text-sm text-status-danger-text",children:v}),y.jsx("button",{type:"button",onClick:()=>M(u||(o==null?void 0:o.current_path)||""),className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Retry"})]}):y.jsxs("ul",{className:"space-y-1",children:[o==null?void 0:o.items.map(R=>{if(R.is_dir)return y.jsx("li",{children:y.jsx("button",{onClick:()=>M(R.path),onDoubleClick:()=>M(R.path),className:"flex w-full items-center justify-between rounded-md px-3 py-1.5 text-left text-xs text-ink-secondary hover:bg-elevated",children:y.jsxs("span",{className:"flex items-center gap-2",children:[y.jsx(lu,{className:"h-3.5 w-3.5 text-chip-indigo-text"}),R.name]})})},R.path);const P=d===R.path;return y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>m(R.path),"aria-pressed":P,className:`flex w-full items-center justify-between rounded-lg px-3 py-1.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-400 ${P?"bg-chip-indigo-bg text-chip-indigo-text":"text-ink-secondary hover:bg-elevated hover:text-ink"}`,children:[y.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[y.jsx(sa,{className:"h-5 w-5 shrink-0 text-chip-amber-text"}),y.jsx("span",{className:"truncate",children:R.name})]}),R.is_config&&y.jsx(Qo,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),P&&y.jsx(Sr,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},R.path)}),(o==null?void 0:o.items.filter(R=>R.is_config).length)===0&&y.jsxs("li",{className:"flex h-full min-h-36 flex-col items-center justify-center gap-2.5 text-center text-sm text-ink-muted",children:[y.jsx(sa,{className:"h-7 w-7 text-ink-faint"}),"No configuration files found"]})]})}),y.jsxs("div",{className:"flex flex-col gap-2 border-t border-line px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("p",{className:"mb-0.5 text-xs font-medium text-ink-muted",children:"Selected file"}),y.jsx("p",{className:"truncate font-mono text-sm text-ink",title:d||u,children:d||u||"—"})]}),y.jsxs("div",{className:"flex shrink-0 justify-end gap-1.5",children:[y.jsx("button",{type:"button",onClick:i,className:"min-h-10 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),_?y.jsxs("button",{type:"button",onClick:D,disabled:!u.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Qo,{className:"h-4 w-4"}),"Create configuration"]}):y.jsxs("button",{type:"button",onClick:B,disabled:!d,className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Qo,{className:"h-4 w-4"}),"Load configuration"]})]})]})]})}):null}function dA({isOpen:n,onClose:e,initialFilePath:t,md5:i}){const[l,o]=E.useState(null),[a,u]=E.useState(""),[f,d]=E.useState([]),[m,g]=E.useState(!1),[b,v]=E.useState(null),[w,S]=E.useState(null),[C,O]=E.useState(!1),[_,M]=E.useState(!1),[H,B]=E.useState(null),D=E.useRef(null),R=E.useRef(0),P=E.useRef(null),te=Wl({isOpen:n,onClose:e,dialogRef:D});E.useEffect(()=>{n||P.current!==null&&(window.clearTimeout(P.current),P.current=null)},[n]),E.useEffect(()=>{if(!n)return;async function N(){if(t){g(!0);try{const he=await Pk({filePath:t});o(he.image),u(he.content),I(he.content)}catch(he){v(he.message)}finally{g(!1)}}}N()},[n,t]);const I=N=>{const he=N.split(";").map(ye=>{const z=ye.split("=");return{key:z[0]||"",value:z[1]||""}}).filter(ye=>ye.key||ye.value);d(he)},F=async N=>{const he=++R.current;try{const ye=await Pk({content:N});if(R.current!==he)return;o(ye.image),S(null)}catch(ye){if(R.current!==he)return;S(ye instanceof Error?ye.message:"Failed to generate the barcode")}},A=N=>{const he=N.filter(ye=>ye.key.trim()).map(ye=>`${ye.key.trim()}=${ye.value.trim()}`).join(";");if(u(he),P.current!==null&&(window.clearTimeout(P.current),P.current=null),!he){R.current+=1,o(null),S(null);return}P.current=window.setTimeout(()=>void F(he),250)},ne=(N,he,ye)=>{const z=[...f];z[N][he]=ye,d(z),A(z)},ae=()=>{const N=[...f,{key:"",value:""}];d(N)},ie=N=>{const he=f.filter((ye,z)=>z!==N);d(he),A(he)},$=()=>{if(!i||f.some(he=>he.key.toLowerCase()==="md5"))return;const N=[...f,{key:"md5",value:i}];d(N),A(N)},oe=async()=>{if(l){B("Saving…");try{const N=await zM(l,`profiles-qr-${Date.now()}.png`);B(N.path||N.message)}catch(N){B(`Save failed: ${(N==null?void 0:N.message)??N}`)}finally{setTimeout(()=>B(null),6e3)}}},Z=async()=>{try{await navigator.clipboard.writeText(a),O(!0),setTimeout(()=>O(!1),2e3)}catch(N){console.error("Copy failed",N)}},Y=async()=>{if(l)try{const he=await(await fetch(l)).blob();await navigator.clipboard.write([new ClipboardItem({[he.type]:he})]),M(!0),setTimeout(()=>M(!1),2e3)}catch(N){console.error("Image copy failed",N)}};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4",onClick:e,children:y.jsxs("div",{ref:D,role:"dialog","aria-modal":"true","aria-label":"QR Code Settings",onKeyDown:te,className:"animate-modal-in w-full max-w-md rounded-xl border border-frame-line glass-panel p-6",onClick:N=>N.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[y.jsx("h3",{className:"text-sm font-semibold text-ink",children:"QR Code Settings"}),y.jsx("button",{onClick:e,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(bi,{className:"h-4 w-4"})})]}),m?y.jsx("div",{className:"flex h-48 items-center justify-center",children:y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"})}):b?y.jsx("div",{className:"rounded-md border border-status-danger-border bg-status-danger-bg p-4 text-center text-xs text-status-danger-text",children:b}):y.jsxs("div",{className:"space-y-6",children:[y.jsxs("div",{className:"flex flex-col items-center gap-4",children:[y.jsxs("div",{className:"relative group",children:[y.jsx("div",{className:"h-48 w-48 overflow-hidden rounded-lg border border-line bg-white p-2",children:l?y.jsx("img",{src:l,alt:"QR Code",className:"h-full w-full object-contain"}):y.jsx("div",{className:"flex h-full items-center justify-center text-xs text-slate-400",children:"No content"})}),l&&y.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity bg-black/20 rounded-lg",children:y.jsxs("button",{onClick:Y,className:"focus-ring flex items-center gap-2 rounded-md bg-white/90 p-2 text-xs font-medium text-slate-900 shadow-sm hover:bg-white",children:[_?y.jsx(Sr,{className:"h-3.5 w-3.5"}):y.jsx(Zn,{className:"h-3.5 w-3.5"}),_?"Copied":"Copy Image"]})})]}),y.jsxs("div",{className:"flex w-full gap-2",children:[y.jsxs("button",{onClick:Z,className:"btn btn-secondary flex-1 px-3 py-1.5",children:[C?y.jsx(Sr,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(Zn,{className:"h-3.5 w-3.5"}),"Copy Content"]}),y.jsxs("button",{onClick:oe,disabled:!l,className:"btn btn-primary flex-1 px-3 py-1.5",children:[y.jsx(YC,{className:"h-3.5 w-3.5"}),"Save Image"]})]}),H&&y.jsx("p",{className:"break-all text-center text-[11px] text-ink-muted",role:"status",children:H}),w&&y.jsx("p",{role:"alert",className:"break-all text-center text-[11px] text-status-danger-text",children:w})]}),y.jsxs("div",{className:"space-y-3",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("label",{className:"text-xs font-medium text-ink-muted uppercase tracking-wider",children:"Payload Fields"}),y.jsxs("div",{className:"flex gap-2",children:[i&&!f.some(N=>N.key==="md5")&&y.jsxs("button",{onClick:$,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-purple-text border border-chip-purple-border",children:[y.jsx(Xo,{className:"h-3 w-3"})," Inc. MD5"]}),y.jsxs("button",{onClick:ae,className:"btn-chip flex items-center gap-1 rounded px-2 py-0.5 text-[10px] font-bold text-chip-indigo-text border border-chip-indigo-border",children:[y.jsx(r4,{className:"h-3 w-3"})," Add Field"]})]})]}),y.jsxs("div",{className:"max-h-48 space-y-2 overflow-y-auto pr-1 custom-scrollbar",children:[f.map((N,he)=>y.jsxs("div",{className:"flex gap-2 items-center slide-in",children:[y.jsx("input",{type:"text",placeholder:"key",value:N.key,onChange:ye=>ne(he,"key",ye.target.value),className:"w-1/3 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("input",{type:"text",placeholder:"value",value:N.value,onChange:ye=>ne(he,"value",ye.target.value),className:"flex-1 rounded border border-line bg-elevated px-2 py-1 text-xs text-ink focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{onClick:()=>ie(he),className:"p-1 text-ink-muted hover:text-status-danger-text transition-colors","aria-label":"Remove field",children:y.jsx(nO,{className:"h-3.5 w-3.5"})})]},he)),f.length===0&&y.jsx("p",{className:"text-center py-4 text-xs text-ink-muted italic",children:"No fields defined"})]})]}),y.jsxs("div",{className:"pt-2 border-t border-line",children:[y.jsx("label",{className:"text-[10px] font-medium text-ink-muted uppercase tracking-wider block mb-1.5",children:"Raw Preview"}),y.jsx("div",{className:"rounded bg-elevated p-2 font-mono text-[10px] text-ink-secondary break-all border border-line",children:a||y.jsx("span",{className:"italic text-ink-muted/50",children:"empty"})})]})]})]})}):null}const K2=["Bytes","KB","MB","GB","TB"];function mA(n){if(n===0)return"0 Bytes";const e=1024,t=Math.max(0,Math.min(K2.length-1,Math.floor(Math.log(n)/Math.log(e))));return parseFloat((n/Math.pow(e,t)).toFixed(2))+" "+K2[t]}function T8(n){const e=Math.max(n.lastIndexOf("\\"),n.lastIndexOf("/"));return e===-1?"":n.slice(0,e)}function N8(n){const e=[`File Properties: ${n.name}`,`Path: ${n.path}`,`Type: ${n.type}`,`Size: ${mA(n.size_bytes)}`,`Created: ${n.created}`,`Modified: ${n.modified}`];return n.md5&&e.push(`MD5: ${n.md5}`),n.sha256&&e.push(`SHA256: ${n.sha256}`),e.join(` +`)}function g0(n,e,t){return n.length<=e+t+1?n:`${n.slice(0,e)}…${n.slice(-t)}`}function A8(n){const e=n.includes("\\")?"\\":"/",t=n.split(/[\\/]/);return t.length<=5?n:[t[0],t[1],"…",t[t.length-2],t[t.length-1]].join(e)}const E8=[{ms:1e3*60,unit:"minute"},{ms:1e3*60*60,unit:"hour"},{ms:1e3*60*60*24,unit:"day"},{ms:1e3*60*60*24*30,unit:"month"},{ms:1e3*60*60*24*365,unit:"year"}];function W2(n,e=new Date){const t=new Date(n.replace(" ","T"));if(Number.isNaN(t.getTime()))return"just now";const i=e.getTime()-t.getTime();if(i<6e4)return"just now";let l="just now";for(const{ms:o,unit:a}of E8){if(i{var A;n||((A=M.current)==null||A.focus(),v(!1))},[n]),E.useEffect(()=>{if(!n||!e)return;const A=new AbortController;return H.current=A,o(null),O(null),u(!0),d(null),(async()=>{try{const ne=await _M(e.path,A.signal);if(H.current!==A)return;o(ne)}catch(ne){if(H.current!==A||ne instanceof DOMException&&ne.name==="AbortError")return;d(ne instanceof Error?ne.message:"Failed to load properties")}finally{H.current===A&&u(!1)}})(),()=>{H.current=null,A.abort()}},[n,e]),E.useEffect(()=>{if(!n)return;const A=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=A}},[n]),E.useEffect(()=>{if(!n)return;const A=ne=>{if(ne.key==="Escape"){if(b)return;t();return}if(ne.key!=="Tab")return;const ae=_.current;if(!ae)return;const ie=Array.from(ae.querySelectorAll('button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(Y=>Y.offsetParent!==null);if(ie.length===0)return;const $=ie[0],oe=ie[ie.length-1],Z=document.activeElement instanceof HTMLElement?document.activeElement:null;ne.shiftKey?(Z===$||!ae.contains(Z))&&(ne.preventDefault(),oe.focus()):Z===oe&&(ne.preventDefault(),$.focus())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[n,b,t]),E.useEffect(()=>{if(!n)return;const A=document.activeElement instanceof HTMLElement?document.activeElement:null;M.current=A;const ne=requestAnimationFrame(()=>{var ae,ie;(ie=(ae=_.current)==null?void 0:ae.querySelector("button"))==null||ie.focus()});return()=>cancelAnimationFrame(ne)},[n]);const B=async(A,ne)=>{try{await navigator.clipboard.writeText(A),g(ne),setTimeout(()=>g(null),2e3)}catch(ae){console.error("Failed to copy:",ae)}},D=async(A,ne,ae)=>{S(A),O(null);try{await ae(),O(ne)}catch{O("Action failed")}finally{S(null)}},R=A=>`btn btn-chip rounded-md border px-3 py-2 text-xs ${{reveal:"bg-chip-sky-bg text-chip-sky-text border-chip-sky-border",launch:"border-emerald-500/30 bg-emerald-600 font-semibold text-white hover:bg-emerald-500",folder:"bg-chip-amber-bg text-chip-amber-text border-chip-amber-border"}[A]??"bg-chip-indigo-bg text-chip-indigo-text border-chip-indigo-border"}`,P=(A,ne,ae,ie=!1,$)=>y.jsxs("div",{className:"flex items-start gap-2 py-1.5 group",children:[y.jsxs("span",{className:"text-ink-muted min-w-[100px] text-xs",children:[A,":"]}),y.jsx("div",{className:"flex-1 min-w-0",children:y.jsx("span",{className:`text-ink text-xs break-all ${ie?"font-mono":""}`,children:$??ne})}),y.jsx(Xe,{text:"Copy to clipboard",block:!1,children:y.jsx("button",{onClick:()=>B(ne,ae),className:"opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded hover:bg-elevated","aria-label":`Copy ${A}`,children:m===ae?y.jsx(Sr,{className:"h-3.5 w-3.5 text-status-success-text"}):y.jsx(Zn,{className:"h-3.5 w-3.5 text-ink-muted"})})})]}),te=(A,ne,ae)=>y.jsxs("div",{className:"rounded-lg border border-line bg-elevated p-4",children:[y.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[ne,y.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide text-ink-muted",children:A})]}),ae]}),I=()=>y.jsx(Xe,{text:"Click to copy full path",children:y.jsxs("button",{onClick:()=>void B(l.path,"path"),className:"group mb-3 flex w-full items-center gap-2 rounded-lg border border-line bg-elevated px-3 py-2 text-left hover:bg-surface",children:[y.jsx(lu,{className:"text-chip-amber-text h-4 w-4 flex-shrink-0"}),y.jsx("span",{className:"text-ink min-w-0 flex-1 truncate font-mono text-xs",children:A8(l.path)}),m==="path"?y.jsx(Sr,{className:"text-status-success-text h-3.5 w-3.5"}):y.jsx(Zn,{className:"text-ink-muted h-3.5 w-3.5"})]})});if(!n||!e)return null;const F=e;return y.jsxs("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 backdrop-blur-md p-4",role:"dialog","aria-modal":"true","aria-labelledby":"properties-modal-title",children:[y.jsx("div",{className:"absolute inset-0",onClick:t,onContextMenu:A=>{A.preventDefault(),t()}}),y.jsxs("div",{ref:_,className:"animate-modal-in relative w-full max-w-4xl max-h-[90vh] overflow-hidden rounded-xl border border-frame-line glass-panel flex flex-col",children:[y.jsx("div",{className:"flex-shrink-0 border-b border-line px-6 py-4",children:y.jsxs("div",{className:"flex items-start justify-between gap-4",children:[y.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[y.jsx("div",{className:"rounded-lg bg-indigo-600 p-2 flex-shrink-0",children:y.jsx(Bg,{className:"h-5 w-5 text-white"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h3",{id:"properties-modal-title",className:"text-base font-semibold text-ink truncate",children:"File Properties"}),y.jsx("p",{className:"text-xs text-ink-muted truncate",children:e.filename})]}),y.jsx(Xe,{text:"Copy all properties to clipboard",block:!1,children:y.jsx("button",{onClick:()=>{l&&B(N8(l),"all")},disabled:!l||a||f!==null,className:"btn-chip ml-2 flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text","aria-label":"Copy all properties",children:m==="all"?y.jsx(Sr,{className:"h-4 w-4 text-status-success-text"}):y.jsx(Zn,{className:"h-4 w-4"})})}),y.jsx(Xe,{text:"Generate Barcode/QR Code",block:!1,children:y.jsx("button",{onClick:()=>v(!0),className:"btn-chip rounded-md border border-chip-indigo-border bg-chip-indigo-bg p-1.5 text-chip-indigo-text",children:y.jsx(ny,{className:"h-4 w-4"})})})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink flex-shrink-0","aria-label":"Close",children:y.jsx(bi,{className:"h-4 w-4"})})]})}),y.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-4",children:[a&&y.jsx("div",{className:"flex items-center justify-center py-8",children:y.jsxs("div",{className:"flex flex-col items-center gap-2",children:[y.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-indigo-600 border-t-transparent"}),y.jsx("p",{className:"text-xs text-ink-muted",children:"Loading properties..."})]})}),f&&y.jsx("div",{className:"rounded-lg border border-status-danger-border bg-status-danger-bg p-4 text-center",children:y.jsx("p",{className:"text-xs text-status-danger-text",children:f})}),l&&!a&&!f&&y.jsxs("div",{children:[y.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-x-4 gap-y-1.5 rounded-lg border border-line bg-elevated px-4 py-2.5",children:[y.jsx("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-indigo-border bg-chip-indigo-bg px-2 py-0.5 text-xs font-semibold text-chip-indigo-text",children:l.type}),l.attributes.extension&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-line bg-surface px-2 py-0.5 text-xs font-medium text-ink-muted",children:l.attributes.extension}),y.jsxs("span",{className:"text-xs text-ink-muted",title:`${l.size_bytes} bytes`,children:["Size ",y.jsx("strong",{className:"text-ink font-medium",children:mA(l.size_bytes)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.created,children:["Created ",y.jsx("strong",{className:"text-ink font-medium",children:W2(l.created)})]}),y.jsxs("span",{className:"text-xs text-ink-muted",title:l.modified,children:["Modified ",y.jsx("strong",{className:"text-ink font-medium",children:W2(l.modified)})]}),l.md5&&y.jsx("span",{className:"inline-flex items-center rounded-md border border-chip-purple-border bg-chip-purple-bg px-2 py-0.5 font-mono text-xs font-medium text-chip-purple-text",title:`MD5 ${l.md5}`,children:g0(l.md5,4,4)}),l.attributes.is_symlink&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-chip-fuchsia-border bg-chip-fuchsia-bg px-2 py-0.5 text-xs font-medium text-chip-fuchsia-text",children:[y.jsx(GD,{className:"h-3 w-3"})," Symlink"]})]}),I(),y.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[te("Hashes",y.jsx(Xo,{className:"text-chip-purple-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[P("MD5",l.md5,"md5",!0,g0(l.md5,10,6)),P("SHA256",l.sha256,"sha256",!0,g0(l.sha256,10,6))]})),te("Timestamps",y.jsx(nD,{className:"text-chip-sky-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[P("Created",l.created,"created",!0),P("Modified",l.modified,"modified",!0)]})),te("Identity",y.jsx(Bg,{className:"text-chip-indigo-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[P("Type",l.type,"type"),l.attributes.stem&&P("Stem",l.attributes.stem,"attrStem"),P("Extension",l.name.includes(".")?l.name.slice(l.name.lastIndexOf(".")):"None","extension"),P("Directory",T8(l.path)||"None","directory",!0)]})),te("System",y.jsx(Bg,{className:"text-status-success-text h-3.5 w-3.5"}),y.jsxs("div",{children:[y.jsxs("div",{className:"mb-1 flex min-h-[24px] flex-wrap items-center gap-1.5",children:[l.attributes.is_readonly&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-status-danger-border bg-status-danger-bg px-2 py-0.5 text-xs text-status-danger-text",children:[y.jsx(WD,{className:"h-3 w-3"})," Read-only"]}),l.attributes.is_hidden&&y.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-line bg-elevated px-2 py-0.5 text-xs text-ink-muted",children:[y.jsx(OD,{className:"h-3 w-3"})," Hidden"]}),!l.attributes.is_readonly&&!l.attributes.is_hidden&&!l.attributes.is_symlink&&y.jsx("span",{className:"text-xs text-ink-muted",children:"No special flags"})]}),y.jsxs("div",{className:"space-y-0.5",children:[P("File Type",l.attributes.is_file?"Regular File":l.attributes.is_dir?"Directory":"Other","fileType"),l.attributes.permissions&&P("Permissions",l.attributes.permissions,"permissions",!0),l.attributes.owner_uid!==void 0&&P("Owner UID",String(l.attributes.owner_uid),"ownerUid"),l.attributes.group_gid!==void 0&&P("Group GID",String(l.attributes.group_gid),"groupGid")]})]}))]})]})]}),y.jsx("div",{className:"flex-shrink-0 border-t border-line px-6 py-3",children:y.jsxs("div",{className:"flex justify-between items-center gap-2",children:[y.jsx("p",{className:"min-w-0 text-xs text-ink-muted truncate",children:C??"Click the copy icon next to any field to copy its value"}),y.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap",children:[y.jsx(Xe,{text:"Show file in Explorer",block:!1,children:y.jsxs("button",{onClick:()=>void D("reveal","Revealed in Explorer",()=>QC(F.path)),disabled:w!==null,className:R("reveal"),children:[y.jsx(_0,{className:"h-3.5 w-3.5"})," Reveal"]})}),y.jsx(Xe,{text:"Launch file with default association",block:!1,children:y.jsxs("button",{onClick:()=>{i&&(S("launch"),Promise.resolve(i(F)).finally(()=>S(null)))},disabled:w!==null||!i,className:R("launch"),children:[y.jsx(Ul,{className:"h-3.5 w-3.5"})," Launch"]})}),y.jsx(Xe,{text:"Open containing folder",block:!1,children:y.jsxs("button",{onClick:()=>void D("folder","Opened folder",()=>j0(F.path)),disabled:w!==null,className:R("folder"),children:[y.jsx(Hl,{className:"h-3.5 w-3.5"})," Open Folder"]})}),y.jsx("button",{onClick:t,className:"btn btn-primary px-4 py-2",children:"Close"})]})]})})]}),y.jsx(dA,{isOpen:b,onClose:()=>v(!1),initialFilePath:e.path,md5:l==null?void 0:l.md5})]})}const D8=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"],R8=250,j8=400,_8=.7;function L8(n,e=j8,t=_8){const i=n.videoWidth,l=n.videoHeight;if(!i||!l)return null;const o=Math.min(i,l),a=document.createElement("canvas");a.width=Math.min(e,o),a.height=a.width;const u=a.getContext("2d");if(!u)return null;u.drawImage(n,(i-o)/2,(l-o)/2,o,o,0,0,a.width,a.height);const f=a.toDataURL("image/jpeg",t);return f.slice(f.indexOf(",")+1)}function z8(n,e){const t=n.intervalMs??R8;let i=!1,l=!1;const o=()=>{i=!0,clearInterval(a)},a=setInterval(()=>{if(i||l)return;const u=n.capture();u&&(l=!0,n.decode(u).then(f=>{i||f.decoded&&(o(),e.onDetected(f.decoded))}).catch(f=>{i||(o(),e.onError(f instanceof Error?f.message:"Frame decoding failed"))}).finally(()=>{l=!1}))},t);return o}const B8=8e3;function P8({isOpen:n,onClose:e,onDetected:t}){const i=E.useRef(null),l=E.useRef(null),o=Wl({isOpen:n,onClose:e,dialogRef:l}),a=E.useRef(null),u=E.useRef(null),f=E.useRef(null),[d,m]=E.useState(null),[g,b]=E.useState(!1),v=()=>{f.current&&(f.current(),f.current=null),u.current&&(cancelAnimationFrame(u.current),u.current=null),a.current&&(a.current.getTracks().forEach(C=>C.stop()),a.current=null),i.current&&(i.current.srcObject=null)};E.useEffect(()=>{if(!n){v(),m(null);return}let C=!0;async function O(){var M,H,B,D,R;if(m(null),b(!1),typeof window<"u"&&!window.isSecureContext&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1"){m("Camera access requires HTTPS or localhost. If connecting across a local network IP (e.g. 192.168.x.x), modern browsers disable camera access for insecure HTTP.");return}const _=((H=(M=navigator.mediaDevices)==null?void 0:M.getUserMedia)==null?void 0:H.bind(navigator.mediaDevices))||((B=navigator.getUserMedia)==null?void 0:B.bind(navigator))||((D=navigator.webkitGetUserMedia)==null?void 0:D.bind(navigator))||((R=navigator.mozGetUserMedia)==null?void 0:R.bind(navigator));if(!_){m(window.isSecureContext?"Camera access is not supported by your browser or environment.":"Camera access is blocked because the page is not served over a secure origin (HTTPS or localhost/127.0.0.1).");return}try{let P;const te=await Promise.race([_({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),new Promise((I,F)=>{P=window.setTimeout(()=>F(new DOMException("Camera did not start in time","TimeoutError")),B8)})]).finally(()=>{P!==void 0&&window.clearTimeout(P)});if(!C){te.getTracks().forEach(I=>I.stop());return}a.current=te,i.current&&(i.current.srcObject=te,await i.current.play()),"BarcodeDetector"in window?S():w()}catch(P){if(!C)return;console.error("Camera access error:",P),m(P.name==="NotAllowedError"||P.name==="PermissionDeniedError"?"Camera permission denied. Please allow camera access in your browser settings.":P.name==="TimeoutError"?"The camera did not start in time. On macOS, camera capture needs the packaged desktop app — a bare Python process cannot access the camera. Alternatively, open ProFiles in Chrome, Edge or Safari.":`Could not access camera: ${P.message||"Unknown error"}`)}}return O(),()=>{C=!1,v()}},[n]);const w=()=>{b(!0),f.current=z8({capture:()=>i.current?L8(i.current):null,decode:C=>jM({imageBase64:C,formats:[...D8]})},{onDetected:C=>{v(),t(C)},onError:C=>{v(),m(C)}})},S=()=>{const C=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"];let O;try{O=new window.BarcodeDetector({formats:C})}catch(M){console.warn("BarcodeDetector formats unsupported:",M),O=new window.BarcodeDetector}const _=async()=>{if(!i.current||i.current.readyState<2){u.current=requestAnimationFrame(_);return}try{const M=await O.detect(i.current);if(M&&M.length>0){const H=M[0].rawValue;if(H){v(),t(H);return}}}catch(M){console.debug("Frame detection error:",M)}u.current=requestAnimationFrame(_)};u.current=requestAnimationFrame(_)};return n?y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:e,children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Camera barcode scanner",onKeyDown:o,className:"relative w-full max-w-lg rounded-2xl border border-frame-line glass-panel p-6 flex flex-col",onClick:C=>C.stopPropagation(),children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(GC,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Scan with Camera"})]}),y.jsx("button",{onClick:e,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink transition-colors","aria-label":"Close",children:y.jsx(bi,{className:"h-4 w-4"})})]}),d?y.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[y.jsx("div",{className:"rounded-full bg-status-danger-bg p-3 text-status-danger-text mb-3",children:y.jsx(Ec,{className:"h-6 w-6"})}),y.jsx("p",{className:"text-xs text-status-danger-text max-w-xs",children:d}),y.jsx("button",{onClick:e,className:"btn btn-secondary mt-6 px-4 py-2",children:"Close"})]}):y.jsxs("div",{className:"flex flex-col items-center",children:[y.jsxs("div",{className:"relative aspect-video w-full overflow-hidden rounded-xl bg-black border border-line flex items-center justify-center",children:[y.jsx("video",{ref:i,playsInline:!0,muted:!0,className:"h-full w-full object-cover"}),y.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:y.jsxs("div",{className:"relative h-48 w-48 rounded-lg border-2 border-dashed border-indigo-400/80 bg-indigo-500/5 shadow-[0_0_0_9999px_rgba(0,0,0,0.45)]",children:[y.jsx("div",{className:"absolute top-0 left-0 h-4 w-4 border-t-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute top-0 right-0 h-4 w-4 border-t-2 border-r-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 left-0 h-4 w-4 border-b-2 border-l-2 border-indigo-400"}),y.jsx("div",{className:"absolute bottom-0 right-0 h-4 w-4 border-b-2 border-r-2 border-indigo-400"})]})})]}),y.jsx("p",{className:"mt-4 text-center text-xs text-ink-muted",children:g?"Hold a QR code or barcode steady in front of your camera — frames are decoded by the local ProFiles server (no native Barcode Detector in this browser).":"Hold a QR code or barcode steady in front of your camera to auto-scan."})]})]})}):null}function H8({isOpen:n,file:e,onConfirm:t,onDismiss:i}){const l=E.useRef(null);return E.useEffect(()=>{var o;if(n){const a=u=>{u.key==="Enter"?(u.preventDefault(),t()):u.key==="Escape"&&(u.preventDefault(),i())};return window.addEventListener("keydown",a),(o=l.current)==null||o.focus(),()=>window.removeEventListener("keydown",a)}},[n,t,i]),!n||!e?null:y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:i,children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`1 file matched: ${e.filename}`,className:"animate-modal-in w-full max-w-sm rounded-xl border border-frame-line glass-panel p-5 flex flex-col gap-4",onClick:o=>o.stopPropagation(),children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink text-sm",children:[e.has_hook?y.jsx(N4,{className:"h-4 w-4 text-chip-purple-text"}):y.jsx(Ul,{className:"h-4 w-4 text-status-success-text"}),y.jsx("span",{children:"1 File Matched"})]}),y.jsx("button",{onClick:i,className:"focus-ring rounded p-1 text-ink-muted hover:bg-elevated hover:text-ink","aria-label":"Dismiss",children:y.jsx(bi,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-line bg-elevated/50 p-3",children:[y.jsx(sa,{className:"h-5 w-5 text-chip-indigo-text shrink-0 mt-0.5"}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h4",{className:"text-xs font-semibold text-ink truncate",children:e.filename}),y.jsx("p",{className:"text-[11px] text-ink-muted truncate mt-0.5",children:e.rel_path||e.path}),e.has_hook&&y.jsx("span",{className:"inline-block mt-1 text-[10px] text-chip-purple-text bg-chip-purple-bg px-1.5 py-0.5 rounded border border-chip-purple-border/50 font-medium",children:"Workflow Hook Configured"})]})]}),y.jsx("p",{className:"text-xs text-ink-muted text-center",children:"Launch this file now?"}),y.jsxs("div",{className:"flex gap-2",children:[y.jsx("button",{type:"button",onClick:i,className:"btn btn-secondary flex-1 px-3 py-1.5",children:"Dismiss (Esc)"}),y.jsxs("button",{ref:l,type:"button",onClick:t,className:"btn btn-primary flex-1 px-3 py-1.5 shadow-md",children:[y.jsx(Ul,{className:"h-3 w-3 fill-current"}),"Launch (Enter)"]})]})]})})}function I8({systemInfo:n,fileCount:e,theme:t,onToggleTheme:i,onOpenLog:l,onOpenConfig:o,onShowShortcuts:a,onReloadConfig:u,onExport:f,exportDisabled:d=!1,language:m="en",onLanguageChange:g,lanEnabled:b,onToggleLan:v}){return y.jsxs("footer",{className:"flex items-center justify-between border-t border-line bg-app px-4 py-2 text-[11px] text-ink-muted transition-colors duration-200",children:[y.jsx("div",{className:"flex items-center gap-4",children:n&&y.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-line bg-surface px-2.5 py-0.5 text-ink-secondary",children:[y.jsx(qM,{className:"h-3 w-3 text-status-success-text"}),y.jsx("a",{href:`http://${n.hostname}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.hostname}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.hostname}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx("a",{href:`http://${n.ip}:${window.location.port}`,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ProFiles on ${n.ip}`,className:"font-mono hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 rounded px-1 py-0.5",children:n.ip}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsxs("span",{className:"flex items-center gap-1",title:"Session user",children:[y.jsx(C4,{className:"h-3 w-3 text-ink-faint"}),y.jsx("span",{children:n.username||"operator"})]}),v!==void 0&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx(Xe,{text:"LAN access",block:!1,children:y.jsxs("button",{onClick:()=>v(b!==!0),disabled:b===null,"aria-pressed":b===!0,className:`focus-ring flex items-center gap-1 rounded px-1 py-0.5 text-[10px] ${b===null?"text-ink-faint cursor-not-allowed":b===!0?"text-status-success-text":"text-ink-muted hover:text-ink"}`,children:[y.jsx(t4,{className:"h-3 w-3"}),y.jsx("span",{children:"LAN"})]})})]})]})}),y.jsxs("div",{className:"flex items-center gap-3",children:[y.jsxs("span",{children:[y.jsx("strong",{className:"text-ink",children:e})," files found"]}),y.jsx("span",{className:"text-ink-faint",children:"|"}),y.jsx(Xe,{text:"Keyboard shortcuts (?)",block:!1,children:y.jsxs("button",{onClick:a,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(WC,{className:"h-3 w-3"}),y.jsx("span",{children:"Shortcuts"})]})}),y.jsx(Xe,{text:"Open the application log viewer",block:!1,children:y.jsxs("button",{onClick:l,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(sa,{className:"h-3 w-3"}),y.jsx("span",{children:"Logs"})]})}),y.jsx("span",{className:"text-ink-faint",children:"|"}),u&&y.jsx(Xe,{text:"Reload configuration from disk",block:!1,children:y.jsxs("button",{onClick:u,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(Md,{className:"h-3 w-3"}),y.jsx("span",{children:"Reload"})]})}),f&&y.jsx(Xe,{text:"Export the current results as CSV",block:!1,children:y.jsxs("button",{onClick:f,disabled:d,className:"focus-ring flex items-center gap-1 rounded text-ink-muted hover:text-ink disabled:opacity-40 disabled:hover:text-ink-muted",children:[y.jsx(YC,{className:"h-3 w-3"}),y.jsx("span",{children:"Export CSV"})]})}),g&&y.jsxs("div",{className:"flex items-center overflow-hidden rounded border border-line text-[10px]",children:[y.jsx(Xe,{text:"English",block:!1,children:y.jsxs("button",{onClick:()=>g("en"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="en"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:[y.jsx(FD,{className:"h-3 w-3"}),y.jsx("span",{children:"EN"})]})}),y.jsx(Xe,{text:"Français",block:!1,children:y.jsx("button",{onClick:()=>g("fr"),className:`flex items-center gap-1 px-1.5 py-0.5 transition-colors ${m==="fr"?"bg-indigo-600 text-white focus-ring":"text-ink-muted hover:text-ink focus-ring"}`,children:y.jsx("span",{children:"FR"})})})]}),y.jsx(Xe,{text:"Open the configuration editor",block:!1,children:y.jsxs("button",{onClick:o,className:"focus-ring flex items-center gap-1 text-ink-muted hover:text-ink",children:[y.jsx(g4,{className:"h-3 w-3"}),y.jsx("span",{children:"Config"})]})}),y.jsx(Xe,{text:`Switch to ${t==="dark"?"light":"dark"} mode`,block:!1,children:y.jsxs("button",{onClick:i,className:"focus-ring flex items-center gap-1 rounded px-1.5 py-0.5 text-ink-muted hover:bg-elevated hover:text-status-warning-text",children:[t==="dark"?y.jsx(y4,{className:"h-3 w-3 text-status-warning-text"}):y.jsx(JD,{className:"h-3 w-3 text-chip-indigo-text"}),y.jsx("span",{children:t==="dark"?"Light":"Dark"})]})})]})]})}const U8=[{label:"5 seconds",seconds:5},{label:"10 seconds",seconds:10},{label:"30 seconds",seconds:30},{label:"1 minute",seconds:60},{label:"5 minutes",seconds:300}];function F8({isOpen:n,currentInterval:e,onClose:t,onSetInterval:i}){const l=E.useRef(null),o=Wl({isOpen:n,onClose:t,dialogRef:l});if(!n)return null;const a=e>0,u=m=>{i(m)},f=m=>{m.preventDefault();const b=m.currentTarget.elements.namedItem("custom-interval"),v=parseInt(b.value,10);!isNaN(v)&&v>0&&i(v)},d=()=>{i(0)};return y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",children:y.jsxs("div",{ref:l,role:"dialog","aria-modal":"true","aria-label":"Auto-Rescan Timer",onKeyDown:o,className:"animate-modal-in w-[420px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2 font-semibold text-ink",children:[y.jsx(tO,{className:"h-5 w-5 text-chip-indigo-text"}),y.jsx("span",{children:"Auto-Rescan Timer"})]}),y.jsx("button",{onClick:t,className:"focus-ring rounded-lg p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(bi,{className:"h-4 w-4"})})]}),y.jsx("div",{className:"mb-4 rounded-lg bg-elevated/50 px-3 py-2 text-xs",children:a?y.jsxs("div",{className:"flex items-center gap-2 text-status-success-text",children:[y.jsx(xD,{className:"h-4 w-4 animate-pulse"}),y.jsxs("span",{children:["Auto-rescan every ",e,"s"]})]}):y.jsxs("div",{className:"flex items-center gap-2 text-ink-secondary",children:[y.jsx(pD,{className:"h-4 w-4"}),y.jsx("span",{children:"Auto-rescan is disabled"})]})}),y.jsxs("div",{className:"mb-4 space-y-1 text-xs",children:[y.jsx("p",{className:"text-ink-muted",children:"Presets:"}),y.jsx("div",{className:"grid grid-cols-2 gap-2",children:U8.map(m=>y.jsx("button",{onClick:()=>u(m.seconds),className:"rounded-lg border border-line bg-elevated/50 px-3 py-1.5 text-left font-medium text-ink-secondary hover:border-chip-indigo-border hover:bg-chip-indigo-bg/40 hover:text-chip-indigo-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:m.label},m.seconds))})]}),y.jsxs("form",{onSubmit:f,className:"mb-4",children:[y.jsxs("label",{className:"flex items-center gap-2 text-xs font-medium text-ink-secondary",children:[y.jsx(vD,{className:"h-3.5 w-3.5"}),y.jsx("span",{children:"Custom interval (seconds):"})]}),y.jsxs("div",{className:"mt-1 flex gap-2",children:[y.jsx("input",{type:"number",name:"custom-interval",min:"1",placeholder:"e.g. 45",className:"flex-1 rounded-lg border border-line bg-app px-2 py-1 text-xs text-ink placeholder-ink-faint focus:border-indigo-500 focus:outline-none"}),y.jsx("button",{type:"submit",className:"btn btn-primary rounded-lg px-3 py-1 font-semibold",children:"Set"})]})]}),a&&y.jsx("button",{onClick:d,className:"btn w-full rounded-lg border-line bg-elevated/50 px-3 py-2 text-status-warning-text hover:border-status-warning-border hover:bg-status-warning-bg/40",children:"Stop Auto-Rescan"}),y.jsx("div",{className:"flex justify-end gap-2 border-t border-line pt-3",children:y.jsx("button",{onClick:t,className:"rounded-lg border border-line bg-elevated px-4 py-2 text-xs font-semibold text-ink-secondary hover:bg-elevated/70 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:"Close"})})]})})}function V8(n,e){const t={};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const q8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Q8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,X8={};function Z2(n,e){return(X8.jsx?Q8:q8).test(n)}const $8=/[ \t\n\f\r]/g;function G8(n){return typeof n=="object"?n.type==="text"?J2(n.value):!1:J2(n)}function J2(n){return n.replace($8,"")===""}class du{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}du.prototype.normal={};du.prototype.property={};du.prototype.space=void 0;function pA(n,e){const t={},i={};for(const l of n)Object.assign(t,l.property),Object.assign(i,l.normal);return new du(t,i,e)}function Bx(n){return n.toLowerCase()}class li{constructor(e,t){this.attribute=t,this.property=e}}li.prototype.attribute="";li.prototype.booleanish=!1;li.prototype.boolean=!1;li.prototype.commaOrSpaceSeparated=!1;li.prototype.commaSeparated=!1;li.prototype.defined=!1;li.prototype.mustUseProperty=!1;li.prototype.number=!1;li.prototype.overloadedBoolean=!1;li.prototype.property="";li.prototype.spaceSeparated=!1;li.prototype.space=void 0;let Y8=0;const Qe=Vs(),Zt=Vs(),Px=Vs(),ge=Vs(),Ct=Vs(),Bs=Vs(),gi=Vs();function Vs(){return 2**++Y8}const Hx=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:Zt,commaOrSpaceSeparated:gi,commaSeparated:Bs,number:ge,overloadedBoolean:Px,spaceSeparated:Ct},Symbol.toStringTag,{value:"Module"})),x0=Object.keys(Hx);class Vy extends li{constructor(e,t,i,l){let o=-1;if(super(e,t),eC(this,"space",l),typeof i=="number")for(;++o4&&t.slice(0,4)==="data"&&eP.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(tC,iP);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!tC.test(o)){let a=o.replace(J8,nP);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}l=Vy}return new l(i,e)}function nP(n){return"-"+n.toLowerCase()}function iP(n){return n.charAt(1).toUpperCase()}const rP=pA([gA,K8,bA,vA,wA],"html"),qy=pA([gA,W8,bA,vA,wA],"svg");function lP(n){return n.join(" ").trim()}var nC=/\/\*(?:[^*]|\*(?!\/))*\*\//g,sP=/\n/g,oP=/^\s*/,aP=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,cP=/^:\s*/,uP=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,fP=/^[;\s]*/,hP=` +`,iC="/",rC="*",wc="",dP="comment",mP="declaration";function pP(n,e){if(typeof n!="string")throw new TypeError("First argument must be a string");if(!n)return[];e=e||{};var t=1,i=1;function l(w){var S=w.match(sP);S&&(t+=S.length);var C=w.lastIndexOf(hP);i=~C?w.length-C:i+w.length}function o(){var w={line:t,column:i};return function(S){return S.position=new a(w),d(),S}}function a(w){this.start=w,this.end={line:t,column:i},this.source=e.source}a.prototype.content=n;function u(w){var S=new Error(e.source+":"+t+":"+i+": "+w);if(S.reason=w,S.filename=e.source,S.line=t,S.column=i,S.source=n,!e.silent)throw S}function f(w){var S=w.exec(n);if(S){var C=S[0];return l(C),n=n.slice(C.length),S}}function d(){f(oP)}function m(w){for(var S;S=g();)w.push(S);return w}function g(){var w=o();if(!(iC!=n.charAt(0)||rC!=n.charAt(1))){for(var S=2;wc!=n.charAt(S)&&(rC!=n.charAt(S)||iC!=n.charAt(S+1));)++S;if(S+=2,wc===n.charAt(S-1))return u("End of comment missing");var C=n.slice(2,S-2);return i+=2,l(C),n=n.slice(S),i+=2,w({type:dP,comment:C})}}function b(){var w=o(),S=f(aP);if(S){if(g(),!f(cP))return u("property missing ':'");var C=f(uP),O=w({type:mP,property:S[0].replace(nC,wc).trim(),value:C?C[0].replace(nC,wc).trim():wc});return f(fP),O}}function v(){var w=[];m(w);for(var S;S=b();)w.push(S),m(w);return w}return d(),v()}function gP(n,e){let t=null;if(!n||typeof n!="string")return t;const i=pP(n),l=typeof e=="function";return i.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:u}=o;l?e(a,u,o):u&&(t=t??{},t[a]=u)}),t}const kA=SA("end"),Qy=SA("start");function SA(n){return e;function e(t){const i=t&&t.position&&t.position[n]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function xP(n){const e=Qy(n),t=kA(n);if(e&&t)return{start:e,end:t}}function Pc(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?lC(n.position):"start"in n||"end"in n?lC(n):"line"in n||"column"in n?Ix(n):""}function Ix(n){return sC(n&&n.line)+":"+sC(n&&n.column)}function lC(n){return Ix(n&&n.start)+"-"+Ix(n&&n.end)}function sC(n){return n&&typeof n=="number"?n:1}class _n extends Error{constructor(e,t,i){super(),typeof t=="string"&&(i=t,t=void 0);let l="",o={},a=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?l=e:!o.cause&&e&&(a=!0,l=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof i=="string"){const f=i.indexOf(":");f===-1?o.ruleId=i:(o.source=i.slice(0,f),o.ruleId=i.slice(f+1))}if(!o.place&&o.ancestors&&o.ancestors){const f=o.ancestors[o.ancestors.length-1];f&&(o.place=f.position)}const u=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=u?u.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=u?u.line:void 0,this.name=Pc(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}_n.prototype.file="";_n.prototype.name="";_n.prototype.reason="";_n.prototype.message="";_n.prototype.stack="";_n.prototype.column=void 0;_n.prototype.line=void 0;_n.prototype.ancestors=void 0;_n.prototype.cause=void 0;_n.prototype.fatal=void 0;_n.prototype.place=void 0;_n.prototype.ruleId=void 0;_n.prototype.source=void 0;const Xy={}.hasOwnProperty,yP=new Map,bP=/[A-Z]/g,vP=/-([a-z])/g,wP=new Set(["table","tbody","thead","tfoot","tr"]),kP=new Set(["td","th"]),CA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function SP(n,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=e.filePath||void 0;let i;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=DP(t,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=MP(t,e.jsx,e.jsxs)}const l={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:i,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?qy:rP,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=OA(l,n,void 0);return o&&typeof o!="string"?o:l.create(n,l.Fragment,{children:o||void 0},void 0)}function OA(n,e,t){if(e.type==="element")return CP(n,e,t);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return OP(n,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return NP(n,e,t);if(e.type==="mdxjsEsm")return TP(n,e);if(e.type==="root")return AP(n,e,t);if(e.type==="text")return EP(n,e)}function CP(n,e,t){const i=n.schema;let l=i;e.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=qy,n.schema=l),n.ancestors.push(e);const o=NA(n,e.tagName,!1),a=RP(n,e);let u=Gy(n,e);return wP.has(e.tagName)&&(u=u.filter(function(f){return typeof f=="string"?!G8(f):!0})),TA(n,a,o,e),$y(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function OP(n,e){if(e.data&&e.data.estree&&n.evaluater){const i=e.data.estree.body[0];return i.type,n.evaluater.evaluateExpression(i.expression)}ru(n,e.position)}function TP(n,e){if(e.data&&e.data.estree&&n.evaluater)return n.evaluater.evaluateProgram(e.data.estree);ru(n,e.position)}function NP(n,e,t){const i=n.schema;let l=i;e.name==="svg"&&i.space==="html"&&(l=qy,n.schema=l),n.ancestors.push(e);const o=e.name===null?n.Fragment:NA(n,e.name,!0),a=jP(n,e),u=Gy(n,e);return TA(n,a,o,e),$y(a,u),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function AP(n,e,t){const i={};return $y(i,Gy(n,e)),n.create(e,n.Fragment,i,t)}function EP(n,e){return e.value}function TA(n,e,t,i){typeof t!="string"&&t!==n.Fragment&&n.passNode&&(e.node=i)}function $y(n,e){if(e.length>0){const t=e.length>1?e:e[0];t&&(n.children=t)}}function MP(n,e,t){return i;function i(l,o,a,u){const d=Array.isArray(a.children)?t:e;return u?d(o,a,u):d(o,a)}}function DP(n,e){return t;function t(i,l,o,a){const u=Array.isArray(o.children),f=Qy(i);return e(l,o,a,u,{columnNumber:f?f.column-1:void 0,fileName:n,lineNumber:f?f.line:void 0},void 0)}}function RP(n,e){const t={};let i,l;for(l in e.properties)if(l!=="children"&&Xy.call(e.properties,l)){const o=_P(n,l,e.properties[l]);if(o){const[a,u]=o;n.tableCellAlignToStyle&&a==="align"&&typeof u=="string"&&kP.has(e.tagName)?i=u:t[a]=u}}if(i){const o=t.style||(t.style={});o[n.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return t}function jP(n,e){const t={};for(const i of e.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&n.evaluater){const o=i.data.estree.body[0];o.type;const a=o.expression;a.type;const u=a.properties[0];u.type,Object.assign(t,n.evaluater.evaluateExpression(u.argument))}else ru(n,e.position);else{const{name:l}=i;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&n.evaluater){const u=i.value.data.estree.body[0];u.type,o=n.evaluater.evaluateExpression(u.expression)}else ru(n,e.position);else o=i.value===null?!0:i.value;t[l]=o}return t}function Gy(n,e){const t=[];let i=-1;const l=n.passKeys?new Map:yP;for(;++il?0:l+e:e=e>l?l:e,t=t>0?t:0,i.length<1e4)a=Array.from(i),a.unshift(e,t),n.splice(...a);else for(t&&n.splice(e,t);o0?(Yi(n,n.length,0,e),n):e}const cC={}.hasOwnProperty;function EA(n){const e={};let t=-1;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function Ki(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=Zl(/[A-Za-z]/),On=Zl(/[\dA-Za-z]/),qP=Zl(/[#-'*+\--9=?A-Z^-~]/);function Sd(n){return n!==null&&(n<32||n===127)}const Ux=Zl(/\d/),QP=Zl(/[\dA-Fa-f]/),DA=Zl(/[!-/:-@[-`{-~]/);function He(n){return n!==null&&n<-2}function Tt(n){return n!==null&&(n<0||n===32)}function Je(n){return n===-2||n===-1||n===32}const $d=Zl(new RegExp("\\p{P}|\\p{S}","u")),Us=Zl(/\s/);function Zl(n){return e;function e(t){return t!==null&&t>-1&&n.test(String.fromCharCode(t))}}function wa(n){const e=[];let t=-1,i=0,l=0;for(;++t55295&&o<57344){const u=n.charCodeAt(t+1);o<56320&&u>56319&&u<57344?(a=String.fromCharCode(o,u),l=1):a="�"}else a=String.fromCharCode(o);a&&(e.push(n.slice(i,t),encodeURIComponent(a)),i=t+l+1,a=""),l&&(t+=l,l=0)}return e.join("")+n.slice(i)}function ft(n,e,t,i){const l=i?i-1:1/0;let o=0;return a;function a(f){return Je(f)?(n.enter(t),u(f)):e(f)}function u(f){return Je(f)&&o++=l?e(m):t(m)}}const XP={tokenize:$P};function $P(n){const e=n.attempt(this.parser.constructs.contentInitial,i,l);let t;return e;function i(u){if(u===null){n.consume(u);return}return n.enter("lineEnding"),n.consume(u),n.exit("lineEnding"),ft(n,e,"linePrefix")}function l(u){return n.enter("paragraph"),o(u)}function o(u){const f=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=f),t=f,a(u)}function a(u){if(u===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(u);return}return He(u)?(n.consume(u),n.exit("chunkText"),o):(n.consume(u),a)}}let Cd=class{constructor(){this.index=new Map,this.map=[]}add(e,t,i){uC(this,e,t,i,!1)}addBefore(e,t,i){uC(this,e,t,i,!0)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}};function uC(n,e,t,i,l){if(t===0&&i.length===0)return;const o=n.index.get(e);if(o){o[1]+=t,l?(i.push(...o[2]),o[2]=i):o[2].push(...i);return}const a=[e,t,i];n.map.push(a),n.index.set(e,a)}const GP={tokenize:YP},fC={tokenize:KP};function YP(n){const e=this,t=[];let i=0,l,o,a;return u;function u(M){if(ia))return;const R=e.events.length;let P=R,te,I;for(;P--;)if(e.events[P][0]==="exit"&&e.events[P][1].type==="chunkFlow"){if(te){I=e.events[P][1].end;break}te=!0}for(O(i),D=R;DM;){const B=t[H];e.containerState=B[1],B[0].exit.call(e,n)}t.length=M}function _(){l.write([null]),o=void 0,l=void 0,e.containerState._closeFlow=void 0}}function KP(n,e,t){return ft(n,n.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Yl(n){if(n===null||Tt(n)||Us(n))return 1;if($d(n))return 2}function Gd(n,e,t){const i=[];let l=-1;for(;++l1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1,a={...n[l][1].end},u={...n[t][1].start};hC(a,-o),hC(u,o);const f={type:o>1?"strongSequence":"emphasisSequence",start:a,end:{...n[l][1].end}},d={type:o>1?"strongSequence":"emphasisSequence",start:{...n[t][1].start},end:u},m={type:o>1?"strongText":"emphasisText",start:{...n[l][1].end},end:{...n[t][1].start}},g={type:o>1?"strong":"emphasis",start:{...f.start},end:{...d.end}};n[l][1].end={...f.start},n[t][1].start={...d.end},i=[],n[l][1].end.offset-n[l][1].start.offset&&(i=Di(i,[["enter",n[l][1],e],["exit",n[l][1],e]])),i=Di(i,[["enter",g,e],["enter",f,e],["exit",f,e],["enter",m,e]]),i=Di(i,Gd(e.parser.constructs.insideSpan.null,n.slice(l+1,t),e)),i=Di(i,[["exit",m,e],["enter",d,e],["exit",d,e],["exit",g,e]]);let b=0;n[t][1].end.offset-n[t][1].start.offset&&(b=2,i=Di(i,[["enter",n[t][1],e],["exit",n[t][1],e]])),Yi(n,l-1,t-l+3,i),t=l+i.length-b-2;break}}for(t=-1;++t0&&Je(D)?ft(n,_,"linePrefix",o+1)(D):_(D)}function _(D){return D===null||He(D)?n.check(Vx,S,H)(D):(n.enter("codeFlowValue"),M(D))}function M(D){return D===null||He(D)?(n.exit("codeFlowValue"),_(D)):(n.consume(D),M)}function H(D){return n.exit("codeFenced"),e(D)}function B(D,R,P){let te=0;return I;function I(ie){return D.enter("lineEnding"),D.consume(ie),D.exit("lineEnding"),F}function F(ie){return D.enter("codeFencedFence"),Je(ie)?ft(D,A,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(ie):A(ie)}function A(ie){return ie===u?(D.enter("codeFencedFenceSequence"),ne(ie)):P(ie)}function ne(ie){return ie===u?(te++,D.consume(ie),ne):te>=a?(D.exit("codeFencedFenceSequence"),Je(ie)?ft(D,ae,"whitespace")(ie):ae(ie)):P(ie)}function ae(ie){return ie===null||He(ie)?(D.exit("codeFencedFence"),R(ie)):P(ie)}}}const b0={name:"codeIndented",tokenize:uH},cH={partial:!0,tokenize:fH};function uH(n,e,t){return i;function i(u){return n.enter("codeIndented"),RA(n,l,t,"linePrefix",4,4)(u)}function l(u){return u===null?a(u):He(u)?n.attempt(cH,l,a)(u):(n.enter("codeFlowValue"),o(u))}function o(u){return u===null||He(u)?(n.exit("codeFlowValue"),l(u)):(n.consume(u),o)}function a(u){return n.exit("codeIndented"),e(u)}}function fH(n,e,t){const i=this;return l;function l(a){return i.parser.lazy[i.now().line]?t(a):He(a)?(n.enter("lineEnding"),n.consume(a),n.exit("lineEnding"),l):RA(n,e,o,"linePrefix",4,4)(a)}function o(a){return He(a)?l(a):t(a)}}const hH={name:"codeText",previous:mH,resolve:dH,tokenize:pH};function dH(n){let e=n.length-4,t=3,i,l;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[e][1].type==="lineEnding"||n[e][1].type==="space")){for(i=t;++i=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,t,i){const l=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-l,Number.POSITIVE_INFINITY);return i&&kc(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),kc(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),kc(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e=4?e(a):n.interrupt(i.parser.constructs.flow,t,e)(a)}}function BA(n,e,t,i,l,o,a,u,f){const d=f||Number.POSITIVE_INFINITY;let m=0;return g;function g(O){return O===60?(n.enter(i),n.enter(l),n.enter(o),n.consume(O),n.exit(o),b):O===null||O===32||O===41||Sd(O)?t(O):(n.enter(i),n.enter(a),n.enter(u),n.enter("chunkString",{contentType:"string"}),S(O))}function b(O){return O===62?(n.enter(o),n.consume(O),n.exit(o),n.exit(l),n.exit(i),e):(n.enter(u),n.enter("chunkString",{contentType:"string"}),v(O))}function v(O){return O===62?(n.exit("chunkString"),n.exit(u),b(O)):O===null||O===60||He(O)?t(O):(n.consume(O),O===92?w:v)}function w(O){return O===60||O===62||O===92?(n.consume(O),v):v(O)}function S(O){return!m&&(O===null||O===41||Tt(O))?(n.exit("chunkString"),n.exit(u),n.exit(a),n.exit(i),e(O)):m999||v===null||v===91||v===93&&!f||v===94&&!u&&"_hiddenFootnoteSupport"in a.parser.constructs?t(v):v===93?(n.exit(o),n.enter(l),n.consume(v),n.exit(l),n.exit(i),e):He(v)?(n.enter("lineEnding"),n.consume(v),n.exit("lineEnding"),m):(n.enter("chunkString",{contentType:"string"}),g(v))}function g(v){return v===null||v===91||v===93||He(v)||u++>999?(n.exit("chunkString"),m(v)):(n.consume(v),f||(f=!Je(v)),v===92?b:g)}function b(v){return v===91||v===92||v===93?(n.consume(v),u++,g):g(v)}}function HA(n,e,t,i,l,o){let a;return u;function u(b){return b===34||b===39||b===40?(n.enter(i),n.enter(l),n.consume(b),n.exit(l),a=b===40?41:b,f):t(b)}function f(b){return b===a?(n.enter(l),n.consume(b),n.exit(l),n.exit(i),e):(n.enter(o),d(b))}function d(b){return b===a?(n.exit(o),f(a)):b===null?t(b):He(b)?(n.enter("lineEnding"),n.consume(b),n.exit("lineEnding"),ft(n,d,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===a||b===null||He(b)?(n.exit("chunkString"),d(b)):(n.consume(b),b===92?g:m)}function g(b){return b===a||b===92?(n.consume(b),m):m(b)}}function Hc(n,e){let t;return i;function i(l){return He(l)?(n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),t=!0,i):Je(l)?ft(n,i,t?"linePrefix":"lineSuffix")(l):e(l)}}const SH={name:"definition",tokenize:OH},CH={partial:!0,tokenize:TH};function OH(n,e,t){const i=this;let l;return o;function o(v){return n.enter("definition"),a(v)}function a(v){return PA.call(i,n,u,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function u(v){return l=Ki(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),v===58?(n.enter("definitionMarker"),n.consume(v),n.exit("definitionMarker"),f):t(v)}function f(v){return Tt(v)?Hc(n,d)(v):d(v)}function d(v){return BA(n,m,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function m(v){return n.attempt(CH,g,g)(v)}function g(v){return Je(v)?ft(n,b,"whitespace")(v):b(v)}function b(v){return v===null||He(v)?(n.exit("definition"),i.parser.defined.push(l),e(v)):t(v)}}function TH(n,e,t){return i;function i(u){return Tt(u)?Hc(n,l)(u):t(u)}function l(u){return HA(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(u)}function o(u){return Je(u)?ft(n,a,"whitespace")(u):a(u)}function a(u){return u===null||He(u)?e(u):t(u)}}const NH={name:"hardBreakEscape",tokenize:AH};function AH(n,e,t){return i;function i(o){return n.enter("hardBreakEscape"),n.consume(o),l}function l(o){return He(o)?(n.exit("hardBreakEscape"),e(o)):t(o)}}const EH={name:"headingAtx",resolve:MH,tokenize:DH};function MH(n,e){let t=n.length-2,i=3;if(n[i][1].type==="whitespace"&&(i+=2),t-2>i&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(i===t-1||t-4>i&&n[t-2][1].type==="whitespace")&&(t-=i+1===t?2:4),t>i){const l={type:"atxHeadingText",start:n[i][1].start,end:n[t][1].end},o={type:"chunkText",start:n[i][1].start,end:n[t][1].end,contentType:"text"};Yi(n,i,t-i+1,[["enter",l,e],["enter",o,e],["exit",o,e],["exit",l,e]])}return n}function DH(n,e,t){let i=0;return l;function l(m){return n.enter("atxHeading"),o(m)}function o(m){return n.enter("atxHeadingSequence"),a(m)}function a(m){return m===35&&i++<6?(n.consume(m),a):m===null||Tt(m)?(n.exit("atxHeadingSequence"),u(m)):t(m)}function u(m){return m===35?(n.enter("atxHeadingSequence"),f(m)):m===null||He(m)?(n.exit("atxHeading"),e(m)):Je(m)?ft(n,u,"whitespace")(m):(n.enter("atxHeadingText"),d(m))}function f(m){return m===35?(n.consume(m),f):(n.exit("atxHeadingSequence"),u(m))}function d(m){return m===null||m===35||Tt(m)?(n.exit("atxHeadingText"),u(m)):(n.consume(m),d)}}const IA=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],qx=["pre","script","style","textarea"],RH={concrete:!0,name:"htmlFlow",resolveTo:_H,tokenize:LH},jH={partial:!0,tokenize:zH};function _H(n){let e=n.length;for(;e--&&!(n[e][0]==="enter"&&n[e][1].type==="htmlFlow"););return e>1&&n[e-2][1].type==="linePrefix"&&(n[e][1].start=n[e-2][1].start,n[e+1][1].start=n[e-2][1].start,n.splice(e-2,2)),n}function LH(n,e,t){const i=this;let l,o,a,u,f;return d;function d(z){return m(z)}function m(z){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(z),g}function g(z){return z===33?(n.consume(z),b):z===47?(n.consume(z),o=!0,S):z===63?(n.consume(z),l=3,i.interrupt?e:N):Cn(z)?(n.consume(z),a=String.fromCharCode(z),C):t(z)}function b(z){return z===45?(n.consume(z),l=2,v):z===91?(n.consume(z),l=5,u=0,w):Cn(z)?(n.consume(z),l=4,i.interrupt?e:N):t(z)}function v(z){return z===45?(n.consume(z),i.interrupt?e:N):t(z)}function w(z){const j="CDATA[";return z===j.charCodeAt(u++)?(n.consume(z),u===j.length?i.interrupt?e:A:w):t(z)}function S(z){return Cn(z)?(n.consume(z),a=String.fromCharCode(z),C):t(z)}function C(z){if(z===null||z===47||z===62||Tt(z)){const j=z===47,q=a.toLowerCase();return!j&&!o&&qx.includes(q)?(l=1,i.interrupt?e(z):A(z)):IA.includes(a.toLowerCase())?(l=6,j?(n.consume(z),O):i.interrupt?e(z):A(z)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?t(z):o?_(z):M(z))}return z===45||On(z)?(n.consume(z),a+=String.fromCharCode(z),C):t(z)}function O(z){return z===62?(n.consume(z),i.interrupt?e:A):t(z)}function _(z){return Je(z)?(n.consume(z),_):I(z)}function M(z){return z===47?(n.consume(z),I):z===58||z===95||Cn(z)?(n.consume(z),H):Je(z)?(n.consume(z),M):I(z)}function H(z){return z===45||z===46||z===58||z===95||On(z)?(n.consume(z),H):B(z)}function B(z){return z===61?(n.consume(z),D):Je(z)?(n.consume(z),B):M(z)}function D(z){return z===null||z===60||z===61||z===62||z===96?t(z):z===34||z===39?(n.consume(z),f=z,R):Je(z)?(n.consume(z),D):P(z)}function R(z){return z===f?(n.consume(z),f=null,te):z===null||He(z)?t(z):(n.consume(z),R)}function P(z){return z===null||z===34||z===39||z===47||z===60||z===61||z===62||z===96||Tt(z)?B(z):(n.consume(z),P)}function te(z){return z===47||z===62||Je(z)?M(z):t(z)}function I(z){return z===62?(n.consume(z),F):t(z)}function F(z){return z===null||He(z)?A(z):Je(z)?(n.consume(z),F):t(z)}function A(z){return z===45&&l===2?(n.consume(z),$):z===60&&l===1?(n.consume(z),oe):z===62&&l===4?(n.consume(z),he):z===63&&l===3?(n.consume(z),N):z===93&&l===5?(n.consume(z),Y):He(z)&&(l===6||l===7)?(n.exit("htmlFlowData"),n.check(jH,ye,ne)(z)):z===null||He(z)?(n.exit("htmlFlowData"),ne(z)):(n.consume(z),A)}function ne(z){return n.check(Vx,ae,ye)(z)}function ae(z){return n.enter("lineEnding"),n.consume(z),n.exit("lineEnding"),ie}function ie(z){return z===null||He(z)?ne(z):(n.enter("htmlFlowData"),A(z))}function $(z){return z===45?(n.consume(z),N):A(z)}function oe(z){return z===47?(n.consume(z),a="",Z):A(z)}function Z(z){if(z===62){const j=a.toLowerCase();return qx.includes(j)?(n.consume(z),he):A(z)}return Cn(z)&&a.length<8?(n.consume(z),a+=String.fromCharCode(z),Z):A(z)}function Y(z){return z===93?(n.consume(z),N):A(z)}function N(z){return z===62?(n.consume(z),he):z===45&&l===2?(n.consume(z),N):A(z)}function he(z){return z===null||He(z)?(n.exit("htmlFlowData"),ye(z)):(n.consume(z),he)}function ye(z){return n.exit("htmlFlow"),e(z)}}function zH(n,e,t){return i;function i(l){return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),n.attempt(mu,e,t)}}const BH={name:"htmlText",tokenize:PH};function PH(n,e,t){const i=this;let l,o,a;return u;function u(N){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(N),f}function f(N){return N===33?(n.consume(N),d):N===47?(n.consume(N),B):N===63?(n.consume(N),M):Cn(N)?(n.consume(N),P):t(N)}function d(N){return N===45?(n.consume(N),m):N===91?(n.consume(N),o=0,w):Cn(N)?(n.consume(N),_):t(N)}function m(N){return N===45?(n.consume(N),v):t(N)}function g(N){return N===null?t(N):N===45?(n.consume(N),b):He(N)?(a=g,oe(N)):(n.consume(N),g)}function b(N){return N===45?(n.consume(N),v):g(N)}function v(N){return N===62?$(N):N===45?b(N):g(N)}function w(N){const he="CDATA[";return N===he.charCodeAt(o++)?(n.consume(N),o===he.length?S:w):t(N)}function S(N){return N===null?t(N):N===93?(n.consume(N),C):He(N)?(a=S,oe(N)):(n.consume(N),S)}function C(N){return N===93?(n.consume(N),O):S(N)}function O(N){return N===62?$(N):N===93?(n.consume(N),O):S(N)}function _(N){return N===null||N===62?$(N):He(N)?(a=_,oe(N)):(n.consume(N),_)}function M(N){return N===null?t(N):N===63?(n.consume(N),H):He(N)?(a=M,oe(N)):(n.consume(N),M)}function H(N){return N===62?$(N):M(N)}function B(N){return Cn(N)?(n.consume(N),D):t(N)}function D(N){return N===45||On(N)?(n.consume(N),D):R(N)}function R(N){return He(N)?(a=R,oe(N)):Je(N)?(n.consume(N),R):$(N)}function P(N){return N===45||On(N)?(n.consume(N),P):N===47||N===62||Tt(N)?te(N):t(N)}function te(N){return N===47?(n.consume(N),$):N===58||N===95||Cn(N)?(n.consume(N),I):He(N)?(a=te,oe(N)):Je(N)?(n.consume(N),te):$(N)}function I(N){return N===45||N===46||N===58||N===95||On(N)?(n.consume(N),I):F(N)}function F(N){return N===61?(n.consume(N),A):He(N)?(a=F,oe(N)):Je(N)?(n.consume(N),F):te(N)}function A(N){return N===null||N===60||N===61||N===62||N===96?t(N):N===34||N===39?(n.consume(N),l=N,ne):He(N)?(a=A,oe(N)):Je(N)?(n.consume(N),A):(n.consume(N),ae)}function ne(N){return N===l?(n.consume(N),l=void 0,ie):N===null?t(N):He(N)?(a=ne,oe(N)):(n.consume(N),ne)}function ae(N){return N===null||N===34||N===39||N===60||N===61||N===96?t(N):N===47||N===62||Tt(N)?te(N):(n.consume(N),ae)}function ie(N){return N===47||N===62||Tt(N)?te(N):t(N)}function $(N){return N===62?(n.consume(N),n.exit("htmlTextData"),n.exit("htmlText"),e):t(N)}function oe(N){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(N),n.exit("lineEnding"),Z}function Z(N){return Je(N)?ft(n,Y,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):Y(N)}function Y(N){return n.enter("htmlTextData"),a(N)}}const Wy={name:"labelEnd",resolveAll:FH,resolveTo:VH,tokenize:qH},HH={tokenize:QH},IH={tokenize:XH},UH={tokenize:$H};function FH(n){let e=-1;const t=[];for(;++e0&&l[l.length-1]._balanced;)l.pop();o=l[l.length-1]}return u;function u(b){return o?o._inactive?g(b):(a=i.parser.defined.includes(Ki(i.sliceSerialize({start:o.end,end:i.now()}))),n.enter("labelEnd"),n.enter("labelMarker"),n.consume(b),n.exit("labelMarker"),n.exit("labelEnd"),f):t(b)}function f(b){return b===40?n.attempt(HH,m,a?m:g)(b):b===91?n.attempt(IH,m,a?d:g)(b):a?m(b):g(b)}function d(b){return n.attempt(UH,m,g)(b)}function m(b){return l.pop(),e(b)}function g(b){return o._balanced=!0,t(b)}}function QH(n,e,t){return i;function i(g){return n.enter("resource"),n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),l}function l(g){return Tt(g)?Hc(n,o)(g):o(g)}function o(g){return g===41?m(g):BA(n,a,u,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function a(g){return Tt(g)?Hc(n,f)(g):m(g)}function u(g){return t(g)}function f(g){return g===34||g===39||g===40?HA(n,d,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):m(g)}function d(g){return Tt(g)?Hc(n,m)(g):m(g)}function m(g){return g===41?(n.enter("resourceMarker"),n.consume(g),n.exit("resourceMarker"),n.exit("resource"),e):t(g)}}function XH(n,e,t){const i=this;return l;function l(u){return PA.call(i,n,o,a,"reference","referenceMarker","referenceString")(u)}function o(u){return i.parser.defined.includes(Ki(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(u):t(u)}function a(u){return t(u)}}function $H(n,e,t){return i;function i(o){return n.enter("reference"),n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),l}function l(o){return o===93?(n.enter("referenceMarker"),n.consume(o),n.exit("referenceMarker"),n.exit("reference"),e):t(o)}}const GH={name:"labelStartImage",resolveAll:Wy.resolveAll,tokenize:YH};function YH(n,e,t){const i=this;let l;return o;function o(f){return n.enter("labelImage"),n.enter("labelImageMarker"),n.consume(f),n.exit("labelImageMarker"),a}function a(f){return f===91?(n.enter("labelMarker"),n.consume(f),n.exit("labelMarker"),l=n.exit("labelImage"),u):t(f)}function u(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(f):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(f))}}const KH={name:"labelStartLink",resolveAll:Wy.resolveAll,tokenize:WH};function WH(n,e,t){const i=this;let l;return o;function o(u){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(u),n.exit("labelMarker"),l=n.exit("labelLink"),a}function a(u){return u===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(u):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(u))}}const v0={name:"lineEnding",tokenize:ZH};function ZH(n,e){return t;function t(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),ft(n,e,"linePrefix")}}const Vh={name:"thematicBreak",tokenize:JH};function JH(n,e,t){let i=0,l;return o;function o(d){return n.enter("thematicBreak"),a(d)}function a(d){return l=d,u(d)}function u(d){return d===l?(n.enter("thematicBreakSequence"),f(d)):i>=3&&(d===null||He(d))?(n.exit("thematicBreak"),e(d)):t(d)}function f(d){return d===l?(n.consume(d),i++,f):(n.exit("thematicBreakSequence"),Je(d)?ft(n,u,"whitespace")(d):u(d))}}const Wn={continuation:{tokenize:i7},exit:l7,name:"list",tokenize:n7},e7={partial:!0,tokenize:s7},t7={partial:!0,tokenize:r7};function n7(n,e,t){const i=this,l=i.events[i.events.length-1];let o=l&&l[1].type==="linePrefix"?l[2].sliceSerialize(l[1],!0).length:0,a=0;return u;function u(v){const w=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:Ux(v)){if(i.containerState.type||(i.containerState.type=w,n.enter(w,{_container:!0})),w==="listUnordered")return n.enter("listItemPrefix"),v===42||v===45?n.check(Vh,t,d)(v):d(v);if(!i.interrupt||v===49)return n.enter("listItemPrefix"),n.enter("listItemValue"),f(v)}return t(v)}function f(v){return Ux(v)&&++a<10?(n.consume(v),f):(!i.interrupt||a<2)&&(i.containerState.marker?v===i.containerState.marker:v===41||v===46)?(n.exit("listItemValue"),d(v)):t(v)}function d(v){return n.enter("listItemMarker"),n.consume(v),n.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||v,n.check(mu,i.interrupt?t:m,n.attempt(e7,b,g))}function m(v){return i.containerState.initialBlankLine=!0,o++,b(v)}function g(v){return Je(v)?(n.enter("listItemPrefixWhitespace"),n.consume(v),n.exit("listItemPrefixWhitespace"),b):t(v)}function b(v){return i.containerState.size=o+i.sliceSerialize(n.exit("listItemPrefix"),!0).length,e(v)}}function i7(n,e,t){const i=this;return i.containerState._closeFlow=void 0,n.check(mu,l,o);function l(u){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,ft(n,e,"listItemIndent",i.containerState.size+1)(u)}function o(u){return i.containerState.furtherBlankLines||!Je(u)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(u)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,n.attempt(t7,e,a)(u))}function a(u){return i.containerState._closeFlow=!0,i.interrupt=void 0,ft(n,n.attempt(Wn,e,t),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u)}}function r7(n,e,t){const i=this;return ft(n,l,"listItemIndent",i.containerState.size+1);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?e(o):t(o)}}function l7(n){n.exit(this.containerState.type)}function s7(n,e,t){const i=this;return ft(n,l,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function l(o){const a=i.events[i.events.length-1];return!Je(o)&&a&&a[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}const mC={name:"setextUnderline",resolveTo:o7,tokenize:a7};function o7(n,e){const t=new Cd;let i=n.length,l,o,a;for(;i--;)if(n[i][0]==="enter"){if(n[i][1].type==="content"){l=i;break}n[i][1].type==="paragraph"&&(o=i)}else n[i][1].type==="content"&&t.add(i,1,[]),!a&&n[i][1].type==="definition"&&(a=i);const u={type:"setextHeading",start:{...n[l][1].start},end:{...n[n.length-1][1].end}};return n[o][1].type="setextHeadingText",a?(t.add(o,0,[["enter",u,e]]),t.add(a+1,0,[["exit",n[l][1],e]]),n[l][1].end={...n[a][1].end}):n[l][1]=u,t.add(n.length,0,[["exit",u,e]]),t.consume(n),n}function a7(n,e,t){const i=this;let l;return o;function o(d){let m=i.events.length,g;for(;m--;)if(i.events[m][1].type!=="lineEnding"&&i.events[m][1].type!=="linePrefix"&&i.events[m][1].type!=="content"){g=i.events[m][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(n.enter("setextHeadingLine"),l=d,a(d)):t(d)}function a(d){return n.enter("setextHeadingLineSequence"),u(d)}function u(d){return d===l?(n.consume(d),u):(n.exit("setextHeadingLineSequence"),Je(d)?ft(n,f,"lineSuffix")(d):f(d))}function f(d){return d===null||He(d)?(n.exit("setextHeadingLine"),e(d)):t(d)}}const c7={tokenize:u7};function u7(n){const e=this,t=n.attempt(mu,i,n.attempt(this.parser.constructs.flowInitial,l,ft(n,n.attempt(this.parser.constructs.flow,l,n.attempt(yH,l)),"linePrefix")));return t;function i(o){if(o===null){n.consume(o);return}return n.enter("lineEndingBlank"),n.consume(o),n.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function l(o){if(o===null){n.consume(o);return}return n.enter("lineEnding"),n.consume(o),n.exit("lineEnding"),e.currentConstruct=void 0,t}}const f7={resolveAll:FA()},h7=UA("string"),d7=UA("text");function UA(n){return{resolveAll:FA(n==="text"?m7:void 0),tokenize:e};function e(t){const i=this,l=this.parser.constructs[n],o=t.attempt(l,a,u);return a;function a(m){return d(m)?o(m):u(m)}function u(m){if(m===null){t.consume(m);return}return t.enter("data"),t.consume(m),f}function f(m){return d(m)?(t.exit("data"),o(m)):(t.consume(m),f)}function d(m){if(m===null)return!0;const g=l[m];let b=-1;if(g)for(;++b-1){const u=a[0];typeof u=="string"?a[0]=u.slice(i):a.shift()}o>0&&a.push(n[l].slice(0,o))}return a}function N7(n,e){let t=-1;const i=[];let l;for(;++t0&&l(e.beforeEnter,{..._e,sliceSerialize:ee[ce][2].sliceSerialize},ee[ce][1]),VA.call(xe,ee[ce][1].type)&&xe[ee[ce][1].type].call({..._e,sliceSerialize:ee[ce][2].sliceSerialize},ee[ce][1]),ee[ce][0]==="exit"&&e.afterExit.length>0&&l(e.afterExit,{..._e,sliceSerialize:ee[ce][2].sliceSerialize},ee[ce][1])}if(_e.tokenStack.length>0){const xe=_e.tokenStack[_e.tokenStack.length-1];(xe[1]||gC).call(_e,void 0,xe[0])}for(fe.position={start:Dl(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:Dl(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},ce=-1;++ce0&&(i.className=["language-"+l[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:t}]};return e.meta&&(o.data={meta:e.meta}),n.patch(e,o),o=n.applyData(e,o),o={type:"element",tagName:"pre",properties:{},children:[o]},n.patch(e,o),o}function U7(n,e){const t={type:"element",tagName:"del",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function F7(n,e){const t={type:"element",tagName:"em",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function V7(n,e){const t=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",i=String(e.identifier).toUpperCase(),l=wa(i.toLowerCase()),o=n.footnoteOrder.indexOf(i);let a,u=n.footnoteCounts.get(i);u===void 0?(u=0,n.footnoteOrder.push(i),a=n.footnoteOrder.length):a=o+1,u+=1,n.footnoteCounts.set(i,u);const f={type:"element",tagName:"a",properties:{href:"#"+t+"fn-"+l,id:t+"fnref-"+l+(u>1?"-"+u:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};n.patch(e,f);const d={type:"element",tagName:"sup",properties:{},children:[f]};return n.patch(e,d),n.applyData(e,d)}function q7(n,e){const t={type:"element",tagName:"h"+e.depth,properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function Q7(n,e){if(n.options.allowDangerousHtml){const t={type:"raw",value:e.value};return n.patch(e,t),n.applyData(e,t)}}function QA(n,e){const t=e.referenceType;let i="]";if(t==="collapsed"?i+="[]":t==="full"&&(i+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+i}];const l=n.all(e),o=l[0];o&&o.type==="text"?o.value="["+o.value:l.unshift({type:"text",value:"["});const a=l[l.length-1];return a&&a.type==="text"?a.value+=i:l.push({type:"text",value:i}),l}function X7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return QA(n,e);const l={src:wa(i.url||""),alt:e.alt};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"img",properties:l,children:[]};return n.patch(e,o),n.applyData(e,o)}function $7(n,e){const t={src:wa(e.url)};e.alt!==null&&e.alt!==void 0&&(t.alt=e.alt),e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"img",properties:t,children:[]};return n.patch(e,i),n.applyData(e,i)}function G7(n,e){const t={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};n.patch(e,t);const i={type:"element",tagName:"code",properties:{},children:[t]};return n.patch(e,i),n.applyData(e,i)}function Y7(n,e){const t=String(e.identifier).toUpperCase(),i=n.definitionById.get(t);if(!i)return QA(n,e);const l={href:wa(i.url||"")};i.title!==null&&i.title!==void 0&&(l.title=i.title);const o={type:"element",tagName:"a",properties:l,children:n.all(e)};return n.patch(e,o),n.applyData(e,o)}function K7(n,e){const t={href:wa(e.url)};e.title!==null&&e.title!==void 0&&(t.title=e.title);const i={type:"element",tagName:"a",properties:t,children:n.all(e)};return n.patch(e,i),n.applyData(e,i)}function W7(n,e,t){const i=n.all(e),l=t?Z7(t):XA(e),o={},a=[];if(typeof e.checked=="boolean"){const m=i[0];let g;m&&m.type==="element"&&m.tagName==="p"?g=m:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let u=-1;for(;++u1}function J7(n,e){const t={},i=n.all(e);let l=-1;for(typeof e.start=="number"&&e.start!==1&&(t.start=e.start);++l0){const a={type:"element",tagName:"tbody",properties:{},children:n.wrap(t,!0)},u=Qy(e.children[1]),f=kA(e.children[e.children.length-1]);u&&f&&(a.position={start:u,end:f}),l.push(a)}const o={type:"element",tagName:"table",properties:{},children:n.wrap(l,!0)};return n.patch(e,o),n.applyData(e,o)}function rI(n,e,t){const i=t?t.children:void 0,o=(i?i.indexOf(e):1)===0?"th":"td",a=t&&t.type==="table"?t.align:void 0,u=a?a.length:e.children.length;let f=-1;const d=[];for(;++f0,!0),i[0]),l=i.index+i[0].length,i=t.exec(e);return o.push(bC(e.slice(l),l>0,!1)),o.join("")}function bC(n,e,t){let i=0,l=n.length;if(e){let o=n.codePointAt(i);for(;o===xC||o===yC;)i++,o=n.codePointAt(i)}if(t){let o=n.codePointAt(l-1);for(;o===xC||o===yC;)l--,o=n.codePointAt(l-1)}return l>i?n.slice(i,l):""}function oI(n,e){const t={type:"text",value:sI(String(e.value))};return n.patch(e,t),n.applyData(e,t)}function aI(n,e){const t={type:"element",tagName:"hr",properties:{},children:[]};return n.patch(e,t),n.applyData(e,t)}const cI={blockquote:P7,break:H7,code:I7,delete:U7,emphasis:F7,footnoteReference:V7,heading:q7,html:Q7,imageReference:X7,image:$7,inlineCode:G7,linkReference:Y7,link:K7,listItem:W7,list:J7,paragraph:eI,root:tI,strong:nI,table:iI,tableCell:lI,tableRow:rI,text:oI,thematicBreak:aI,toml:Ch,yaml:Ch,definition:Ch,footnoteDefinition:Ch};function Ch(){}const $A=-1,Yd=0,Ic=1,Od=2,Zy=3,Jy=4,eb=5,tb=6,GA=7,YA=8,{defineProperty:uI}=Object,KA=typeof self=="object"?self:globalThis,vC=(n,e)=>{switch(n){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+n)}return new KA[n](e)},fI=(n,e)=>{const t=(l,o)=>(n.set(o,l),l),i=l=>{if(n.has(l))return n.get(l);const[o,a]=e[l];switch(o){case Yd:case $A:return t(a,l);case Ic:{const u=t([],l);for(const f of a)u.push(i(f));return u}case Od:{const u=t({},l);for(const[f,d]of a){const m=i(f),g=i(d);m==="__proto__"?uI(u,m,{value:g,configurable:!0,enumerable:!0,writable:!0}):u[m]=g}return u}case Zy:return t(new Date(a),l);case Jy:{const{source:u,flags:f}=a;return t(new RegExp(u,f),l)}case eb:{const u=t(new Map,l);for(const[f,d]of a)u.set(i(f),i(d));return u}case tb:{const u=t(new Set,l);for(const f of a)u.add(i(f));return u}case GA:{const{name:u,message:f}=a;return t(typeof KA[u]=="function"?vC(u,f):new Error(f),l)}case YA:return t(BigInt(a),l);case"BigInt":return t(Object(BigInt(a)),l);case"ArrayBuffer":return t(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:u}=new Uint8Array(a);return t(new DataView(u),a)}case"-0":return-0}return t(vC(o,a),l)};return i},wC=n=>fI(new Map,n)(0),Ts="",{toString:hI}={},{keys:dI,is:mI}=Object,Sc=n=>{const e=typeof n;if(e!=="object"||!n)return[Yd,e];const t=hI.call(n).slice(8,-1);switch(t){case"Array":return[Ic,Ts];case"Object":return[Od,Ts];case"Date":return[Zy,Ts];case"RegExp":return[Jy,Ts];case"Map":return[eb,Ts];case"Set":return[tb,Ts];case"DataView":return[Ic,t]}return t.includes("Array")?[Ic,t]:n instanceof Error?[GA,n.name||"Error"]:[Od,t]},Oh=([n,e])=>n===Yd&&(e==="function"||e==="symbol"),pI=(n,e,t,i)=>{const l=(a,u)=>{const f=i.push(a)-1;return t.set(u,f),f},o=a=>{if(t.has(a))return t.get(a);let[u,f]=Sc(a);switch(u){case Yd:{let m=a;switch(f){case"bigint":u=YA,m=a.toString();break;case"number":if(!a&&mI(a,-0))return i.push(["-0"])-1;break;case"function":case"symbol":if(n)throw new TypeError("unable to serialize "+f);m=null;break;case"undefined":return l([$A],a)}return l([u,m],a)}case Ic:{if(f){let b=a;return f==="DataView"?b=new Uint8Array(a.buffer):f==="ArrayBuffer"&&(b=new Uint8Array(a)),l([f,[...b]],a)}const m=[],g=l([u,m],a);for(const b of a)m.push(o(b));return g}case Od:{if(f)switch(f){case"BigInt":return l([f,a.toString()],a);case"Boolean":case"Number":case"String":return l([f,a.valueOf()],a)}if(e&&"toJSON"in a)return o(a.toJSON());const m=[],g=l([u,m],a);for(const b of dI(a))(n||!Oh(Sc(a[b])))&&m.push([o(b),o(a[b])]);return g}case Zy:return l([u,isNaN(a.getTime())?Ts:a.toISOString()],a);case Jy:{const{source:m,flags:g}=a;return l([u,{source:m,flags:g}],a)}case eb:{const m=[],g=l([u,m],a);for(const[b,v]of a)(n||!(Oh(Sc(b))||Oh(Sc(v))))&&m.push([o(b),o(v)]);return g}case tb:{const m=[],g=l([u,m],a);for(const b of a)(n||!Oh(Sc(b)))&&m.push(o(b));return g}}const{message:d}=a;return l([u,{name:f,message:d}],a)};return o},kC=(n,{json:e,lossy:t}={})=>{const i=[];return pI(!(e||t),!!e,new Map,i)(n),i},Td=typeof structuredClone=="function"?(n,e)=>e&&("json"in e||"lossy"in e)?wC(kC(n,e)):structuredClone(n):(n,e)=>wC(kC(n,e));function gI(n,e){const t=[{type:"text",value:"↩"}];return e>1&&t.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),t}function xI(n,e){return"Back to reference "+(n+1)+(e>1?"-"+e:"")}function yI(n){const e=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",t=n.options.footnoteBackContent||gI,i=n.options.footnoteBackLabel||xI,l=n.options.footnoteLabel||"Footnotes",o=n.options.footnoteLabelTagName||"h2",a=n.options.footnoteLabelProperties||{className:["sr-only"]},u=[];let f=-1;for(;++f0&&w.push({type:"text",value:" "});let _=typeof t=="string"?t:t(f,v);typeof _=="string"&&(_={type:"text",value:_}),w.push({type:"element",tagName:"a",properties:{href:"#"+e+"fnref-"+b+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(f,v),className:["data-footnote-backref"]},children:Array.isArray(_)?_:[_]})}const C=m[m.length-1];if(C&&C.type==="element"&&C.tagName==="p"){const _=C.children[C.children.length-1];_&&_.type==="text"?_.value+=" ":C.children.push({type:"text",value:" "}),C.children.push(...w)}else m.push(...w);const O={type:"element",tagName:"li",properties:{id:e+"fn-"+b},children:n.wrap(m,!0)};n.patch(d,O),u.push(O)}if(u.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Td(a),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:n.wrap(u,!0)},{type:"text",value:` +`}]}}const Kd=(function(n){if(n==null)return kI;if(typeof n=="function")return Wd(n);if(typeof n=="object")return Array.isArray(n)?bI(n):vI(n);if(typeof n=="string")return wI(n);throw new Error("Expected function, string, or object as test")});function bI(n){const e=[];let t=-1;for(;++t":""))+")"})}return C;function C(){const O=!o||d(b,v,w[w.length-1]||void 0);let _=WA;if(u&&O&&(_=SC(u(b,w,v)),_[0]===qh))return _;if("children"in b&&b.children){const M=b;if(M.children&&_[0]!==Qx){let H=(l?-1:M.children.length)+m;const B=[...w,M];for(;H>-1&&H0&&t.push({type:"text",value:` +`}),t}function CC(n){let e=0,t=n.charCodeAt(e);for(;t===9||t===32;)e++,t=n.charCodeAt(e);return n.slice(e)}function OC(n,e){const t=NI(n,e),i=t.one(n,void 0),l=yI(t),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&o.children.push({type:"text",value:` +`},l),o}function RI(n,e){return n&&"run"in n?async function(t,i){const l=OC(t,{file:i,...e});await n.run(l,i)}:function(t,i){return OC(t,{file:i,...n||e})}}function TC(n){if(n)throw n}var w0,NC;function jI(){if(NC)return w0;NC=1;var n=Object.prototype.hasOwnProperty,e=Object.prototype.toString,t=Object.defineProperty,i=Object.getOwnPropertyDescriptor,l=function(d){return typeof Array.isArray=="function"?Array.isArray(d):e.call(d)==="[object Array]"},o=function(d){if(!d||e.call(d)!=="[object Object]")return!1;var m=n.call(d,"constructor"),g=d.constructor&&d.constructor.prototype&&n.call(d.constructor.prototype,"isPrototypeOf");if(d.constructor&&!m&&!g)return!1;var b;for(b in d);return typeof b>"u"||n.call(d,b)},a=function(d,m){t&&m.name==="__proto__"?t(d,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):d[m.name]=m.newValue},u=function(d,m){if(m==="__proto__")if(n.call(d,m)){if(i)return i(d,m).value}else return;return d[m]};return w0=function f(){var d,m,g,b,v,w,S=arguments[0],C=1,O=arguments.length,_=!1;for(typeof S=="boolean"&&(_=S,S=arguments[1]||{},C=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});Ca.length;let f;u&&a.push(l);try{f=n.apply(this,a)}catch(d){const m=d;if(u&&t)throw m;return l(m)}u||(f&&f.then&&typeof f.then=="function"?f.then(o,l):f instanceof Error?l(f):o(f))}function l(a,...u){t||(t=!0,e(a,...u))}function o(a){l(null,a)}}const pr={basename:BI,dirname:PI,extname:HI,join:II,sep:"/"};function BI(n,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');pu(n);let t=0,i=-1,l=n.length,o;if(e===void 0||e.length===0||e.length>n.length){for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else i<0&&(o=!0,i=l+1);return i<0?"":n.slice(t,i)}if(e===n)return"";let a=-1,u=e.length-1;for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else a<0&&(o=!0,a=l+1),u>-1&&(n.codePointAt(l)===e.codePointAt(u--)?u<0&&(i=l):(u=-1,i=a));return t===i?i=a:i<0&&(i=n.length),n.slice(t,i)}function PI(n){if(pu(n),n.length===0)return".";let e=-1,t=n.length,i;for(;--t;)if(n.codePointAt(t)===47){if(i){e=t;break}}else i||(i=!0);return e<0?n.codePointAt(0)===47?"/":".":e===1&&n.codePointAt(0)===47?"//":n.slice(0,e)}function HI(n){pu(n);let e=n.length,t=-1,i=0,l=-1,o=0,a;for(;e--;){const u=n.codePointAt(e);if(u===47){if(a){i=e+1;break}continue}t<0&&(a=!0,t=e+1),u===46?l<0?l=e:o!==1&&(o=1):l>-1&&(o=-1)}return l<0||t<0||o===0||o===1&&l===t-1&&l===i+1?"":n.slice(l,t)}function II(...n){let e=-1,t;for(;++e0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function FI(n,e){let t="",i=0,l=-1,o=0,a=-1,u,f;for(;++a<=n.length;){if(a2){if(f=t.lastIndexOf("/"),f!==t.length-1){f<0?(t="",i=0):(t=t.slice(0,f),i=t.length-1-t.lastIndexOf("/")),l=a,o=0;continue}}else if(t.length>0){t="",i=0,l=a,o=0;continue}}e&&(t=t.length>0?t+"/..":"..",i=2)}else t.length>0?t+="/"+n.slice(l+1,a):t=n.slice(l+1,a),i=a-l-1;l=a,o=0}else u===46&&o>-1?o++:o=-1}return t}function pu(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}const VI={cwd:qI};function qI(){return"/"}function Kx(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function QI(n){if(typeof n=="string")n=new URL(n);else if(!Kx(n)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+n+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(n.protocol!=="file:"){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return XI(n)}function XI(n){if(n.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const e=n.pathname;let t=-1;for(;++t0){let[v,...w]=m;const S=i[b][1];Yx(S)&&Yx(v)&&(v=k0(!0,S,v)),i[b]=[d,v,...w]}}}}const KI=new ib().freeze();function T0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function N0(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function A0(n,e){if(e)throw new Error("Cannot call `"+n+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function EC(n){if(!Yx(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function MC(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Th(n){return WI(n)?n:new ZA(n)}function WI(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function ZI(n){return typeof n=="string"||JI(n)}function JI(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const eU="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",DC=[],RC={allowDangerousHtml:!0},tU=/^(https?|ircs?|mailto|xmpp)$/i,nU=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function iU(n){const e=rU(n),t=lU(n);return sU(e.runSync(e.parse(t),t),n)}function rU(n){const e=n.rehypePlugins||DC,t=n.remarkPlugins||DC,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...RC}:RC;return KI().use(B7).use(t).use(RI,i).use(e)}function lU(n){const e=n.children||"",t=new ZA;return typeof e=="string"&&(t.value=e),t}function sU(n,e){const t=e.allowedElements,i=e.allowElement,l=e.components,o=e.disallowedElements,a=e.skipHtml,u=e.unwrapDisallowed,f=e.urlTransform||oU;for(const m of nU)Object.hasOwn(e,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+eU+m.id,void 0);return nb(n,d),SP(n,{Fragment:y.Fragment,components:l,ignoreInvalidStyle:!0,jsx:y.jsx,jsxs:y.jsxs,passKeys:!0,passNode:!0});function d(m,g,b){if(m.type==="raw"&&b&&typeof g=="number")return a?b.children.splice(g,1):b.children[g]={type:"text",value:m.value},g;if(m.type==="element"){let v;for(v in y0)if(Object.hasOwn(y0,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],S=y0[v];(S===null||S.includes(m.tagName))&&(m.properties[v]=f(String(w||""),v,m))}}if(m.type==="element"){let v=t?!t.includes(m.tagName):o?o.includes(m.tagName):!1;if(!v&&i&&typeof g=="number"&&(v=!i(m,g,b)),v&&b&&typeof g=="number")return u&&m.children?b.children.splice(g,1,...m.children):b.children.splice(g,1),g}}}function oU(n){const e=n.indexOf(":"),t=n.indexOf("?"),i=n.indexOf("#"),l=n.indexOf("/");return e===-1||l!==-1&&e>l||t!==-1&&e>t||i!==-1&&e>i||tU.test(n.slice(0,e))?n:""}function aU(n){if(typeof n!="string")throw new TypeError("Expected a string");return n.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function JA(n,e,t){const l=Kd((t||{}).ignore||[]),o=cU(e);let a=-1;for(;++a0?{type:"text",value:D}:void 0),D===!1)v.lastIndex=H+1;else{if(S!==H&&M({type:"text",value:d.value.slice(S,H)}),Array.isArray(D))for(const R of D)M(R);else D&&M(D);S=H+_[0].length,C=!0}if(!v.global)break;_=v.exec(d.value)}return C?(S?\]}]+$/.exec(n);if(!e)return[n,void 0];n=n.slice(0,e.index);let t=e[0],i=t.indexOf(")");const l=jC(n,"(");let o=jC(n,")");for(;i!==-1&&l>o;)n+=t.slice(0,i+1),t=t.slice(i+1),i=t.indexOf(")"),o++;return[n,t]}function eE(n,e){const t=n.input.charCodeAt(n.index-1);return(n.index===0||Us(t)||$d(t))&&(!e||t!==47)}tE.peek=LU;function NU(){this.buffer()}function AU(n){this.enter({type:"footnoteReference",identifier:"",label:""},n)}function EU(){this.buffer()}function MU(n){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},n)}function DU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=Ki(this.sliceSerialize(n)).toLowerCase(),t.label=e}function RU(n){this.exit(n)}function jU(n){const e=this.resume(),t=this.stack[this.stack.length-1];t.type,t.identifier=Ki(this.sliceSerialize(n)).toLowerCase(),t.label=e}function _U(n){this.exit(n)}function LU(){return"["}function tE(n,e,t,i){const l=t.createTracker(i);let o=l.move("[^");const a=t.enter("footnoteReference"),u=t.enter("reference");return o+=l.move(t.safe(t.associationId(n),{after:"]",before:o})),u(),a(),o+=l.move("]"),o}function zU(){return{enter:{gfmFootnoteCallString:NU,gfmFootnoteCall:AU,gfmFootnoteDefinitionLabelString:EU,gfmFootnoteDefinition:MU},exit:{gfmFootnoteCallString:DU,gfmFootnoteCall:RU,gfmFootnoteDefinitionLabelString:jU,gfmFootnoteDefinition:_U}}}function BU(n){let e=!1;return n&&n.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:t,footnoteReference:tE},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function t(i,l,o,a){const u=o.createTracker(a);let f=u.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return f+=u.move(o.safe(o.associationId(i),{before:f,after:"]"})),m(),f+=u.move("]:"),i.children&&i.children.length>0&&(u.shift(4),f+=u.move((e?` +`:" ")+o.indentLines(o.containerFlow(i,u.current()),e?nE:PU))),d(),f}}function PU(n,e,t){return e===0?n:nE(n,e,t)}function nE(n,e,t){return(t?"":" ")+n}const HU=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];rb.attention=qU;rb.peek=QU;function IU(){return{canContainEols:["delete"],enter:{strikethrough:FU},exit:{strikethrough:VU}}}function UU(){return{handlers:{delete:rb},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:HU}]}}function FU(n){this.enter({type:"delete",children:[],position:void 0},n)}function VU(n){this.exit(n)}function rb(n,e,t,i){const l=t.createTracker(i),o=t.stack.includes("strikethrough")?"~":"~~",a=t.enter("strikethrough");let u=l.move(o);return u+=t.containerPhrasing(n,{...l.current(),before:u,after:"~"}),u+=l.move(o),a(),u}function qU(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function QU(){return"~"}function XU(n){return n.length}function $U(n,e){const t=e||{},i=(t.align||[]).concat(),l=t.stringLength||XU,o=[],a=[],u=[],f=[];let d=0,m=-1;for(;++md&&(d=n[m].length);++Of[O])&&(f[O]=M)}S.push(_)}a[m]=S,u[m]=C}let g=-1;if(typeof i=="object"&&"length"in i)for(;++gf[g]&&(f[g]=_),v[g]=_),b[g]=M}a.splice(1,0,b),u.splice(1,0,v),m=-1;const w=[];for(;++m "),o.shift(2);const a=t.indentLines(t.containerFlow(n,o.current()),WU);return l(),a}function WU(n,e,t){return">"+(t?"":" ")+n}function ZU(n,e){return LC(n,e.inConstruct,!0)&&!LC(n,e.notInConstruct,!1)}function LC(n,e,t){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return t;let i=-1;for(;++ia&&(a=o):o=1,l=i+e.length,i=t.indexOf(e,l);return a}function eF(n,e){return!!(e.options.fences===!1&&n.value&&!n.lang&&/[^\n\r ]/.test(n.value)&&!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(n.value))}function tF(n){const e=n.options.fence||"`";if(e!=="`"&&e!=="~")throw new Error("Cannot serialize code with `"+e+"` for `options.fence`, expected `` ` `` or `~`");return e}function nF(n,e,t,i){const l=tF(t),o=n.value||"";if(eF(n,t)){const g=t.enter("codeIndented"),b=t.indentLines(o,iF);return g(),b}const a=t.createTracker(i),u=l.repeat(Math.max(JU(o,l)+1,3)),f=t.enter("codeFenced"),d=l==="`"?"GraveAccent":"Tilde";let m=a.move(u);if(n.lang){const g=t.enter(`codeFencedLang${d}`);m+=a.move(t.safe(n.lang,{before:m,after:" ",encode:["`"],...a.current()})),g()}if(n.lang&&n.meta){const g=t.enter(`codeFencedMeta${d}`);m+=a.move(" "),m+=a.move(t.safe(n.meta,{before:m,after:` +`,encode:["`"],...a.current()})),g()}return m+=a.move(` +`),o&&(m+=a.move(o+` +`)),m+=a.move(u),f(),m}function iF(n,e,t){return(t?"":" ")+n}function lb(n){const e=n.options.quote||'"';if(e!=='"'&&e!=="'")throw new Error("Cannot serialize title with `"+e+"` for `options.quote`, expected `\"`, or `'`");return e}function rF(n,e,t,i){const l=lb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("definition");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("[");return d+=f.move(t.safe(t.associationId(n),{before:d,after:"]",...f.current()})),d+=f.move("]: "),u(),!n.url||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":` +`,...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),a(),d}function lF(n){const e=n.options.emphasis||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize emphasis with `"+e+"` for `options.emphasis`, expected `*`, or `_`");return e}function Nd(n){const e=n.codePointAt(0);return e===void 0?"":String.fromCodePoint(e)}function la(n){const e=n.codePointAt(n.length-2);return e!==void 0&&e>65535?n.slice(-2):n.slice(-1)}function iE(n){return"&#x"+n.toString(16).toUpperCase()+";"}function BC(n,e,t){const i=Yl(n),l=Yl(e);return i===void 0?l===void 0?t==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:l===void 0?{inside:!1,outside:!1}:l===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}function sF(n){if(n.charCodeAt(0)!==60)return;const e=n.charCodeAt(1);if(e===33){const u=n.charCodeAt(2);return u===45?2:u===91?5:Cn(u)?4:void 0}if(e===63)return 3;const t=e===47,i=t?2:1;let l=i,o=n.charCodeAt(l);if(!Cn(o))return;for(;o===45||On(o);)o=n.charCodeAt(++l);const a=n.slice(i,l).toLowerCase();return!t&&o!==47&&qx.includes(a)?1:IA.includes(a)?6:7}const oF=new Map([["*",!1],["_",!0]]);function aF(n,e,t){const i=new Set;for(const o of n){const a=t.get(o);if(a&&o.attention&&e.some(u=>u.attention===o.attention))for(const u of a.tokens)i.add(u.attention)}const l=[];for(const o of n)o.attention&&i.delete(o.attention)&&l.push(o.attention);return l.reverse(),l}function rE(n,e,t){const i=[],l=new Map,o=new Map;let a=0;for(;at.index)return{chosen:f,mistake:m,tokens:d}}}}function uF(n,e){const t=new Map;for(const i of n){const l=i.tokens[0].value.charAt(0);let o=t.get(l);o||(o=[],t.set(l,o));let a=i.close?o.length:0;for(;a--&&i.start1&&d>1?2:1:d,g=u.markers.slice(u.end-m,u.end),b=i.markers.slice(i.start,i.start+m),v=g[0],w=b[0];if(v===g[m-1]&&v.value.length===m&&w===b[m-1]&&w.value.length===m&&v.attention===w.attention)e.delete(v),e.delete(w);else{const S=[...new Set([...g,...b])];for(const C of S){const O=e.get(C);O&&O.push(...S)}}u.end-=m,i.start+=m,u.start===u.end&&o.splice(a,1),a=o.length}i.open&&i.start0?w[0].value:"",C=BC(b.charCodeAt(b.length-1),S.charCodeAt(0),m);C.inside&&Nh(w,!0);const O=w.length>0?la(w[w.length-1].value):"",_=BC(v.charCodeAt(0),O.charCodeAt(O.length-1),m);_.inside&&Nh(w,!1),C.outside&&b!==` +`&&b!=="\r"&&Nh(l,!1),_.outside&&(o=v),l.push({value:d,attention:f},...w,{value:d,attention:f}),a=d.charAt(d.length-1)}return l}function Zd(n,e,t){let i=new Map;const l=ob(n,i,e,t);let o=l,a=rE(o,e,t);for(;a;){const f=cF(n,i,a,e,t);if(!f){o=l;break}i=f.chosen,o=f.tokens,a=f.mistake}let u="";for(const f of o)u+=f.value;return u}ab.attention=lE;ab.peek=dF;function ab(n,e,t,i){const l=t.enter("phrasing"),o=sb(n,lE,t,t.createTracker(i)),a=Zd([o],i.before,i.after);return l(),a}function lE(n,e){return{construct:"emphasis",markers:lF(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function dF(n,e,t){return t.options.emphasis||"*"}function mF(n,e){let t=!1;return nb(n,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return t=!0,qh}),!!((!n.depth||n.depth<3)&&Yy(n)&&(e.options.setext||t))}function pF(n,e,t,i){const l=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(i);if(mF(n,t)){const g=t.enter("headingSetext"),b=t.enter("phrasing"),v=t.containerPhrasing(n,{...o.current(),before:` +`,after:` +`});return b(),g(),v+` +`+(l===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(` +`))+1))}const a="#".repeat(l),u=t.enter("headingAtx"),f=t.enter("phrasing");o.move(a+" ");let d=t.containerPhrasing(n,{before:"# ",after:` +`,...o.current()});const m=d.charCodeAt(0);return(m===9||m===32)&&(d=iE(m)+d.slice(1)),d=d?a+" "+d:a,t.options.closeAtx&&(d+=" "+a),f(),u(),d}sE.peek=gF;function sE(n){return n.value||""}function gF(){return"<"}oE.peek=xF;function oE(n,e,t,i){const l=lb(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("image");let u=t.enter("label");const f=t.createTracker(i);let d=f.move("![");return d+=f.move(t.safe(n.alt,{before:d,after:"]",...f.current()})),d+=f.move("]("),u(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(u=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(u=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":")",...f.current()}))),u(),n.title&&(u=t.enter(`title${o}`),d+=f.move(" "+l),d+=f.move(t.safe(n.title,{before:d,after:l,...f.current()})),d+=f.move(l),u()),d+=f.move(")"),a(),d}function xF(){return"!"}aE.peek=yF;function aE(n,e,t,i){const l=n.referenceType,o=t.enter("imageReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("![");const d=t.safe(n.alt,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function yF(){return"!"}cE.peek=bF;function cE(n,e,t){let i=n.value||"",l="`",o=-1;for(;new RegExp("(^|[^`])"+l+"([^`]|$)").test(i);)l+="`";for(/[^\n\r ]/.test(i)&&(/^[\n\r ]/.test(i)&&/[\n\r ]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o\u007F]/.test(n.url))}fE.peek=vF;function fE(n,e,t,i){const l=lb(t),o=l==='"'?"Quote":"Apostrophe",a=t.createTracker(i);if(uE(n,t)){const w=t.stack;t.stack=w.filter(function(O){return O!=="phrasing"});const S=t.enter("autolink");let C=a.move("<");return C+=a.move(t.containerPhrasing(n,{before:C,after:">",...a.current()})),C+=a.move(">"),S(),t.stack=w,C}const u=t.enter("link");let f=t.enter("label"),d=a.move("[");const m=t.containerPhrasing(n,{before:d,after:"](",...a.current()});d+=a.move(m),f(),d+=a.move("](");const g=/[\0- \u007F]/.test(n.url),b=i.before.charAt(i.before.length-1);let v=n.title||void 0;if(!v&&!g&&(b===` +`||b==="\r")){let w=0;for(;w",...a.current()})),d+=a.move(">")):(f=t.enter("destinationRaw"),d+=a.move(t.safe(n.url,{before:d,after:typeof v=="string"?" ":")",...a.current()}))),f(),typeof v=="string"&&(f=t.enter(`title${o}`),d+=a.move(" "+l),d+=a.move(t.safe(v,{before:d,after:l,...a.current()})),d+=a.move(l),f()),d+=a.move(")"),u(),d}function vF(n,e,t){return uE(n,t)?"<":"["}hE.peek=wF;function hE(n,e,t,i){const l=n.referenceType,o=t.enter("linkReference");let a=t.enter("label");const u=t.createTracker(i);let f=u.move("[");const d=t.containerPhrasing(n,{before:f,after:"]",...u.current()});f+=u.move(d+"]["),a();const m=t.stack;t.stack=m.filter(function(b){return b!=="phrasing"}),a=t.enter("reference");const g=t.safe(t.associationId(n),{before:f,after:"]",...u.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=u.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=u.move("]"),f}function wF(){return"["}function cb(n){const e=n.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function kF(n){const e=cb(n),t=n.options.bulletOther;if(!t)return e==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+t+"`) to be different");return t}function SF(n){const e=n.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function dE(n){const e=n.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function CF(n,e,t,i){const l=t.enter("list"),o=t.bulletCurrent;let a=n.ordered?SF(t):cb(t);const u=n.ordered?a==="."?")":".":kF(t);let f=e&&t.bulletLastUsed?a===t.bulletLastUsed:!1;if(!n.ordered){const m=n.children?n.children[0]:void 0;if((a==="*"||a==="-")&&m&&(!m.children||!m.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(f=!0),dE(t)===a&&m){let g=-1;for(;++g-1?e.start:1)+(t.options.incrementListMarker===!1?0:e.children.indexOf(n))+o);let a=o.length+1;(l==="tab"||l==="mixed"&&(e&&e.type==="list"&&e.spread||n.spread))&&(a=Math.ceil(a/4)*4);const u=t.createTracker(i);u.move(o+" ".repeat(a-o.length)),u.shift(a);const f=t.enter("listItem"),d=t.indentLines(t.containerFlow(n,u.current()),m);return f(),d;function m(g,b,v){return b?(v?"":" ".repeat(a))+g:(v?o:o+" ".repeat(a-o.length))+g}}function NF(n,e,t,i){const l=t.enter("paragraph"),o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),l(),a}function AF(n,e,t,i){if(!n.children.some(function(u){return YU(u)}))return t.containerFlow(n,i);const o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),a}function EF(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}ub.attention=mE;ub.peek=MF;function ub(n,e,t,i){const l=t.enter("phrasing"),o=sb(n,mE,t,t.createTracker(i)),a=Zd([o],i.before,i.after);return l(),a}function mE(n,e){return{construct:"strong",markers:EF(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function MF(n,e,t){return t.options.strong||"*"}function DF(n,e,t,i){const l=e?e.children:[],o=t.indexStack[t.indexStack.length-1];return t.safe(n.value,{...i,afterNode:l[o+1],beforeNode:l[o-1]})}function RF(n){const e=n.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function jF(n,e,t){const i=(dE(t)+(t.options.ruleSpaces?" ":"")).repeat(RF(t));return t.options.ruleSpaces?i.slice(0,-1):i}const pE={blockquote:KU,break:zC,code:nF,definition:rF,emphasis:ab,hardBreak:zC,heading:pF,html:sE,image:oE,imageReference:aE,inlineCode:cE,link:fE,linkReference:hE,list:CF,listItem:TF,paragraph:NF,root:AF,strong:ub,text:DF,thematicBreak:jF};function _F(){return{enter:{table:LF,tableData:PC,tableHeader:PC,tableRow:BF},exit:{codeText:PF,table:zF,tableData:R0,tableHeader:R0,tableRow:R0}}}function LF(n){const e=n._align;this.enter({type:"table",align:e.map(function(t){return t==="none"?null:t}),children:[]},n),this.data.inTable=!0}function zF(n){this.exit(n),this.data.inTable=void 0}function BF(n){this.enter({type:"tableRow",children:[]},n)}function R0(n){this.exit(n)}function PC(n){this.enter({type:"tableCell",children:[]},n)}function PF(n){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,HF));const t=this.stack[this.stack.length-1];t.type,t.value=e,this.exit(n)}function HF(n,e){return e==="|"?e:n}function IF(n){const e=n||{},t=e.tableCellPadding,i=e.tablePipeAlign,l=e.stringLength,o=t?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:a,tableCell:f,tableRow:u}};function a(v,w,S,C){return d(m(v,S,C),v.align)}function u(v,w,S,C){const O=g(v,S,C),_=d([O]);return _.slice(0,_.indexOf(` +`))}function f(v,w,S,C){const O=S.enter("tableCell"),_=S.enter("phrasing"),M=S.containerPhrasing(v,{...C,before:o,after:o});return _(),O(),M}function d(v,w){return $U(v,{align:w,alignDelimiters:i,padding:t,stringLength:l})}function m(v,w,S){const C=v.children;let O=-1;const _=[],M=w.enter("table");for(;++O0&&!t&&(n[n.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}const rV={tokenize:hV,partial:!0};function lV(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:cV,continuation:{tokenize:uV},exit:fV}},text:{91:{name:"gfmFootnoteCall",tokenize:aV},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:sV,resolveTo:oV}}}}function sV(n,e,t){const i=this;let l=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let a;for(;l--;){const f=i.events[l][1];if(f.type==="labelImage"){a=f;break}if(f.type==="gfmFootnoteCall"||f.type==="labelLink"||f.type==="label"||f.type==="image"||f.type==="link")break}return u;function u(f){if(!a||!a._balanced)return t(f);const d=Ki(i.sliceSerialize({start:a.end,end:i.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?t(f):(n.enter("gfmFootnoteCallLabelMarker"),n.consume(f),n.exit("gfmFootnoteCallLabelMarker"),e(f))}}function oV(n,e){let t=n.length;for(;t--;)if(n[t][1].type==="labelImage"&&n[t][0]==="enter"){n[t][1];break}n[t+1][1].type="data",n[t+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},n[t+3][1].start),end:Object.assign({},n[n.length-1][1].end)},l={type:"gfmFootnoteCallMarker",start:Object.assign({},n[t+3][1].end),end:Object.assign({},n[t+3][1].end)};l.end.column++,l.end.offset++,l.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},l.end),end:Object.assign({},n[n.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},u=[n[t+1],n[t+2],["enter",i,e],n[t+3],n[t+4],["enter",l,e],["exit",l,e],["enter",o,e],["enter",a,e],["exit",a,e],["exit",o,e],n[n.length-2],n[n.length-1],["exit",i,e]];return n.splice(t,n.length-t+1,...u),n}function aV(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,a;return u;function u(g){return n.enter("gfmFootnoteCall"),n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),f}function f(g){return g!==94?t(g):(n.enter("gfmFootnoteCallMarker"),n.consume(g),n.exit("gfmFootnoteCallMarker"),n.enter("gfmFootnoteCallString"),n.enter("chunkString").contentType="string",d)}function d(g){if(o>999||g===93&&!a||g===null||g===91||Tt(g))return t(g);if(g===93){n.exit("chunkString");const b=n.exit("gfmFootnoteCallString");return l.includes(Ki(i.sliceSerialize(b)))?(n.enter("gfmFootnoteCallLabelMarker"),n.consume(g),n.exit("gfmFootnoteCallLabelMarker"),n.exit("gfmFootnoteCall"),e):t(g)}return Tt(g)||(a=!0),o++,n.consume(g),g===92?m:d}function m(g){return g===91||g===92||g===93?(n.consume(g),o++,d):d(g)}}function cV(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,a=0,u;return f;function f(w){return n.enter("gfmFootnoteDefinition")._container=!0,n.enter("gfmFootnoteDefinitionLabel"),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(w){return w===94?(n.enter("gfmFootnoteDefinitionMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionMarker"),n.enter("gfmFootnoteDefinitionLabelString"),n.enter("chunkString").contentType="string",m):t(w)}function m(w){if(a>999||w===93&&!u||w===null||w===91||Tt(w))return t(w);if(w===93){n.exit("chunkString");const S=n.exit("gfmFootnoteDefinitionLabelString");return o=Ki(i.sliceSerialize(S)),n.enter("gfmFootnoteDefinitionLabelMarker"),n.consume(w),n.exit("gfmFootnoteDefinitionLabelMarker"),n.exit("gfmFootnoteDefinitionLabel"),b}return Tt(w)||(u=!0),a++,n.consume(w),w===92?g:m}function g(w){return w===91||w===92||w===93?(n.consume(w),a++,m):m(w)}function b(w){return w===58?(n.enter("definitionMarker"),n.consume(w),n.exit("definitionMarker"),l.includes(o)||l.push(o),ft(n,v,"gfmFootnoteDefinitionWhitespace")):t(w)}function v(w){return e(w)}}function uV(n,e,t){return n.check(mu,e,n.attempt(rV,e,t))}function fV(n){n.exit("gfmFootnoteDefinition")}function hV(n,e,t){const i=this;return ft(n,l,"gfmFootnoteDefinitionIndent",5);function l(o){const a=i.events[i.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?e(o):t(o)}}function dV(n){let t=(n||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:l};return t==null&&(t=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function l(a,u){let f=-1;for(;++f1?f(w):(a.consume(w),g++,v);if(g<2&&!t)return f(w);const C=a.exit("strikethroughSequenceTemporary"),O=Yl(w);return C._open=!O||O===2&&!!S,C._close=!S||S===2&&!!O,u(w)}}}class mV{constructor(){this.map=[],this.index=new Map}add(e,t,i){pV(this,e,t,i)}consume(e){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let t=this.map.length;const i=[];for(;t>0;)t-=1,i.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];i.push(e.slice()),e.length=0;let l=i.pop();for(;l;){for(const o of l)e.push(o);l=i.pop()}this.map.length=0,this.index.clear()}}function pV(n,e,t,i){if(t===0&&i.length===0)return;const l=n.index.get(e);if(l){l[1]+=t,l[2].push(...i);return}const o=[e,t,i];n.map.push(o),n.index.set(e,o)}function gV(n,e){let t=!1;const i=[];for(;e-1;){const{type:ae}=i.events[F][1];if(ae==="lineEnding"||ae==="linePrefix")F--;else break}const A=F>-1?i.events[F][1].type:null,ne=A==="tableHead"||A==="tableRow"?D:f;return ne===D&&i.parser.lazy[i.now().line]?t(I):ne(I)}function f(I){return n.enter("tableHead"),n.enter("tableRow"),d(I)}function d(I){return I===124||(a=!0,o+=1),m(I)}function m(I){return I===null?t(I):He(I)?o>1?(o=0,i.interrupt=!0,n.exit("tableRow"),n.enter("lineEnding"),n.consume(I),n.exit("lineEnding"),v):t(I):Je(I)?ft(n,m,"whitespace")(I):(o+=1,a&&(a=!1,l+=1),I===124?(n.enter("tableCellDivider"),n.consume(I),n.exit("tableCellDivider"),a=!0,m):(n.enter("data"),g(I)))}function g(I){return I===null||I===124||Tt(I)?(n.exit("data"),m(I)):(n.consume(I),I===92?b:g)}function b(I){return I===92||I===124?(n.consume(I),g):g(I)}function v(I){return i.interrupt=!1,i.parser.lazy[i.now().line]?t(I):(n.enter("tableDelimiterRow"),a=!1,Je(I)?ft(n,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):w(I))}function w(I){return I===45||I===58?C(I):I===124?(a=!0,n.enter("tableCellDivider"),n.consume(I),n.exit("tableCellDivider"),S):B(I)}function S(I){return Je(I)?ft(n,C,"whitespace")(I):C(I)}function C(I){return I===58?(o+=1,a=!0,n.enter("tableDelimiterMarker"),n.consume(I),n.exit("tableDelimiterMarker"),O):I===45?(o+=1,O(I)):I===null||He(I)?H(I):B(I)}function O(I){return I===45?(n.enter("tableDelimiterFiller"),_(I)):B(I)}function _(I){return I===45?(n.consume(I),_):I===58?(a=!0,n.exit("tableDelimiterFiller"),n.enter("tableDelimiterMarker"),n.consume(I),n.exit("tableDelimiterMarker"),M):(n.exit("tableDelimiterFiller"),M(I))}function M(I){return Je(I)?ft(n,H,"whitespace")(I):H(I)}function H(I){return I===124?w(I):I===null||He(I)?!a||l!==o?B(I):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(I)):B(I)}function B(I){return t(I)}function D(I){return n.enter("tableRow"),R(I)}function R(I){return I===124?(n.enter("tableCellDivider"),n.consume(I),n.exit("tableCellDivider"),R):I===null||He(I)?(n.exit("tableRow"),e(I)):Je(I)?ft(n,R,"whitespace")(I):(n.enter("data"),P(I))}function P(I){return I===null||I===124||Tt(I)?(n.exit("data"),R(I)):(n.consume(I),I===92?te:P)}function te(I){return I===92||I===124?(n.consume(I),P):P(I)}}function bV(n,e){let t=-1,i=!0,l=0,o=[0,0,0,0],a=[0,0,0,0],u=!1,f=0,d,m,g;const b=new mV;for(;++tt[2]+1){const w=t[2]+1,S=t[3]-t[2]-1;n.add(w,S,[])}}n.add(t[3]+1,0,[["exit",g,e]])}return l!==void 0&&(o.end=Object.assign({},qo(e.events,l)),n.add(l,0,[["exit",o,e]]),o=void 0),o}function IC(n,e,t,i,l){const o=[],a=qo(e.events,t);l&&(l.end=Object.assign({},a),o.push(["exit",l,e])),i.end=Object.assign({},a),o.push(["exit",i,e]),n.add(t+1,0,o)}function qo(n,e){const t=n[e],i=t[0]==="enter"?"start":"end";return t[1][i]}const vV={name:"tasklistCheck",tokenize:kV};function wV(){return{text:{91:vV}}}function kV(n,e,t){const i=this;return l;function l(f){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?t(f):(n.enter("taskListCheck"),n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),o)}function o(f){return Tt(f)?(n.enter("taskListCheckValueUnchecked"),n.consume(f),n.exit("taskListCheckValueUnchecked"),a):f===88||f===120?(n.enter("taskListCheckValueChecked"),n.consume(f),n.exit("taskListCheckValueChecked"),a):t(f)}function a(f){return f===93?(n.enter("taskListCheckMarker"),n.consume(f),n.exit("taskListCheckMarker"),n.exit("taskListCheck"),u):t(f)}function u(f){return He(f)?e(f):Je(f)?n.check({tokenize:SV},e,t)(f):t(f)}}function SV(n,e,t){return ft(n,i,"whitespace");function i(l){return l===null?t(l):e(l)}}function CV(n){return EA([YF(),lV(),dV(n),xV(),wV()])}const OV={};function TV(n){const e=this,t=n||OV,i=e.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(CV(t)),o.push(QF()),a.push(XF(t))}function NV(n){return n.replace(/\\n/g,` +`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}const AV={h1:({children:n})=>y.jsx("h3",{className:"mt-3 mb-1.5 text-base font-bold text-ink first:mt-0",children:n}),h2:({children:n})=>y.jsx("h4",{className:"mt-3 mb-1 text-sm font-semibold text-ink first:mt-0",children:n}),h3:({children:n})=>y.jsx("h5",{className:"mt-2 mb-1 text-xs font-semibold text-ink first:mt-0",children:n}),p:({children:n})=>y.jsx("p",{className:"my-1.5 leading-relaxed first:mt-0 last:mb-0",children:n}),strong:({children:n})=>y.jsx("strong",{className:"font-semibold text-ink",children:n}),em:({children:n})=>y.jsx("em",{className:"italic text-ink-secondary",children:n}),del:({children:n})=>y.jsx("del",{className:"text-ink-muted line-through",children:n}),a:({children:n,href:e})=>y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-chip-indigo-text underline underline-offset-2 hover:text-ink",children:n}),code:({children:n,className:e})=>y.jsx("code",{className:`break-words rounded bg-elevated px-1 py-0.5 font-mono text-chip-indigo-text whitespace-pre-wrap ${e??""}`,children:n}),pre:({children:n})=>y.jsx("pre",{className:"my-2 overflow-x-auto rounded-lg border border-line bg-elevated p-3 font-mono text-xs text-ink [&_code]:bg-transparent [&_code]:px-0 [&_code]:py-0 [&_code]:text-inherit",children:n}),ul:({children:n})=>y.jsx("ul",{className:"my-1.5 list-disc space-y-0.5 pl-5",children:n}),ol:({children:n})=>y.jsx("ol",{className:"my-1.5 list-decimal space-y-0.5 pl-5",children:n}),li:({children:n})=>y.jsx("li",{className:"leading-relaxed",children:n}),blockquote:({children:n})=>y.jsx("blockquote",{className:"my-2 border-l-2 border-line-strong pl-3 text-ink-secondary italic",children:n}),table:({children:n})=>y.jsx("div",{className:"my-2 overflow-x-auto",children:y.jsx("table",{className:"w-full border-collapse text-xs",children:n})}),th:({children:n})=>y.jsx("th",{className:"border border-line bg-elevated px-2 py-1 text-left font-semibold",children:n}),td:({children:n})=>y.jsx("td",{className:"border border-line px-2 py-1 align-top",children:n}),hr:()=>y.jsx("hr",{className:"my-3 border-line"}),img:({alt:n,src:e,title:t})=>y.jsx("img",{src:e,alt:n,title:t,loading:"lazy",referrerPolicy:"no-referrer",className:"my-2 max-w-full rounded-lg border border-line"})};function Eh({text:n}){return n?y.jsx(iU,{remarkPlugins:[TV,mU],components:AV,children:NV(n)}):null}function CE(n){return n==="completed"||n==="aborted"||n==="failed"}function Cc({label:n}){return y.jsx("kbd",{"aria-hidden":"true",className:"ml-1.5 inline-block rounded border border-line/60 bg-elevated/60 px-1 py-px font-mono text-[10px] font-normal leading-none opacity-90",children:n})}function UC(n){!n||CE(n.status)||HM(n.session_id).catch(()=>{})}const EV={running:"running",completed:"done",skipped:"skipped",failed:"failed",pending:"pending"};function Mh({text:n}){const[e,t]=E.useState(!1),i=E.useRef(void 0);E.useEffect(()=>()=>window.clearTimeout(i.current),[]);const l=async()=>{try{await navigator.clipboard.writeText(n),t(!0),window.clearTimeout(i.current),i.current=window.setTimeout(()=>t(!1),1500)}catch{}};return y.jsx("button",{type:"button",onClick:l,"aria-label":e?"Copied":"Copy content",title:e?"Copied!":"Copy content",className:"absolute right-2 top-2 rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:e?y.jsx(Sr,{className:"h-3.5 w-3.5"}):y.jsx(Zn,{className:"h-3.5 w-3.5"})})}function MV({isOpen:n,onClose:e,directory:t,filename:i,release:l,args:o,onFinished:a}){var ye,z;const[u,f]=E.useState(null),[d,m]=E.useState(!1),[g,b]=E.useState(null),[v,w]=E.useState(null),[S,C]=E.useState(!1),[O,_]=E.useState(0),M=E.useRef(null),H=E.useRef(!1),B=E.useRef(null),D=E.useRef(!1);E.useEffect(()=>{if(!n||!t||!i){f(null),b(null),C(!1),w(null),D.current=!1;return}let j=!0;return m(!0),b(null),C(!1),w(null),BM({directory:t,filename:i,release:l,args:o}).then(q=>{j&&(f(q),m(!1),(q.status==="completed"||q.status==="aborted"||q.status==="failed")&&(a==null||a(q.status,q.final_message||"")))}).catch(q=>{j&&((q==null?void 0:q.status)===404&&C(!0),b(q.message||"Failed to start workflow"),m(!1))}),()=>{j=!1}},[n,t,i,l,o,O]);const R=async j=>{if(!(!u||H.current)){H.current=!0,m(!0);try{const q=await PM(u.session_id,j);f(q),(q.status==="completed"||q.status==="aborted"||q.status==="failed")&&(a==null||a(q.status,q.final_message||""))}catch(q){(q==null?void 0:q.status)===404?(C(!0),b(q.message||"Workflow session on the server has expired.")):b(q.message||"Failed to process workflow response")}finally{H.current=!1,m(!1)}}},P=E.useRef(u);P.current=u;const te=E.useRef(R);te.current=R;const I=E.useRef(v);I.current=v;const F=E.useRef([]),A=(j,q)=>{var De,Te;if(j.key!=="ArrowDown"&&j.key!=="ArrowUp"&&j.key!=="Home"&&j.key!=="End")return;j.preventDefault();const ue=((De=P.current)==null?void 0:De.steps.length)??0;if(ue===0)return;const pe=j.key==="ArrowDown"?(q+1)%ue:j.key==="ArrowUp"?(q-1+ue)%ue:j.key==="Home"?0:ue-1;w(pe),(Te=F.current[pe])==null||Te.focus()};E.useEffect(()=>()=>UC(P.current),[]);const ne=()=>{D.current||(D.current=!0,UC(P.current),e())},ae=()=>{f(null),b(null),C(!1),w(null),D.current=!1,_(j=>j+1)},ie=Wl({isOpen:n,onClose:ne,dialogRef:M,initialFocusRef:B});if(E.useEffect(()=>{if(!n)return;const j=q=>{var Ee,Rt,Ut;if(q.key==="Escape"){q.preventDefault(),ne();return}const ue=P.current;if(!ue)return;if(CE(ue.status)){q.key==="Enter"&&!q.repeat&&!q.ctrlKey&&!q.metaKey&&!q.altKey&&!H.current&&((Ee=q.target)==null?void 0:Ee.tagName)!=="BUTTON"&&((Rt=document.activeElement)==null?void 0:Rt.tagName)!=="BUTTON"&&(q.preventDefault(),ne());return}if(H.current||q.repeat||q.ctrlKey||q.metaKey||q.altKey)return;const pe=q.target;if((pe==null?void 0:pe.tagName)==="INPUT"||(pe==null?void 0:pe.tagName)==="TEXTAREA"||pe!=null&&pe.isContentEditable)return;const De=I.current,Te=De===null||De===ue.current_index,Pe=ue.status==="waiting_ask"?"yes":ue.status==="waiting_notify"||ue.status==="waiting_notice"?"ack":null;if(!Te||Pe===null)return;if(q.key==="Enter"){const Ft=q.target;if((Ft==null?void 0:Ft.tagName)==="BUTTON"||((Ut=document.activeElement)==null?void 0:Ut.tagName)==="BUTTON")return;q.preventDefault(),te.current(Pe);return}if(ue.status!=="waiting_ask")return;const ve=q.key.toLowerCase();ve==="y"?(q.preventDefault(),te.current("yes")):ve==="s"?(q.preventDefault(),te.current("skip")):ve==="n"&&(q.preventDefault(),te.current("no"))};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,e]),E.useEffect(()=>{if(!n||!u)return;const j=requestAnimationFrame(()=>{var q;return(q=B.current)==null?void 0:q.focus()});return()=>cancelAnimationFrame(j)},[n,u==null?void 0:u.status]),!n)return null;const $=v!==null?u==null?void 0:u.steps[v]:u==null?void 0:u.steps[u.current_index],oe=(u==null?void 0:u.status)==="completed"||(u==null?void 0:u.status)==="aborted"||(u==null?void 0:u.status)==="failed",Z=!!u&&!oe&&!S&&(((ye=u.status)==null?void 0:ye.startsWith("waiting"))??!1),Y=(((z=u==null?void 0:u.steps[(u==null?void 0:u.current_index)??-1])==null?void 0:z.phase)??"pre")==="post",he=!S&&(v===null||v===(u==null?void 0:u.current_index))&&($!=null&&$.command)&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_notice"||(u==null?void 0:u.status)==="waiting_ask")?y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsxs("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 pr-10 font-mono text-xs text-ink leading-relaxed",children:[y.jsx(Mh,{text:$.command}),$.command]})]}):null;return y.jsx("div",{ref:M,role:"dialog","aria-modal":"true","aria-labelledby":"workflow-runner-title",onKeyDown:ie,className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-xs",children:y.jsxs("div",{className:"animate-modal-in flex h-[80vh] w-full max-w-5xl flex-col rounded-xl border border-frame-line glass-panel overflow-hidden",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line px-5 py-3.5 bg-surface-strong/30 shrink-0",children:[y.jsxs("div",{className:"flex items-center gap-2.5",children:[y.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-chip-indigo-bg text-chip-indigo-text",children:y.jsx(iO,{className:"h-4 w-4"})}),y.jsxs("div",{children:[y.jsx("h2",{id:"workflow-runner-title",className:"text-sm font-semibold text-ink",children:"Launch Workflow Engine"}),y.jsxs("p",{className:"text-xs text-ink-muted",children:[i," ",u!=null&&u.pattern?`• Pattern: ${u.pattern}`:""]})]})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[u&&!oe&&!S&&y.jsxs("button",{type:"button",disabled:!Z||d,onClick:()=>R("bypass"),title:Y?"Skip the remaining post-launch steps":"Skip the remaining steps and launch with the OS default app",className:"btn inline-flex items-center gap-1.5 rounded-md border border-line bg-surface px-3 py-1.5 text-xs font-medium text-status-warning-text hover:bg-status-warning-bg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 disabled:cursor-not-allowed disabled:opacity-40",children:[y.jsx(a4,{className:"h-3.5 w-3.5"}),Y?"Skip rest":"Launch now"]}),y.jsx("button",{type:"button",onClick:ne,className:"rounded-md p-1.5 text-ink-muted hover:bg-elevated hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500",children:y.jsx(bi,{className:"h-4 w-4"})})]})]}),y.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[y.jsxs("div",{className:"w-72 border-r border-line bg-surface-strong/20 p-4 overflow-y-auto flex flex-col gap-2 shrink-0",children:[y.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-ink-muted px-1 mb-1",children:"Workflow Steps (Click to inspect)"}),u&&u.steps.length>0?y.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:u.steps.map((j,q)=>{const ue=u.current_index===q&&!oe,pe=v===q||v===null&&ue,De=EV[j.status];return y.jsx("li",{children:y.jsxs("button",{ref:Te=>{F.current[q]=Te},type:"button",tabIndex:pe?0:-1,"aria-current":pe?"step":void 0,onKeyDown:Te=>A(Te,q),onClick:()=>w(q),className:`flex items-start text-left gap-2.5 rounded-lg border px-3 py-2.5 transition-colors cursor-pointer w-full ${pe?"border-chip-indigo-border bg-chip-indigo-bg shadow-xs ring-1 ring-chip-indigo-border/40":"border-line/60 bg-surface/60 hover:bg-elevated/80"}`,children:[y.jsxs("div",{className:"mt-0.5 shrink-0",children:[j.status==="running"&&y.jsx(Yr,{className:"h-4 w-4 animate-spin text-chip-indigo-text"}),j.status==="completed"&&y.jsx(Ik,{className:"h-4 w-4 text-status-success-text"}),j.status==="skipped"&&y.jsx(AD,{className:"h-4 w-4 text-status-warning-text"}),j.status==="failed"&&y.jsx(Ec,{className:"h-4 w-4 text-status-danger-text"}),j.status==="pending"&&y.jsx("div",{className:"h-4 w-4 rounded-full border border-line-strong flex items-center justify-center text-[10px] text-ink-faint font-mono",children:j.index})]}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsxs("div",{className:"flex items-center justify-between",children:[y.jsx("span",{className:"font-mono text-[11px] font-bold uppercase text-chip-indigo-text",children:j.action}),y.jsxs("span",{className:"text-[10px] font-mono text-ink-faint",children:["#",j.index," · ",De]})]}),y.jsx("p",{className:"truncate font-mono text-[11px] text-ink-secondary mt-0.5",title:j.command,children:j.message?j.message.split(` +`)[0]:j.command}),j.note&&y.jsx("p",{className:"mt-1 text-[10px] text-ink-faint italic",children:j.note})]})]})},j.index)})}):y.jsx("div",{className:"p-4 text-center text-xs text-ink-faint",children:g||S?"Session unavailable — see the error panel.":"Loading steps..."})]}),y.jsxs("div",{className:"flex-1 flex flex-col bg-app",children:[y.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-6",children:y.jsx("div",{className:"space-y-6",children:y.jsxs("div",{className:"rounded-xl border border-line bg-surface p-5 shadow-xs space-y-4",children:[y.jsxs("div",{className:"flex items-center justify-between border-b border-line pb-3",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("span",{className:"rounded bg-chip-indigo-bg px-2 py-0.5 font-mono text-xs font-semibold uppercase text-chip-indigo-text",children:($==null?void 0:$.action)||(u==null?void 0:u.status)}),y.jsx("span",{className:"text-xs text-ink-muted",children:$?`Step ${$.index} of ${u==null?void 0:u.steps.length}`:"Status"}),v!==null&&v!==(u==null?void 0:u.current_index)&&y.jsx("button",{type:"button",onClick:()=>w(null),className:"text-[11px] text-chip-indigo-text hover:underline ml-2",children:"(Return to active step)"})]}),d&&y.jsx(Yr,{className:"h-4 w-4 animate-spin text-chip-indigo-text"})]}),y.jsxs("div",{className:"space-y-3 text-xs text-ink font-sans leading-relaxed",children:[(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notify"&&u.notify_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notification Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Eh,{text:u.notify_message})}),he]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_notice"&&u.notice_message&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Notice:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Eh,{text:u.notice_message})}),he,y.jsx("p",{className:"text-[11px] text-ink-faint",children:"The command will run when you continue."})]}),(v===null||v===(u==null?void 0:u.current_index))&&(u==null?void 0:u.status)==="waiting_ask"&&u.ask_prompt&&y.jsxs("div",{className:"space-y-2",children:[u.ask_message&&y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Eh,{text:u.ask_message})}),y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-status-warning-text",children:"Confirmation Prompt:"}),y.jsx("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-4 text-sm font-medium text-ink",children:u.ask_prompt}),he]}),oe&&v===null&&y.jsxs("div",{className:`rounded-xl border p-8 text-center space-y-4 ${(u==null?void 0:u.status)==="completed"?"border-status-success-border bg-status-success-bg text-status-success-text":"border-status-danger-border bg-status-danger-bg text-status-danger-text"}`,children:[y.jsx("div",{className:"inline-flex h-12 w-12 items-center justify-center rounded-full bg-surface/50 mx-auto",children:(u==null?void 0:u.status)==="completed"?y.jsx(Ik,{className:"h-6 w-6 text-status-success-text"}):y.jsx(Ec,{className:"h-6 w-6 text-status-danger-text"})}),y.jsxs("div",{className:"space-y-1",children:[y.jsx("h3",{className:"text-base font-bold",children:(u==null?void 0:u.status)==="completed"?"Workflow Finished":"Workflow Terminated"}),y.jsx("p",{className:"text-xs text-ink-secondary max-w-md mx-auto",children:(u==null?void 0:u.final_message)||"The launch sequence has ended."})]}),y.jsx("div",{className:"pt-2",children:y.jsx("button",{type:"button",onClick:e,className:"btn btn-primary px-8 py-2.5 font-bold shadow-lg",children:"Close Engine Runner"})})]}),oe&&v===null&&(u==null?void 0:u.last_output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Mh,{text:u.last_output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:u.last_output})]})]}),!S&&!(oe&&v===null)&&!((v===null||v===(u==null?void 0:u.current_index))&&((u==null?void 0:u.status)==="waiting_notify"||(u==null?void 0:u.status)==="waiting_ask"||(u==null?void 0:u.status)==="waiting_notice"))&&y.jsxs("div",{className:"space-y-4",children:[($==null?void 0:$.message)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Message:"}),y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-xs text-ink",children:y.jsx(Eh,{text:$.message})})]}),y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Command:"}),y.jsx("div",{className:"relative rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink leading-relaxed",children:$!=null&&$.command?y.jsxs(y.Fragment,{children:[y.jsx(Mh,{text:$.command}),y.jsx("span",{className:"block pr-8",children:$.command})]}):"Waiting..."})]}),($==null?void 0:$.output)&&y.jsxs("div",{className:"space-y-2",children:[y.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wider text-ink-muted",children:"Output:"}),y.jsxs("div",{className:"relative",children:[y.jsx(Mh,{text:$.output}),y.jsx("pre",{className:"max-h-48 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-strong p-4 font-mono text-xs text-ink",children:$.output})]})]}),($==null?void 0:$.ask)&&y.jsxs("div",{className:"rounded-lg border border-status-warning-border bg-status-warning-bg p-3 text-xs text-status-warning-text",children:[y.jsx("span",{className:"font-semibold",children:"Workflow Guard:"})," ",$.ask]}),($==null?void 0:$.note)&&y.jsxs("div",{className:"rounded-lg border border-line bg-surface-strong p-3 text-xs text-ink-muted italic",children:[y.jsx("span",{className:"font-semibold text-ink-secondary not-italic uppercase text-[10px]",children:"Log:"})," ",$.note]})]})]})]})})}),(g||S)&&y.jsx("div",{className:"shrink-0 px-6 pt-3",children:y.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-status-danger-border bg-status-danger-bg p-3 text-xs text-status-danger-text",children:[y.jsx(Ec,{className:"mt-0.5 h-4 w-4 shrink-0"}),y.jsxs("div",{className:"min-w-0 flex-1 space-y-1.5",children:[y.jsx("p",{children:S?"Workflow session on the server has expired or ended.":g}),S?y.jsxs("div",{className:"space-y-2",children:[g&&y.jsxs("details",{className:"text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer select-none text-[11px] underline",children:"Raw error (for bug reports)"}),y.jsx("pre",{className:"mt-1 overflow-x-auto whitespace-pre-wrap break-words font-mono text-[11px]",children:g})]}),y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("button",{type:"button",onClick:ae,className:"btn btn-primary px-4 py-1.5 text-xs font-semibold",children:"Restart workflow"}),y.jsx("button",{type:"button",onClick:ne,className:"btn rounded-md border-line bg-surface px-4 py-1.5 text-xs",children:"Close"})]})]}):null]})]})}),y.jsxs("div",{className:"shrink-0 px-6 pt-4 pb-4 border-t border-line flex items-center justify-between bg-app",children:[y.jsx("div",{className:"text-xs text-ink-muted","aria-live":"polite",children:S?"Session unavailable — restart or close above.":(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)?"Action required to proceed:":(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)?"Acknowledge message to proceed:":(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)?"Continue to run the command:":oe?"Session terminated.":"Step in progress..."}),y.jsxs("div",{className:"flex items-center gap-2",children:[!S&&(u==null?void 0:u.status)==="waiting_notice"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:B,disabled:d,onClick:()=>R("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Run Command",y.jsx(Cc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_notify"&&(v===null||v===u.current_index)&&y.jsxs("button",{type:"button",ref:B,disabled:d,onClick:()=>R("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Continue Workflow",y.jsx(Cc,{label:"↵"})]}),!S&&(u==null?void 0:u.status)==="waiting_ask"&&(v===null||v===u.current_index)&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{type:"button",disabled:d,onClick:()=>R("no"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-danger-text hover:bg-status-danger-bg",children:["Abort Launch",y.jsx(Cc,{label:"N"})]}),y.jsxs("button",{type:"button",disabled:d,onClick:()=>R("skip"),className:"btn rounded-md border-line bg-surface px-4 py-2 text-status-warning-text hover:bg-status-warning-bg",children:["Skip Step",y.jsx(Cc,{label:"S"})]}),y.jsxs("button",{type:"button",ref:B,disabled:d,onClick:()=>R("yes"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Execute Step",y.jsx(Cc,{label:"Y"})]})]}),oe&&y.jsx("button",{type:"button",ref:B,onClick:e,className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:"Close Runner"})]})]})]})]})]})})}function Oc(n){return/[",\n\r]/.test(n)?`"${n.replace(/"/g,'""')}"`:n}function DV(n,e,t,i){var f,d;const l=[],a=[["Exported",new Date().toISOString()],["App Version",(t==null?void 0:t.release)??"unknown"],["Config File",(t==null?void 0:t.config_path)??"none"],["Config Exists",String((t==null?void 0:t.config_exists)??!1)],["Directory",(t==null?void 0:t.active_directory)??""],["Extensions",((f=t==null?void 0:t.extensions)==null?void 0:f.join(" | "))??""],["Filter Text",i??((d=t==null?void 0:t.filters)==null?void 0:d[0])??""],["Recursive",String((t==null?void 0:t.recursive_search)??!0)],["Title",(t==null?void 0:t.title)??""],["Release",(t==null?void 0:t.release)??""]];for(const[m,g]of a)l.push(`${Oc(m)},${Oc(g)}`);l.push("");const u=e.length>0?e:["filename","path","rel_path"];l.push(u.map(Oc).join(","));for(const m of n){const g=u.map(b=>b in m?Oc(String(m[b]??"")):Oc(m.column_values[b]??""));l.push(g.join(","))}return l.join(`\r +`)}function RV(n){const e=n.replace(/\\/g,"/"),t=e.startsWith("//"),i=_V(e.replace(/^\/+/,""));return t?`file://${i}`:`file:///${i}`}const jV=/[A-Za-z0-9\-._~!$&'()*+,;=:@]/;function _V(n){return[...n].map(e=>e==="/"||jV.test(e)?e:LV(e)).join("")}function LV(n){return Array.from(new TextEncoder().encode(n),e=>`%${e.toString(16).toUpperCase().padStart(2,"0")}`).join("")}const zV=120;function BV(){const{theme:n,applyTheme:e,toggleTheme:t}=V4(),[i,l]=E.useState(null),[o,a]=E.useState(null),[u,f]=E.useState(""),[d,m]=E.useState(""),[g,b]=E.useState(""),[v,w]=E.useState(!0),[S,C]=E.useState(null),[O,_]=E.useState(!1),[M,H]=E.useState(0),[B,D]=E.useState(""),[R,P]=E.useState(null),[te,I]=E.useState(!1),{toastMessage:F,showToast:A,dismissToast:ne}=j4(),[ae,ie]=E.useState(!1),[$,oe]=E.useState("en"),[Z,Y]=E.useState(!1),[N,he]=E.useState(null),[ye,z]=E.useState(!1),[j,q]=E.useState(0),[ue,pe]=E.useState(!1),[De,Te]=E.useState(null),[Pe,ve]=E.useState(null),[Ee,Rt]=E.useState(!1),[Ut,Ft]=E.useState(!1),[zt,gt]=E.useState(null),[$e,Xt]=E.useState(null),[Nn,en]=E.useState(!1),[tn,Ce]=E.useState(void 0),[Fe,qe]=E.useState(null),[at,ee]=E.useState(""),[fe,_e]=E.useState(!1),[ze,Dt]=E.useState(null),ce=K=>{gt(K)},xe=E.useRef(null),Le=()=>({directory:u,extension:d,filter_text:g,recursive:v}),we=R4({showToast:A,getScanParams:Le,onFreshResults:()=>{xe.current=null,H(0)}}),{barcodeMode:mt,setBarcodeMode:An,handleBarcodeToggle:mn,handleCameraDetected:Nt}=U4({showToast:A,scanWith:we.scanWith,getScanParams:Le,onApplyValues:K=>{K.filter!==void 0&&b(K.filter),K.ext!==void 0&&m(K.ext),K.recursive!==void 0&&w(K.recursive),K.dir!==void 0&&f(K.dir)},onSingleMatch:Dt,onCameraClose:()=>_e(!1),setFilterText:b});E.useEffect(()=>{if(!g.trim()){D("");return}const K=window.setTimeout(()=>D(g),zV);return()=>window.clearTimeout(K)},[g]);const ht=E.useMemo(()=>B.trim()===""?we.files:we.files.filter(K=>x8(K.rel_path,B)),[we.files,B]),Bi=g.trim()&&we.files.length{const K=xe.current,de=K?ht.findIndex(Oe=>Oe.path===K):-1;if(de>=0){H(Oe=>de!==Oe?de:Oe);return}H(Oe=>Math.min(Oe,Math.max(0,ht.length-1)))},[ht]);const Ln=async()=>{if(ae)return;ie(!0),A("Reloading configuration...");const K=we.beginScan();try{const de=await Qh();l(de);const Oe=await TM();a(Oe),e(zg(Oe.theme),{persist:!1});const We=Oe.active_directory||u,$t=Oe.extensions[0]??"",Qn=Oe.filters[0]??"";We&&f(We),m($t),b(Qn),w(Oe.recursive_search),Oe.reloaded===!1?A(`Config file not found: ${Oe.config_path||"(unknown path)"} — kept current configuration.`,"error"):A("Configuration reloaded."),We&&await we.scanWithGeneration(K,{directory:We,extension:$t,filter_text:Qn,recursive:Oe.recursive_search},{errorPrefix:"Failed to reload configuration"})}catch(de){A(`Failed to reload configuration: ${de.message}`,"error")}finally{ie(!1),we.finishScan(K)}},Er=async K=>{const de=we.beginScan();a(K),e(zg(K.theme),{persist:!1});const Oe=K.active_directory||u||(K.directories[0]??""),We=K.extensions[0]??"",$t=K.filters[0]??"";Oe&&f(Oe),m(We),b($t),w(K.recursive_search),K.session_trial||A(K.config_exists?`Loaded config: ${K.config_path}`:"Starter configuration created."),Oe?await we.scanWithGeneration(de,{directory:Oe,extension:We,filter_text:$t,recursive:K.recursive_search},{errorPrefix:"Scan failed after config load"}):we.finishScan(de)},{dropOverlayVisible:Jd,resetDrop:gu,applyConfigFile:em}=$4({onConfigLoaded:Er,showToast:A});L4({onConfigApplied:async()=>{const K=await Ek();await Er(K)},showToast:A});const tm=()=>{Y(!0)},Jl=async K=>{const de=we.beginScan();Y(!1),f(K),A(`Directory selected: ${K}`);let Oe;try{Oe=await Mk(K),a(Oe)}catch(Qn){console.error("select-directory failed:",Qn)}if(!we.isCurrentScan(de))return;const We=Yf(d,Oe==null?void 0:Oe.extensions,d),$t=Yf(g,Oe==null?void 0:Oe.filters,g);m(We),b($t),await we.scanWithGeneration(de,{directory:K,extension:We,filter_text:$t,recursive:v},{errorPrefix:"Scan failed"})},zn=async(K,de)=>{if(!we.isCurrentScan(de))return;e(zg(K.theme),{persist:!0}),a(K);const Oe=K.active_directory||(K.directories.length>0?K.directories[0]:""),We=K.extensions.length>0?K.extensions[0]:"",$t=K.filters.length>0?K.filters[0]:"";if(Oe&&f(Oe),We&&m(We),K.recursive_search!==void 0&&w(K.recursive_search),$t&&b($t),K.config_exists||he("create"),Oe)try{await we.runScan(de,{directory:Oe,extension:We,filter_text:$t,recursive:K.recursive_search})}catch(Qn){we.isCurrentScan(de)&&A(`Initial scan failed: ${Qn.message}`,"error")}},Pi=async()=>{const K=we.claimGeneration();C(null),_(!0);try{const de=await Qh();l(de);const Oe=await Ek();await zn(Oe,K)}catch(de){C((de==null?void 0:de.message)||"Couldn't fetch system info or configuration.")}finally{_(!1)}};E.useEffect(()=>{Pi()},[]);const on=async K=>{const de=we.beginScan();f(K);try{const Oe=await Mk(K);if(!we.isCurrentScan(de))return!1;a(Oe);const We=Yf(d,Oe.extensions,""),$t=Yf(g,Oe.filters,"");return m(We),b($t),(await we.scanWithGeneration(de,{directory:K,extension:We,filter_text:$t,recursive:v},{errorPrefix:"Directory change failed"})).ok}catch(Oe){return we.isCurrentScan(de)&&A(`Directory change failed: ${Oe.message}`,"error"),!1}finally{we.finishScan(de)}},qs=async()=>{await we.scanWith({directory:u,extension:d,filter_text:g,recursive:v},{errorPrefix:"Scan failed"})},{autoRescanInterval:xu,handleTimerSet:nm}=B4({scan:()=>{qs()},showToast:A}),Qs=K=>{b(K),we.scheduleDeferredRescan()},Xs=K=>{w(K),we.scheduleDeferredRescan()},$s=K=>{m(K),we.scheduleDeferredRescan()},Mr=async()=>{b(""),await we.scanWith({directory:u,extension:d,filter_text:"",recursive:v},{errorPrefix:"Scan failed"})},Gs=async()=>{w(!1),await we.scanWith({directory:u,extension:d,filter_text:g,recursive:!1},{errorPrefix:"Scan failed"})},vi=async(K,de)=>{if(K.has_hook){Xt({file:K,args:de});return}try{await DM({directory:u,filename:K.rel_path,release:o==null?void 0:o.release,args:de}),A(`Launched ${K.filename}`)}catch(Oe){A(`Launch error: ${Oe.message}`,"error")}},ka=()=>{ht.length>0&&ht[M]&&vi(ht[M])},im=K=>{var de;xe.current=((de=ht[K])==null?void 0:de.path)??null,H(K)},yu=async(K,de)=>{vi(K,de)},Sa=async K=>{try{await QC(K.path),A("Revealed in file manager.")}catch(de){A(`Error: ${de.message}`,"error")}},es=async K=>{try{await j0(K.path),A("Folder opened in file manager.")}catch(de){A(`Error: ${de.message}`,"error")}},rm=async K=>{try{const de=await zk(K.path);A(de.message||"Terminal opened.")}catch(de){A(`Error: ${de.message}`,"error")}},bu=async K=>{await on(K)&&A(`Scanned directory: ${K}`)},vu=K=>{b(K),we.scanWith({directory:u,extension:d,filter_text:K,recursive:v},{errorPrefix:"Scan failed"})},wu=K=>{m(K),we.scanWith({directory:u,extension:K,filter_text:g,recursive:v},{errorPrefix:"Scan failed"})},Ca=async(K,de)=>{const Oe=de?K.path.replace(/\\/g,"/"):K.path;try{await navigator.clipboard.writeText(Oe),A("Path copied to clipboard.")}catch(We){A(`Copy failed: ${(We==null?void 0:We.message)??We}`,"error")}},Oa=async(K,de)=>{let Oe=K.filename;if(de){const We=Oe.lastIndexOf(".");We!==-1&&(Oe=Oe.slice(0,We))}try{await navigator.clipboard.writeText(Oe),A("Filename copied to clipboard.")}catch(We){A(`Copy failed: ${(We==null?void 0:We.message)??We}`,"error")}},ku=async(K,de)=>{try{A(`Computing ${de.toUpperCase()}...`);const Oe=await Bk(K.path,de);await navigator.clipboard.writeText(Oe.hash),A(`${de.toUpperCase()} hash copied: ${Oe.hash.slice(0,12)}...`)}catch(Oe){A(`Hash computation failed: ${Oe.message}`,"error")}},Su=async K=>{try{const de=RV(K.path);await navigator.clipboard.writeText(de),A("File URI copied to clipboard.")}catch(de){A(`URI copy failed: ${de.message}`,"error")}},wi=async(K,de,Oe)=>{A(`Computing ${de.toUpperCase()}...`);try{const $t=(await Bk(K.path,de)).hash.toLowerCase()===Oe.trim().toLowerCase();A($t?`✅ ${de.toUpperCase()} matches!`:`❌ ${de.toUpperCase()} mismatch`)}catch(We){A(`Verification failed: ${We.message}`,"error")}},nn=async(K,de)=>{let Oe;try{Oe=await navigator.clipboard.readText()}catch{ee(""),qe({file:K,algorithm:de});return}if(!Oe.trim()){A("Clipboard is empty — copy a hash first, then try again.");return}await wi(K,de,Oe)},pn=K=>{ve(K),pe(!0)},nl=K=>{Te(K)},Cu=async()=>{const K=De;if(Te(null),!!K)try{if(A("Deleting file..."),!(await fetch("/api/actions/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_path:K.path})})).ok)throw new Error("Failed to delete file");A("File deleted successfully."),qs()}catch(de){A(`Delete failed: ${de.message}`,"error")}},lm=K=>{Ce(K.path),en(!0)},Ou=async()=>{if(u)try{await j0(u),A("Directory opened in file manager.")}catch(K){A(`Error: ${K.message}`,"error")}},Tu=async K=>{if(K)try{await zk(K),A("Terminal opened in directory.")}catch(de){A(`Error: ${de.message}`,"error")}},il=async()=>{try{await on("~"),A("Directory set to home folder.")}catch(K){A(`Error: ${K.message}`,"error")}},Ys=async()=>{if(u)try{const K=await qC(u);K.parent_path?(await on(K.parent_path),A("Moved to parent directory.")):A("Already at root directory.")}catch(K){A(`Error: ${K.message}`,"error")}},Ks=async()=>{if(we.files.length===0){A("No files to export.");return}try{const K=DV(we.files,(o==null?void 0:o.column_names)||[],o??void 0,g),de=`profiles-export-${new Date().toISOString().slice(0,19).replace(/[:.]/g,"-")}.csv`,Oe=await LM(K,de);A(`Exported ${we.files.length} loaded row${we.files.length===1?"":"s"}${g?` matching "${g}"`:""} — ${Oe.message}`)}catch(K){A(`Export failed: ${K.message}`,"error")}};return z4({anyModalOpen:!!(R||te||Z||N!==null||ue||Ee||Ut||Nn||fe||ze||$e||De),visibleFiles:ht,selectedIndex:M,activeDirectory:u,activeExtension:d,filterText:g,recursive:v,barcodeMode:mt,onEscape:()=>{P(null),I(!1),Rt(!1),Ft(!1),gu()},onContextMenu:P,onExecute:ka,onScan:qs,onReloadConfig:Ln,onGoHome:il,onProperties:pn,onToggleTheme:()=>t({persist:!0}),setShowLogViewer:Rt,setShowShortcuts:I,setShowTimerModal:Ft,setShowConfigEditor:z,setBarcodeMode:An,setShowCameraScanner:_e,moveSelection:K=>{H(de=>{var We;const Oe=K(de,ht.length);return xe.current=((We=ht[Oe])==null?void 0:We.path)??null,Oe})}}),y.jsxs("div",{className:"flex h-dvh flex-col bg-elevated/30 p-1 font-sans text-ink transition-colors duration-200 sm:p-1.5",children:[y.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-frame-line bg-app shadow-[0_2px_6px_rgb(0_0_0/0.35)] transition-colors duration-200 sm:rounded-xl",children:[y.jsx(c8,{title:(o==null?void 0:o.title)||"",release:(o==null?void 0:o.release)||"",directories:(o==null?void 0:o.directories)||[],activeDirectory:u,onDirectoryChange:on,onBrowseDirectory:tm,onGoToParentDirectory:Ys,onGoToHomeDirectory:il,onOpenActiveDirectory:Ou,onOpenTerminal:Tu}),y.jsx(b8,{extensions:(o==null?void 0:o.extensions)||[],activeExtension:d,onExtensionChange:$s,filterOptions:(o==null?void 0:o.filters)||[],filterText:g,onFilterTextChange:Qs,recursive:v,onRecursiveChange:Xs,onScan:qs,scanning:we.scanning,barcodeMode:mt,onBarcodeToggle:mn,onCameraBarcodeClick:()=>_e(!0),autoRescanActive:xu>0,onTimerClick:()=>Ft(!0)}),S?y.jsx(u8,{message:S,onRetry:()=>void Pi(),retrying:O}):y.jsx(M4,{files:ht,totalCount:we.totalCount,rawLoadedCount:we.files.length,onLoadMore:we.handleLoadMore,loadingMore:we.loadingMore,scanning:we.scanning,hasScanned:we.hasScanned,activeDirectory:u,recursive:v,onDisableRecursive:Gs,onOpenDirectory:Ou,onLoadConfig:()=>he("load"),filterText:g,onClearFilter:Mr,columnHeaders:(o==null?void 0:o.column_headers)||[],columnNames:(o==null?void 0:o.column_names)||[],selectedIndex:M,onSelectIndex:im,prefilterNote:Bi,onLaunch:vi,onContextMenu:(K,de,Oe)=>{K.preventDefault(),xe.current=de.path,H(Oe),P({x:K.clientX,y:K.clientY,file:de})},rowColors:(o==null?void 0:o.row_colors)||[],sort:we.sort,onSortChange:we.applySort}),y.jsx(W4,{onExecute:ka,scanning:we.scanning,scanningDirectory:u,hasSelection:ht.length>0,fileCount:ht.length,totalCount:we.totalCount,toastMessage:F,onToastDismiss:ne}),y.jsx(I8,{systemInfo:i,fileCount:we.totalCount,theme:n,onToggleTheme:()=>t({persist:!0}),onOpenLog:()=>Rt(!0),onOpenConfig:()=>z(!0),onShowShortcuts:()=>I(!0),onReloadConfig:Ln,onExport:Ks,exportDisabled:we.files.length===0||we.scanning,language:$,onLanguageChange:oe,lanEnabled:(i==null?void 0:i.lan_enabled)??null,onToggleLan:ce})]}),y.jsx(r8,{open:ye,onClose:()=>z(!1),onApplied:Er,onLoadConfig:()=>he("load"),reloadKey:j}),y.jsx(O8,{isOpen:N!==null,mode:N??"load",activeConfigPath:o==null?void 0:o.config_path,onClose:()=>he(null),onLoaded:K=>{Er(K),q(de=>de+1)}}),y.jsx(o8,{visible:Jd,onFileSelected:em}),y.jsx(s8,{isOpen:Z,initialPath:u,onClose:()=>Y(!1),onSelect:Jl}),y.jsx(l8,{position:R,onClose:()=>P(null),onLaunch:vi,onLaunchWithArgs:yu,onReveal:Sa,onOpenFolder:es,onOpenTerminal:rm,onScanDirectory:bu,onFilterFolder:vu,onFilterExtension:wu,onCopyPath:Ca,onCopyFilename:Oa,onCopyUri:Su,onComputeHash:ku,onVerifyHash:nn,onProperties:pn,onClearFile:nl,onGenerateBarcode:lm,showToast:A}),y.jsx(C8,{isOpen:te,onClose:()=>I(!1)}),y.jsx(M8,{isOpen:ue,file:Pe,onLaunch:vi,onClose:()=>{pe(!1),ve(null)}}),y.jsx(F8,{isOpen:Ut,currentInterval:xu,onClose:()=>Ft(!1),onSetInterval:nm}),y.jsx(S8,{isOpen:Ee,onClose:()=>Rt(!1),onOpenExternally:()=>{wM().then(K=>A(K.message)).catch(K=>A(K instanceof Error?K.message:"Failed to open the log file","error"))}}),y.jsx(MV,{isOpen:!!$e,onClose:()=>Xt(null),directory:u,filename:($e==null?void 0:$e.file.rel_path)||"",release:o==null?void 0:o.release,args:$e==null?void 0:$e.args,onFinished:(K,de)=>{K==="completed"?A(de||"Workflow launched successfully."):(K==="aborted"||K==="failed")&&A(`Workflow stopped: ${de}`,"error")}}),y.jsx(dA,{isOpen:Nn,onClose:()=>{en(!1),Ce(void 0)},initialFilePath:tn}),Fe&&y.jsx("div",{className:"animate-overlay-in fixed inset-0 z-[var(--z-modal)] flex items-center justify-center bg-black/60 p-4 backdrop-blur-sm",onClick:()=>qe(null),children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"verify-hash-title",onKeyDown:K=>{K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),qe(null))},onClick:K=>K.stopPropagation(),className:"animate-modal-in w-[440px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("h2",{id:"verify-hash-title",className:"mb-1 text-sm font-semibold text-ink",children:["Verify ",Fe.algorithm.toUpperCase()]}),y.jsx("p",{className:"mb-3 text-xs text-ink-muted",children:"Clipboard access is unavailable here — paste the expected hash below."}),y.jsx("input",{autoFocus:!0,type:"text",value:at,onChange:K=>ee(K.target.value),placeholder:"Expected hash","aria-label":"Expected hash",className:"mb-4 w-full rounded-lg border border-line bg-elevated px-3 py-2 font-mono text-xs text-ink placeholder:text-ink-faint focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400"}),y.jsxs("div",{className:"flex justify-end gap-2",children:[y.jsx("button",{type:"button",onClick:()=>qe(null),className:"min-h-9 rounded-lg border border-line bg-elevated px-3.5 text-sm text-ink-secondary transition-colors hover:bg-surface-strong hover:text-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Cancel"}),y.jsx("button",{type:"button",disabled:!at.trim(),onClick:()=>{const{file:K,algorithm:de}=Fe;qe(null),wi(K,de,at)},className:"min-h-9 rounded-lg border border-transparent bg-indigo-600 px-4 text-sm font-semibold text-white transition-colors hover:bg-indigo-500 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400",children:"Verify"})]})]})}),y.jsx(P8,{isOpen:fe,onClose:()=>_e(!1),onDetected:Nt}),y.jsx(js,{isOpen:!!De,title:"Delete file",message:`Delete this file? + +${(De==null?void 0:De.path)??""} + +This action cannot be undone.`,confirmLabel:"Delete",danger:!0,onConfirm:Cu,onCancel:()=>Te(null)}),y.jsx(f8,{pending:zt,systemInfo:i,showToast:A,onConfirmed:l,onCancel:()=>gt(null)}),y.jsx(H8,{isOpen:!!ze,file:ze,onConfirm:()=>{if(ze){const K=ze;Dt(null),vi(K)}},onDismiss:()=>Dt(null)})]})}class PV extends E.Component{constructor(){super(...arguments);Gf(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,i){console.error("Application render error:",t,i.componentStack)}render(){return this.state.error?y.jsx("main",{className:"flex min-h-screen items-center justify-center bg-app p-6 text-ink",children:y.jsxs("section",{className:"w-full max-w-lg rounded-lg border border-line bg-surface p-6",children:[y.jsx("h1",{className:"text-base font-semibold",children:"ProFiles encountered an error"}),y.jsx("p",{className:"mt-2 text-sm text-ink-secondary",children:"The interface could not continue. Reload the application to try again."}),y.jsxs("details",{className:"mt-4 text-xs text-ink-muted",children:[y.jsx("summary",{className:"cursor-pointer",children:"Error details"}),y.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap",children:this.state.error.message})]}),y.jsx("button",{type:"button",onClick:()=>window.location.reload(),className:"btn btn-primary mt-5 px-4 py-2 text-sm font-semibold",children:"Reload application"})]})}):this.props.children}}bM.createRoot(document.getElementById("root")).render(y.jsx(hM.StrictMode,{children:y.jsx(PV,{children:y.jsx(BV,{})})})); diff --git a/src/profiles/web/dist/index.html b/src/profiles/web/dist/index.html index 6cd0e01..034f4a7 100644 --- a/src/profiles/web/dist/index.html +++ b/src/profiles/web/dist/index.html @@ -5,7 +5,7 @@ ProFiles - + diff --git a/src/profiles/web/dist/sw.js b/src/profiles/web/dist/sw.js index c8314dc..894fa93 100644 --- a/src/profiles/web/dist/sw.js +++ b/src/profiles/web/dist/sw.js @@ -1 +1 @@ -if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const l=e=>i(e,t),d={module:{uri:t},exports:o,require:l};s[t]=Promise.all(n.map(e=>d[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"778a914068300ade6b80616b5b3c633e"},{url:"assets/index-C_WnxvAZ.js",revision:null},{url:"assets/index-CUYujBAx.css",revision:null},{url:"manifest.webmanifest",revision:"5a42ebe8b55b07b5831cbbddda834829"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); +if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const d=e=>i(e,t),l={module:{uri:t},exports:o,require:d};s[t]=Promise.all(n.map(e=>l[e]||d(e))).then(e=>(r(...e),o))}}define(["./workbox-9c191d2f"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"index.html",revision:"a4a459d53fdfc7b117de69888f43a65e"},{url:"assets/index-DzeM--qU.js",revision:null},{url:"assets/index-CUYujBAx.css",revision:null},{url:"manifest.webmanifest",revision:"5a42ebe8b55b07b5831cbbddda834829"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))}); diff --git a/src/profiles/web/src/App.configEditor.test.tsx b/src/profiles/web/src/App.configEditor.test.tsx index 949f1ef..b9794e7 100644 --- a/src/profiles/web/src/App.configEditor.test.tsx +++ b/src/profiles/web/src/App.configEditor.test.tsx @@ -281,3 +281,75 @@ describe("App config editor integration", () => { ); }); }); + +/** + * Picker-mode regressions (issue #192): with NO active configuration + * (`config_exists: false`), only the first-run auto-prompt opens Create + * mode. Every explicit Load/Choose action must open Load mode — previously + * the picker inferred its mode from `configExists` and all entry points + * rendered Create. + */ +describe("App config picker mode (issue #192)", () => { + /** A no-config session: per-user default path, no directories. */ + const NO_CONFIG_OVERRIDES = { + config_exists: false, + config_path: "C:/Users/op/.profiles/.profiles", + directories: [], + active_directory: "", + }; + + it("test_first_run_auto_prompt_opens_create_mode_then_editor_entry_opens_load_mode", async () => { + const user = userEvent.setup(); + fetchConfigSpy.mockResolvedValue(makeAppConfig(NO_CONFIG_OVERRIDES)); + render(); + + // First-run auto-prompt: Create mode, as before. + const firstRun = await screen.findByRole("dialog", { name: /create configuration/i }); + expect( + within(firstRun).getByRole("button", { name: /create configuration/i }), + ).toBeTruthy(); + + // Dismiss it — nothing else opens until the user acts. + await user.click(within(firstRun).getByRole("button", { name: /^cancel$/i })); + await waitFor(() => + expect(screen.queryByRole("dialog", { name: /configuration/i })).toBeNull(), + ); + + // Editor header "Load config file…": an explicit load action → Load mode. + await user.click(screen.getByRole("button", { name: /^config$/i })); + const editor = await screen.findByRole("dialog", { name: /configuration editor/i }); + browseSpy.mockResolvedValue( + makeBrowseResult({ + current_path: "C:/Users/op/.profiles", + items: [{ name: "user.profiles", path: "C:/Users/op/.profiles/user.profiles", is_dir: false, is_config: true }], + }), + ); + await user.click(within(editor).getByRole("button", { name: /load config file/i })); + + const picker = await screen.findByRole("dialog", { name: /load configuration/i }); + expect( + within(picker).getByRole("button", { name: /^load configuration$/i }), + ).toBeTruthy(); + expect(within(picker).queryByText(/no configuration file was found/i)).toBeNull(); + }); + + it("test_filelist_choose_configuration_opens_load_mode", async () => { + const user = userEvent.setup(); + fetchConfigSpy.mockResolvedValue(makeAppConfig(NO_CONFIG_OVERRIDES)); + render(); + + // Dismiss the first-run auto-prompt. + const firstRun = await screen.findByRole("dialog", { name: /create configuration/i }); + await user.click(within(firstRun).getByRole("button", { name: /^cancel$/i })); + await waitFor(() => + expect(screen.queryByRole("dialog", { name: /configuration/i })).toBeNull(), + ); + + // FileList empty-state "Choose configuration": Load mode, not Create. + await user.click(screen.getByRole("button", { name: /choose configuration/i })); + const picker = await screen.findByRole("dialog", { name: /load configuration/i }); + expect( + within(picker).getByRole("button", { name: /^load configuration$/i }), + ).toBeTruthy(); + }); +}); diff --git a/src/profiles/web/src/App.tsx b/src/profiles/web/src/App.tsx index a2d9cc8..b3fdaaa 100644 --- a/src/profiles/web/src/App.tsx +++ b/src/profiles/web/src/App.tsx @@ -37,6 +37,7 @@ import { SearchBar } from "./components/SearchBar"; import { LogViewerModal } from "./components/LogViewerModal"; import { ShortcutsModal } from "./components/ShortcutsModal"; import { LoadConfigModal } from "./components/LoadConfigModal"; +import type { ConfigPickerMode } from "./components/LoadConfigModal"; import { FilePropertiesModal } from "./components/FilePropertiesModal"; import { BarcodeModal } from "./components/BarcodeModal"; import { CameraBarcodeModal } from "./components/CameraBarcodeModal"; @@ -77,7 +78,13 @@ export default function App() { const [reloading, setReloading] = useState(false); const [language, setLanguage] = useState<"en" | "fr">("en"); const [showDirPicker, setShowDirPicker] = useState(false); - const [showConfigPicker, setShowConfigPicker] = useState(false); + /** + * Config picker intent (issue #192): null = closed, "create" = the + * first-run auto-prompt, "load" = an explicit Load/Choose action. The + * mode lives HERE because the caller knows why the picker opened; + * LoadConfigModal no longer infers it from the global config state. + */ + const [configPickerMode, setConfigPickerMode] = useState(null); // In-app YAML configuration editor (issue #95), opened from the StatusBar // "Config" button. The old OS-launch behavior moved into the editor's // header ("Open in OS"). @@ -393,7 +400,8 @@ export default function App() { if (cfg.recursive_search !== undefined) setRecursive(cfg.recursive_search); if (initialFilter) setFilterText(initialFilter); if (!cfg.config_exists) { - setShowConfigPicker(true); + // First-run auto-prompt: the ONLY entry point that proposes create. + setConfigPickerMode("create"); } if (initialDir) { @@ -810,7 +818,7 @@ export default function App() { contextMenuPos || showShortcuts || showDirPicker || - showConfigPicker || + configPickerMode !== null || showPropertiesModal || showLogViewer || showTimerModal || @@ -907,7 +915,9 @@ export default function App() { recursive={recursive} onDisableRecursive={handleDisableRecursive} onOpenDirectory={handleOpenActiveDirectory} - onLoadConfig={() => setShowConfigPicker(true)} + // FileList empty-state "Choose configuration" (issue #192): an + // explicit choose action always opens the picker in Load mode. + onLoadConfig={() => setConfigPickerMode("load")} filterText={filterText} onClearFilter={handleClearFilter} columnHeaders={config?.column_headers || []} @@ -972,7 +982,9 @@ export default function App() { open={showConfigEditor} onClose={() => setShowConfigEditor(false)} onApplied={handleConfigLoaded} - onLoadConfig={() => setShowConfigPicker(true)} + // Editor header "Load config file…" (issue #192): an explicit load + // action opens the picker in Load mode, never the first-run Create. + onLoadConfig={() => setConfigPickerMode("load")} reloadKey={editorReloadKey} /> @@ -980,10 +992,10 @@ export default function App() { so an editor left open underneath re-fetches the freshly picked file instead of keeping stale text (issue #101). */} setShowConfigPicker(false)} + onClose={() => setConfigPickerMode(null)} onLoaded={(cfg) => { void handleConfigLoaded(cfg); setEditorReloadKey((key) => key + 1); diff --git a/src/profiles/web/src/components/LoadConfigModal.test.tsx b/src/profiles/web/src/components/LoadConfigModal.test.tsx new file mode 100644 index 0000000..75a0fd3 --- /dev/null +++ b/src/profiles/web/src/components/LoadConfigModal.test.tsx @@ -0,0 +1,158 @@ +// @vitest-environment jsdom +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { cleanup, render, screen, waitFor, within } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { LoadConfigModal } from "./LoadConfigModal"; +import { browseForConfigFiles, createConfigFile, loadConfigFile } from "../api/client"; +import type { AppConfigData, BrowseResult } from "../api/types"; + +/** + * Unit tests for the config picker's explicit mode (issue #192): the + * caller tells the component WHY it opened — an explicit load action or + * the first-run create prompt — instead of the component inferring it + * from the global config state (`configExists === false`). + */ + +vi.mock("../api/client", () => ({ + browseForConfigFiles: vi.fn(), + createConfigFile: vi.fn(), + loadConfigFile: vi.fn(), +})); + +const browseSpy = vi.mocked(browseForConfigFiles); +const createSpy = vi.mocked(createConfigFile); +const loadSpy = vi.mocked(loadConfigFile); + +function makeBrowse(overrides: Partial = {}): BrowseResult { + return { + current_path: "/home/user/.profiles", + parent_path: "/home/user", + items: [ + { + name: "other.profiles", + path: "/home/user/.profiles/other.profiles", + is_dir: false, + is_config: true, + }, + ], + ...overrides, + }; +} + +function makeLoadedConfig(overrides: Partial = {}): AppConfigData { + return { + title: "other", + release: "1.0", + search_dir: "/home/user/data", + recursive_search: false, + theme: "dark", + directories: ["/home/user/data"], + extensions: [".mttl"], + filters: [], + active_directory: "/home/user/data", + config_path: "/home/user/.profiles/other.profiles", + config_exists: true, + column_headers: [], + column_names: [], + row_colors: [], + ...overrides, + }; +} + +function renderModal(overrides: { mode?: "load" | "create"; isOpen?: boolean } = {}) { + const onClose = vi.fn(); + const onLoaded = vi.fn(); + render( + , + ); + return { onClose, onLoaded }; +} + +beforeEach(() => { + vi.clearAllMocks(); + browseSpy.mockResolvedValue(makeBrowse()); +}); + +afterEach(() => { + cleanup(); + document.body.innerHTML = ""; +}); + +describe("LoadConfigModal modes (issue #192)", () => { + it("mode=create renders the create title, banner and primary button", async () => { + renderModal({ mode: "create" }); + + const dialog = await screen.findByRole("dialog"); + expect(within(dialog).getByRole("heading", { name: "Create configuration" })).toBeTruthy(); + expect( + within(dialog).getByText(/no configuration file was found/i), + ).toBeTruthy(); + expect( + await within(dialog).findByRole("button", { name: /create configuration/i }), + ).toBeTruthy(); + expect(browseSpy).toHaveBeenCalled(); + }); + + it("mode=create creates the config in the typed directory", async () => { + createSpy.mockResolvedValue(makeLoadedConfig()); + const { onLoaded, onClose } = renderModal({ mode: "create" }); + + const dialog = await screen.findByRole("dialog"); + await userEvent.setup().click( + await within(dialog).findByRole("button", { name: /create configuration/i }), + ); + + await waitFor(() => expect(createSpy).toHaveBeenCalledWith("/home/user/.profiles")); + await waitFor(() => expect(onLoaded).toHaveBeenCalledWith(makeLoadedConfig())); + await waitFor(() => expect(onClose).toHaveBeenCalled()); + }); + + it("mode=load renders the load title and primary button without the create banner", async () => { + renderModal({ mode: "load" }); + + const dialog = await screen.findByRole("dialog"); + expect(within(dialog).getByRole("heading", { name: "Load configuration" })).toBeTruthy(); + expect(within(dialog).queryByText(/no configuration file was found/i)).toBeNull(); + expect( + await within(dialog).findByRole("button", { name: /^load configuration$/i }), + ).toBeTruthy(); + }); + + it("mode=load keeps the load button disabled until a config is selected", async () => { + renderModal({ mode: "load" }); + + const loadButton = () => + screen.getByRole("button", { name: /^load configuration$/i }) as HTMLButtonElement; + await waitFor(() => expect(loadButton()).toBeTruthy()); + expect(loadButton().disabled).toBe(true); + + // Selecting a configuration file enables the load action. + await userEvent.setup().click(screen.getByRole("button", { name: /other\.profiles/i })); + expect(loadButton().disabled).toBe(false); + }); + + it("mode=load loads the selected config file", async () => { + loadSpy.mockResolvedValue(makeLoadedConfig()); + const { onLoaded, onClose } = renderModal({ mode: "load" }); + + await userEvent + .setup() + .click(await screen.findByRole("button", { name: /other\.profiles/i })); + await userEvent.setup().click(screen.getByRole("button", { name: /^load configuration$/i })); + + await waitFor(() => expect(loadSpy).toHaveBeenCalledWith("/home/user/.profiles/other.profiles")); + await waitFor(() => expect(onLoaded).toHaveBeenCalledWith(makeLoadedConfig())); + await waitFor(() => expect(onClose).toHaveBeenCalled()); + }); + + it("closed modal renders nothing", () => { + renderModal({ isOpen: false }); + expect(screen.queryByRole("dialog")).toBeNull(); + }); +}); diff --git a/src/profiles/web/src/components/LoadConfigModal.tsx b/src/profiles/web/src/components/LoadConfigModal.tsx index 71fbe78..a68abe5 100644 --- a/src/profiles/web/src/components/LoadConfigModal.tsx +++ b/src/profiles/web/src/components/LoadConfigModal.tsx @@ -6,18 +6,24 @@ import { Check, ChevronRight, FileCog, FileText, Folder, Home, Loader2, X } from import { browseForConfigFiles, createConfigFile, loadConfigFile } from "../api/client"; import type { AppConfigData, BrowseResult } from "../api/types"; +/** Why the picker is open: an explicit load action, or the first-run + * auto-prompt that proposes creating a starter configuration (#192). + * The caller owns the intent; the component never infers it from + * unrelated global config state. */ +export type ConfigPickerMode = "load" | "create"; + export interface LoadConfigModalProps { isOpen: boolean; + mode: ConfigPickerMode; activeConfigPath?: string; - configExists?: boolean; onClose: () => void; onLoaded: (config: AppConfigData) => void; } export function LoadConfigModal({ isOpen, + mode, activeConfigPath, - configExists = true, onClose, onLoaded, }: LoadConfigModalProps) { @@ -30,7 +36,7 @@ export function LoadConfigModal({ const pathInputRef = useRef(null); const previousFocusRef = useRef(null); - const isCreateMode = configExists === false; + const isCreateMode = mode === "create"; useEffect(() => { if (!isOpen) { diff --git a/src/profiles/web/tsconfig.tsbuildinfo b/src/profiles/web/tsconfig.tsbuildinfo index 262f229..a7c57eb 100644 --- a/src/profiles/web/tsconfig.tsbuildinfo +++ b/src/profiles/web/tsconfig.tsbuildinfo @@ -1 +1 @@ -{"root":["./src/app.configeditor.test.tsx","./src/app.tsx","./src/main.tsx","./src/setup-tests.ts","./src/vite-env.d.ts","./src/vitest.d.ts","./src/api/client.test.ts","./src/api/client.ts","./src/api/types.ts","./src/components/actionbar.tsx","./src/components/barcodemodal.test.tsx","./src/components/barcodemodal.tsx","./src/components/camerabarcodemodal.tsx","./src/components/configeditormodal.test.tsx","./src/components/configeditormodal.tsx","./src/components/confirmdialog.tsx","./src/components/contextmenu.tsx","./src/components/copyableurl.test.tsx","./src/components/copyableurl.tsx","./src/components/directorypickermodal.tsx","./src/components/dropconfigoverlay.tsx","./src/components/editablecombobox.test.tsx","./src/components/editablecombobox.tsx","./src/components/errorboundary.tsx","./src/components/filelisttable.tsx","./src/components/filepropertiesmodal.tsx","./src/components/filtersyntaxhelper.tsx","./src/components/headerbar.tsx","./src/components/initerrorpanel.tsx","./src/components/loadconfigmodal.tsx","./src/components/logviewermodal.test.tsx","./src/components/logviewermodal.tsx","./src/components/markdownmessage.test.tsx","./src/components/markdownmessage.tsx","./src/components/saveasdialog.test.tsx","./src/components/saveasdialog.tsx","./src/components/scanstatusstrip.tsx","./src/components/searchbar.tsx","./src/components/shortcutsmodal.tsx","./src/components/singlematchpromptmodal.tsx","./src/components/statusbar.test.tsx","./src/components/statusbar.tsx","./src/components/timermodal.tsx","./src/components/tooltip.tsx","./src/components/workflowrunnermodal.test.tsx","./src/components/workflowrunnermodal.tsx","./src/utils/barcodedecoder.test.ts","./src/utils/barcodedecoder.ts","./src/utils/barcodescanner.ts","./src/utils/configdrop.test.ts","./src/utils/configdrop.ts","./src/utils/exportcsv.ts","./src/utils/fileproperties.test.ts","./src/utils/fileproperties.ts","./src/utils/searchsyntax.test.ts","./src/utils/searchsyntax.ts","./src/utils/theme.test.ts","./src/utils/theme.ts","./src/utils/usemodala11y.test.tsx","./src/utils/usemodala11y.ts","./src/utils/version.test.ts","./src/utils/version.ts"],"version":"5.7.3"} \ No newline at end of file +{"root":["./src/app.configeditor.test.tsx","./src/app.scanflow.test.tsx","./src/app.tsx","./src/main.tsx","./src/setup-tests.ts","./src/vite-env.d.ts","./src/vitest.d.ts","./src/api/client.test.ts","./src/api/client.ts","./src/api/types.ts","./src/components/actionbar.tsx","./src/components/barcodemodal.test.tsx","./src/components/barcodemodal.tsx","./src/components/camerabarcodemodal.tsx","./src/components/configeditormodal.test.tsx","./src/components/configeditormodal.tsx","./src/components/confirmdialog.tsx","./src/components/contextmenu.tsx","./src/components/copyableurl.test.tsx","./src/components/copyableurl.tsx","./src/components/directorypickermodal.tsx","./src/components/dropconfigoverlay.tsx","./src/components/editablecombobox.test.tsx","./src/components/editablecombobox.tsx","./src/components/errorboundary.tsx","./src/components/filelisttable.tsx","./src/components/filepropertiesmodal.tsx","./src/components/filtersyntaxhelper.tsx","./src/components/headerbar.tsx","./src/components/initerrorpanel.tsx","./src/components/lanconfirmdialog.test.tsx","./src/components/lanconfirmdialog.tsx","./src/components/loadconfigmodal.test.tsx","./src/components/loadconfigmodal.tsx","./src/components/logviewermodal.test.tsx","./src/components/logviewermodal.tsx","./src/components/markdownmessage.test.tsx","./src/components/markdownmessage.tsx","./src/components/saveasdialog.test.tsx","./src/components/saveasdialog.tsx","./src/components/scanstatusstrip.tsx","./src/components/searchbar.tsx","./src/components/shortcutsmodal.tsx","./src/components/singlematchpromptmodal.tsx","./src/components/statusbar.test.tsx","./src/components/statusbar.tsx","./src/components/timermodal.tsx","./src/components/tooltip.tsx","./src/components/workflowrunnermodal.test.tsx","./src/components/workflowrunnermodal.tsx","./src/hooks/useautorescantimer.test.tsx","./src/hooks/useautorescantimer.ts","./src/hooks/usebarcodemode.test.tsx","./src/hooks/usebarcodemode.ts","./src/hooks/usedragdropconfig.test.tsx","./src/hooks/usedragdropconfig.ts","./src/hooks/useexternalevents.test.tsx","./src/hooks/useexternalevents.ts","./src/hooks/useglobalshortcuts.test.tsx","./src/hooks/useglobalshortcuts.ts","./src/hooks/usemodala11y.test.tsx","./src/hooks/usemodala11y.ts","./src/hooks/usescancontroller.test.tsx","./src/hooks/usescancontroller.ts","./src/hooks/usetheme.test.tsx","./src/hooks/usetheme.ts","./src/hooks/usetoast.test.tsx","./src/hooks/usetoast.ts","./src/utils/barcodedecoder.test.ts","./src/utils/barcodedecoder.ts","./src/utils/barcodescanner.test.ts","./src/utils/barcodescanner.ts","./src/utils/configdrop.test.ts","./src/utils/configdrop.ts","./src/utils/exportcsv.ts","./src/utils/fileproperties.test.ts","./src/utils/fileproperties.ts","./src/utils/fileuri.test.ts","./src/utils/fileuri.ts","./src/utils/scandefaults.test.ts","./src/utils/scandefaults.ts","./src/utils/searchsyntax.test.ts","./src/utils/searchsyntax.ts","./src/utils/theme.test.ts","./src/utils/theme.ts","./src/utils/version.test.ts","./src/utils/version.ts"],"version":"5.7.3"} \ No newline at end of file diff --git a/tests/AGENTS.md b/tests/AGENTS.md index dcb1b4d..4af3212 100644 --- a/tests/AGENTS.md +++ b/tests/AGENTS.md @@ -37,6 +37,7 @@ tests/ ├── characterization/ # cross-cutting golden baseline (see exceptions) ├── core/ │ ├── test_actions.py # ← core/actions.py +│ ├── test_paths.py # ← core/paths.py (per-user path policy, #191) │ ├── config/ │ │ ├── test_inheritance.py # ← core/config/inheritance.py │ │ ├── test_loader.py # ← core/config/loader.py diff --git a/tests/conftest.py b/tests/conftest.py index a616189..e5cfe5a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,3 +55,20 @@ def empty_config_path(tmp_path: Path) -> Path: config_file = tmp_path / ".profiles" config_file.write_text(dedent(config_content)) return config_file + + +@pytest.fixture(scope="function") +def isolated_user_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: + """Point the per-user data dir at a temp home (issue #191 hermeticity). + + Every path helper in :mod:`profiles.core.paths` resolves the user + home through ``Path.home()``; patching it makes ``user_data_dir``, + ``user_config_path``, ``find_user_config``, the uninformative-directory + home check and the ``default_search_directory`` fallback all see the + same fake home, so tests never depend on (or pollute) the developer's + real ``~/.profiles`` folder. Returns the fake home itself. + """ + user_home = tmp_path / "uhome" + user_home.mkdir() + monkeypatch.setattr("profiles.core.paths.Path.home", lambda: user_home) + return user_home diff --git a/tests/core/config/test_loader.py b/tests/core/config/test_loader.py index d98f8b8..a31c41f 100644 --- a/tests/core/config/test_loader.py +++ b/tests/core/config/test_loader.py @@ -29,10 +29,11 @@ def test_with_none_searches_tree(self, tmp_path: Path, monkeypatch: pytest.Monke assert config.theme == "light" def test_not_found_uses_default_path( - self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, isolated_user_home ) -> None: monkeypatch.chdir(tmp_path) - # No .profiles in tree — falls back to default ".profiles" in CWD + # No .profiles in tree or user dir — defaults bound to the default + # path (issue #191: the project folder for a terminal launch) config = load_config() assert config.config_path == Path.cwd() / ".profiles" @@ -47,6 +48,45 @@ def test_fallback_to_profiles_yaml_when_profiles_missing( assert config.theme == "dark" assert config.config_path == fallback + def test_user_config_loaded_when_project_tree_empty( + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, isolated_user_home + ) -> None: + """No project config but ~/.profiles/.profiles exists → it loads (#191).""" + monkeypatch.chdir(tmp_path) + user_config = isolated_user_home / ".profiles" / ".profiles" + user_config.parent.mkdir(parents=True) + user_config.write_text("defaults:\n theme: dark\n", encoding="utf-8") + + config = load_config() + assert config.theme == "dark" + assert config.config_path == user_config + + def test_uninformative_cwd_skips_tree_search( + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, isolated_user_home + ) -> None: + """A System32-style CWD is never searched for configs (#191).""" + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + (system32 / ".profiles").write_text("defaults:\n theme: light\n", encoding="utf-8") + monkeypatch.chdir(system32) + + config = load_config() + # Not the System32 "project" config: defaults bound to the user path + assert config.config_path == isolated_user_home / ".profiles" / ".profiles" + + def test_default_path_is_user_config_for_launcher_cwd( + self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch, isolated_user_home + ) -> None: + """No config anywhere + System32 CWD → defaults bound to the user path.""" + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + + config = load_config() + assert config.config_path == isolated_user_home / ".profiles" / ".profiles" + class TestDefaultColumnsWithoutConfig: """Tests verifying default columns are set when no config file exists.""" @@ -140,3 +180,18 @@ def failing_write(*args, **kwargs): # noqa: ANN001 monkeypatch.setattr("profiles.core.actions.write_text_atomic", failing_write) assert propose_config_creation() is False + + def test_launcher_cwd_creates_in_user_dir( + self, monkeypatch: pytest.MonkeyPatch, tmp_path: Path, isolated_user_home + ) -> None: + """A System32-style CWD creates the config in ~/.profiles (#191).""" + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + monkeypatch.setattr("builtins.input", lambda: "y") + + assert propose_config_creation() is True + target = isolated_user_home / ".profiles" / ".profiles" + assert target.exists() + assert not (system32 / ".profiles").exists() diff --git a/tests/core/test_paths.py b/tests/core/test_paths.py new file mode 100644 index 0000000..68d2af1 --- /dev/null +++ b/tests/core/test_paths.py @@ -0,0 +1,205 @@ +"""Tests for :mod:`profiles.core.paths` — the per-user path policy. + +Issue #191: launcher-style launches (Start Menu, ``.desktop``) run with +an uninformative CWD (System32, the home folder) and must propose +``~/.profiles/.profiles`` instead of writing a config into a system +directory. All user-home-dependent behaviour is exercised through the +``isolated_user_home`` fixture so no test touches the real home. +""" + +from __future__ import annotations + +import sys +from pathlib import Path + +import pytest + +from profiles.core.paths import ( + USER_DATA_DIRNAME, + default_config_path, + default_search_directory, + find_user_config, + is_uninformative_directory, + user_config_path, + user_data_dir, +) + +pytestmark = pytest.mark.usefixtures("isolated_user_home") + + +class TestUserDataDir: + def test_user_data_dir_is_under_home(self, isolated_user_home: Path) -> None: + assert user_data_dir() == isolated_user_home / USER_DATA_DIRNAME + assert USER_DATA_DIRNAME == ".profiles" + + def test_user_config_path_is_primary_name_in_data_dir(self, isolated_user_home: Path) -> None: + assert user_config_path() == isolated_user_home / ".profiles" / ".profiles" + + def test_default_log_path_shares_the_data_dir(self, isolated_user_home: Path) -> None: + """Logs and the per-user config live in the same folder (#191).""" + from profiles.core.telemetry.diagnostics import default_log_path + + assert default_log_path() == user_data_dir() / "profiles.log" + + +class TestFindUserConfig: + def test_returns_none_when_data_dir_is_missing(self) -> None: + assert find_user_config() is None + + def test_finds_primary_name(self, isolated_user_home: Path) -> None: + config = user_config_path() + config.parent.mkdir(parents=True) + config.write_text("defaults:\n theme: light\n") + assert find_user_config() == config + + def test_yaml_fallback_only_without_primary(self, isolated_user_home: Path) -> None: + data_dir = user_data_dir() + data_dir.mkdir(parents=True) + yaml_config = data_dir / ".profiles.yaml" + yaml_config.write_text("defaults:\n theme: dark\n") + assert find_user_config() == yaml_config + + def test_primary_beats_yaml(self, isolated_user_home: Path) -> None: + data_dir = user_data_dir() + data_dir.mkdir(parents=True) + (data_dir / ".profiles").write_text("x") + yaml_config = data_dir / ".profiles.yaml" + yaml_config.write_text("x") + assert find_user_config() == data_dir / ".profiles" + + def test_ignores_directories_named_like_configs(self, isolated_user_home: Path) -> None: + """A directory must never be mistaken for a config file.""" + data_dir = user_data_dir() + (data_dir / ".profiles").mkdir(parents=True) + assert find_user_config() is None + + def test_ignores_nested_configs(self, isolated_user_home: Path) -> None: + """Depth 0 only: no wildcard walk of the data dir.""" + nested = user_data_dir() / "sub" / ".profiles" + nested.parent.mkdir(parents=True) + nested.write_text("x") + assert find_user_config() is None + + +class TestIsUninformativeDirectory: + def test_none_is_uninformative(self) -> None: + assert is_uninformative_directory(None) is True + + def test_filesystem_root_is_uninformative(self) -> None: + root = Path(tmp_root()) + assert is_uninformative_directory(root) is True + + def test_home_itself_is_uninformative(self, isolated_user_home: Path) -> None: + assert is_uninformative_directory(isolated_user_home) is True + + def test_directory_inside_home_is_informative(self, isolated_user_home: Path) -> None: + project = isolated_user_home / "project" + project.mkdir() + assert is_uninformative_directory(project) is False + + def test_python_prefix_is_uninformative(self, isolated_user_home: Path) -> None: + inside_runtime = Path(sys.prefix) / "lib" + assert is_uninformative_directory(inside_runtime) is True + + def test_executable_directory_is_uninformative(self, isolated_user_home: Path) -> None: + exe_dir = Path(sys.executable).resolve().parent + assert is_uninformative_directory(exe_dir) is True + + def test_system_root_env_is_uninformative( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + """A fake %SystemRoot% (via env, portable on every platform).""" + monkeypatch.setenv("SystemRoot", str(isolated_user_home / "Windows")) + system32 = isolated_user_home / "Windows" / "System32" + system32.mkdir(parents=True) + assert is_uninformative_directory(system32) is True + + def test_windir_env_is_uninformative( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + monkeypatch.setenv("windir", str(isolated_user_home / "WinDir")) + inside = isolated_user_home / "WinDir" / "SysWOW64" + inside.mkdir(parents=True) + assert is_uninformative_directory(inside) is True + + def test_program_files_env_is_uninformative( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + monkeypatch.setenv("ProgramFiles", str(isolated_user_home / "Program Files")) + inside = isolated_user_home / "Program Files" / "ProFiles" + inside.mkdir(parents=True) + assert is_uninformative_directory(inside) is True + + def test_program_files_x86_env_is_uninformative( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + monkeypatch.setenv("ProgramFiles(x86)", str(isolated_user_home / "PF86")) + inside = isolated_user_home / "PF86" / "ProFiles" + inside.mkdir(parents=True) + assert is_uninformative_directory(inside) is True + + def test_temp_dir_is_informative(self, tmp_path: Path) -> None: + assert is_uninformative_directory(tmp_path) is False + + +def tmp_root() -> str: + """Return a filesystem root for the current platform.""" + return "/" if sys.platform != "win32" else "C:\\" + + +class TestDefaultConfigPath: + def test_uninformative_start_proposes_user_config( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + system32 = isolated_user_home / "Windows" / "System32" + system32.mkdir(parents=True) + monkeypatch.setenv("SystemRoot", str(isolated_user_home / "Windows")) + assert default_config_path(system32) == user_config_path() + + def test_none_start_uses_cwd_policy( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + """None start resolves the CWD; an uninformative one → per-user path.""" + system32 = isolated_user_home / "Windows" / "System32" + system32.mkdir(parents=True) + monkeypatch.setenv("SystemRoot", str(isolated_user_home / "Windows")) + monkeypatch.chdir(system32) + assert default_config_path(None) == user_config_path() + + def test_informative_start_proposes_in_place(self, tmp_path: Path) -> None: + assert default_config_path(tmp_path) == tmp_path / ".profiles" + + def test_directory_collision_falls_back_to_user_config( + self, isolated_user_home: Path, tmp_path: Path + ) -> None: + """start/.profiles already being a DIRECTORY must never be proposed.""" + (tmp_path / ".profiles").mkdir() + assert default_config_path(tmp_path) == user_config_path() + + def test_existing_file_does_not_trigger_collision_fallback( + self, isolated_user_home: Path, tmp_path: Path + ) -> None: + """An existing .profiles FILE stays the candidate (idempotent).""" + (tmp_path / ".profiles").write_text("x") + assert default_config_path(tmp_path) == tmp_path / ".profiles" + + +class TestDefaultSearchDirectory: + def test_uninformative_start_returns_home( + self, isolated_user_home: Path, monkeypatch: pytest.MonkeyPatch + ) -> None: + system32 = isolated_user_home / "Windows" / "System32" + system32.mkdir(parents=True) + monkeypatch.setenv("SystemRoot", str(isolated_user_home / "Windows")) + assert default_search_directory(system32) == isolated_user_home + + def test_informative_start_returns_itself(self, tmp_path: Path) -> None: + assert default_search_directory(tmp_path) == tmp_path + + def test_none_start_resolves_cwd(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.chdir(tmp_path) + assert default_search_directory() == tmp_path + + def test_home_cwd_resolves_to_home(self, isolated_user_home: Path) -> None: + """CWD == home is uninformative: the scan target becomes home.""" + assert default_search_directory(isolated_user_home) == isolated_user_home diff --git a/tests/desktop/test_launcher.py b/tests/desktop/test_launcher.py index db0d532..4d47ab8 100644 --- a/tests/desktop/test_launcher.py +++ b/tests/desktop/test_launcher.py @@ -114,16 +114,51 @@ def test_applies_config_and_records_notification(self, tmp_path) -> None: assert events[-1]["config_applied"] is True assert "b.profiles" in events[-1]["message"] - def test_rejects_and_reports_a_non_config_file(self, tmp_path) -> None: + def test_skips_a_folder_document_without_events(self, tmp_path) -> None: + """A folder opened with the running app is not a config apply (#193). + + macOS delivers the opened folder as an odoc document too; launch + resolution skips it and falls back to the directory search, so the + running-window applier must not report a failed config apply — + no toast, no state change. + """ + state = ServerState(config=AppConfig(title="t")) + folder = tmp_path / "session" + folder.mkdir() + (folder / "a.profiles").write_text("defaults:\n title: A\n", encoding="utf-8") + + _make_document_applier(state)([str(folder)]) # must not raise + + assert state.external_events_after(0) == [] + assert state.config_path is None + + def test_skips_a_non_config_file_silently(self, tmp_path) -> None: + """A non-config document is skipped like launch resolution does (#193).""" state = ServerState(config=AppConfig(title="t")) junk = tmp_path / "junk.txt" junk.write_text("nope", encoding="utf-8") _make_document_applier(state)([str(junk)]) # must not raise + assert state.external_events_after(0) == [] + assert state.config_path is None + + def test_applies_a_case_variant_config_name(self, tmp_path) -> None: + """The skip guard accepts exactly what the apply step accepts. + + Case-insensitive like the load/save endpoints (issue #95 wave): a + ``ConfigB.PROFILES`` document applies instead of being skipped. + """ + state = ServerState(config=AppConfig(title="t")) + config = tmp_path / "ConfigB.PROFILES" + config.write_text("defaults:\n title: B\n", encoding="utf-8") + + _make_document_applier(state)([str(config)]) # must not raise + + assert state.config_path == config.resolve() events = state.external_events_after(0) - assert events[-1]["kind"] == "config_handoff_failed" - assert events[-1]["config_applied"] is False + assert events[-1]["kind"] == "config_handoff" + assert events[-1]["config_applied"] is True def test_reports_a_missing_file_without_raising(self, tmp_path) -> None: state = ServerState(config=AppConfig(title="t")) diff --git a/tests/launch/test_context.py b/tests/launch/test_context.py index ccb2b45..b91cfa4 100644 --- a/tests/launch/test_context.py +++ b/tests/launch/test_context.py @@ -282,7 +282,13 @@ def test_relative_documents_resolve_against_cwd(self, monkeypatch, tmp_path) -> class TestCwdIsUninformative: - """The GUI-launch CWD heuristic shared by the probe and odoc capture.""" + """The GUI-launch CWD heuristic shared by the probe and odoc capture. + + Delegates to profiles.core.paths.is_uninformative_directory (issue + #191), so System32-style and home-folder CWDs are uninformative on + every platform — verified here with monkeypatched env vars / homes + for portability. + """ def test_root_is_uninformative(self) -> None: assert cwd_is_uninformative(Path("/")) is True @@ -295,3 +301,14 @@ def test_runtime_prefix_is_uninformative(self) -> None: def test_real_working_directory_is_informative(self, tmp_path) -> None: assert cwd_is_uninformative(tmp_path) is False + + def test_system32_is_uninformative(self, isolated_user_home, monkeypatch) -> None: + """Start-Menu CWD (%SystemRoot%\\System32) must be discarded (#191).""" + monkeypatch.setenv("SystemRoot", str(isolated_user_home / "Windows")) + system32 = isolated_user_home / "Windows" / "System32" + system32.mkdir(parents=True) + assert cwd_is_uninformative(system32) is True + + def test_home_folder_is_uninformative(self, isolated_user_home) -> None: + """A launcher CWD == home says nothing about a project (#191).""" + assert cwd_is_uninformative(isolated_user_home) is True diff --git a/tests/launch/test_creation.py b/tests/launch/test_creation.py index 6e101b8..6f94ff6 100644 --- a/tests/launch/test_creation.py +++ b/tests/launch/test_creation.py @@ -84,3 +84,53 @@ def test_creation_result_is_immutable(self) -> None: # Should raise AttributeError if we try to modify with pytest.raises(AttributeError): result.status = "SKIPPED" # type: ignore + + +class TestStarterSearchDir: + """The starter's search_dir template placeholder (issue #191).""" + + @staticmethod + def _starter_search_dir(config_path: Path) -> str: + """Extract the search_dir value from a written starter file.""" + for line in config_path.read_text(encoding="utf-8").splitlines(): + stripped = line.strip() + if stripped.startswith("search_dir:"): + return stripped.split(":", 1)[1].strip().strip("'\"") + raise AssertionError("starter has no search_dir line") + + def test_project_target_scans_itself(self, tmp_path, monkeypatch) -> None: + """A project-directory creation scans the project folder.""" + monkeypatch.chdir(tmp_path) + result = propose_creation(tmp_path) + + assert result.status == "CREATED" + assert self._starter_search_dir(result.path) == str(tmp_path) + + def test_explicit_search_dir_is_used(self, tmp_path) -> None: + """An explicit search_dir lands in the template verbatim.""" + scan_dir = tmp_path / "programs" + scan_dir.mkdir() + result = propose_creation(tmp_path, search_dir=scan_dir) + + assert result.status == "CREATED" + assert self._starter_search_dir(result.path) == str(scan_dir) + + def test_user_data_dir_target_scans_home( + self, tmp_path, isolated_user_home, monkeypatch + ) -> None: + """Creating in ~/.profiles scans the home, not the data dir (#191). + + The data folder only holds logs and configs, so scanning it is + useless; with an uninformative CWD (Start-Menu style) the scan + target falls back to the home folder itself. + """ + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + + data_dir = isolated_user_home / ".profiles" + result = propose_creation(data_dir) + + assert result.status == "CREATED" + assert self._starter_search_dir(result.path) == str(isolated_user_home) diff --git a/tests/launch/test_resolution.py b/tests/launch/test_resolution.py index e7fcaf7..123055e 100644 --- a/tests/launch/test_resolution.py +++ b/tests/launch/test_resolution.py @@ -3,10 +3,17 @@ These tests verify the pure decision logic that chooses which configuration file ProFiles should use at startup. No files are read or written here; that is tested in :mod:`test_creation`. + +Since issue #191 the resolution also consults the per-user default +(``~/.profiles/.profiles``) as the final fallback and skips the CWD tree +search for uninformative directories — the user home is isolated through +the ``isolated_user_home`` fixture wherever that fallback is in play. """ from __future__ import annotations +import pytest + from profiles.launch.context import LaunchContext from profiles.launch.resolution import resolve_config_path @@ -76,8 +83,8 @@ def test_tree_search_from_working_directory(self, tmp_path) -> None: result = resolve_config_path(ctx) assert result == deep - def test_no_match_returns_none(self, tmp_path) -> None: - """When nothing is found, resolve_config_path returns None.""" + def test_no_match_returns_none(self, tmp_path, isolated_user_home) -> None: + """When nothing is found anywhere, resolve_config_path returns None.""" ctx = LaunchContext( document_paths=(), working_directory=tmp_path, @@ -157,3 +164,108 @@ def test_search_tier_priority(self, tmp_path) -> None: source="cwd", ) assert resolve_config_path(ctx) == yaml_conf + + +class TestPerUserConfigFallback: + """The per-user default (~/.profiles/.profiles) as final fallback (#191).""" + + def test_empty_tree_falls_back_to_user_config(self, tmp_path, isolated_user_home) -> None: + """Matrix row 6: no project config, user config exists → it wins.""" + user_config = isolated_user_home / ".profiles" / ".profiles" + user_config.parent.mkdir(parents=True) + user_config.write_text("defaults:\n theme: dark\n") + + ctx = LaunchContext( + document_paths=(), + working_directory=tmp_path, + explicit_config=None, + source="cwd", + ) + assert resolve_config_path(ctx) == user_config + + def test_project_config_beats_user_config(self, tmp_path, isolated_user_home) -> None: + """A project config in the CWD tree still wins over the user one.""" + user_config = isolated_user_home / ".profiles" / ".profiles" + user_config.parent.mkdir(parents=True) + user_config.write_text("x") + + project_config = tmp_path / ".profiles" + project_config.write_text("x") + + ctx = LaunchContext( + document_paths=(), + working_directory=tmp_path, + explicit_config=None, + source="cwd", + ) + assert resolve_config_path(ctx) == project_config + + def test_uninformative_cwd_skips_tree_search( + self, tmp_path, isolated_user_home, monkeypatch + ) -> None: + """A System32-style CWD is never walked for configs (#191).""" + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + # A config inside the "system" tree must NOT be discovered. + (system32 / ".profiles").write_text("x") + + ctx = LaunchContext( + document_paths=(), + working_directory=system32, + explicit_config=None, + source="cwd", + ) + assert resolve_config_path(ctx) is None + + def test_uninformative_cwd_with_user_config_falls_back( + self, tmp_path, isolated_user_home, monkeypatch + ) -> None: + """Matrix row 4: launcher start, user config exists → loaded.""" + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + + user_config = isolated_user_home / ".profiles" / ".profiles" + user_config.parent.mkdir(parents=True) + user_config.write_text("x") + + ctx = LaunchContext( + document_paths=(), + working_directory=system32, + explicit_config=None, + source="cwd", + ) + assert resolve_config_path(ctx) == user_config + + def test_yaml_user_config_is_found(self, tmp_path, isolated_user_home) -> None: + """The legacy .profiles.yaml name also works as the user default.""" + user_config = isolated_user_home / ".profiles" / ".profiles.yaml" + user_config.parent.mkdir(parents=True) + user_config.write_text("x") + + ctx = LaunchContext( + document_paths=(), + working_directory=tmp_path, + explicit_config=None, + source="cwd", + ) + assert resolve_config_path(ctx) == user_config + + @pytest.mark.parametrize("winner", ["explicit", "document"]) + def test_explicit_and_document_still_win(self, tmp_path, isolated_user_home, winner) -> None: + """Explicit flags and opened documents outrank the user default.""" + user_config = isolated_user_home / ".profiles" / ".profiles" + user_config.parent.mkdir(parents=True) + user_config.write_text("x") + + winning = tmp_path / "winner.profiles" + winning.write_text("x") + + ctx = LaunchContext( + document_paths=(winning,) if winner == "document" else (), + working_directory=tmp_path, + explicit_config=winning if winner == "explicit" else None, + source=winner, + ) + assert resolve_config_path(ctx) == winning diff --git a/tests/server/routes/test_config.py b/tests/server/routes/test_config.py index 1f4d3a3..ae17692 100644 --- a/tests/server/routes/test_config.py +++ b/tests/server/routes/test_config.py @@ -138,3 +138,76 @@ async def test_fs_browse(test_state: ServerState, tmp_path: Path) -> None: data = response.json() assert "items" in data assert any(item["name"] == "programs" and item["is_dir"] for item in data["items"]) + + +# --------------------------------------------------------------------------- +# Per-user config path policy (issue #191) +# --------------------------------------------------------------------------- + + +class TestActiveConfigPathPolicy: + """ServerState.active_config_path fallback rules from issue #191.""" + + def test_never_returns_an_existing_directory(self, test_state, tmp_path: Path) -> None: + """A directory (the ~/.profiles log-dir collision) is never the config.""" + collision = tmp_path / ".profiles" + collision.mkdir() # a DIRECTORY named like a config + test_state.config_path = collision + assert test_state.active_config_path() != collision + assert not test_state.active_config_path().is_dir() + + def test_falls_back_to_default_config_path_when_unanchored( + self, test_state, tmp_path: Path, isolated_user_home, monkeypatch + ) -> None: + """No recorded path → default_config_path (CWD-aware, issue #191). + + An informative empty CWD proposes in place; a System32-style CWD + proposes the per-user ``~/.profiles/.profiles``. + """ + test_state.config_path = None + test_state.config.config_path = None + + empty_cwd = tmp_path / "empty-cwd" + empty_cwd.mkdir() + monkeypatch.chdir(empty_cwd) + assert test_state.active_config_path() == empty_cwd / ".profiles" + + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + assert test_state.active_config_path() == (isolated_user_home / ".profiles" / ".profiles") + + def test_recorded_file_path_is_returned_as_is(self, test_state, tmp_path: Path) -> None: + anchored = tmp_path / "sub" / ".profiles" + anchored.parent.mkdir() + anchored.write_text("version: 1\n", encoding="utf-8") + test_state.config_path = anchored + assert test_state.active_config_path() == anchored + + +@pytest.mark.anyio +async def test_get_config_prefills_home_for_uninformative_cwd( + tmp_path: Path, isolated_user_home, monkeypatch +) -> None: + """Empty-config first paint never scans System32 (issue #191). + + Given: a defaults-only config with NO candidate directories at all + When: GET /api/config runs with a %SystemRoot%\\System32-style CWD + Then: the active-directory fallback is the (isolated) home folder + """ + config = AppConfig(title="Fresh Install", search_dir="", extensions=(".mttl",)) + config.config_path = tmp_path / "nowhere" / ".profiles" + state = ServerState(config=config, active_directory=None) + + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.get("/api/config") + + assert response.status_code == 200 + assert response.json()["active_directory"] == str(isolated_user_home) diff --git a/tests/server/routes/test_config_editor.py b/tests/server/routes/test_config_editor.py index 31ed258..5c7df38 100644 --- a/tests/server/routes/test_config_editor.py +++ b/tests/server/routes/test_config_editor.py @@ -963,3 +963,34 @@ async def test_save_as_response_carries_content_hash(tmp_path: Path) -> None: payload = response.json() assert payload["status"] == "SAVED" assert payload["content_hash"] == content_hash(new_text) + + +@pytest.mark.anyio +async def test_template_without_active_directory_uses_default_search_directory( + tmp_path: Path, isolated_user_home, monkeypatch +) -> None: + """No active directory + launcher-style CWD → scan target is home (#191). + + The template's search_dir fallback must not inherit the process CWD: + a Start-Menu launch would otherwise draft a starter scanning System32. + """ + state = ServerState( + config=AppConfig(title="Fresh", search_dir="", extensions=(".txt",)), + active_directory=None, + ) + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post("/api/config/template") + + assert response.status_code == 200 + search_line = next( + line + for line in response.json()["content"].splitlines() + if line.lstrip().startswith("search_dir:") + ) + assert str(isolated_user_home) in search_line diff --git a/tests/server/routes/test_config_load.py b/tests/server/routes/test_config_load.py index 587c8cb..70a6ac9 100644 --- a/tests/server/routes/test_config_load.py +++ b/tests/server/routes/test_config_load.py @@ -369,3 +369,41 @@ async def test_create_refuses_overwrite(config_state: ServerState, tmp_path: Pat assert response.status_code == 400 assert "already exists" in response.json()["detail"].lower() + + +@pytest.mark.anyio +async def test_create_in_user_data_dir_scans_home( + tmp_path: Path, isolated_user_home, monkeypatch +) -> None: + """Creating in ~/.profiles writes there and drafts a home scan dir (#191). + + Given: a session with no active directory and a System32-style CWD + When: POST /api/config/create targets the per-user data directory + Then: the starter lands at ~/.profiles/.profiles and its search_dir + points at the home folder — never at the process CWD. + """ + state = ServerState( + config=AppConfig(title="Fresh", search_dir="", extensions=(".mttl",)), + active_directory=None, + ) + monkeypatch.setenv("SystemRoot", str(tmp_path)) + system32 = tmp_path / "System32" + system32.mkdir() + monkeypatch.chdir(system32) + + data_dir = isolated_user_home / ".profiles" + app = create_app(state) + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post("/api/config/create", json={"directory": str(data_dir)}) + + assert response.status_code == 200 + created = data_dir / ".profiles" + assert created.exists() + assert response.json()["config_path"] == str(created) + search_line = next( + line + for line in created.read_text(encoding="utf-8").splitlines() + if line.lstrip().startswith("search_dir:") + ) + assert str(isolated_user_home) in search_line + assert "System32" not in search_line diff --git a/tests/test_app_launch_resolution.py b/tests/test_app_launch_resolution.py index 5011c32..f82e2ab 100644 --- a/tests/test_app_launch_resolution.py +++ b/tests/test_app_launch_resolution.py @@ -2,6 +2,8 @@ from __future__ import annotations +import pytest + from profiles.app import ProFileApp @@ -14,7 +16,7 @@ def test_explicit_config_flag_wins(self, tmp_path, monkeypatch) -> None: explicit.write_text("x") app = ProFileApp(config_path=explicit) - resolved, missing = app._resolve_startup_config(explicit) + resolved, missing, _default = app._resolve_startup_config(explicit) assert resolved == explicit assert missing is False @@ -30,16 +32,18 @@ def test_no_args_in_dir_with_config_finds_it( monkeypatch.chdir(tmp_path) app = ProFileApp() - resolved, missing = app._resolve_startup_config(None) + resolved, missing, _default = app._resolve_startup_config(None) assert resolved == config assert missing is False - def test_no_args_no_config_returns_none(self, monkeypatch, tmp_path) -> None: + def test_no_args_no_config_returns_none( + self, monkeypatch, tmp_path, isolated_user_home + ) -> None: """When no config found anywhere, returns None.""" monkeypatch.chdir(tmp_path) app = ProFileApp() - resolved, missing = app._resolve_startup_config(None) + resolved, missing, _default = app._resolve_startup_config(None) assert resolved is None assert missing is False @@ -53,7 +57,7 @@ def test_missing_explicit_config_is_reported( missing = tmp_path / "nonexistent.profiles" app = ProFileApp(config_path=missing) - resolved, missing_flag = app._resolve_startup_config(missing) + resolved, missing_flag, _default = app._resolve_startup_config(missing) assert resolved == missing assert missing_flag is True @@ -62,11 +66,13 @@ def test_missing_explicit_config_is_reported( class TestLaunchSourceRecording: """The context source is remembered for the handoff gate (issue #188).""" - def test_folder_search_launch_records_cwd_source(self, monkeypatch, tmp_path) -> None: + def test_folder_search_launch_records_cwd_source( + self, monkeypatch, tmp_path, isolated_user_home + ) -> None: """A launch with no explicit/doc signal is folder-search driven.""" monkeypatch.chdir(tmp_path) app = ProFileApp() - resolved, _missing = app._resolve_startup_config(None) + resolved, _missing, _default = app._resolve_startup_config(None) assert resolved is None # no literal config name in the folder assert app._launch_source == "cwd" @@ -107,8 +113,69 @@ def test_odoc_document_drives_resolution(self, monkeypatch, tmp_path, mocker) -> ) app = ProFileApp() - resolved, missing = app._resolve_startup_config(None) + resolved, missing, _default = app._resolve_startup_config(None) assert resolved == clicked assert missing is False assert app._launch_source == "document" + + +class TestStartMenuLaunch: + """Simulated launcher-style launches with an uninformative CWD (#191). + + A Start-Menu shortcut with an empty "Start in" runs with + ``CWD = %SystemRoot%\\System32``. The simulated repro monkeypatches + the CWD to a fake System32 and ``Path.home()`` to a temp folder, so + the whole startup resolution is exercised hermetically on any OS. + """ + + @pytest.fixture + def fake_system32_home(self, tmp_path, monkeypatch): + """Fake %SystemRoot%\\System32 CWD + fake home; yields (cwd, home). + + The macOS Finder probe is stubbed out: an uninformative CWD is + exactly the condition that triggers it, and the dev machine's + real front Finder window must never leak into the result. + """ + system_root = tmp_path / "Windows" + system32 = system_root / "System32" + system32.mkdir(parents=True) + user_home = tmp_path / "uhome" + user_home.mkdir() + monkeypatch.setenv("SystemRoot", str(system_root)) + monkeypatch.chdir(system32) + monkeypatch.setattr("profiles.core.paths.Path.home", lambda: user_home) + monkeypatch.setattr("profiles.launch.context._finder_working_directory", lambda: None) + return system32, user_home + + def test_resolution_proposes_user_config_path(self, fake_system32_home, monkeypatch) -> None: + """System32 CWD + empty home → launch default is ~/.profiles/.profiles.""" + _system32, user_home = fake_system32_home + app = ProFileApp() + resolved, missing, launch_default = app._resolve_startup_config(None) + + assert resolved is None # System32 tree is never searched + assert missing is False + assert launch_default == user_home / ".profiles" / ".profiles" + + def test_load_configuration_binds_user_config_path(self, fake_system32_home, mocker) -> None: + """AppConfig.config_path carries the per-user path for the UI.""" + _system32, user_home = fake_system32_home + app = ProFileApp() + config = app._load_configuration(mocker.Mock()) + + assert config.config_path == user_home / ".profiles" / ".profiles" + assert app._config_path == config.config_path + + def test_existing_user_config_is_loaded_on_relaunch(self, fake_system32_home) -> None: + """Matrix row 4: second Start-Menu launch loads the user config.""" + _system32, user_home = fake_system32_home + user_config = user_home / ".profiles" / ".profiles" + user_config.parent.mkdir(parents=True) + user_config.write_text("defaults:\n theme: dark\n", encoding="utf-8") + + app = ProFileApp() + resolved, missing, _default = app._resolve_startup_config(None) + + assert resolved == user_config + assert missing is False