diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9daeb0..e042ef2 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'] + # dist/ is committed on purpose (see src/profiles/web/.gitignore): + # the built frontend ships with the package, and the minified + # bundle legitimately exceeds 1 MB. + exclude: ^src/profiles/web/dist/ # Ruff - Linter et formatter - repo: https://github.com/astral-sh/ruff-pre-commit diff --git a/src/profiles/core/telemetry/events.py b/src/profiles/core/telemetry/events.py index 3aace9a..9469b0e 100644 --- a/src/profiles/core/telemetry/events.py +++ b/src/profiles/core/telemetry/events.py @@ -98,6 +98,31 @@ def web_client_left(logger: logging.Logger, *, ip: str, idle_s: int) -> None: logger.info('WEB_CLIENT event="disconnected" ip="%s" idle_s=%d', ip, idle_s) +def toast( + logger: logging.Logger, + *, + source: str, + kind: str, + message: str, + applied: bool | None = None, +) -> None: + """Emit TOAST — a UI toast notification mirrored into the log (issue #194). + + DEBUG by design ("nice to have, zero noise"): the record reaches + ``profiles.log`` only when the config's ``verbose`` is ``DEBUG``. + ``source`` distinguishes server-buffered events (``server``, logged at + the :meth:`ServerState.record_external_event` choke point) from + frontend toasts relayed by ``POST /api/logs/client`` (``web``). + ``applied`` is only emitted when known — server handoff events carry + it, frontend toasts do not. + """ + parts = [f"source={_quote(source)}", f"kind={_quote(kind)}"] + if applied is not None: + parts.append(f"applied={_bool(applied)}") + parts.append(f"msg={_quote(message)}") + logger.debug("TOAST %s", " ".join(parts)) + + def bind_changed(logger: logging.Logger, *, host: str, lan: bool) -> None: """Emit BIND_CHANGED — the server rebound between LAN exposure and loopback.""" logger.info('BIND_CHANGED host="%s" lan=%s', host, "true" if lan else "false") diff --git a/src/profiles/server/routes/logs.py b/src/profiles/server/routes/logs.py index 7903745..6ef65e6 100644 --- a/src/profiles/server/routes/logs.py +++ b/src/profiles/server/routes/logs.py @@ -2,16 +2,35 @@ from __future__ import annotations +import logging +from typing import Literal + from fastapi import APIRouter, HTTPException, Query +from pydantic import BaseModel, Field -from profiles.core.telemetry import log_viewer +from profiles.core.telemetry import events, log_viewer from profiles.core.telemetry.diagnostics import default_log_path router = APIRouter(prefix="/api/logs", tags=["logs"]) +# Server-side telemetry logger (the "profiles" logger writes profiles.log); +# same module-level lookup as server/app.py. +_LOGGER = logging.getLogger("profiles") + # Matches the default used by ProFileApp; overridable per request. _DEFAULT_LOG_PATH = default_log_path() +# Frontend toasts are one-liners by construction; the cap keeps a stray or +# hostile client (the server can be LAN-exposed) from flooding profiles.log. +_MAX_CLIENT_MESSAGE_LENGTH = 500 + + +class ClientLogRequest(BaseModel): + """Body of ``POST /api/logs/client`` — a frontend toast mirror (issue #194).""" + + message: str = Field(min_length=1, max_length=_MAX_CLIENT_MESSAGE_LENGTH) + kind: Literal["info", "error"] = "info" + @router.get("") async def get_logs( @@ -60,3 +79,15 @@ async def get_logs( for entry in entries ], } + + +@router.post("/client") +async def post_client_log(payload: ClientLogRequest) -> dict: + """Mirror a frontend toast into ``profiles.log`` at DEBUG (issue #194). + + Logging only, fire-and-forget from the client's perspective: failures + here must never surface in the UI, and this endpoint must never buffer + an external event (no toast feedback loop). + """ + events.toast(_LOGGER, source="web", kind=payload.kind, message=payload.message) + return {"status": "ok"} diff --git a/src/profiles/server/state.py b/src/profiles/server/state.py index efc4e32..1d7870c 100644 --- a/src/profiles/server/state.py +++ b/src/profiles/server/state.py @@ -2,15 +2,21 @@ from __future__ import annotations +import logging from dataclasses import dataclass, field 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.models import AppConfig +from profiles.core.telemetry import events _MAX_EXTERNAL_EVENTS = 50 +# Server-side telemetry logger (the "profiles" logger writes profiles.log); +# same module-level lookup as server/app.py. +_LOGGER = logging.getLogger("profiles") + class BindableServer(Protocol): """The subset of ``BackgroundServer`` the route layer touches. @@ -76,6 +82,10 @@ def record_external_event( The buffer is capped so a long-lived server cannot grow it without bound even when no client is polling. + + Every event is also mirrored to the logger as a DEBUG TOAST + record (issue #194): the single choke point covers all current + and future producers (odoc applier, instance handoff route). """ self._external_event_seq += 1 self._external_events.append( @@ -89,6 +99,13 @@ def record_external_event( if len(self._external_events) > _MAX_EXTERNAL_EVENTS: excess = len(self._external_events) - _MAX_EXTERNAL_EVENTS del self._external_events[:excess] + events.toast( + _LOGGER, + source="server", + kind=kind, + message=message, + applied=config_applied, + ) return self._external_event_seq def external_events_after(self, after_id: int) -> list[dict[str, Any]]: diff --git a/src/profiles/web/dist/assets/index-CUYujBAx.css b/src/profiles/web/dist/assets/index-CUYujBAx.css deleted file mode 100644 index 3dd59ca..0000000 --- a/src/profiles/web/dist/assets/index-CUYujBAx.css +++ /dev/null @@ -1 +0,0 @@ -/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-800:oklch(43.2% .095 166.913);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-indigo-600:oklch(51.1% .262 276.966);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-900:oklch(20.8% .042 265.755);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-xs:4px;--blur-sm:8px;--blur-md:12px;--blur-xl:24px;--aspect-video:16 / 9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components{.glass-panel{background:var(--app-glass-panel);-webkit-backdrop-filter:blur(24px)saturate(160%);backdrop-filter:blur(24px)saturate(160%);box-shadow:var(--app-panel-shadow),inset 0 1px 0 var(--app-glass-highlight)}.glass-panel-strong{background:var(--app-glass-panel-strong);-webkit-backdrop-filter:blur(28px)saturate(180%);backdrop-filter:blur(28px)saturate(180%);box-shadow:var(--app-panel-shadow),inset 0 1px 0 var(--app-glass-highlight)}.btn{justify-content:center;align-items:center;gap:calc(var(--spacing) * 1.5);border-radius:var(--radius-md);border-style:var(--tw-border-style);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-width:1px;display:inline-flex}.btn:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);--tw-ring-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.btn:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 70%, transparent)}}.btn:focus-visible{--tw-outline-style:none;outline-style:none}.btn:disabled{cursor:not-allowed;opacity:.4}.btn-primary{background-color:var(--color-indigo-600);color:var(--color-white);border-color:#0000}@media(hover:hover){.btn-primary:hover{background-color:var(--color-indigo-500)}}.btn-secondary{border-color:var(--app-border);background-color:var(--app-elevated);color:var(--app-text-secondary)}@media(hover:hover){.btn-secondary:hover{border-color:var(--color-indigo-500);color:var(--app-text-primary)}.btn-chip:hover{--tw-brightness:brightness(95%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}}.btn-chip:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);--tw-ring-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.btn-chip:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 70%, transparent)}}.btn-chip:focus-visible{--tw-outline-style:none;outline-style:none}.btn-chip:disabled{cursor:not-allowed;opacity:.4}.focus-ring:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);--tw-ring-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.focus-ring:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 70%, transparent)}}.focus-ring:focus-visible{--tw-outline-style:none;outline-style:none}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{inset-block:0}.-top-1{top:calc(var(--spacing) * -1)}.top-0{top:0}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing) * 2)}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing) * -.5)}.-right-1{right:calc(var(--spacing) * -1)}.right-0{right:0}.right-2{right:calc(var(--spacing) * 2)}.-bottom-0\.5{bottom:calc(var(--spacing) * -.5)}.-bottom-1{bottom:calc(var(--spacing) * -1)}.bottom-0{bottom:0}.bottom-2{bottom:calc(var(--spacing) * 2)}.-left-1{left:calc(var(--spacing) * -1)}.left-0{left:0}.left-1\/2{left:50%}.left-2\.5{left:calc(var(--spacing) * 2.5)}.left-3{left:calc(var(--spacing) * 3)}.isolate{isolation:isolate}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-\[calc\(var\(--z-context-menu\)-1\)\]{z-index:calc(var(--z-context-menu) - 1)}.z-\[var\(--z-combobox-list\)\]{z-index:var(--z-combobox-list)}.z-\[var\(--z-context-menu\)\]{z-index:var(--z-context-menu)}.z-\[var\(--z-drop-overlay\)\]{z-index:var(--z-drop-overlay)}.z-\[var\(--z-modal\)\]{z-index:var(--z-modal)}.z-\[var\(--z-syntax-helper\)\]{z-index:var(--z-syntax-helper)}.z-\[var\(--z-toast\)\]{z-index:var(--z-toast)}.z-\[var\(--z-tooltip\)\]{z-index:var(--z-tooltip)}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.container\!{width:100%!important}@media(min-width:40rem){.container\!{max-width:40rem!important}}@media(min-width:48rem){.container\!{max-width:48rem!important}}@media(min-width:64rem){.container\!{max-width:64rem!important}}@media(min-width:80rem){.container\!{max-width:80rem!important}}@media(min-width:96rem){.container\!{max-width:96rem!important}}.mx-1{margin-inline:var(--spacing)}.mx-auto{margin-inline:auto}.my-1{margin-block:var(--spacing)}.my-1\.5{margin-block:calc(var(--spacing) * 1.5)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mr-1\.5{margin-right:calc(var(--spacing) * 1.5)}.mr-auto{margin-right:auto}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:var(--spacing)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.list-item{display:list-item}.table{display:table}.aspect-video{aspect-ratio:var(--aspect-video)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-12{height:calc(var(--spacing) * 12)}.h-48{height:calc(var(--spacing) * 48)}.h-\[80vh\]{height:80vh}.h-\[90vh\]{height:90vh}.h-\[min\(84dvh\,760px\)\]{height:min(84dvh,760px)}.h-dvh{height:100dvh}.h-full{height:100%}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[calc\(100dvh-1\.5rem\)\]{max-height:calc(100dvh - 1.5rem)}.max-h-\[calc\(100dvh-2rem\)\]{max-height:calc(100dvh - 2rem)}.max-h-\[calc\(100dvh-16px\)\]{max-height:calc(100dvh - 16px)}.min-h-0{min-height:0}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-10{min-height:calc(var(--spacing) * 10)}.min-h-16{min-height:calc(var(--spacing) * 16)}.min-h-24{min-height:calc(var(--spacing) * 24)}.min-h-36{min-height:calc(var(--spacing) * 36)}.min-h-\[24px\]{min-height:24px}.min-h-\[44px\]{min-height:44px}.min-h-screen{min-height:100vh}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-44{width:calc(var(--spacing) * 44)}.w-48{width:calc(var(--spacing) * 48)}.w-56{width:calc(var(--spacing) * 56)}.w-72{width:calc(var(--spacing) * 72)}.w-96{width:calc(var(--spacing) * 96)}.w-\[52px\]{width:52px}.w-\[138px\]{width:138px}.w-\[150px\]{width:150px}.w-\[280px\]{width:280px}.w-\[400px\]{width:400px}.w-\[420px\]{width:420px}.w-\[440px\]{width:440px}.w-\[450px\]{width:450px}.w-\[clamp\(560px\,85vw\,1500px\)\]{width:clamp(560px,85vw,1500px)}.w-\[min\(94vw\,560px\)\]{width:min(94vw,560px)}.w-\[min\(94vw\,960px\)\]{width:min(94vw,960px)}.w-full{width:100%}.w-max{width:max-content}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-\[220px\]{max-width:220px}.max-w-\[calc\(100vw-16px\)\]{max-width:calc(100vw - 16px)}.max-w-\[min\(70vw\,560px\)\]{max-width:min(70vw,560px)}.max-w-\[min\(80vw\,640px\)\]{max-width:min(80vw,640px)}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:0}.min-w-48{min-width:calc(var(--spacing) * 48)}.min-w-\[100px\]{min-width:100px}.min-w-\[220px\]{min-width:220px}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.basis-64{flex-basis:calc(var(--spacing) * 64)}.basis-full{flex-basis:100%}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-45{rotate:45deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.resize\!{resize:both!important}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-3\.5{gap:calc(var(--spacing) * 3.5)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-l-md{border-top-left-radius:var(--radius-md);border-bottom-left-radius:var(--radius-md)}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-2{border-right-style:var(--tw-border-style);border-right-width:2px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-0{border-left-style:var(--tw-border-style);border-left-width:0}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[var\(--app-editor-border\)\]{border-color:var(--app-editor-border)}.border-chip-amber-border{border-color:var(--chip-amber-border)}.border-chip-fuchsia-border{border-color:var(--chip-fuchsia-border)}.border-chip-indigo-border,.border-chip-indigo-border\/50{border-color:var(--chip-indigo-border)}@supports (color:color-mix(in lab,red,red)){.border-chip-indigo-border\/50{border-color:color-mix(in oklab,var(--chip-indigo-border) 50%,transparent)}}.border-chip-purple-border,.border-chip-purple-border\/50{border-color:var(--chip-purple-border)}@supports (color:color-mix(in lab,red,red)){.border-chip-purple-border\/50{border-color:color-mix(in oklab,var(--chip-purple-border) 50%,transparent)}}.border-chip-sky-border{border-color:var(--chip-sky-border)}.border-emerald-300\/50{border-color:#5ee9b580}@supports (color:color-mix(in lab,red,red)){.border-emerald-300\/50{border-color:color-mix(in oklab,var(--color-emerald-300) 50%,transparent)}}.border-emerald-500\/30{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/30{border-color:color-mix(in oklab,var(--color-emerald-500) 30%,transparent)}}.border-frame-line{border-color:var(--app-frame-border)}.border-indigo-400{border-color:var(--color-indigo-400)}.border-indigo-400\/80{border-color:#7d87ffcc}@supports (color:color-mix(in lab,red,red)){.border-indigo-400\/80{border-color:color-mix(in oklab,var(--color-indigo-400) 80%,transparent)}}.border-indigo-600{border-color:var(--color-indigo-600)}.border-line,.border-line\/40{border-color:var(--app-border)}@supports (color:color-mix(in lab,red,red)){.border-line\/40{border-color:color-mix(in oklab,var(--app-border) 40%,transparent)}}.border-line\/60{border-color:var(--app-border)}@supports (color:color-mix(in lab,red,red)){.border-line\/60{border-color:color-mix(in oklab,var(--app-border) 60%,transparent)}}.border-status-danger-border{border-color:var(--status-danger-border)}.border-status-success-border{border-color:var(--status-success-border)}.border-status-warning-border{border-color:var(--status-warning-border)}.border-transparent{border-color:#0000}.border-t-transparent{border-top-color:#0000}.border-l-transparent{border-left-color:#0000}.bg-\[var\(--app-editor-bg\)\]{background-color:var(--app-editor-bg)}.bg-app,.bg-app\/90{background-color:var(--app-bg)}@supports (color:color-mix(in lab,red,red)){.bg-app\/90{background-color:color-mix(in oklab,var(--app-bg) 90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black) 20%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-black\/65{background-color:#000000a6}@supports (color:color-mix(in lab,red,red)){.bg-black\/65{background-color:color-mix(in oklab,var(--color-black) 65%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black) 70%,transparent)}}.bg-chip-amber-bg{background-color:var(--chip-amber-bg)}.bg-chip-fuchsia-bg{background-color:var(--chip-fuchsia-bg)}.bg-chip-indigo-bg,.bg-chip-indigo-bg\/20{background-color:var(--chip-indigo-bg)}@supports (color:color-mix(in lab,red,red)){.bg-chip-indigo-bg\/20{background-color:color-mix(in oklab,var(--chip-indigo-bg) 20%,transparent)}}.bg-chip-purple-bg{background-color:var(--chip-purple-bg)}.bg-chip-sky-bg{background-color:var(--chip-sky-bg)}.bg-elevated,.bg-elevated\/30{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/30{background-color:color-mix(in oklab,var(--app-elevated) 30%,transparent)}}.bg-elevated\/50{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/50{background-color:color-mix(in oklab,var(--app-elevated) 50%,transparent)}}.bg-elevated\/60{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/60{background-color:color-mix(in oklab,var(--app-elevated) 60%,transparent)}}.bg-emerald-400{background-color:var(--color-emerald-400)}.bg-emerald-500{background-color:var(--color-emerald-500)}.bg-emerald-600{background-color:var(--color-emerald-600)}.bg-emerald-800\/60{background-color:#005f4699}@supports (color:color-mix(in lab,red,red)){.bg-emerald-800\/60{background-color:color-mix(in oklab,var(--color-emerald-800) 60%,transparent)}}.bg-indigo-500\/5{background-color:#625fff0d}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/5{background-color:color-mix(in oklab,var(--color-indigo-500) 5%,transparent)}}.bg-indigo-600{background-color:var(--color-indigo-600)}.bg-ink-faint{background-color:var(--app-text-faint)}.bg-status-danger-bg,.bg-status-danger-bg\/30{background-color:var(--status-danger-bg)}@supports (color:color-mix(in lab,red,red)){.bg-status-danger-bg\/30{background-color:color-mix(in oklab,var(--status-danger-bg) 30%,transparent)}}.bg-status-danger-bg\/40{background-color:var(--status-danger-bg)}@supports (color:color-mix(in lab,red,red)){.bg-status-danger-bg\/40{background-color:color-mix(in oklab,var(--status-danger-bg) 40%,transparent)}}.bg-status-success-bg{background-color:var(--status-success-bg)}.bg-status-warning-bg{background-color:var(--status-warning-bg)}.bg-surface{background-color:var(--app-surface)}.bg-surface-glass{background-color:var(--app-glass)}.bg-surface-strong,.bg-surface-strong\/20{background-color:var(--app-glass-strong)}@supports (color:color-mix(in lab,red,red)){.bg-surface-strong\/20{background-color:color-mix(in oklab,var(--app-glass-strong) 20%,transparent)}}.bg-surface-strong\/30{background-color:var(--app-glass-strong)}@supports (color:color-mix(in lab,red,red)){.bg-surface-strong\/30{background-color:color-mix(in oklab,var(--app-glass-strong) 30%,transparent)}}.bg-surface\/50{background-color:var(--app-surface)}@supports (color:color-mix(in lab,red,red)){.bg-surface\/50{background-color:color-mix(in oklab,var(--app-surface) 50%,transparent)}}.bg-surface\/60{background-color:var(--app-surface)}@supports (color:color-mix(in lab,red,red)){.bg-surface\/60{background-color:color-mix(in oklab,var(--app-surface) 60%,transparent)}}.bg-white{background-color:var(--color-white)}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-emerald-400\/90{--tw-gradient-from:#00d294e6}@supports (color:color-mix(in lab,red,red)){.from-emerald-400\/90{--tw-gradient-from:color-mix(in oklab, var(--color-emerald-400) 90%, transparent)}}.from-emerald-400\/90{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-emerald-600\/90{--tw-gradient-to:#009767e6}@supports (color:color-mix(in lab,red,red)){.to-emerald-600\/90{--tw-gradient-to:color-mix(in oklab, var(--color-emerald-600) 90%, transparent)}}.to-emerald-600\/90{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.fill-current{fill:currentColor}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-3\.5{padding-block:calc(var(--spacing) * 3.5)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-px{padding-block:1px}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pr-1{padding-right:var(--spacing)}.pr-2\.5{padding-right:calc(var(--spacing) * 2.5)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pr-10{padding-right:calc(var(--spacing) * 10)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-8{padding-left:calc(var(--spacing) * 8)}.pl-9{padding-left:calc(var(--spacing) * 9)}.text-center{text-align:center}.text-left{text-align:left}.align-\[1px\]{vertical-align:1px}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-chip-amber-text{color:var(--chip-amber-text)}.text-chip-fuchsia-text{color:var(--chip-fuchsia-text)}.text-chip-indigo-text{color:var(--chip-indigo-text)}.text-chip-purple-text{color:var(--chip-purple-text)}.text-chip-sky-text{color:var(--chip-sky-text)}.text-emerald-200{color:var(--color-emerald-200)}.text-ink{color:var(--app-text-primary)}.text-ink-faint{color:var(--app-text-faint)}.text-ink-muted,.text-ink-muted\/50{color:var(--app-text-muted)}@supports (color:color-mix(in lab,red,red)){.text-ink-muted\/50{color:color-mix(in oklab,var(--app-text-muted) 50%,transparent)}}.text-ink-secondary{color:var(--app-text-secondary)}.text-ink\/70{color:var(--app-text-primary)}@supports (color:color-mix(in lab,red,red)){.text-ink\/70{color:color-mix(in oklab,var(--app-text-primary) 70%,transparent)}}.text-slate-400{color:var(--color-slate-400)}.text-slate-900{color:var(--color-slate-900)}.text-status-danger-text,.text-status-danger-text\/60{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/60{color:color-mix(in oklab,var(--status-danger-text) 60%,transparent)}}.text-status-danger-text\/70{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/70{color:color-mix(in oklab,var(--status-danger-text) 70%,transparent)}}.text-status-danger-text\/80{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/80{color:color-mix(in oklab,var(--status-danger-text) 80%,transparent)}}.text-status-danger-text\/90{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/90{color:color-mix(in oklab,var(--status-danger-text) 90%,transparent)}}.text-status-success-text{color:var(--status-success-text)}.text-status-warning-text{color:var(--status-warning-text)}.text-white{color:var(--color-white)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.not-italic{font-style:normal}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.placeholder-ink-faint::placeholder{color:var(--app-text-faint)}.opacity-0{opacity:0}.opacity-40{opacity:.4}.opacity-90{opacity:.9}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_0_9999px_rgba\(0\,0\,0\,0\.45\)\]{--tw-shadow:0 0 0 9999px var(--tw-shadow-color,#00000073);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_2px_6px_rgb\(0_0_0\/0\.35\)\]{--tw-shadow:0 2px 6px var(--tw-shadow-color,#00000059);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.12\)\]{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff1f);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.35\)\,0_8px_24px_-6px_rgb\(16_185_129\/0\.55\)\]{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff59), 0 8px 24px -6px var(--tw-shadow-color,#10b9818c);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-app{--tw-ring-color:var(--app-bg)}.ring-chip-indigo-border\/40{--tw-ring-color:var(--chip-indigo-border)}@supports (color:color-mix(in lab,red,red)){.ring-chip-indigo-border\/40{--tw-ring-color:color-mix(in oklab, var(--chip-indigo-border) 40%, transparent)}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter\!{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )!important}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.backdrop-blur-xl{--tw-backdrop-blur:blur(var(--blur-xl));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.backdrop-blur-xs{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[filter\,box-shadow\,transform\]{transition-property:filter,box-shadow,transform;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){:is(:where(.group):hover .group-hover\:text-white){color:var(--color-white)}:is(:where(.group):hover .group-hover\:opacity-40){opacity:.4}:is(:where(.group):hover .group-hover\:opacity-100){opacity:1}}.selection\:bg-indigo-500 ::selection{background-color:var(--color-indigo-500)}.selection\:bg-indigo-500::selection{background-color:var(--color-indigo-500)}.selection\:text-white ::selection{color:var(--color-white)}.selection\:text-white::selection{color:var(--color-white)}.placeholder\:text-ink-faint::placeholder{color:var(--app-text-faint)}.first\:mt-0:first-child{margin-top:0}.last\:mb-0:last-child{margin-bottom:0}@media(hover:hover){.hover\:-translate-y-px:hover{--tw-translate-y:-1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.hover\:border-chip-indigo-border:hover{border-color:var(--chip-indigo-border)}.hover\:border-indigo-400:hover{border-color:var(--color-indigo-400)}.hover\:border-indigo-500:hover{border-color:var(--color-indigo-500)}.hover\:border-status-warning-border:hover{border-color:var(--status-warning-border)}.hover\:bg-chip-indigo-bg\/40:hover{background-color:var(--chip-indigo-bg)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-chip-indigo-bg\/40:hover{background-color:color-mix(in oklab,var(--chip-indigo-bg) 40%,transparent)}}.hover\:bg-elevated:hover,.hover\:bg-elevated\/50:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/50:hover{background-color:color-mix(in oklab,var(--app-elevated) 50%,transparent)}}.hover\:bg-elevated\/60:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/60:hover{background-color:color-mix(in oklab,var(--app-elevated) 60%,transparent)}}.hover\:bg-elevated\/70:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/70:hover{background-color:color-mix(in oklab,var(--app-elevated) 70%,transparent)}}.hover\:bg-elevated\/80:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/80:hover{background-color:color-mix(in oklab,var(--app-elevated) 80%,transparent)}}.hover\:bg-emerald-500:hover{background-color:var(--color-emerald-500)}.hover\:bg-hover-surface:hover{background-color:var(--app-hover)}.hover\:bg-indigo-500:hover{background-color:var(--color-indigo-500)}.hover\:bg-indigo-600:hover{background-color:var(--color-indigo-600)}.hover\:bg-status-danger-bg:hover,.hover\:bg-status-danger-bg\/60:hover{background-color:var(--status-danger-bg)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-status-danger-bg\/60:hover{background-color:color-mix(in oklab,var(--status-danger-bg) 60%,transparent)}}.hover\:bg-status-warning-bg:hover,.hover\:bg-status-warning-bg\/40:hover{background-color:var(--status-warning-bg)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-status-warning-bg\/40:hover{background-color:color-mix(in oklab,var(--status-warning-bg) 40%,transparent)}}.hover\:bg-surface:hover{background-color:var(--app-surface)}.hover\:bg-surface-strong:hover{background-color:var(--app-glass-strong)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:text-chip-indigo-text:hover,.hover\:text-chip-indigo-text\/80:hover{color:var(--chip-indigo-text)}@supports (color:color-mix(in lab,red,red)){.hover\:text-chip-indigo-text\/80:hover{color:color-mix(in oklab,var(--chip-indigo-text) 80%,transparent)}}.hover\:text-ink:hover{color:var(--app-text-primary)}.hover\:text-status-danger-text:hover{color:var(--status-danger-text)}.hover\:text-status-warning-text:hover{color:var(--status-warning-text)}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-40:hover{opacity:.4}.hover\:shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.35\)\,0_12px_30px_-6px_rgb\(16_185_129\/0\.7\)\]:hover{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff59), 0 12px 30px -6px var(--tw-shadow-color,#10b981b3);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:brightness-95:hover{--tw-brightness:brightness(95%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}}.focus\:border-indigo-500:focus{border-color:var(--color-indigo-500)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-indigo-500:focus{--tw-ring-color:var(--color-indigo-500)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:z-10:focus-visible{z-index:10}.focus-visible\:border-indigo-400:focus-visible{border-color:var(--color-indigo-400)}.focus-visible\:border-indigo-500:focus-visible{border-color:var(--color-indigo-500)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-emerald-400:focus-visible{--tw-ring-color:var(--color-emerald-400)}.focus-visible\:ring-indigo-400:focus-visible{--tw-ring-color:var(--color-indigo-400)}.focus-visible\:ring-indigo-500:focus-visible{--tw-ring-color:var(--color-indigo-500)}.focus-visible\:ring-indigo-500\/30:focus-visible{--tw-ring-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-indigo-500\/30:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 30%, transparent)}}.focus-visible\:ring-status-danger-border:focus-visible{--tw-ring-color:var(--status-danger-border)}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset, ) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus-visible\:ring-offset-app:focus-visible{--tw-ring-offset-color:var(--app-bg)}.focus-visible\:outline:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-\[-2px\]:focus-visible{outline-offset:-2px}.focus-visible\:outline-indigo-500:focus-visible{outline-color:var(--color-indigo-500)}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset:inset}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:translate-y-0:disabled:hover{--tw-translate-y:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.disabled\:hover\:text-ink-muted:disabled:hover{color:var(--app-text-muted)}.disabled\:hover\:shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.35\)\,0_8px_24px_-6px_rgb\(16_185_129\/0\.55\)\]:disabled:hover{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff59), 0 8px 24px -6px var(--tw-shadow-color,#10b9818c);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.disabled\:hover\:brightness-100:disabled:hover{--tw-brightness:brightness(100%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}}@media(prefers-reduced-motion:reduce){.motion-reduce\:animate-none{animation:none}}@media(min-width:40rem){.sm\:inline{display:inline}.sm\:basis-auto{flex-basis:auto}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:rounded-2xl{border-radius:var(--radius-2xl)}.sm\:rounded-xl{border-radius:var(--radius-xl)}.sm\:p-1\.5{padding:calc(var(--spacing) * 1.5)}.sm\:p-4{padding:calc(var(--spacing) * 4)}.sm\:p-6{padding:calc(var(--spacing) * 6)}.sm\:px-3{padding-inline:calc(var(--spacing) * 3)}.sm\:px-5{padding-inline:calc(var(--spacing) * 5)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}.sm\:py-3{padding-block:calc(var(--spacing) * 3)}}@media(min-width:64rem){.lg\:flex{display:flex}}.\[\&_code\]\:bg-transparent code{background-color:#0000}.\[\&_code\]\:px-0 code{padding-inline:0}.\[\&_code\]\:py-0 code{padding-block:0}.\[\&_code\]\:text-inherit code{color:inherit}.animate-modal-in{animation:.15s cubic-bezier(.2,.8,.2,1) modal-in}.animate-overlay-in{animation:.15s ease-out overlay-in}.animate-toast-in{animation:.12s ease-out toast-in}}:where(button,[role=button],input,select,textarea,a,summary,video[tabindex],[tabindex]):focus-visible{outline:2px solid var(--color-indigo-500,#6366f1);outline-offset:2px}:root{color-scheme:light dark;--z-combobox-list:60;--z-syntax-helper:65;--z-context-menu:70;--z-modal:80;--z-drop-overlay:85;--z-toast:90;--z-tooltip:100}:root,[data-theme=dark]{--app-bg:#020617;--app-surface:#0f172a;--app-elevated:#1e293b;--app-hover:#334155;--app-border:#334155;--app-frame-border:#94a3b84d;--app-text-primary:#f8fafc;--app-text-secondary:#cbd5e1;--app-text-muted:#94a3b8;--app-text-faint:#94a3b8;--app-glass:#0f172a99;--app-glass-strong:#020617e6;--app-glass-panel:#0f172ac7;--app-glass-panel-strong:#020617e0;--app-glass-highlight:#ffffff17;--app-panel-shadow:0 24px 60px -12px #0206178c;--app-editor-bg:#1e1e1e;--app-editor-gutter-bg:#181818;--app-editor-active-line:#282828;--app-editor-selection:#6366f14d;--app-editor-border:#34343e;--app-editor-syntax-comment:#6a9955;--app-editor-syntax-key:#9cdcfe;--app-editor-syntax-string:#ce9178;--app-editor-syntax-keyword:#569cd6;--app-editor-syntax-label:#4ec9b0;color-scheme:dark;--chip-indigo-bg:#6366f140;--chip-indigo-border:#818cf880;--chip-indigo-text:#c7d2fe;--chip-purple-bg:#a855f740;--chip-purple-border:#c084fc80;--chip-purple-text:#f3e8ff;--chip-fuchsia-bg:#c026d340;--chip-fuchsia-border:#e879f980;--chip-fuchsia-text:#f5d0fe;--chip-sky-bg:#0ea5e940;--chip-sky-border:#38bdf880;--chip-sky-text:#bae6fd;--chip-amber-bg:#f59e0b40;--chip-amber-border:#fbbf2480;--chip-amber-text:#fde68a;--status-success-bg:#10b98140;--status-success-border:#34d39980;--status-success-text:#a7f3d0;--status-warning-bg:#f59e0b40;--status-warning-border:#fbbf2480;--status-warning-text:#fde68a;--status-danger-bg:#f43f5e40;--status-danger-border:#fb718580;--status-danger-text:#fecdd3}[data-theme=light]{--chip-indigo-bg:#e0e7ff;--chip-indigo-border:#a5b4fc;--chip-indigo-text:#3730a3;--chip-purple-bg:#f3e8ff;--chip-purple-border:#d8b4fe;--chip-purple-text:#6b21a8;--chip-fuchsia-bg:#fae8ff;--chip-fuchsia-border:#f0abfc;--chip-fuchsia-text:#86198f;--chip-sky-bg:#e0f2fe;--chip-sky-border:#7dd3fc;--chip-sky-text:#0369a1;--chip-amber-bg:#fef3c7;--chip-amber-border:#fcd34d;--chip-amber-text:#92400e;--status-success-bg:#d1fae5;--status-success-border:#6ee7b7;--status-success-text:#065f46;--status-warning-bg:#fef3c7;--status-warning-border:#fcd34d;--status-warning-text:#92400e;--status-danger-bg:#ffe4e6;--status-danger-border:#fda4af;--status-danger-text:#9f1239;--app-bg:#f8fafc;--app-surface:#fff;--app-elevated:#f1f5f9;--app-hover:#e2e8f0;--app-border:#cbd5e1;--app-frame-border:#0f172a29;--app-text-primary:#0f172a;--app-text-secondary:#334155;--app-text-muted:#475569;--app-text-faint:#475569;--app-glass:#ffffffb3;--app-glass-strong:#f8fafcf2;--app-glass-panel:#fffc;--app-glass-panel-strong:#f8fafceb;--app-glass-highlight:#ffffffe6;--app-panel-shadow:0 24px 60px -18px #0f172a47;--app-editor-bg:#fff;--app-editor-gutter-bg:#f8fafc;--app-editor-active-line:#f1f5f9;--app-editor-selection:#6366f129;--app-editor-border:#e2e8f0;--app-editor-syntax-comment:green;--app-editor-syntax-key:#0451a5;--app-editor-syntax-string:#a31515;--app-editor-syntax-keyword:#00f;--app-editor-syntax-label:#267f99;color-scheme:light}body{background-color:var(--app-bg);min-height:100vh;color:var(--app-text-primary);margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;transition:background-color .2s,color .2s}@media(prefers-reduced-motion:reduce){*,:before,:after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes modal-in{0%{opacity:0;transform:translateY(4px)scale(.995)}to{opacity:1;transform:none}}@keyframes overlay-in{0%{opacity:0}to{opacity:1}}@keyframes toast-in{0%{opacity:0;translate:-50% calc(6px - 50%)}to{opacity:1;translate:-50% -50%}}*{scrollbar-color:var(--app-border) transparent;scrollbar-width:thin}::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background-color:var(--app-border);background-clip:content-box;border:2px solid #0000;border-radius:9999px}::-webkit-scrollbar-thumb:hover{background-color:var(--app-text-faint)}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} 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-DTCv5-8y.css b/src/profiles/web/dist/assets/index-DTCv5-8y.css new file mode 100644 index 0000000..ca3daf5 --- /dev/null +++ b/src/profiles/web/dist/assets/index-DTCv5-8y.css @@ -0,0 +1 @@ +/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1}}}@layer theme{:root,:host{--font-sans:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-800:oklch(43.2% .095 166.913);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-indigo-600:oklch(51.1% .262 276.966);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-900:oklch(20.8% .042 265.755);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wide:.025em;--tracking-wider:.05em;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--blur-xs:4px;--blur-sm:8px;--blur-md:12px;--blur-xl:24px;--aspect-video:16 / 9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components{.glass-panel{background:var(--app-glass-panel);-webkit-backdrop-filter:blur(24px)saturate(160%);backdrop-filter:blur(24px)saturate(160%);box-shadow:var(--app-panel-shadow),inset 0 1px 0 var(--app-glass-highlight)}.glass-panel-strong{background:var(--app-glass-panel-strong);-webkit-backdrop-filter:blur(28px)saturate(180%);backdrop-filter:blur(28px)saturate(180%);box-shadow:var(--app-panel-shadow),inset 0 1px 0 var(--app-glass-highlight)}.btn{justify-content:center;align-items:center;gap:calc(var(--spacing) * 1.5);border-radius:var(--radius-md);border-style:var(--tw-border-style);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-width:1px;display:inline-flex}.btn:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);--tw-ring-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.btn:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 70%, transparent)}}.btn:focus-visible{--tw-outline-style:none;outline-style:none}.btn:disabled{cursor:not-allowed;opacity:.4}.btn-primary{background-color:var(--color-indigo-600);color:var(--color-white);border-color:#0000}@media(hover:hover){.btn-primary:hover{background-color:var(--color-indigo-500)}}.btn-secondary{border-color:var(--app-border);background-color:var(--app-elevated);color:var(--app-text-secondary)}@media(hover:hover){.btn-secondary:hover{border-color:var(--color-indigo-500);color:var(--app-text-primary)}.btn-chip:hover{--tw-brightness:brightness(95%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}}.btn-chip:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);--tw-ring-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.btn-chip:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 70%, transparent)}}.btn-chip:focus-visible{--tw-outline-style:none;outline-style:none}.btn-chip:disabled{cursor:not-allowed;opacity:.4}.focus-ring:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);--tw-ring-color:#625fffb3}@supports (color:color-mix(in lab,red,red)){.focus-ring:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 70%, transparent)}}.focus-ring:focus-visible{--tw-outline-style:none;outline-style:none}}@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{inset-block:0}.-top-1{top:calc(var(--spacing) * -1)}.top-0{top:0}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing) * 2)}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing) * -.5)}.-right-1{right:calc(var(--spacing) * -1)}.right-0{right:0}.right-2{right:calc(var(--spacing) * 2)}.-bottom-0\.5{bottom:calc(var(--spacing) * -.5)}.-bottom-1{bottom:calc(var(--spacing) * -1)}.bottom-0{bottom:0}.bottom-2{bottom:calc(var(--spacing) * 2)}.-left-1{left:calc(var(--spacing) * -1)}.left-0{left:0}.left-1\/2{left:50%}.left-2\.5{left:calc(var(--spacing) * 2.5)}.left-3{left:calc(var(--spacing) * 3)}.isolate{isolation:isolate}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-\[calc\(var\(--z-context-menu\)-1\)\]{z-index:calc(var(--z-context-menu) - 1)}.z-\[var\(--z-combobox-list\)\]{z-index:var(--z-combobox-list)}.z-\[var\(--z-context-menu\)\]{z-index:var(--z-context-menu)}.z-\[var\(--z-drop-overlay\)\]{z-index:var(--z-drop-overlay)}.z-\[var\(--z-modal\)\]{z-index:var(--z-modal)}.z-\[var\(--z-syntax-helper\)\]{z-index:var(--z-syntax-helper)}.z-\[var\(--z-toast\)\]{z-index:var(--z-toast)}.z-\[var\(--z-tooltip\)\]{z-index:var(--z-tooltip)}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.container\!{width:100%!important}@media(min-width:40rem){.container\!{max-width:40rem!important}}@media(min-width:48rem){.container\!{max-width:48rem!important}}@media(min-width:64rem){.container\!{max-width:64rem!important}}@media(min-width:80rem){.container\!{max-width:80rem!important}}@media(min-width:96rem){.container\!{max-width:96rem!important}}.mx-1{margin-inline:var(--spacing)}.mx-auto{margin-inline:auto}.my-1{margin-block:var(--spacing)}.my-1\.5{margin-block:calc(var(--spacing) * 1.5)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-3\.5{margin-top:calc(var(--spacing) * 3.5)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-5{margin-top:calc(var(--spacing) * 5)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mr-1\.5{margin-right:calc(var(--spacing) * 1.5)}.mr-auto{margin-right:auto}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:var(--spacing)}.mb-1\.5{margin-bottom:calc(var(--spacing) * 1.5)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.list-item{display:list-item}.table{display:table}.aspect-video{aspect-ratio:var(--aspect-video)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-7{height:calc(var(--spacing) * 7)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-12{height:calc(var(--spacing) * 12)}.h-40{height:calc(var(--spacing) * 40)}.h-48{height:calc(var(--spacing) * 48)}.h-\[7px\]{height:7px}.h-\[80vh\]{height:80vh}.h-\[90vh\]{height:90vh}.h-\[min\(84dvh\,760px\)\]{height:min(84dvh,760px)}.h-dvh{height:100dvh}.h-full{height:100%}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-\[60vh\]{max-height:60vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[calc\(100dvh-1\.5rem\)\]{max-height:calc(100dvh - 1.5rem)}.max-h-\[calc\(100dvh-2rem\)\]{max-height:calc(100dvh - 2rem)}.max-h-\[calc\(100dvh-16px\)\]{max-height:calc(100dvh - 16px)}.min-h-0{min-height:0}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-10{min-height:calc(var(--spacing) * 10)}.min-h-16{min-height:calc(var(--spacing) * 16)}.min-h-24{min-height:calc(var(--spacing) * 24)}.min-h-36{min-height:calc(var(--spacing) * 36)}.min-h-\[24px\]{min-height:24px}.min-h-\[44px\]{min-height:44px}.min-h-screen{min-height:100vh}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing) * 2)}.w-2\.5{width:calc(var(--spacing) * 2.5)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-7{width:calc(var(--spacing) * 7)}.w-8{width:calc(var(--spacing) * 8)}.w-9{width:calc(var(--spacing) * 9)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-40{width:calc(var(--spacing) * 40)}.w-44{width:calc(var(--spacing) * 44)}.w-48{width:calc(var(--spacing) * 48)}.w-56{width:calc(var(--spacing) * 56)}.w-72{width:calc(var(--spacing) * 72)}.w-96{width:calc(var(--spacing) * 96)}.w-\[7px\]{width:7px}.w-\[52px\]{width:52px}.w-\[138px\]{width:138px}.w-\[150px\]{width:150px}.w-\[280px\]{width:280px}.w-\[400px\]{width:400px}.w-\[420px\]{width:420px}.w-\[440px\]{width:440px}.w-\[450px\]{width:450px}.w-\[480px\]{width:480px}.w-\[clamp\(560px\,85vw\,1500px\)\]{width:clamp(560px,85vw,1500px)}.w-\[min\(94vw\,560px\)\]{width:min(94vw,560px)}.w-\[min\(94vw\,960px\)\]{width:min(94vw,960px)}.w-full{width:100%}.w-max{width:max-content}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-\[220px\]{max-width:220px}.max-w-\[calc\(100vw-16px\)\]{max-width:calc(100vw - 16px)}.max-w-\[min\(70vw\,560px\)\]{max-width:min(70vw,560px)}.max-w-\[min\(80vw\,640px\)\]{max-width:min(80vw,640px)}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:0}.min-w-48{min-width:calc(var(--spacing) * 48)}.min-w-\[100px\]{min-width:100px}.min-w-\[220px\]{min-width:220px}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.flex-grow,.grow{flex-grow:1}.basis-64{flex-basis:calc(var(--spacing) * 64)}.basis-full{flex-basis:100%}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-45{rotate:45deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.touch-none{touch-action:none}.resize{resize:both}.resize\!{resize:both!important}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.place-items-center{place-items:center}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-3\.5{gap:calc(var(--spacing) * 3.5)}.gap-4{gap:calc(var(--spacing) * 4)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 1.5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 1.5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-y-1\.5{row-gap:calc(var(--spacing) * 1.5)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.overscroll-contain{overscroll-behavior:contain}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-l-md{border-top-left-radius:var(--radius-md);border-bottom-left-radius:var(--radius-md)}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-2{border-right-style:var(--tw-border-style);border-right-width:2px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-0{border-left-style:var(--tw-border-style);border-left-width:0}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-\[var\(--app-editor-border\)\]{border-color:var(--app-editor-border)}.border-chip-amber-border{border-color:var(--chip-amber-border)}.border-chip-fuchsia-border{border-color:var(--chip-fuchsia-border)}.border-chip-indigo-border,.border-chip-indigo-border\/50{border-color:var(--chip-indigo-border)}@supports (color:color-mix(in lab,red,red)){.border-chip-indigo-border\/50{border-color:color-mix(in oklab,var(--chip-indigo-border) 50%,transparent)}}.border-chip-purple-border,.border-chip-purple-border\/50{border-color:var(--chip-purple-border)}@supports (color:color-mix(in lab,red,red)){.border-chip-purple-border\/50{border-color:color-mix(in oklab,var(--chip-purple-border) 50%,transparent)}}.border-chip-sky-border{border-color:var(--chip-sky-border)}.border-current{border-color:currentColor}.border-emerald-300\/50{border-color:#5ee9b580}@supports (color:color-mix(in lab,red,red)){.border-emerald-300\/50{border-color:color-mix(in oklab,var(--color-emerald-300) 50%,transparent)}}.border-emerald-500\/30{border-color:#00bb7f4d}@supports (color:color-mix(in lab,red,red)){.border-emerald-500\/30{border-color:color-mix(in oklab,var(--color-emerald-500) 30%,transparent)}}.border-frame-line{border-color:var(--app-frame-border)}.border-indigo-400{border-color:var(--color-indigo-400)}.border-indigo-400\/80{border-color:#7d87ffcc}@supports (color:color-mix(in lab,red,red)){.border-indigo-400\/80{border-color:color-mix(in oklab,var(--color-indigo-400) 80%,transparent)}}.border-indigo-600{border-color:var(--color-indigo-600)}.border-line,.border-line\/40{border-color:var(--app-border)}@supports (color:color-mix(in lab,red,red)){.border-line\/40{border-color:color-mix(in oklab,var(--app-border) 40%,transparent)}}.border-line\/60{border-color:var(--app-border)}@supports (color:color-mix(in lab,red,red)){.border-line\/60{border-color:color-mix(in oklab,var(--app-border) 60%,transparent)}}.border-status-danger-border{border-color:var(--status-danger-border)}.border-status-success-border{border-color:var(--status-success-border)}.border-status-warning-border{border-color:var(--status-warning-border)}.border-transparent{border-color:#0000}.border-t-transparent{border-top-color:#0000}.border-l-transparent{border-left-color:#0000}.bg-\[var\(--app-editor-bg\)\]{background-color:var(--app-editor-bg)}.bg-app,.bg-app\/90{background-color:var(--app-bg)}@supports (color:color-mix(in lab,red,red)){.bg-app\/90{background-color:color-mix(in oklab,var(--app-bg) 90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black) 20%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black) 60%,transparent)}}.bg-black\/65{background-color:#000000a6}@supports (color:color-mix(in lab,red,red)){.bg-black\/65{background-color:color-mix(in oklab,var(--color-black) 65%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab,red,red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black) 70%,transparent)}}.bg-chip-amber-bg{background-color:var(--chip-amber-bg)}.bg-chip-fuchsia-bg{background-color:var(--chip-fuchsia-bg)}.bg-chip-indigo-bg,.bg-chip-indigo-bg\/20{background-color:var(--chip-indigo-bg)}@supports (color:color-mix(in lab,red,red)){.bg-chip-indigo-bg\/20{background-color:color-mix(in oklab,var(--chip-indigo-bg) 20%,transparent)}}.bg-chip-purple-bg{background-color:var(--chip-purple-bg)}.bg-chip-sky-bg{background-color:var(--chip-sky-bg)}.bg-current{background-color:currentColor}.bg-elevated,.bg-elevated\/30{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/30{background-color:color-mix(in oklab,var(--app-elevated) 30%,transparent)}}.bg-elevated\/40{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/40{background-color:color-mix(in oklab,var(--app-elevated) 40%,transparent)}}.bg-elevated\/50{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/50{background-color:color-mix(in oklab,var(--app-elevated) 50%,transparent)}}.bg-elevated\/60{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.bg-elevated\/60{background-color:color-mix(in oklab,var(--app-elevated) 60%,transparent)}}.bg-emerald-400{background-color:var(--color-emerald-400)}.bg-emerald-500{background-color:var(--color-emerald-500)}.bg-emerald-600{background-color:var(--color-emerald-600)}.bg-emerald-800\/60{background-color:#005f4699}@supports (color:color-mix(in lab,red,red)){.bg-emerald-800\/60{background-color:color-mix(in oklab,var(--color-emerald-800) 60%,transparent)}}.bg-indigo-500\/5{background-color:#625fff0d}@supports (color:color-mix(in lab,red,red)){.bg-indigo-500\/5{background-color:color-mix(in oklab,var(--color-indigo-500) 5%,transparent)}}.bg-indigo-600{background-color:var(--color-indigo-600)}.bg-ink-faint{background-color:var(--app-text-faint)}.bg-status-danger-bg,.bg-status-danger-bg\/30{background-color:var(--status-danger-bg)}@supports (color:color-mix(in lab,red,red)){.bg-status-danger-bg\/30{background-color:color-mix(in oklab,var(--status-danger-bg) 30%,transparent)}}.bg-status-danger-bg\/40{background-color:var(--status-danger-bg)}@supports (color:color-mix(in lab,red,red)){.bg-status-danger-bg\/40{background-color:color-mix(in oklab,var(--status-danger-bg) 40%,transparent)}}.bg-status-success-bg{background-color:var(--status-success-bg)}.bg-status-warning-bg{background-color:var(--status-warning-bg)}.bg-surface{background-color:var(--app-surface)}.bg-surface-glass{background-color:var(--app-glass)}.bg-surface-strong,.bg-surface-strong\/20{background-color:var(--app-glass-strong)}@supports (color:color-mix(in lab,red,red)){.bg-surface-strong\/20{background-color:color-mix(in oklab,var(--app-glass-strong) 20%,transparent)}}.bg-surface-strong\/30{background-color:var(--app-glass-strong)}@supports (color:color-mix(in lab,red,red)){.bg-surface-strong\/30{background-color:color-mix(in oklab,var(--app-glass-strong) 30%,transparent)}}.bg-surface\/50{background-color:var(--app-surface)}@supports (color:color-mix(in lab,red,red)){.bg-surface\/50{background-color:color-mix(in oklab,var(--app-surface) 50%,transparent)}}.bg-surface\/60{background-color:var(--app-surface)}@supports (color:color-mix(in lab,red,red)){.bg-surface\/60{background-color:color-mix(in oklab,var(--app-surface) 60%,transparent)}}.bg-white{background-color:var(--color-white)}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab,red,red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white) 90%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-emerald-400\/90{--tw-gradient-from:#00d294e6}@supports (color:color-mix(in lab,red,red)){.from-emerald-400\/90{--tw-gradient-from:color-mix(in oklab, var(--color-emerald-400) 90%, transparent)}}.from-emerald-400\/90{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.to-emerald-600\/90{--tw-gradient-to:#009767e6}@supports (color:color-mix(in lab,red,red)){.to-emerald-600\/90{--tw-gradient-to:color-mix(in oklab, var(--color-emerald-600) 90%, transparent)}}.to-emerald-600\/90{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position))}.fill-current{fill:currentColor}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-2\.5{padding:calc(var(--spacing) * 2.5)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-5{padding:calc(var(--spacing) * 5)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-3\.5{padding-inline:calc(var(--spacing) * 3.5)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.px-8{padding-inline:calc(var(--spacing) * 8)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-3\.5{padding-block:calc(var(--spacing) * 3.5)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-px{padding-block:1px}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pr-1{padding-right:var(--spacing)}.pr-2\.5{padding-right:calc(var(--spacing) * 2.5)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pr-10{padding-right:calc(var(--spacing) * 10)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-8{padding-left:calc(var(--spacing) * 8)}.pl-9{padding-left:calc(var(--spacing) * 9)}.text-center{text-align:center}.text-left{text-align:left}.align-\[1px\]{vertical-align:1px}.align-top{vertical-align:top}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11\.5px\]{font-size:11.5px}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-chip-amber-text{color:var(--chip-amber-text)}.text-chip-fuchsia-text{color:var(--chip-fuchsia-text)}.text-chip-indigo-text{color:var(--chip-indigo-text)}.text-chip-purple-text{color:var(--chip-purple-text)}.text-chip-sky-text{color:var(--chip-sky-text)}.text-emerald-200{color:var(--color-emerald-200)}.text-ink{color:var(--app-text-primary)}.text-ink-faint{color:var(--app-text-faint)}.text-ink-muted,.text-ink-muted\/50{color:var(--app-text-muted)}@supports (color:color-mix(in lab,red,red)){.text-ink-muted\/50{color:color-mix(in oklab,var(--app-text-muted) 50%,transparent)}}.text-ink-secondary{color:var(--app-text-secondary)}.text-ink\/70{color:var(--app-text-primary)}@supports (color:color-mix(in lab,red,red)){.text-ink\/70{color:color-mix(in oklab,var(--app-text-primary) 70%,transparent)}}.text-slate-400{color:var(--color-slate-400)}.text-slate-900{color:var(--color-slate-900)}.text-status-danger-text,.text-status-danger-text\/60{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/60{color:color-mix(in oklab,var(--status-danger-text) 60%,transparent)}}.text-status-danger-text\/70{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/70{color:color-mix(in oklab,var(--status-danger-text) 70%,transparent)}}.text-status-danger-text\/80{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/80{color:color-mix(in oklab,var(--status-danger-text) 80%,transparent)}}.text-status-danger-text\/90{color:var(--status-danger-text)}@supports (color:color-mix(in lab,red,red)){.text-status-danger-text\/90{color:color-mix(in oklab,var(--status-danger-text) 90%,transparent)}}.text-status-success-text{color:var(--status-success-text)}.text-status-warning-text{color:var(--status-warning-text)}.text-white{color:var(--color-white)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.not-italic{font-style:normal}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.decoration-line{-webkit-text-decoration-color:var(--app-border);text-decoration-color:var(--app-border)}.underline-offset-2{text-underline-offset:2px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.placeholder-ink-faint::placeholder{color:var(--app-text-faint)}.opacity-0{opacity:0}.opacity-40{opacity:.4}.opacity-90{opacity:.9}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_0_9999px_rgba\(0\,0\,0\,0\.45\)\]{--tw-shadow:0 0 0 9999px var(--tw-shadow-color,#00000073);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_2px_6px_rgb\(0_0_0\/0\.35\)\]{--tw-shadow:0 2px 6px var(--tw-shadow-color,#00000059);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.12\)\]{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff1f);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.35\)\,0_8px_24px_-6px_rgb\(16_185_129\/0\.55\)\]{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff59), 0 8px 24px -6px var(--tw-shadow-color,#10b9818c);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-app{--tw-ring-color:var(--app-bg)}.ring-chip-indigo-border\/40{--tw-ring-color:var(--chip-indigo-border)}@supports (color:color-mix(in lab,red,red)){.ring-chip-indigo-border\/40{--tw-ring-color:color-mix(in oklab, var(--chip-indigo-border) 40%, transparent)}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter\!{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )!important}.backdrop-blur-md{--tw-backdrop-blur:blur(var(--blur-md));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.backdrop-blur-xl{--tw-backdrop-blur:blur(var(--blur-xl));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.backdrop-blur-xs{--tw-backdrop-blur:blur(var(--blur-xs));-webkit-backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, );backdrop-filter:var(--tw-backdrop-blur, ) var(--tw-backdrop-brightness, ) var(--tw-backdrop-contrast, ) var(--tw-backdrop-grayscale, ) var(--tw-backdrop-hue-rotate, ) var(--tw-backdrop-invert, ) var(--tw-backdrop-opacity, ) var(--tw-backdrop-saturate, ) var(--tw-backdrop-sepia, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-\[filter\,box-shadow\,transform\]{transition-property:filter,box-shadow,transform;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}@media(hover:hover){:is(:where(.group):hover .group-hover\:text-white){color:var(--color-white)}:is(:where(.group):hover .group-hover\:opacity-40){opacity:.4}:is(:where(.group):hover .group-hover\:opacity-100){opacity:1}}.selection\:bg-indigo-500 ::selection{background-color:var(--color-indigo-500)}.selection\:bg-indigo-500::selection{background-color:var(--color-indigo-500)}.selection\:text-white ::selection{color:var(--color-white)}.selection\:text-white::selection{color:var(--color-white)}.placeholder\:text-ink-faint::placeholder{color:var(--app-text-faint)}.first\:mt-0:first-child{margin-top:0}.last\:mb-0:last-child{margin-bottom:0}@media(hover:hover){.hover\:-translate-y-px:hover{--tw-translate-y:-1px;translate:var(--tw-translate-x) var(--tw-translate-y)}.hover\:border-chip-indigo-border:hover{border-color:var(--chip-indigo-border)}.hover\:border-indigo-400:hover{border-color:var(--color-indigo-400)}.hover\:border-indigo-500:hover{border-color:var(--color-indigo-500)}.hover\:border-status-warning-border:hover{border-color:var(--status-warning-border)}.hover\:bg-chip-indigo-bg\/40:hover{background-color:var(--chip-indigo-bg)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-chip-indigo-bg\/40:hover{background-color:color-mix(in oklab,var(--chip-indigo-bg) 40%,transparent)}}.hover\:bg-elevated:hover,.hover\:bg-elevated\/50:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/50:hover{background-color:color-mix(in oklab,var(--app-elevated) 50%,transparent)}}.hover\:bg-elevated\/60:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/60:hover{background-color:color-mix(in oklab,var(--app-elevated) 60%,transparent)}}.hover\:bg-elevated\/70:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/70:hover{background-color:color-mix(in oklab,var(--app-elevated) 70%,transparent)}}.hover\:bg-elevated\/80:hover{background-color:var(--app-elevated)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-elevated\/80:hover{background-color:color-mix(in oklab,var(--app-elevated) 80%,transparent)}}.hover\:bg-emerald-500:hover{background-color:var(--color-emerald-500)}.hover\:bg-hover-surface:hover{background-color:var(--app-hover)}.hover\:bg-indigo-500:hover{background-color:var(--color-indigo-500)}.hover\:bg-indigo-600:hover{background-color:var(--color-indigo-600)}.hover\:bg-status-danger-bg:hover,.hover\:bg-status-danger-bg\/60:hover{background-color:var(--status-danger-bg)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-status-danger-bg\/60:hover{background-color:color-mix(in oklab,var(--status-danger-bg) 60%,transparent)}}.hover\:bg-status-warning-bg:hover,.hover\:bg-status-warning-bg\/40:hover{background-color:var(--status-warning-bg)}@supports (color:color-mix(in lab,red,red)){.hover\:bg-status-warning-bg\/40:hover{background-color:color-mix(in oklab,var(--status-warning-bg) 40%,transparent)}}.hover\:bg-surface:hover{background-color:var(--app-surface)}.hover\:bg-surface-strong:hover{background-color:var(--app-glass-strong)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:text-chip-indigo-text:hover,.hover\:text-chip-indigo-text\/80:hover{color:var(--chip-indigo-text)}@supports (color:color-mix(in lab,red,red)){.hover\:text-chip-indigo-text\/80:hover{color:color-mix(in oklab,var(--chip-indigo-text) 80%,transparent)}}.hover\:text-indigo-400:hover{color:var(--color-indigo-400)}.hover\:text-ink:hover{color:var(--app-text-primary)}.hover\:text-status-danger-text:hover{color:var(--status-danger-text)}.hover\:text-status-warning-text:hover{color:var(--status-warning-text)}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-40:hover{opacity:.4}.hover\:shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.35\)\,0_12px_30px_-6px_rgb\(16_185_129\/0\.7\)\]:hover{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff59), 0 12px 30px -6px var(--tw-shadow-color,#10b981b3);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:brightness-95:hover{--tw-brightness:brightness(95%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}}.focus\:border-indigo-500:focus{border-color:var(--color-indigo-500)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-indigo-500:focus{--tw-ring-color:var(--color-indigo-500)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:z-10:focus-visible{z-index:10}.focus-visible\:border-indigo-400:focus-visible{border-color:var(--color-indigo-400)}.focus-visible\:border-indigo-500:focus-visible{border-color:var(--color-indigo-500)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-emerald-400:focus-visible{--tw-ring-color:var(--color-emerald-400)}.focus-visible\:ring-indigo-400:focus-visible{--tw-ring-color:var(--color-indigo-400)}.focus-visible\:ring-indigo-500:focus-visible{--tw-ring-color:var(--color-indigo-500)}.focus-visible\:ring-indigo-500\/30:focus-visible{--tw-ring-color:#625fff4d}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-indigo-500\/30:focus-visible{--tw-ring-color:color-mix(in oklab, var(--color-indigo-500) 30%, transparent)}}.focus-visible\:ring-status-danger-border:focus-visible{--tw-ring-color:var(--status-danger-border)}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset, ) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus-visible\:ring-offset-app:focus-visible{--tw-ring-offset-color:var(--app-bg)}.focus-visible\:outline:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-\[-2px\]:focus-visible{outline-offset:-2px}.focus-visible\:outline-indigo-500:focus-visible{outline-color:var(--color-indigo-500)}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset:inset}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(hover:hover){.disabled\:hover\:translate-y-0:disabled:hover{--tw-translate-y:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.disabled\:hover\:text-ink-muted:disabled:hover{color:var(--app-text-muted)}.disabled\:hover\:shadow-\[inset_0_1px_0_rgb\(255_255_255\/0\.35\)\,0_8px_24px_-6px_rgb\(16_185_129\/0\.55\)\]:disabled:hover{--tw-shadow:inset 0 1px 0 var(--tw-shadow-color,#ffffff59), 0 8px 24px -6px var(--tw-shadow-color,#10b9818c);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.disabled\:hover\:brightness-100:disabled:hover{--tw-brightness:brightness(100%);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}}@media(prefers-reduced-motion:reduce){.motion-reduce\:animate-none{animation:none}}@media(min-width:40rem){.sm\:inline{display:inline}.sm\:basis-auto{flex-basis:auto}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:rounded-2xl{border-radius:var(--radius-2xl)}.sm\:rounded-xl{border-radius:var(--radius-xl)}.sm\:p-1\.5{padding:calc(var(--spacing) * 1.5)}.sm\:p-4{padding:calc(var(--spacing) * 4)}.sm\:p-6{padding:calc(var(--spacing) * 6)}.sm\:px-3{padding-inline:calc(var(--spacing) * 3)}.sm\:px-5{padding-inline:calc(var(--spacing) * 5)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}.sm\:py-3{padding-block:calc(var(--spacing) * 3)}}@media(min-width:64rem){.lg\:flex{display:flex}}.\[\&_code\]\:bg-transparent code{background-color:#0000}.\[\&_code\]\:px-0 code{padding-inline:0}.\[\&_code\]\:py-0 code{padding-block:0}.\[\&_code\]\:text-inherit code{color:inherit}.animate-modal-in{animation:.15s cubic-bezier(.2,.8,.2,1) modal-in}.animate-overlay-in{animation:.15s ease-out overlay-in}.animate-toast-in{animation:.12s ease-out toast-in}}:where(button,[role=button],input,select,textarea,a,summary,video[tabindex],[tabindex]):focus-visible{outline:2px solid var(--color-indigo-500,#6366f1);outline-offset:2px}:root{color-scheme:light dark;--z-combobox-list:60;--z-syntax-helper:65;--z-context-menu:70;--z-modal:80;--z-drop-overlay:85;--z-toast:90;--z-tooltip:100}:root,[data-theme=dark]{--app-bg:#020617;--app-surface:#0f172a;--app-elevated:#1e293b;--app-hover:#334155;--app-border:#334155;--app-frame-border:#94a3b84d;--app-text-primary:#f8fafc;--app-text-secondary:#cbd5e1;--app-text-muted:#94a3b8;--app-text-faint:#94a3b8;--app-glass:#0f172a99;--app-glass-strong:#020617e6;--app-glass-panel:#0f172ac7;--app-glass-panel-strong:#020617e0;--app-glass-highlight:#ffffff17;--app-panel-shadow:0 24px 60px -12px #0206178c;--app-editor-bg:#1e1e1e;--app-editor-gutter-bg:#181818;--app-editor-active-line:#282828;--app-editor-selection:#6366f14d;--app-editor-border:#34343e;--app-editor-syntax-comment:#6a9955;--app-editor-syntax-key:#9cdcfe;--app-editor-syntax-string:#ce9178;--app-editor-syntax-keyword:#569cd6;--app-editor-syntax-label:#4ec9b0;color-scheme:dark;--chip-indigo-bg:#6366f140;--chip-indigo-border:#818cf880;--chip-indigo-text:#c7d2fe;--chip-purple-bg:#a855f740;--chip-purple-border:#c084fc80;--chip-purple-text:#f3e8ff;--chip-fuchsia-bg:#c026d340;--chip-fuchsia-border:#e879f980;--chip-fuchsia-text:#f5d0fe;--chip-sky-bg:#0ea5e940;--chip-sky-border:#38bdf880;--chip-sky-text:#bae6fd;--chip-amber-bg:#f59e0b40;--chip-amber-border:#fbbf2480;--chip-amber-text:#fde68a;--status-success-bg:#10b98140;--status-success-border:#34d39980;--status-success-text:#a7f3d0;--status-warning-bg:#f59e0b40;--status-warning-border:#fbbf2480;--status-warning-text:#fde68a;--status-danger-bg:#f43f5e40;--status-danger-border:#fb718580;--status-danger-text:#fecdd3}[data-theme=light]{--chip-indigo-bg:#e0e7ff;--chip-indigo-border:#a5b4fc;--chip-indigo-text:#3730a3;--chip-purple-bg:#f3e8ff;--chip-purple-border:#d8b4fe;--chip-purple-text:#6b21a8;--chip-fuchsia-bg:#fae8ff;--chip-fuchsia-border:#f0abfc;--chip-fuchsia-text:#86198f;--chip-sky-bg:#e0f2fe;--chip-sky-border:#7dd3fc;--chip-sky-text:#0369a1;--chip-amber-bg:#fef3c7;--chip-amber-border:#fcd34d;--chip-amber-text:#92400e;--status-success-bg:#d1fae5;--status-success-border:#6ee7b7;--status-success-text:#065f46;--status-warning-bg:#fef3c7;--status-warning-border:#fcd34d;--status-warning-text:#92400e;--status-danger-bg:#ffe4e6;--status-danger-border:#fda4af;--status-danger-text:#9f1239;--app-bg:#f8fafc;--app-surface:#fff;--app-elevated:#f1f5f9;--app-hover:#e2e8f0;--app-border:#cbd5e1;--app-frame-border:#0f172a29;--app-text-primary:#0f172a;--app-text-secondary:#334155;--app-text-muted:#475569;--app-text-faint:#475569;--app-glass:#ffffffb3;--app-glass-strong:#f8fafcf2;--app-glass-panel:#fffc;--app-glass-panel-strong:#f8fafceb;--app-glass-highlight:#ffffffe6;--app-panel-shadow:0 24px 60px -18px #0f172a47;--app-editor-bg:#fff;--app-editor-gutter-bg:#f8fafc;--app-editor-active-line:#f1f5f9;--app-editor-selection:#6366f129;--app-editor-border:#e2e8f0;--app-editor-syntax-comment:green;--app-editor-syntax-key:#0451a5;--app-editor-syntax-string:#a31515;--app-editor-syntax-keyword:#00f;--app-editor-syntax-label:#267f99;color-scheme:light}body{background-color:var(--app-bg);min-height:100vh;color:var(--app-text-primary);margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;transition:background-color .2s,color .2s}@media(prefers-reduced-motion:reduce){*,:before,:after{scroll-behavior:auto!important;transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}@keyframes modal-in{0%{opacity:0;transform:translateY(4px)scale(.995)}to{opacity:1;transform:none}}@keyframes overlay-in{0%{opacity:0}to{opacity:1}}@keyframes toast-in{0%{opacity:0;translate:-50% calc(6px - 50%)}to{opacity:1;translate:-50% -50%}}*{scrollbar-color:var(--app-border) transparent;scrollbar-width:thin}::-webkit-scrollbar{width:10px;height:10px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background-color:var(--app-border);background-clip:content-box;border:2px solid #0000;border-radius:9999px}::-webkit-scrollbar-thumb:hover{background-color:var(--app-text-faint)}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/src/profiles/web/dist/assets/index-Dsvw1NQU.js b/src/profiles/web/dist/assets/index-Dsvw1NQU.js new file mode 100644 index 0000000..cdbbcb7 --- /dev/null +++ b/src/profiles/web/dist/assets/index-Dsvw1NQU.js @@ -0,0 +1,458 @@ +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 ey(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Dg={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 wk;function cM(){if(wk)return mc;wk=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 c in l)c!=="key"&&(o[c]=l[c])}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 kk;function uM(){return kk||(kk=1,Dg.exports=cM()),Dg.exports}var y=uM(),jg={exports:{}},qe={};/** + * @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 Sk;function fM(){if(Sk)return qe;Sk=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"),c=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,O={};function _(R,V,ue){this.props=R,this.context=V,this.refs=O,this.updater=ue||S}_.prototype.isReactComponent={},_.prototype.setState=function(R,V){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,V,"setState")},_.prototype.forceUpdate=function(R){this.updater.enqueueForceUpdate(this,R,"forceUpdate")};function M(){}M.prototype=_.prototype;function P(R,V,ue){this.props=R,this.context=V,this.refs=O,this.updater=ue||S}var L=P.prototype=new M;L.constructor=P,C(L,_.prototype),L.isPureReactComponent=!0;var D=Array.isArray;function j(){}var H={H:null,A:null,T:null,S:null},Z=Object.prototype.hasOwnProperty;function I(R,V,ue){var pe=ue.ref;return{$$typeof:n,type:R,key:V,ref:pe!==void 0?pe:null,props:ue}}function F(R,V){return I(R.type,V,R.props)}function A(R){return typeof R=="object"&&R!==null&&R.$$typeof===n}function ne(R){var V={"=":"=0",":":"=2"};return"$"+R.replace(/[=:]/g,function(ue){return V[ue]})}var ae=/\/+/g;function ie(R,V){return typeof R=="object"&&R!==null&&R.key!=null?ne(""+R.key):V.toString(36)}function $(R){switch(R.status){case"fulfilled":return R.value;case"rejected":throw R.reason;default:switch(typeof R.status=="string"?R.then(j,j):(R.status="pending",R.then(function(V){R.status==="pending"&&(R.status="fulfilled",R.value=V)},function(V){R.status==="pending"&&(R.status="rejected",R.reason=V)})),R.status){case"fulfilled":return R.value;case"rejected":throw R.reason}}throw R}function oe(R,V,ue,pe,je){var Ne=typeof R;(Ne==="undefined"||Ne==="boolean")&&(R=null);var Pe=!1;if(R===null)Pe=!0;else switch(Ne){case"bigint":case"string":case"number":Pe=!0;break;case"object":switch(R.$$typeof){case n:case e:Pe=!0;break;case m:return Pe=R._init,oe(Pe(R._payload),V,ue,pe,je)}}if(Pe)return je=je(R),Pe=pe===""?"."+ie(R,0):pe,D(je)?(ue="",Pe!=null&&(ue=Pe.replace(ae,"$&/")+"/"),oe(je,V,ue,"",function(jt){return jt})):je!=null&&(A(je)&&(je=F(je,ue+(je.key==null||R&&R.key===je.key?"":(""+je.key).replace(ae,"$&/")+"/")+Pe)),V.push(je)),1;Pe=0;var ve=pe===""?".":pe+":";if(D(R))for(var Ee=0;Ee>>1,T=$[Y];if(0>>1;Yl(B,J))Rl(V,B)?($[Y]=V,$[R]=J,Y=R):($[Y]=B,$[ye]=J,Y=ye);else if(Rl(V,J))$[Y]=V,$[R]=J,Y=R;else break e}}return oe}function l($,oe){var J=$.sortIndex-oe.sortIndex;return J!==0?J:$.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,c=a.now();n.unstable_now=function(){return a.now()-c}}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 P($){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 L($){if(S=!1,P($),!w)if(t(f)!==null)w=!0,D||(D=!0,A());else{var oe=t(d);oe!==null&&ie(L,oe.startTime-$)}}var D=!1,j=-1,H=5,Z=-1;function I(){return C?!0:!(n.unstable_now()-Z$&&I());){var Y=g.callback;if(typeof Y=="function"){g.callback=null,b=g.priorityLevel;var T=Y(g.expirationTime<=$);if($=n.unstable_now(),typeof T=="function"){g.callback=T,P($),oe=!0;break t}g===t(f)&&i(f),P($)}else i(f);g=t(f)}if(g!==null)oe=!0;else{var he=t(d);he!==null&&ie(L,he.startTime-$),oe=!1}}break e}finally{g=null,b=J,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){j=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"):H=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 J=b;b=oe;try{return $()}finally{b=J}},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 J=b;b=$;try{return oe()}finally{b=J}},n.unstable_scheduleCallback=function($,oe,J){var Y=n.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0Y?($.sortIndex=J,e(d,$),t(f)===null&&$===t(d)&&(S?(_(j),j=-1):S=!0,ie(L,J-Y))):($.sortIndex=T,e(f,$),w||v||(w=!0,D||(D=!0,A()))),$},n.unstable_shouldYield=I,n.unstable_wrapCallback=function($){var oe=b;return function(){var J=b;b=oe;try{return $.apply(this,arguments)}finally{b=J}}}})(Lg)),Lg}var Nk;function mM(){return Nk||(Nk=1,_g.exports=dM()),_g.exports}var zg={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 Tk;function pM(){if(Tk)return wn;Tk=1;var n=ty();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(),zg.exports=pM(),zg.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 Ek;function gM(){if(Ek)return pc;Ek=1;var n=mM(),e=ty(),t=qC();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),Tn=zt(null),en=zt(null),tn=zt(null);function Ce(r,s){switch($e(en,s),$e(Tn,r),$e(Xt,null),s.nodeType){case 9:case 11:r=(r=s.documentElement)&&(r=r.namespaceURI)?Mw(r):0;break;default:if(r=s.tagName,s=s.namespaceURI)s=Mw(s),r=Dw(s,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}mt(Xt),$e(Xt,r)}function Fe(){mt(Xt),mt(Tn),mt(en)}function Ve(r){var s=r.memoizedState;s!==null&&(Lo._currentValue=s.memoizedState,$e(tn,r)),s=Xt.current;var u=Dw(s,r.type);s!==u&&($e(Tn,r),$e(Xt,u))}function at(r){Tn.current===r&&(mt(Xt),mt(Tn)),tn.current===r&&(mt(tn),Lo._currentValue=jt)}var te,fe;function _e(r){if(te===void 0)try{throw Error()}catch(u){var s=u.stack.trim().match(/\n( *(at )?)/);te=s&&s[1]||"",fe=-1)":-1p||z[h]!==X[p]){var ee=` +`+z[h].replace(" at new "," at ");return r.displayName&&ee.includes("")&&(ee=ee.replace("",r.displayName)),ee}while(1<=h&&0<=p);break}}}finally{ze=!1,Error.prepareStackTrace=u}return(u=r?r.displayName||r.name:"")?_e(u):""}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="",u=null;do s+=ce(r,u),u=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,pt=n.unstable_cancelCallback,An=n.unstable_shouldYield,mn=n.unstable_requestPaint,Tt=n.unstable_now,ht=n.unstable_getCurrentPriorityLevel,Bi=n.unstable_ImmediatePriority,Ln=n.unstable_UserBlockingPriority,Er=n.unstable_NormalPriority,em=n.unstable_LowPriority,gu=n.unstable_IdlePriority,tm=n.log,nm=n.unstable_setDisableYieldValue,Jl=null,zn=null;function Pi(r){if(typeof tm=="function"&&nm(r),zn&&typeof zn.setStrictMode=="function")try{zn.setStrictMode(Jl,r)}catch{}}var on=Math.clz32?Math.clz32:im,qs=Math.log,xu=Math.LN2;function im(r){return r>>>=0,r===0?32:31-(qs(r)/xu|0)|0}var Vs=256,Qs=262144,Xs=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 $s(r,s,u){var h=r.pendingLanes;if(h===0)return 0;var p=0,x=r.suspendedLanes,k=r.pingedLanes;r=r.warmLanes;var N=h&134217727;return N!==0?(h=N&~x,h!==0?p=Mr(h):(k&=N,k!==0?p=Mr(k):u||(u=N&~r,u!==0&&(p=Mr(u))))):(N=h&~x,N!==0?p=Mr(N):k!==0?p=Mr(k):u||(u=h&~r,u!==0&&(p=Mr(u)))),p===0?0:s!==0&&s!==p&&(s&x)===0&&(x=p&-p,u=s&-s,x>=u||x===32&&(u&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 u=r.entangledLanes;if(u!==0)for(r=r.entanglements,u&=s;0u;u++)s.push(r);return s}function es(r,s){r.pendingLanes|=s,s!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function lm(r,s,u,h,p,x){var k=r.pendingLanes;r.pendingLanes=u,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=u,r.entangledLanes&=u,r.errorRecoveryDisabledLanes&=u,r.shellSuspendCounter=0;var N=r.entanglements,z=r.expirationTimes,X=r.hiddenUpdates;for(u=k&~u;0"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),mm=!1;if(jr)try{var Ta={};Object.defineProperty(Ta,"passive",{get:function(){mm=!0}}),window.addEventListener("test",Ta,Ta),window.removeEventListener("test",Ta,Ta)}catch{mm=!1}var sl=null,pm=null,Mu=null;function Nb(){if(Mu)return Mu;var r,s=pm,u=s.length,h,p="value"in sl?sl.value:sl.textContent,x=p.length;for(r=0;r=Ma),jb=" ",Rb=!1;function _b(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 Lb(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var no=!1;function s5(r,s){switch(r){case"compositionend":return Lb(s);case"keypress":return s.which!==32?null:(Rb=!0,jb);case"textInput":return r=s.data,r===jb&&Rb?null:r;default:return null}}function o5(r,s){if(no)return r==="compositionend"||!vm&&_b(r,s)?(r=Nb(),Mu=pm=sl=null,no=!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 qb(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Vb(r,s){var u=qb(r);r=0;for(var h;u;){if(u.nodeType===3){if(h=r+u.textContent.length,r<=s&&h>=s)return{node:u,offset:s-r};r=h}e:{for(;u;){if(u.nextSibling){u=u.nextSibling;break e}u=u.parentNode}u=void 0}u=qb(u)}}function Qb(r,s){return r&&s?r===s?!0:r&&r.nodeType===3?!1:s&&s.nodeType===3?Qb(r,s.parentNode):"contains"in r?r.contains(s):r.compareDocumentPosition?!!(r.compareDocumentPosition(s)&16):!1:!1}function Xb(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var s=Sm(r.document);s instanceof r.HTMLIFrameElement;){try{var u=typeof s.contentWindow.location.href=="string"}catch{u=!1}if(u)r=s.contentWindow;else break;s=Sm(r.document)}return s}function Cm(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=jr&&"documentMode"in document&&11>=document.documentMode,io=null,Om=null,_a=null,Nm=!1;function $b(r,s,u){var h=u.window===u?u.document:u.nodeType===9?u:u.ownerDocument;Nm||io==null||io!==Sm(h)||(h=io,"selectionStart"in h&&Cm(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&&Ra(_a,h)||(_a=h,h=zf(Om,"onSelect"),0>=k,p-=k,tr=1<<32-on(s)+p|u<Ie?(Wt=Be,Be=null):Wt=Be.sibling;var st=q(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 u(Q,Be),Ze&&zr(Q,Ie),Me;if(Be===null){for(;IeIe?(Wt=Be,Be=null):Wt=Be.sibling;var Dl=q(Q,Be,st.value,le);if(Dl===null){Be===null&&(Be=Wt);break}r&&Be&&Dl.alternate===null&&s(Q,Be),U=x(Dl,U,Ie),lt===null?Me=Dl:lt.sibling=Dl,lt=Dl,Be=Wt}if(st.done)return u(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 Z:e:{for(var Me=G.key;U!==null;){if(U.key===Me){if(Me=G.type,Me===F){if(U.tag===7){u(Q,U.sibling),le=p(U,G.props.children),hl(le,G),le.return=Q,Q=le;break e}}else if(U.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===T&&hs(Me)===U.type){u(Q,U.sibling),le=p(U,G.props),hl(le,G),le.return=Q,Q=le;break e}u(Q,U);break}else s(Q,U);U=U.sibling}G.type===F?(le=ls(G.props.children,Q.mode,le,G.key),hl(le,G),le.return=Q,Q=le):(le=Iu(G.type,G.key,G.props,null,Q.mode,le),hl(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){u(Q,U.sibling),le=p(U,G.children||[]),le.return=Q,Q=le;break e}else{u(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 T: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?(u(Q,U.sibling),le=p(U,G),le.return=Q,Q=le):(u(Q,U),le=jm(G,Q.mode,le),le.return=Q,Q=le),k(Q)):u(Q,U)}return function(Q,U,G,le){try{Ia=0;var Me=Ye(Q,U,G,le);return ho=null,Me}catch(Be){if(Be===fo||Be===Gu)throw Be;var lt=$n(29,Be,null,Q.mode);return lt.lanes=le,lt.return=Q,lt}finally{}}}var ms=x1(!0),y1=x1(!1),dl=!1;function qm(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 ml(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function pl(r,s,u){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),t1(r,null,u),s}return Pu(r,h,s,u),Hu(r)}function Ua(r,s,u){if(s=s.updateQueue,s!==null&&(s=s.shared,(u&4194048)!==0)){var h=s.lanes;h&=r.pendingLanes,u|=h,s.lanes=u,vu(r,u)}}function Qm(r,s){var u=r.updateQueue,h=r.alternate;if(h!==null&&(h=h.updateQueue,u===h)){var p=null,x=null;if(u=u.firstBaseUpdate,u!==null){do{var k={lane:u.lane,tag:u.tag,payload:u.payload,callback:null,next:null};x===null?p=x=k:x=x.next=k,u=u.next}while(u!==null);x===null?p=x=s:x=x.next=s}else p=x=s;u={baseState:h.baseState,firstBaseUpdate:p,lastBaseUpdate:x,shared:h.shared,callbacks:h.callbacks},r.updateQueue=u;return}r=u.lastBaseUpdate,r===null?u.firstBaseUpdate=s:r.next=s,u.lastBaseUpdate=s}var Xm=!1;function Fa(){if(Xm){var r=uo;if(r!==null)throw r}}function qa(r,s,u,h){Xm=!1;var p=r.updateQueue;dl=!1;var x=p.firstBaseUpdate,k=p.lastBaseUpdate,N=p.shared.pending;if(N!==null){p.shared.pending=null;var z=N,X=z.next;z.next=null,k===null?x=X:k.next=X,k=z;var ee=r.alternate;ee!==null&&(ee=ee.updateQueue,N=ee.lastBaseUpdate,N!==k&&(N===null?ee.firstBaseUpdate=X:N.next=X,ee.lastBaseUpdate=z))}if(x!==null){var se=p.baseState;k=0,ee=X=z=null,N=x;do{var q=N.lane&-536870913,W=q!==N.lane;if(W?(rt&q)===q:(h&q)===q){q!==0&&q===us&&(Xm=!0),ee!==null&&(ee=ee.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var be=r,Re=N;q=s;var Ye=u;switch(Re.tag){case 1:if(be=Re.payload,typeof be=="function"){se=be.call(Ye,se,q);break e}se=be;break e;case 3:be.flags=be.flags&-65537|128;case 0:if(be=Re.payload,q=typeof be=="function"?be.call(Ye,se,q):be,q==null)break e;se=j({},se,q);break e;case 2:dl=!0}}q=N.callback,q!==null&&(r.flags|=64,W&&(r.flags|=8192),W=p.callbacks,W===null?p.callbacks=[q]:W.push(q))}else W={lane:q,tag:N.tag,payload:N.payload,callback:N.callback,next:null},ee===null?(X=ee=W,z=se):ee=ee.next=W,k|=q;if(N=N.next,N===null){if(N=p.shared.pending,N===null)break;W=N,N=W.next,W.next=null,p.lastBaseUpdate=W,p.shared.pending=null}}while(!0);ee===null&&(z=se),p.baseState=z,p.firstBaseUpdate=X,p.lastBaseUpdate=ee,x===null&&(p.shared.lanes=0),kl|=k,r.lanes=k,r.memoizedState=se}}function b1(r,s){if(typeof r!="function")throw Error(i(191,r));r.call(s)}function v1(r,s){var u=r.callbacks;if(u!==null)for(r.callbacks=null,r=0;rx?x:8;var k=ve.T,N={};N.types=k!==null?k.types:null,ve.T=N,hp(r,!1,s,u);try{var z=p(),X=ve.S;if(X!==null&&X(N,z),z!==null&&typeof z=="object"&&typeof z.then=="function"){var ee=N5(z,h);$a(r,s,ee,di(r))}else $a(r,s,h,di(r))}catch(se){$a(r,s,{then:function(){},status:"rejected",reason:se},di())}finally{Ee.p=x,k!==null&&N.types!==null&&(k.types=N.types),ve.T=k}}function j5(){}function up(r,s,u,h){if(r.tag!==5)throw Error(i(476));var p=Z1(r).queue;W1(r,p,s,jt,u===null?j5:function(){return J1(r),u(h)})}function Z1(r){var s=r.memoizedState;if(s!==null)return s;s={memoizedState:jt,baseState:jt,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:jt},next:null};var u={};return s.next={memoizedState:u,baseState:u,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ir,lastRenderedState:u},next:null},r.memoizedState=s,r=r.alternate,r!==null&&(r.memoizedState=s),s}function J1(r){var s=Z1(r);s.next===null&&(s=r.alternate.memoizedState),$a(r,s.next.queue,{},di())}function fp(){return gn(Lo)}function ev(){return qt().memoizedState}function tv(){return qt().memoizedState}function R5(r){for(var s=r.return;s!==null;){switch(s.tag){case 24:case 3:var u=di();r=ml(u);var h=pl(s,r,u);h!==null&&(Wn(h,s,u),Ua(h,s,u)),s={cache:Hm()},r.payload=s;return}s=s.return}}function _5(r,s,u){var h=di();u={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},af(r)?iv(s,u):(u=Mm(r,s,u,h),u!==null&&(Wn(u,r,h),rv(u,s,h)))}function nv(r,s,u){var h=di();$a(r,s,u,h)}function $a(r,s,u,h){var p={lane:h,revertLane:0,gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null};if(af(r))iv(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,N=x(k,u);if(p.hasEagerState=!0,p.eagerState=N,ai(N,k))return Pu(r,s,p,0),St===null&&Bu(),!1}catch{}finally{}if(u=Mm(r,s,p,h),u!==null)return Wn(u,r,h),rv(u,s,h),!0}return!1}function hp(r,s,u,h){if(h={lane:2,revertLane:ng(),gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},af(r)){if(s)throw Error(i(479))}else s=Mm(r,u,h,2),s!==null&&Wn(s,r,2)}function af(r){var s=r.alternate;return r===Ge||s!==null&&s===Ge}function iv(r,s){mo=ef=!0;var u=r.pending;u===null?s.next=s:(s.next=u.next,u.next=s),r.pending=s}function rv(r,s,u){if((u&4194048)!==0){var h=s.lanes;h&=r.pendingLanes,u|=h,s.lanes=u,vu(r,u)}}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},lv={readContext:gn,use:rf,useCallback:function(r,s){return Pn().memoizedState=[r,s===void 0?null:s],r},useContext:gn,useEffect:F1,useImperativeHandle:function(r,s,u){u=u!=null?u.concat([r]):null,sf(4194308,4,X1.bind(null,s,r),u)},useLayoutEffect:function(r,s){return sf(4194308,4,r,s)},useInsertionEffect:function(r,s){sf(4,2,r,s)},useMemo:function(r,s){var u=Pn();s=s===void 0?null:s;var h=r();if(ps){Pi(!0);try{r()}finally{Pi(!1)}}return u.memoizedState=[h,s],h},useReducer:function(r,s,u){var h=Pn();if(u!==void 0){var p=u(s);if(ps){Pi(!0);try{u(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=lp(r);var s=r.queue,u=nv.bind(null,Ge,s);return s.dispatch=u,[r.memoizedState,u]},useDebugValue:ap,useDeferredValue:function(r,s){var u=Pn();return cp(u,r,s)},useTransition:function(){var r=lp(!1);return r=W1.bind(null,Ge,r.queue,!0,!1),Pn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,s,u){var h=Ge,p=Pn();if(Ze){if(u===void 0)throw Error(i(407));u=u()}else{if(u=s(),St===null)throw Error(i(349));(rt&127)!==0||N1(h,s,u)}p.memoizedState=u;var x={value:u,getSnapshot:s};return p.queue=x,F1(A1.bind(null,h,x,r),[r]),h.flags|=2048,go(9,{destroy:void 0},T1.bind(null,h,x,u,s),null),u},useId:function(){var r=Pn(),s=St.identifierPrefix;if(Ze){var u=nr,h=tr;u=(h&~(1<<32-on(h)-1)).toString(32)+u,s="_"+s+"R_"+u,u=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,Op(s,s.type,r===null?null:r.memoizedProps,s.pendingProps,u),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,co(s)){if(r=s.stateNode,u=s.memoizedProps,h=null,p=an,p!==null)switch(p.tag){case 27:case 5:h=p.memoizedProps}r[nn]=s,r=!!(r.nodeValue===u||h!==null&&h.suppressHydrationWarning===!0||Aw(r.nodeValue,u)),r||ul(s,!0)}else r=sc(r).createTextNode(h),r[nn]=s,s.stateNode=r}return Et(s),null;case 31:if(u=s.memoizedState,r===null||r.memoizedState!==null){if(h=co(s),u!==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 u=zm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=u),r=!0;if(!r)return s.flags&256?(ci(s),s):(ci(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=co(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=zm(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=p),p=!0;if(!p)return s.flags&256?(ci(s),s):(ci(s),null)}return ci(s),(s.flags&128)!==0?(s.lanes=u,s):(u=h!==null,r=r!==null&&r.memoizedState!==null,u&&(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)),u!==r&&u&&(s.child.flags|=8192),pf(s,s.updateQueue),Et(s),null);case 4:return Fe(),r===null&&sg(s.stateNode.containerInfo),s.flags|=67108864,Et(s),null;case 10:return Pr(s.type),Et(s),null;case 19:if(Km(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=u,u=s.child;u!==null;)n1(u,r),u=u.sibling;return Va(s,yn.current&1|2),Ze&&zr(s,h.treeForkCount),s.child}r=r.sibling}h.tail!==null&&Tt()>Tf&&(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*Tt()-h.renderingStartTime>Tf&&u!==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(u=r;u!==null;){if(u.alternate!==null){u=!1;break e}u=u.sibling}u=!0}return h.rendering=r,h.tail=r.sibling,h.renderingStartTime=Tt(),r.sibling=null,x=yn.current,x=p?x&1|2:x&1,h.tailMode==="visible"||h.tailMode==="collapsed"||!u||Ze?Va(s,x):(u=x,$e(xn,s),$e(yn,u),En===null&&(En=s)),Ze&&zr(s,h.treeForkCount),r}return Et(s),null;case 22:case 23:return ci(s),Gm(),h=s.memoizedState!==null,r!==null?r.memoizedState!==null!==h&&(s.flags|=8192):h&&(s.flags|=8192),h?(u&536870912)!==0&&(s.flags&128)===0&&(Et(s),s.subtreeFlags&6&&(s.flags|=8192)):Et(s),u=s.updateQueue,u!==null&&pf(s,u.retryQueue),u=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),h=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(h=s.memoizedState.cachePool.pool),h!==u&&(s.flags|=2048),r!==null&&mt(fs),null;case 24:return u=null,r!==null&&(u=r.memoizedState.cache),s.memoizedState.cache!==u&&(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(_m(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(ci(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(ci(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 Km(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 ci(s),Gm(),r!==null&&mt(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 Mv(r,s){switch(_m(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&&ci(s);break;case 13:ci(s);break;case 19:Km(s);break;case 10:Pr(s.type);break;case 22:case 23:ci(s),Gm(),r!==null&&mt(fs);break;case 24:Pr(Gt)}}function Ka(r,s){try{var u=s.updateQueue,h=u!==null?u.lastEffect:null;if(h!==null){var p=h.next;u=p;do{if((u.tag&r)===r){h=void 0;var x=u.create,k=u.inst;h=x(),k.destroy=h}u=u.next}while(u!==p)}}catch(N){yt(s,s.return,N)}}function bl(r,s,u){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,N=k.destroy;if(N!==void 0){k.destroy=void 0,p=s;var z=u,X=N;try{X()}catch(ee){yt(p,z,ee)}}}h=h.next}while(h!==x)}}catch(ee){yt(s,s.return,ee)}}function Dv(r){var s=r.updateQueue;if(s!==null){var u=r.stateNode;try{v1(s,u)}catch(h){yt(r,r.return,h)}}}function jv(r,s,u){u.props=gs(r.type,r.memoizedProps),u.state=r.memoizedState;try{u.componentWillUnmount()}catch(h){yt(r,s,h)}}function ir(r,s){try{var u=r.ref;if(u!==null){switch(r.tag){case 26:case 27:case 5:var h=r.stateNode;break;case 30:var p=r.stateNode,x=Rr(r.memoizedProps,p);(p.ref===null||p.ref.name!==x)&&(p.ref=Hw(x)),h=p.ref;break;case 7:if(r.stateNode===null){var k=new mi(r);g(r.child,!1,D3,k,void 0,void 0),r.stateNode=k}h=r.stateNode;break;default:h=r.stateNode}typeof u=="function"?r.refCleanup=u(h):u.current=h}}catch(N){yt(r,s,N)}}function bn(r,s){var u=r.ref,h=r.refCleanup;if(u!==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 u=="function")try{u(null)}catch(p){yt(r,s,p)}else u.current=null}function gf(r,s){if((r.tag===5||r.tag===27||r.tag===6)&&r.alternate===null&&s!==null)for(var u=0;u title"))),vn(h,s,u),h[nn]=r,de(h),s=h;break e;case"link":if(x=nk("link","href",p).get(s+(u.href||""))){for(k=0;kYe&&(k=Ye,Ye=Re,Re=k);var Q=Vb(N,Re),U=Vb(N,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=N;W=W.parentNode;)W.nodeType===1&&se.push({element:W,left:W.scrollLeft,top:W.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;Nu?32:u,ve.T=null,u=Xp,Xp=null;var x=qi,k=cr;if(Lt=0,vs=qi=null,cr=0,(dt&6)!==0)throw Error(i(331));var N=dt;if(dt|=4,tw(x.current),Zv(x,x.current,k,u),dt=N,ic(0,!1),zn&&typeof zn.onPostCommitFiberRoot=="function")try{zn.onPostCommitFiberRoot(Jl,x)}catch{}return!0}finally{Ee.p=p,ve.T=h,gw(r,s)}}function xw(r,s,u){s=Ci(u,s),s=pp(r.stateNode,s,2),r=pl(r,s,2),r!==null&&(es(r,2),ur(r))}function yt(r,s,u){if(r.tag===3)xw(r,r,u);else for(;s!==null;){if(s.tag===3){xw(s,r,u);break}else if(s.tag===1){var h=s.stateNode;if(typeof s.type.getDerivedStateFromError=="function"||typeof h.componentDidCatch=="function"&&(Sl===null||!Sl.has(h))){r=Ci(u,r),u=dv(2),h=pl(s,u,2),h!==null&&(mv(u,h,s,r),es(h,2),ur(h));break}}s=s.return}}function Jp(r,s,u){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(u)||(qp=!0,p.add(u),r=J5.bind(null,r,s,u),s.then(r,r))}function J5(r,s,u){var h=r.pingCache;h!==null&&h.delete(s),r.pingedLanes|=r.suspendedLanes&u,r.warmLanes&=~u,St===r&&(rt&u)===u&&((Pt===4||Pt===3&&(rt&62914560)===rt&&300>Tt()-Nf)&&(dt&2)===0?To(r,0):Of|=u,ko===rt&&(ko=0)),ur(r)}function yw(r,s){s===0&&(s=yu()),r=rs(r,s),r!==null&&(es(r,s),ur(r))}function e3(r){var s=r.memoizedState,u=0;s!==null&&(u=s.retryLane),yw(r,u)}function t3(r,s){var u=0;switch(r.tag){case 31:case 13:var h=r.stateNode,p=r.memoizedState;p!==null&&(u=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),yw(r,u)}function n3(r,s){return we(r,s)}var Eo=null,Mo=null,eg=!1,_f=!1,tg=!1,Ol=0;function ur(r){r!==Mo&&r.next===null&&(Mo===null?Eo=Mo=r:Mo=Mo.next=r),_f=!0,eg||(eg=!0,r3())}function ic(r,s){if(!tg&&_f){tg=!0;do for(var u=!1,h=Eo;h!==null;){if(r!==0){var p=h.pendingLanes;if(p===0)var x=0;else{var k=h.suspendedLanes,N=h.pingedLanes;x=(1<<31-on(42|r)+1)-1,x&=p&~(k&~N),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(u=!0,kw(h,x))}else x=rt,x=$s(h,h===St?x:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),(x&3)===0||vi(h,x)||(u=!0,kw(h,x));h=h.next}while(u);tg=!1}}function i3(){bw()}function bw(){_f=eg=!1;var r=0;Ol!==0&&p3()&&(r=Ol);for(var s=Tt(),u=null,h=Eo;h!==null;){var p=h.next,x=vw(h,s);x===0?(h.next=null,u===null?Eo=p:u.next=p,p===null&&(Mo=u)):(u=h,(r!==0||(x&3)!==0)&&(_f=!0)),h=p}Lt!==0&&Lt!==5||ic(r),Ol!==0&&(Ol=0)}function vw(r,s){for(var u=r.suspendedLanes,h=r.pingedLanes,p=r.expirationTimes,x=r.pendingLanes&-62914561;0N)break;var ee=z.transferSize,se=z.initiatorType;ee&&Ew(se)&&(z=z.responseEnd,k+=ee*(zHf){Re.length=be;break}G=new Promise(w3.bind(G)),Re.push(G)}}}if(0"u"?null:document;function Zw(r,s,u){var h=jo;if(h&&typeof s=="string"&&s){var p=ki(s);p='link[rel="'+r+'"][href="'+p+'"]',typeof u=="string"&&(p+='[crossorigin="'+u+'"]'),Ww.has(p)||(Ww.add(p),r={rel:r,crossOrigin:u,href:s},h.querySelector(p)===null&&(s=h.createElement("link"),vn(s,"link",r),de(s),h.head.appendChild(s)))}}function I3(r){Vr.D(r),Zw("dns-prefetch",r,null)}function U3(r,s){Vr.C(r,s),Zw("preconnect",r,s)}function F3(r,s,u){Vr.L(r,s,u);var h=jo;if(h&&r&&s){var p='link[rel="preload"][as="'+ki(s)+'"]';s==="image"&&u&&u.imageSrcSet?(p+='[imagesrcset="'+ki(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(p+='[imagesizes="'+ki(u.imageSizes)+'"]')):p+='[href="'+ki(r)+'"]';var x=p;switch(s){case"style":x=Ro(r);break;case"script":x=_o(r)}if(!(Mi.has(x)||(r=j({rel:"preload",href:s==="image"&&u&&u.imageSrcSet?void 0:r,as:s},u),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[Gs]=!0,k.onload=k.onerror=function(){Oe(k)}),de(k),h.head.appendChild(k)}}}function q3(r,s){Vr.m(r,s);var u=jo;if(u&&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=_o(r)}if(!Mi.has(x)&&(r=j({rel:"modulepreload",href:r},s),Mi.set(x,r),u.querySelector(p)===null)){switch(h){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(cc(x)))return}h=u.createElement("link"),vn(h,"link",r),de(h),u.head.appendChild(h)}}}function V3(r,s,u){Vr.S(r,s,u);var h=jo;if(h&&r){var p=K(h).hoistableStyles,x=Ro(r);s=s||"default";var k=p.get(x);if(!k){var N={loading:0,preload:null};if(k=h.querySelector(ac(x)))N.loading=5;else{r=j({rel:"stylesheet",href:r,"data-precedence":s},u),(u=Mi.get(x))&&kg(r,u);var z=k=h.createElement("link");de(z),vn(z,"link",r),z._p=new Promise(function(X,ee){z.onload=X,z.onerror=ee}),z.addEventListener("load",function(){N.loading|=1}),z.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Bf(k,s,h)}k={type:"stylesheet",instance:k,count:1,state:N},p.set(x,k)}}}function Q3(r,s){Vr.X(r,s);var u=jo;if(u&&r){var h=K(u).hoistableScripts,p=_o(r),x=h.get(p);x||(x=u.querySelector(cc(p)),x||(r=j({src:r,async:!0},s),(s=Mi.get(p))&&Sg(r,s),x=u.createElement("script"),de(x),vn(x,"link",r),u.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function X3(r,s){Vr.M(r,s);var u=jo;if(u&&r){var h=K(u).hoistableScripts,p=_o(r),x=h.get(p);x||(x=u.querySelector(cc(p)),x||(r=j({src:r,async:!0,type:"module"},s),(s=Mi.get(p))&&Sg(r,s),x=u.createElement("script"),de(x),vn(x,"link",r),u.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},h.set(p,x))}}function Jw(r,s,u,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 u.precedence=="string"&&typeof u.href=="string"?(u=Ro(u.href),s=K(p).hoistableStyles,h=s.get(u),h||(h={type:"style",instance:null,count:0,state:null},s.set(u,h)),h):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){r=Ro(u.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:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.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=u.async,u=u.src,typeof u=="string"&&s&&typeof s!="function"&&typeof s!="symbol"?(u=_o(u),s=K(p).hoistableScripts,h=s.get(u),h||(h={type:"script",instance:null,count:0,state:null},s.set(u,h)),h):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,r))}}function Ro(r){return'href="'+ki(r)+'"'}function ac(r){return'link[rel="stylesheet"]['+r+"]"}function ek(r){return j({},r,{"data-precedence":r.precedence,precedence:null})}function $3(r,s,u,h){if(s=r.querySelector('link[rel="preload"][as="style"]['+s+"]")){if(s[Gs]!==!0){h.loading=1;return}}else s=r.createElement("link"),s[Gs]=!0,s.onload=s.onerror=Oe.bind(null,s),vn(s,"link",u),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 _o(r){return'[src="'+ki(r)+'"]'}function cc(r){return"script[async]"+r}function tk(r,s,u){if(s.count++,s.instance===null)switch(s.type){case"style":var h=r.querySelector('style[data-href~="'+ki(u.href)+'"]');if(h)return s.instance=h,de(h),h;var p=j({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return h=(r.ownerDocument||r).createElement("style"),de(h),vn(h,"style",p),Bf(h,u.precedence,r),s.instance=h;case"stylesheet":p=Ro(u.href);var x=r.querySelector(ac(p));if(x)return s.state.loading|=4,s.instance=x,de(x),x;h=ek(u),(p=Mi.get(p))&&kg(h,p),x=(r.ownerDocument||r).createElement("link"),de(x);var k=x;return k._p=new Promise(function(N,z){k.onload=N,k.onerror=z}),vn(x,"link",h),s.state.loading|=4,Bf(x,u.precedence,r),s.instance=x;case"script":return x=_o(u.src),(p=r.querySelector(cc(x)))?(s.instance=p,de(p),p):(h=u,(p=Mi.get(x))&&(h=j({},u),Sg(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,u.precedence,r));return s.instance}function Bf(r,s,u){for(var h=u.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,u){if(u===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 ik(r,s){return r==="img"&&s.src!=null&&s.src!==""&&s.onLoad==null&&s.loading!=="lazy"}function rk(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function lk(r){return(r.width||100)*(r.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function sk(r,s){typeof s.decode=="function"&&(r.imgCount++,s.complete||(r.imgBytes+=lk(s),r.suspenseyImages.push(s)),r=W3.bind(r),s.decode().then(r,r))}function Y3(r,s,u,h){if(u.type==="stylesheet"&&(typeof h.media!="string"||matchMedia(h.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var p=Ro(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)),u.state.loading|=4,u.instance=x,de(x);return}x=s.ownerDocument||s,h=ek(h),(p=Mi.get(p))&&kg(h,p),x=x.createElement("link"),de(x);var k=x;k._p=new Promise(function(N,z){k.onload=N,k.onerror=z}),vn(x,"link",h),u.instance=x}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(u,s),(s=u.state.preload)&&(u.state.loading&3)===0&&(r.count++,u=uc.bind(r),s.addEventListener("load",u),s.addEventListener("error",u))}}var Hf=0;function K3(r,s){return r.stylesheets&&r.count===0&&Uf(r,r.stylesheets),0Hf?50:800)+s);return r.unsuspend=u,function(){r.unsuspend=null,clearTimeout(h),clearTimeout(p)}}:null}function ok(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--,ok(this)}function W3(){this.imgCount--,ok(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 u=If.get(r);if(u)var h=u.get(null);else{u=new Map,If.set(r,u);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=ey(yM);class ny 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 Nr(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 ny(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()}function wM(n,e){fetch("/api/logs/client",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:n,kind:e})}).catch(()=>{})}async function kM(){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 SM(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 CM(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 OM(n,e=1e4){const t=Date.now()+e;let i=null;for(;Date.now()setTimeout(l,500))}return i}async function Dk(){const n=await fetch("/api/config");if(!n.ok)throw new Error("Failed to fetch app configuration");return n.json()}async function jk(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 Nr(e,"Failed to select directory");return e.json()}async function NM(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 AM(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 Rk(){const n=await fetch("/api/config/content");if(!n.ok)throw await Nr(n,"Failed to fetch config content");return n.json()}async function _k(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 Nr(t,"Failed to validate config content");return t.json()}async function EM(){const n=await fetch("/api/config/template",{method:"POST"});if(!n.ok)throw await Nr(n,"Failed to fetch config template");return n.json()}async function Lk(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 Nr(i,"Failed to save configuration");const l=await i.json();return{config:l.config,contentHash:l.content_hash??null}}async function MM(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 Nr(e,"Failed to save configuration as");const t=await e.json();return{config:t.config,contentHash:t.content_hash??null}}async function DM(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 zk(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 Nr(t,"Failed to execute scan");return t.json()}async function Bk(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 jM(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 XC(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 _x(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 Pk(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 Hk(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 Lx(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 _M(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 LM(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 zM(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 BM(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 PM(n){const e=await fetch("/api/workflow/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!e.ok)throw await Nr(e,"Failed to start workflow session");return e.json()}async function HM(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 Nr(t,"Failed to respond to workflow prompt");return t.json()}async function IM(n){const e=await fetch(`/api/workflow/${n}/abort`,{method:"POST"});if(!e.ok)throw await Nr(e,"Failed to abort workflow session");return e.json()}function Bg(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 UM=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),$C=(...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 FM={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 qM=E.forwardRef(({color:n="currentColor",size:e=24,strokeWidth:t=2,absoluteStrokeWidth:i,className:l="",children:o,iconNode:a,...c},f)=>E.createElement("svg",{ref:f,...FM,width:e,height:e,stroke:n,strokeWidth:i?Number(t)*24/Number(e):t,className:$C("lucide",l),...c},[...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 De=(n,e)=>{const t=E.forwardRef(({className:i,...l},o)=>E.createElement(qM,{ref:o,iconNode:e,className:$C(`lucide-${UM(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=De("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 XM=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],GC=De("ArrowDown",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 $M=[["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=De("ArrowLeftRight",$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:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],KM=De("ArrowRight",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 WM=[["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"}]],Ik=De("ArrowUpDown",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 ZM=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],JM=De("ArrowUp",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 e4=[["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"}]],t4=De("Bug",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=[["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"}]],i4=De("Calendar",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 r4=[["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"}]],YC=De("Camera",r4);/** + * @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:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Sr=De("Check",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:"m6 9 6 6 6-6",key:"qrunsl"}]],o4=De("ChevronDown",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 a4=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ad=De("ChevronRight",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 c4=[["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=De("CircleAlert",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"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Uk=De("CircleCheck",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:"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"}]],h4=De("CircleDashed",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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],m4=De("CircleDot",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 p4=[["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"}]],g4=De("CirclePause",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:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]],y4=De("CirclePlay",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=[["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=De("CircleX",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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],w4=De("Clock",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 k4=[["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"}]],Fn=De("Copy",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:"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"}]],KC=De("Download",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:"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"}]],iy=De("ExternalLink",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:"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"}]],N4=De("EyeOff",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=[["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"}]],zx=De("Eye",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=[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]],E4=De("FastForward",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 M4=[["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"}]],D4=De("FileCode2",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 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"}]],Bx=De("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 R4=[["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"}]],Vo=De("FileCog",R4);/** + * @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:"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"}]],L4=De("FilePlus2",_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 z4=[["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=De("FileText",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 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"}]],Pg=De("File",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:"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"}]],H4=De("FlaskConical",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 I4=[["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"}]],Il=De("FolderOpen",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 U4=[["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=De("Folder",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:"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"}]],q4=De("Globe",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 V4=[["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"}]],Qo=De("Hash",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 Q4=[["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=De("House",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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ry=De("Info",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=[["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=De("Keyboard",$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 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"}]],Y4=De("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 K4=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Yr=De("LoaderCircle",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 W4=[["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"}]],Z4=De("Lock",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 J4=[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]],eD=De("Moon",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 tD=[["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"}]],nD=De("Network",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=[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]],Fl=De("Play",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:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],lD=De("Plus",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 sD=[["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"}]],ly=De("QrCode",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 oD=[["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=De("RefreshCw",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:"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"}]],cD=De("Rocket",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 uD=[["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"}]],fD=De("RotateCcw",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=[["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"}]],dD=De("SaveAll",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=[["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=De("Save",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 pD=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],JC=De("Search",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=[["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"}]],xD=De("Settings",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:"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"}]],bD=De("Sun",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 vD=[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]],eO=De("Terminal",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 wD=[["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=De("Timer",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:"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=De("Trash2",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:"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"}]],Dd=De("TriangleAlert",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:"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"}]],OD=De("User",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 ND=[["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=De("Webhook",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 TD=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],AD=De("WifiOff",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 ED=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],MD=De("Wifi",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=[["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"}]],jD=De("Workflow",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:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ri=De("X",RD);function _D({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),c=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":c,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(JM,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(GC,{className:"ml-auto h-3 w-3 shrink-0 text-chip-indigo-text"}):y.jsx(Ik,{className:"ml-auto h-3 w-3 shrink-0 opacity-0 transition-opacity group-hover:opacity-40 hover:opacity-40"}):o>0&&y.jsx(Ik,{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":Xo,"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"?Xo: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,Fk=500,Xo=80,Xh=960,Dh=160,Wf=24,qk=44,Zf={File:2,Path:3,FileName:1,Type:1,Version:1};function LD({files:n,totalCount:e,rawLoadedCount:t,onLoadMore:i,loadingMore:l=!1,scanning:o=!1,hasScanned:a=!1,activeDirectory:c="",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:P,rowColors:L,sort:D,onSortChange:j}){const H=["File"],Z=C.length>0?C:H,I=S.length>0?S:Z,F=Array.from({length:Math.max(Z.length,I.length)},(Ce,Fe)=>({key:Z[Fe]??H[0],header:I[Fe]??Z[Fe]??H[0]})),A=E.useRef(null),[ne,ae]=E.useState(0),[ie,$]=E.useState(600),[oe,J]=E.useState(0),[Y,T]=E.useState({}),he=E.useRef(null),ye=E.useRef(!1),B=Z.reduce((Ce,Fe)=>Ce+(Zf[Fe]??1),1),R=(Ce,Fe)=>{const Ve=Math.min(Xh,Math.max(Xo,Math.round(Fe)));T(at=>({...at,[Ce]:Ve}))},V=(Ce,Fe)=>{var te;const Ve=Array.from(((te=A.current)==null?void 0:te.querySelectorAll("[data-column-key]"))??[]).find(fe=>fe.dataset.columnKey===Ce),at=Y[Ce]??(Ve==null?void 0:Ve.getBoundingClientRect().width)??Dh;R(Ce,at+Fe)},ue=[`${qk}px`,...Z.map(Ce=>Y[Ce]?`${Y[Ce]}px`:`minmax(${Xo}px, ${Zf[Ce]??1}fr)`)].join(" "),pe=E.useRef(!1),je=E.useRef(null),Ne=n.length,Pe=t??Ne,ve=e??Pe,Ee=Pe{const Ce=A.current;if(!Ce)return;const Fe=new ResizeObserver(Ve=>{for(const at of Ve)$(at.contentRect.height),J(at.contentRect.width)});return Fe.observe(Ce),$(Ce.clientHeight||600),J(Ce.clientWidth||0),()=>Fe.disconnect()},[]),E.useEffect(()=>{var fe;const Ce=A.current;if(!Ce||O<0||O>=Ne)return;const Fe=((fe=Ce.querySelector("[data-file-list-header]"))==null?void 0:fe.offsetHeight)??0,Ve=Fe+O*Qi,at=Ve+Qi;let te=Ce.scrollTop;VeCe.scrollTop+Ce.clientHeight&&(te=at-Ce.clientHeight),te!==Ce.scrollTop&&(Ce.scrollTop=te,ae(te))},[O,Ne]),E.useEffect(()=>{const Ce=A.current;if(!Ce)return;const Fe=()=>{if(pe.current||!Ut||!i)return;const Ve=Ce.scrollTop+Ce.clientHeight,at=Ne*Qi;at-VeVe&&(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,Ne]),E.useEffect(()=>{if(pe.current||!Ut||!i)return;const Ce=Ne*Qi,Fe=ne+ie;if(!(Ce-FeFe))return;const at=`${Ne}:${Pe}:${ve}`;je.current=at,i()});const Ft=E.useCallback(Ce=>{ae(Ce.currentTarget.scrollTop)},[]),zt=Math.max(0,Math.floor(ne/Qi)-Kf),mt=Math.ceil(ie/Qi)+Kf*2,$e=Math.min(Ne,zt+mt),Xt=zt*Qi,Tn=(Ce,Fe)=>{if(Fe)return{className:"bg-chip-indigo-bg border-l-4 border-chip-indigo-border text-ink",style:{}};for(const[Ve,at]of L)if(Ce.toLowerCase().includes(Ve.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?Ne+mt:Ne)*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,Ne===0?1:0)+1,"aria-colcount":Z.length+1,"aria-activedescendant":Ne>0?`file-row-${O}`:void 0,tabIndex:0,children:[y.jsx("div",{className:"sticky top-0 z-10",role:"presentation",children:y.jsx(_D,{columnTemplate:ue,resizePointerRef:he,resizeMovedRef:ye,items:[{label:"#",icon:y.jsx(Bx,{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(Xo,Math.round((oe-qk)*(Zf[Ce]??1)/B))),canResize:!0,onResizeBy:Ve=>V(Ce,Ve),onResizeTo:Ve=>R(Ce,Ve),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?j({column:Ce,direction:"asc"}):D.direction==="asc"?j({column:Ce,direction:"desc"}):j(null)}}))]})}),w&&Ne>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(ry,{className:"h-3 w-3 shrink-0 text-ink-faint","aria-hidden":"true"}),y.jsx("span",{className:"min-w-0 truncate",children:w})]}),Ne===0?y.jsx("div",{role:"row","aria-rowindex":2,"data-testid":"file-list-empty",children:y.jsx("div",{role:"gridcell","aria-colspan":Z.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..."})]}):!c.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 Ve=zt+Fe,at=Ve===O,te=Tn(Ce.filename,at);return y.jsxs("div",{id:`file-row-${Ve}`,"data-row-index":Ve,role:"row","aria-rowindex":Ve+2,"aria-selected":at,onClick:()=>{var fe;_(Ve),(fe=A.current)==null||fe.focus()},onDoubleClick:()=>M(Ce),onContextMenu:fe=>P(fe,Ce,Ve),className:`grid cursor-pointer items-center transition-colors ${te.className}`,style:{...te.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:Ve+1})]}),Z.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:Xo},title:fe==="Path"?Ce.path:ze,children:ze},_e)})]},Ce.path||Ve)})}),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(GM,{className:"mr-1.5 h-4 w-4 animate-spin motion-reduce:animate-none text-ink-muted"}):null,"(",Pe," of ",ve," loaded)"]})]})]})}const zD=800;function BD(n){const[e,t]=E.useState([]),[i,l]=E.useState(0),[o,a]=E.useState(!1),[c,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,P=A=>{M(A)&&b(!1)},L=async(A,ne=d)=>{var ie;const ae=await Bk({offset:0,limit:Fk,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 zk(ne,(ie=w.current)==null?void 0:ie.signal);return ae.warning&&M(A)&&C.current.showToast(ae.warning,"error"),!M(A)||!await L(A)?!1:(C.current.onFreshResults(),!0)},j=async(A,ne,ae)=>{var ie;if(!ne.directory)return{ok:!1};try{const $=await zk(ne,(ie=w.current)==null?void 0:ie.signal);$.warning&&M(A)&&C.current.showToast($.warning,"error");const oe=await L(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{P(A)}},H=async(A,ne)=>{if(!A.directory)return{ok:!1};const ae=_();return j(ae,A,ne)};return{files:e,totalCount:i,hasScanned:o,loadingMore:c,scanning:g,sort:d,beginScan:_,claimGeneration:O,isCurrentScan:M,finishScan:P,runScan:D,scanWith:H,scanWithGeneration:j,applySort:A=>{m(A),C.current.onFreshResults();const ne=_();L(ne,A).catch(ae=>{M(ne)&&C.current.showToast(`Sort failed: ${(ae==null?void 0:ae.message)??String(ae)}`,"error")}).finally(()=>P(ne))},handleLoadMore:async()=>{if(c||e.length>=i)return;const A=v.current;f(!0);try{const ne=await Bk({offset:e.length,limit:Fk,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,H(C.current.getScanParams())},zD)}}}function PD(){const[n,e]=E.useState(null),t=E.useRef(null);return{toastMessage:n,showToast:(o,a="info",c)=>{o&&(e({message:o,kind:a}),(c==null?void 0:c.mirror)!==!1&&wM(o,a),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>e(null),a==="error"?1e4:3500))},dismissToast:()=>{t.current&&clearTimeout(t.current),e(null)}}}const HD=4e3;function ID(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,"info",{mirror:!1})}},l=setInterval(()=>void i(),HD);return()=>clearInterval(l)},[])}const Vk=20;function UD(n){E.useEffect(()=>{const e=n,t=i=>{var o,a,c,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(),(c=document.querySelector("#extension-combobox"))==null||c.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()==="k"){i.preventDefault(),e.setShowLanModal(!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 FD(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 qD(n){return n.scan===!0||n.filter!==void 0||n.ext!==void 0||n.recursive!==void 0||n.dir!==void 0}const VD=";",Qk="=";function QD(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 Xk(n){const e=n.trim();if(!e.includes(Qk))return{values:{filter:e},isPlainFilter:!0};const t={};for(const i of e.split(VD)){const l=i.trim();if(!l)continue;const o=l.indexOf(Qk);if(o===-1)continue;const a=QD(l.slice(0,o)),c=l.slice(o+1).trim();switch(a){case"filter":t.filter=c;break;case"ext":t.ext=c;break;case"recursive":t.recursive=$k(c,!0);break;case"dir":t.dir=c;break;case"scan":t.scan=$k(c,!1);break}}return{values:t,isPlainFilter:!1}}function $k(n,e){const t=n.toLowerCase();return["0","false","no","off"].includes(t)?!1:["1","true","yes","on"].includes(t)?!0:e}function XD(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=Xk(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})},c=f=>{n.onApplyValues(f),qD(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=Xk(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}`),c(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 $D(){try{const n=localStorage.getItem(rO);return n==="dark"||n==="light"?n:"dark"}catch{return"dark"}}function GD(){const[n,e]=E.useState($D),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 YD=[".profiles",".profiles.yaml",".profiles.yml",".yaml",".yml"];function KD(n){const e=n.toLowerCase();return YD.some(t=>e.endsWith(t))}function WD(n){for(const e of n)if(KD(e.name))return e;return null}function jh(){return{depth:0,overlayVisible:!1}}function Gk(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 jh()}}function ZD(n){const[e,t]=E.useState(!1),i=E.useRef(jh()),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(Gk(i.current,"enter",m(S)))},b=S=>{m(S)&&S.preventDefault()},v=S=>{l(Gk(i.current,"leave",m(S)))},w=S=>{var _;S.preventDefault(),l(jh());const C=Array.from(((_=S.dataTransfer)==null?void 0:_.files)??[]),O=WD(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(jh())},applyConfigFile:d=>{a(d)}}}function JD(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 ej(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 tj({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}=ej(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:JD(e)})]})]})}function nj({onExecute:n,scanning:e,hasSelection:t,fileCount:i,totalCount:l,scanningDirectory:o="",toastMessage:a,onToastDismiss:c}){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}),c&&y.jsx("button",{type:"button",onClick:c,"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(ri,{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(tj,{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(Fl,{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 Px=[],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 Yk(n){return n>=127462&&n<=127487}const Kk=8205;function rj(n,e,t=!0,i=!0){return(t?sO:lj)(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=Hg(n,e);for(e+=Wk(i);e=0&&Yk(Hg(n,a));)o++,a-=2;if(o%2==0)break;e+=2}else break}return e}function lj(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 Wk(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,c=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(c+=l.value.length,l.done||c>=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 Vt(e):xr.from(Vt.split(e,[]))}}class Vt extends ot{constructor(e,t=sj(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],c=l+a.length;if((t?i:c)>=e)return new oj(l,c,i,a);l=c+1,i++}}decompose(e,t,i,l){let o=e<=0&&t>=this.length?this:new Vt(Zk(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(l&1){let a=i.pop(),c=Rh(o.text,a.text.slice(),0,o.length);if(c.length<=32)i.push(new Vt(c,a.length+o.length));else{let f=c.length>>1;i.push(new Vt(c.slice(0,f)),new Vt(c.slice(f)))}}else i.push(o)}replace(e,t,i){if(!(i instanceof Vt))return super.replace(e,t,i);[e,t]=oa(this,e,t);let l=Rh(this.text,Rh(i.text,Zk(this.text,0,e)),t),o=this.length+i.length-(t-e);return l.length<=32?new Vt(l,o):xr.from(Vt.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+=c.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 Vt(i,l)),i=[],l=-1);return l>-1&&t.push(new Vt(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],c=l+a.length,f=i+a.lines-1;if((t?f:c)>=e)return a.lineInner(e,t,i,l);l=c+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(c):c.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<=c){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,c,f)}o=c+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+=c.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,c]=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==c)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 Vt(v,t)}let l=Math.max(32,i>>5),o=l<<1,a=l>>1,c=[],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(),c.push(v)):v instanceof Vt&&f&&(w=m[m.length-1])instanceof Vt&&v.lines+w.lines<=32?(f+=v.lines,d+=v.length+1,m[m.length-1]=new Vt(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&&(c.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(),c.length==1?c[0]:new xr(c,t)}}ot.empty=new Vt([""],0);function sj(n){let e=-1;for(let t of n)e+=t.length+1;return e}function Rh(n,e,t=0,i=1e9){for(let l=0,o=0,a=!0;o=t&&(f>i&&(c=c.slice(0,i-l)),l0?1:(e instanceof Vt?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,c=l instanceof Vt?l.text.length:l.children.length;if(a==(t>0?c: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 Vt){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 Vt?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 oj{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 rj(n,e,t,i)}function aj(n){return n>=56320&&n<57344}function cj(n){return n>=55296&&n<56320}function Jn(n,e){let t=n.charCodeAt(e);if(!cj(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return aj(i)?(t-55296<<10)+(i-56320)+65536:t}function sy(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 Hx=/\r\n?|\n/;var qn=(function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n})(qn||(qn={}));class Cr{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return o+(e-l);o+=c}else{if(i!=qn.Simple&&d>=e&&(i==qn.TrackDel&&le||i==qn.TrackBefore&&le))return null;if(d>e||d==e&&t<0&&!c)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&&c>=e)return lt?"cover":!0;l=c}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 Ix(this,(t,i,l,o,a)=>e=e.replace(l,l+(i-t),a),!1),e}mapDesc(e,t=!1){return Ux(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let l=0,o=0;l=0){t[l]=c,t[l+1]=a;let f=l>>1;for(;i.length0&&Bl(i,t,o.text),o.forward(m),c+=m}let d=e[a++];for(;c>1].toJSON()))}return e}static of(e,t,i){let l=[],o=[],a=0,c=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||Hx)):v:ot.empty,S=w.length;if(g==b&&S==0)return;ga&&Mn(l,g-a,-1),Mn(l,b-g,S),Bl(o,l,w),a=b}}return d(e),f(!c),c}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;lc&&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 Bl(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);)c=n.sections[a++],f=n.sections[a++];e(l,d,o,m,g),l=d,o=m}}}function Ux(n,e,t,i=!1){let l=[],o=i?[]:null,a=new Fc(n),c=new Fc(e);for(let f=-1;;){if(a.done&&c.len||c.done&&a.len)throw new Error("Mismatched change set lengths");if(a.ins==-1&&c.ins==-1){let d=Math.min(a.len,c.len);Mn(l,d,-1),a.forward(d),c.forward(d)}else if(c.ins>=0&&(a.ins<0||f==a.i||a.off==0&&(c.len=0&&f=0){let d=0,m=a.len;for(;m;)if(c.ins==-1){let g=Math.min(m,c.len);d+=g,m-=g,c.forward(g)}else if(c.ins==0&&c.lenf||a.ins>=0&&a.len>f)&&(c||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 Ll{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 Ll(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 Ll(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=>Ll.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,c):re.range(c,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 oy=0;class Te{constructor(e,t,i,l,o){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=l,this.id=oy++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Te(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:ay),!!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 ay(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=oy++}dynamicSlot(e){var t;let i=this.value,l=this.facet.compareInput,o=this.id,a=e[o]>>1,c=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)||Fx(g,m)){let v=i(g);if(c?!Jk(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 Te?b.facet(C)===g.facet(C):C instanceof jn?b.field(C,!1)==g.field(C,!1):!0)||(c?Jk(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 Jk(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 c(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),c;return(c=o.find(f=>f.field==this))&&c!=a.find(f=>f.field==this)?(i.values[t]=c.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 Ts={lowest:4,low:3,default:2,high:1,highest:0};function gc(n){return e=>new dO(e,n)}const Us={highest:gc(Ts.highest),high:gc(Ts.high),default:gc(Ts.default),low:gc(Ts.low),lowest:gc(Ts.lowest)};class dO{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}}class jd{of(e){return new qx(this,e)}reconfigure(e){return jd.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class qx{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 fj(e,t,a))b instanceof jn?l.push(b):(o[b.facet.id]||(o[b.facet.id]=[])).push(b);let c=Object.create(null),f=[],d=[];for(let b of l)c[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(c[w.id]=f.length<<1|1,ay(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?(c[C.id]=f.length<<1|1,f.push(C.value)):(c[C.id]=d.length<<1,d.push(O=>C.dynamicSlot(O)));c[w.id]=d.length<<1,d.push(C=>uj(C,w,v))}}let g=d.map(b=>b(c));return new $h(e,a,g,c,f,o)}}function fj(n,e,t){let i=[[],[],[],[],[]],l=new Map;function o(a,c){let f=l.get(a);if(f!=null){if(f<=c)return;let d=i[f].indexOf(a);d>-1&&i[f].splice(d,1),a instanceof qx&&t.delete(a.compartment)}if(l.set(a,c),Array.isArray(a))for(let d of a)o(d,c);else if(a instanceof qx){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,c)}else if(a instanceof dO)o(a.inner,a.prec);else if(a instanceof jn)i[c].push(a),a.provides&&o(a.provides,c);else if(a instanceof _h)i[c].push(a),a.facet.extensions&&o(a.facet.extensions,Ts.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,c)}}return o(n,Ts.default),i.reduce((a,c)=>a.concat(c))}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=Te.define(),Vx=Te.define({combine:n=>n.some(e=>e),static:!0}),pO=Te.define({combine:n=>n.length?n[0]:void 0,static:!0}),gO=Te.define(),xO=Te.define(),yO=Te.define(),bO=Te.define({combine:n=>n.length?n[0]:!1});class Jr{constructor(e,t){this.type=e,this.value=t}static define(){return new hj}}class hj{of(e){return new Jr(this,e)}}class dj{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 dj(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(c=>c.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 mj(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 gj(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,Qx(e,o,n.changes.newLength),!0))}return i==n?n:sn.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const xj=[];function Zo(n){return n==null?xj: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 yj=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Xx;try{Xx=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function bj(n){if(Xx)return Xx.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||yj.test(t)))return!0}return!1}function vj(n){return e=>{if(!/\S/.test(e))return _t.Space;if(bj(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 c=0;cl.set(d,f)),t=null),l.set(c.value.compartment,c.value.extension)):c.is(Ke.reconfigure)?(t=null,i=c.value):c.is(Ke.appendConfig)&&(t=null,i=Zo(i).concat(c.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(Vx)?e.newSelection:e.newSelection.asSingle();new ut(t,e.newDoc,a,o,(c,f)=>f.update(c,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 c=1;ca.spec.fromJSON(c,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)||Hx)),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(Vx)||(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 vj(t.length?t[0]:"")}wordAt(e){let{text:t,from:i,length:l}=this.doc.lineAt(e),o=this.charCategorizer(e),a=e-i,c=e-i;for(;a>0;){let f=hn(t,a,!1);if(o(t.slice(f,a))!=_t.Word)break;a=f}for(;cn.length?n[0]:4});ut.lineSeparator=pO;ut.readOnly=bO;ut.phrases=Te.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;jd.reconfigure=Ke.define();function Tr(n,e,t={}){let i={};for(let l of n)for(let o of Object.keys(l)){let a=l[o],c=i[o];if(c===void 0)i[o]=a;else if(!(c===a||a===void 0))if(Object.hasOwnProperty.call(t,o))i[o]=t[o](c,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 ql{eq(e){return this==e}range(e,t=e){return $x.create(e,t,this)}}ql.prototype.startSide=ql.prototype.endSide=0;ql.prototype.point=!1;ql.prototype.mapMode=qn.TrackDel;function cy(n,e){return n==e||n.constructor==e.constructor&&n.eq(e)}let $x=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 Gx(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class uy{constructor(e,t,i,l){this.from=e,this.to=t,this.value=i,this.maxPoint=l}get length(){return Po(this.to)}findIndex(e,t,i,l=0){let o=i?this.to:this.from;for(let a=l,c=o.length;;){if(a==c)return a;let f=a+c>>1,d=o[f]-e||(i?this.value[f].endSide:this.value[f].startSide)-t;if(f==a)return d>=0?a:c;d>=0?c=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),c.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),c.splice(O,0,S-d),f.splice(O,0,C-d);continue e}if((S-(c[O-1]+d)||b.endSide-a[O-1].startSide)>0)break}o(S,C,b)}}return{mapped:a.length?new uy(c,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(Gx)),this.isEmpty)return t.length?it.of(t):this;let c=new SO(this,null,-1).goto(0),f=0,d=[],m=new Or;for(;c.value||f=0){let g=t[f++];m.addInner(g.from,g.to,g.value,!1)||d.push(g)}else c.rangeIndex==1&&c.chunkIndexthis.chunkEnd(c.chunkIndex)||oc.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 qc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return qc.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),c=t.filter(g=>g.maxPoint>0||!g.isEmpty&&g.maxPoint>=o),f=eS(a,c,i),d=new xc(a,f,o),m=new xc(c,f,o);i.iterGaps((g,b,v)=>tS(d,g,m,b,v,l)),i.empty&&i.length==0&&tS(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 c=eS(o,a),f=new xc(o,c,0).goto(i),d=new xc(a,c,0).goto(i);for(;;){if(f.to!=d.to||!Yx(f.active,d.active)||f.point&&(!d.point||!cy(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),c=t,f=a.openStart;for(;;){let d=Math.min(a.to,i);if(a.point){let m=a.activeForPoint(a.to),g=a.pointFromc&&(l.span(c,d,a.active,f),f=a.openEnd(d));if(a.to>i)return f+(a.point&&a.to>i?1:0);c=a.to,a.next()}}static of(e,t=!1){let i=new Or;for(let l of e instanceof $x?[e]:t?wj(e):e)i.add(l.from,l.to,l.value);return i.finish()}static join(e){if(!e.length)return it.empty;let t=Po(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 Po(n){return n[n.length-1]}function wj(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(Gx);e=i}return n}it.empty.nextLayer=it.empty;class Or{finishChunk(e){this.chunks.push(new uy(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 eS(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 qc(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--)Ig(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--)Ig(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(),Ig(this.heap,0)}}}function Ig(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=qc.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=nS(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=nS(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 tS(n,e,t,i,l,o){n.goto(e),t.goto(i);let a=i+l,c=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&&cy(n.point,t.point)&&Yx(n.activeForPoint(n.to),t.activeForPoint(t.to))||o.comparePoint(c,w,n.point,t.point),m=!1):(m&&(o.boundChange(c),m=!1),w>c&&!Yx(n.active,t.active)&&o.compareRange(c,w,n.active,t.active),d&&wa)break;c=v,b<=0&&n.next(),b>=0&&t.next()}}function Yx(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 nS(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 Wx="ͼ",iS=typeof Symbol>"u"?"__"+Wx:Symbol.for(Wx),Zx=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),rS=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,c,f,d){let m=[],g=/^@(\w+)\b/.exec(a[0]),b=g&&g[1]=="keyframes";if(g&&c==null)return f.push(a[0]+";");for(let v in c){let w=c[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=rS[iS]||1;return rS[iS]=e+1,Wx+e.toString(36)}static mount(e,t,i){let l=e[Zx],o=i&&i.nonce;l?o&&l.setNonce(o):l=new kj(e,o),l.mount(Array.isArray(t)?t:[t],e)}}let lS=new Map;class kj{constructor(e,t){let i=e.ownerDocument||e,l=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&l.CSSStyleSheet){let o=lS.get(i);if(o)return e[Zx]=o;this.sheet=new l.CSSStyleSheet,lS.set(i,this)}else this.styleTag=i.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[Zx]=this}mount(e,t){let i=this.sheet,l=0,o=0,a=!1;for(let c=0;c-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:'"'},Sj=typeof navigator<"u"&&/Mac/.test(navigator.platform),Cj=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),Vc[Sn]=String.fromCharCode(Sn);for(var Ug in Ql)Vc.hasOwnProperty(Ug)||(Vc[Ug]=Ql[Ug]);function Oj(n){var e=Sj&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Cj&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Vc: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:aS||/Mac/.test(Un.platform),windows:/Win/.test(Un.platform),linux:/Linux|X11/.test(Un.platform),ie:Rd,ie_version:OO?Jx.documentMode||6:t0?+t0[1]:e0?+e0[1]:0,gecko:sS,gecko_version:sS?+(/Firefox\/(\d+)/.exec(Un.userAgent)||[0,0])[1]:0,chrome:!!Fg,chrome_version:Fg?+Fg[1]:0,ios:aS,android:/Android\b/.test(Un.userAgent),webkit:oS,webkit_version:oS?+(/\bAppleWebKit\/(\d+)/.exec(Un.userAgent)||[0,0])[1]:0,safari:n0,safari_version:n0?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Un.userAgent)||[0,0])[1]:0,tabSize:Jx.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function fy(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 hy(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 Nj(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 cS(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 Tj(n){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new Bs(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}=NO(e,t);i=(o?t?-3e8:-1:5e8)-1,l=(a?t?2e8:1:-6e8)+1}return new Bs(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}=NO(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?fy(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&&hy(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&&hy(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=qn.TrackBefore;ou.prototype.point=!0;class Bs 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?qn.TrackBefore:qn.TrackAfter:qn.TrackDel}get type(){return this.startSide!=this.endSide?Nn.WidgetRange:this.startSide<=0?Nn.WidgetBefore:Nn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Bs&&Aj(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)}}Bs.prototype.point=!0;function NO(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 Aj(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 ql{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&&hy(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 i0(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function jc(n,e){if(!e.anchorNode)return!1;try{return i0(n,e.anchorNode)}catch{return!1}}function Lh(n){return aa(n)?$c(n,0,n.nodeValue.length).getClientRects():dn(n)?n.getClientRects():[]}function Rc(n,e,t,i){return t?uS(n,e,t,i,-1)||uS(n,e,t,i,1):!1}function Xl(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 uS(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=Xl(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 Ej(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 TO(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 Mj(n,e,t,i,l,o,a,c){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=Ej(d);else{let P=getComputedStyle(m);if(/^(fixed|sticky)$/.test(P.position)&&(g=!0),(m.scrollHeight<=m.clientHeight||!/auto|scroll/.test(P.overflowY))&&(O=!1),(m.scrollWidth<=m.clientWidth||!/auto|scroll/.test(P.overflowX))&&(C=!1),!C&&!O){m=m.assignedSlot||m.parentNode;continue}let L=m.getBoundingClientRect();({scaleX:w,scaleY:S}=TO(m,L)),b={left:L.left,right:L.left+m.clientWidth*w,top:L.top,bottom:L.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 Dj{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 fS;function $c(n,e,t=e){let i=fS||(fS=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 jj(n){for(;n;){if(n&&(n.nodeType==9||n.nodeType==11&&n.host))return n;n=n.assignedSlot||n.parentNode}return null}function Rj(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=Xl(t),t=t.parentNode}}function jO(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 RO(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=Xl(t),t=t.parentNode;else return null}}function _O(n,e){for(let t=n,i=e;;){if(aa(t)&&i=t){if(c.level==i)return a;(o<0||(l!=0?l<0?c.fromt:e[o].level>c.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),c=S;break}}else{if(fr.length==189)break;fr[c++]=g,fr[c++]=b,fr[c++]=f}else if((w=Ot[g])==2||w==1){let S=w==l;f=S?0:1;for(let C=c-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 Hj(n,e,t,i){for(let l=0,o=i;l<=t.length;l++){let a=l?t[l-1].to:n,c=lf;)w==C&&(w=t[--S].from,C=S?t[S-1].to:n),Ot[--w]=v;f=m}else o=d,f++}}}function l0(n,e,t,i,l,o,a){let c=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);s0(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]!=c:Ot[w]==c))break;w++}b?l0(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!=c&&(m=!1,g=S==16)}let b=!m&&c==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]==c)break e;break}}if(b)b.push(S);else{S.toOt.length;)Ot[Ot.length]=256;let i=[],l=e==ca?0:1;return s0(n,l,l,t,0,n.length,i),i}function PO(n){return[new vr(0,n,0)]}let HO="";function Uj(n,e,t,i,l){var o;if(!n.length)return null;let a=i.head-n.from,c;if(i.head==n.from&&i.assoc<0){if(!l)return null;a=e[c=0].side(!1,t)}else if(i.head==n.to&&i.assoc>0){if(l)return null;a=e[c=e.length-1].side(!0,t)}else c=vr.find(e,a,(o=i.bidiLevel)!==null&&o!==void 0?o:-1,i.assoc);let f=e[c],d=f.side(l,t);if(a==d){let b=c+=l?1:-1;if(b<0||b>=e.length)return null;f=e[c=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=c==(l?e.length-1:0)?null:e[c+(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=Te.define({combine:n=>n.some(e=>e)}),GO=Te.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(qO);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=Te.define({combine:n=>n.length?n[0]:!0});let qj=0;const $o=Te.define({combine(n){return n.filter((e,t)=>{for(let i=0;i{let f=[];return a&&f.push(_d.of(d=>{let m=d.plugin(c);return m?a(m):Ue.none})),o&&f.push(o(c)),f})}static fromClass(e,t){return Qt.define((i,l)=>new e(i,l),t)}}class qg{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=Te.define(),gy=Te.define(),_d=Te.define(),WO=Te.define(),xy=Te.define(),au=Te.define(),ZO=Te.define();function hS(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,c,f){let d=o-e.from,m=a-e.from,g=l;for(let b=c.length-1;b>=0;b--,f--){let v=c[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 ji(o,a,c,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 Vj=[];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 Vj}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&&Nj(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=Xl(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 zd)return e;return null}static get(e){return e.cmTile}}class Ld 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 c of this.children){if(c.sync(e),a+=c.length+c.breakAfter,l=i?i.nextSibling:t.firstChild,o&&l!=c.dom&&(o.written=!0),c.dom.parentNode==t)for(;l&&l!=c.dom;)l=dS(l);else t.insertBefore(c.dom,l);i=c.dom}for(l=i?i.nextSibling:t.firstChild,o&&l&&(o.written=!0);l;)l=dS(l);this.length=a}}function dS(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class zd extends Ld{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 c=o+a.length,f=e(a,o);if(f!==void 0)return f;o=c+a.breakAfter}}}resolveBlock(e,t){let i,l=-1,o,a=-1;if(this.blockTiles((c,f)=>{let d=f+c.length;if(e>=f&&e<=d){if(c.isWidget()&&t>=-1&&t<=1){if(c.flags&32)return!0;c.flags&16&&(i=void 0)}(fe||e==f&&(t>1?c.length:c.covers(-1)))&&(!o||!c.isWidget()&&o.isWidget())&&(o=c,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 Ld{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 Ld{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,c=-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&&Xj(a,w)))&&(S>g||w.flags&32&&t<=1)?(a=w,c=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:c}:null}coordsIn(e,t,i){let l=this.resolveInline(e,t,!0);return l?l.tile.coordsIn(Math.max(0,l.offset),t,i):Qj(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,c=!1;for(let f of a.children){if(c)return new $i(f.dom,0);f==i.tile&&(c=!0)}}return new $i(this.dom,0)}}function Qj(n){let e=n.dom.lastChild;if(!e)return n.dom.getBoundingClientRect();let t=Lh(e);return t[t.length-1]||null}function Xj(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,c=0;e==0&&t<0||e==l&&t>=0?Se.chrome||Se.gecko||(e?(o--,c=1):a=0)?0:f.length-1];return Se.safari&&!c&&d.width==0&&(d=Array.prototype.find.call(f,m=>m.width)||d),i==null?d:Wh(d,(c?c>0:t<0)==i)}static of(e,t){let i=new Ms(t||document.createTextNode(e),e);return t||(i.flags|=2),i}}class Ps 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 c=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=c?o.length-1:0;a=o[f],!(e>0?f==0:f==o.length-1||a.top0==i)}}class $j{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:c}=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&&!c.length)break;i&&i.leave(l),a=!!l.breakAfter,{tile:l,index:o}=c.pop(),o++}else{let f=l.children[o],d=f.breakAfter;(t>0?f.length<=e:f.length=0;c--){let f=t.marks[c],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=tN);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],c;if(t>0&&(c=l.lastChild)&&c instanceof ti&&c.mark.eq(a))l=c,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||!mS(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Se.ios&&mS(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Qg,0,32)||new Ps(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 Gj(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 Kj{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 c=this.textOff=Math.min(e,l.length);return o?null:l.slice(0,c)}let t=Math.min(this.text.length,this.textOff+e),i=this.text.slice(this.textOff,t);return this.textOff=t,i}}const ed=[Ps,ua,Ms,ti,Jh,Gr,zd];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 c=0;c{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 c=al){let d=f-l;this.preserve(d,!a,!c),l=f,o+=d}if(!c)break;t&&c.fromA<=t.range.fromA&&c.toA>=t.range.toA?(this.forward(c.fromA,t.range.fromA,t.range.fromA{if(a.isWidget())if(this.openWidget)this.builder.continueWidget(f-c);else{let d=f>0||c{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:(c,f,d,m,g,b)=>{if(d instanceof Bs){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(c).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-c);else{let v=d.widget||(d.block?fa.block:fa.inline),w=Jj(d),S=this.cache.findWidget(v,f-c,w)||Ps.of(v,this.view,f-c,w);d.block?(d.startSide>0&&l.addLineStartIfNotCovered(i),l.addBlockWidget(S)):(l.ensureLine(i),l.addInlineWidget(S,m,g))}i=null}else i=eR(i,d);f>c&&this.text.skip(f-c)},span:(c,f,d,m)=>{for(let g=c;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,tN):i||t.push(ti.of(new su({tagName:l.nodeName.toLowerCase(),attributes:Tj(l)}),l)))}return i?{line:i,marks:t}:null}}function mS(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 Jj(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 tN={class:"cm-line"};function eR(n,e){let t=e.spec.attributes,i=e.spec.class;return!t&&!i||(n||(n={class:"cm-line"}),t&&fy(t,n),i&&(n.class+=" "+i)),n}function tR(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 pS{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 zd(e,e.contentDOM),this.updateInner([new ji(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:!uR(e.changes,this.hasComposition)&&!e.selectionSet&&(l=e.state.selection.main.head));let o=l>-1?iR(this.view,e.changes,l):null;if(this.domChanged=null,this.hasComposition){let{from:m,to:g}=this.hasComposition;i=new ji(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,c=this.blockWrappers;this.updateDeco();let f=sR(a,this.decorations,e.changes);f.length&&(i=ji.extendWithRanges(i,f));let d=aR(c,this.blockWrappers,e.changes);return d.length&&(i=ji.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,c=new Zj(this.view,a,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&It.get(t.text)&&c.cache.reused.set(It.get(t.text),2),this.tile=c.run(e,t),a0(a,c.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)&&jc(i,this.view.observer.selectionRange)&&!(l&&i.contains(l));if(!(o||t||a))return;let c=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&&nR(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),c=!0}let g=this.view.observer.selectionRange;(c||!g.focusNode||(!Rc(d.node,d.offset,g.anchorNode,g.anchorOffset)||!Rc(m.node,m.offset,g.focusNode,g.focusOffset))&&!this.suppressWidgetCursorChange(g,f))&&(this.view.observer.ignore(()=>{Se.android&&Se.chrome&&i.contains(g.focusNode)&&cR(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=rR(d.node,d.offset);if(v&&v!=3){let w=(v==1?RO:_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&&Rc(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 c=a.posAtStart;if(t.head==c||t.head==c+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 c=e.parentNode;if(c==i.dom)break;a==0&&c.firstChild!=c.lastChild&&(e==c.firstChild?a=-1:a=1),e=c}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,c=l;;a++){let f=i.children[a];if(f.dom==o)return c;c+=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,c=-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,c=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(c,t))}coordsAt(e,t,i){let{tile:l,offset:o}=this.tile.resolveBlock(e,t);return l.isWidget()?l.widget instanceof Xg?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 c of o.children){if(c.length>=a){let f=l(c,a);if(f)return f}if(a-=c.length,a<0)break}else if(o.isText()&&aMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,c=-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,P=M?Lh(M):[];if(P.length){let L=P[P.length-1],D=f?L.right-O.left:O.right-L.left;D>c&&(c=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 c=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;c+=m[0].width,f=m[0].height}if(c)return{lineHeight:a.dom.getBoundingClientRect().height,charWidth:c/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 c=(t.lineBlockAt(a).bottom-t.lineBlockAt(i).top)/this.view.scaleY;e.push(Ue.replace({widget:new Xg(c),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(_d).map(o=>(this.dynamicDecorationMap[e++]=typeof o=="function")?o(this.view):o),i=!1,l=this.view.state.facet(xy).map((o,a)=>{let c=typeof o=="function";return c&&(i=!0),c?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=yy(this.view),a={left:i.left-o.left,top:i.top-o.top,right:i.right+o.right,bottom:i.bottom+o.bottom},{offsetWidth:c,offsetHeight:f}=this.view.scrollDOM;if(Mj(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(){a0(this.tile)}}function a0(n,e){let t=e==null?void 0:e.get(n);if(t!=1){t==null&&n.destroy();for(let i of n.children)a0(i,e)}}function nR(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 nN(n,e){let t=n.observer.selectionRange;if(!t.focusNode)return null;let i=RO(t.focusNode,t.focusOffset),l=_O(t.focusNode,t.focusOffset),o=i||l;if(l&&i&&l.node!=i.node){let c=It.get(l.node);if(!c||c.isText()&&c.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 iR(n,e,t){let i=nN(n,t);if(!i)return null;let{node:l,from:o,to:a}=i,c=l.nodeValue;if(/[\n\r]/.test(c)||n.state.doc.sliceString(i.from,i.to)!=c)return null;let f=e.invertedDesc;return{range:new ji(f.mapPos(o),f.mapPos(a),o,a),text:l}}function rR(n,e){return dn(n)?(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e{ie.from&&(t=!0)}),t}class Xg 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 fR(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,c=o;t<0?a=hn(l.text,o,!1):c=hn(l.text,o);let f=i(l.text.slice(a,c));for(;a>0;){let d=hn(l.text,a,!1);if(i(l.text.slice(d,a))!=f)break;a=d}for(;cn.defaultLineHeight*1.5){let c=n.viewState.heightOracle.textHeight,f=Math.floor((l-t.top-(n.defaultLineHeight-c)*.5)/c);o+=f*n.viewState.heightOracle.lineLength}let a=n.state.sliceDoc(t.from,t.to);return t.from+Kx(a,o,n.state.tabSize)}function c0(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==Nn.Text&&(l.type!=o.type||(t<0?o.frome)))&&(l=o)}}return l||i}return i}function dR(n,e,t,i){let l=c0(n,e.head,e.assoc||-1),o=!i||l.type!=Nn.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(),c=n.textDirectionAt(l.from),f=n.posAndSideAtCoords({x:t==(c==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 gS(n,e,t,i){let l=n.state.doc.lineAt(e.head),o=n.bidiSpans(l),a=n.textDirectionAt(l.from);for(let c=e,f=null;;){let d=Uj(l,o,a,c,t),m=HO;if(!d){if(l.number==(t?n.state.doc.lines:1))return c;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 c}else{if(!i)return d;f=i(m)}c=d}}function mR(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 pR(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,c,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),c=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))),c=(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=c+(v+w)*o,C=u0(n,{x:g,y:S},!1,o);if(t?S>f.bottom:Sc:_{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==Nn.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==Nn.Text){let g=hR(n,l,d,a,c);return new br(g,g==d.from?1:-1)}}if(d.type!=Nn.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 gR(n,a,c,n.textDirectionAt(d.from)).scanTile(m,d.from)}class gR{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 P=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=(c?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,c=i[o+1]-t;return $c(e.dom,a,c).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 c=e.children[0];if(c.isText())return this.scanText(c,t);if(c.isComposite())return this.scanTile(c,t)}let i=[t];for(let c=0,f=t;c{let f=e.children[c];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 Ho="￿";class xR{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+=Ho}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),c=l.nextSibling;if(c==t){a!=null&&a.breakAfter&&!c&&i!=this.view.contentDOM&&this.lineBreak();break}let f=It.get(c);(a&&f?a.breakAfter:(a?a.breakAfter:Kh(l))||Kh(c)&&(l.nodeName!="BR"||a!=null&&a.isWidget())&&this.text.length>o)&&!bR(c,t)&&this.lineBreak(),l=c}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,c;if(this.lineSeparator?(o=t.indexOf(this.lineSeparator,i),a=this.lineSeparator.length):(c=l.exec(t))&&(o=c.index,a=c[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+(yR(e,i.node,i.offset)?t:0))}}function yR(n,e,t){for(;;){if(!e||t-1;let{impreciseHead:o,impreciseAnchor:a}=e.docView,c=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=rN(e.docView.tile,t,i,0))){let f=o||a?[]:kR(e),d=new xR(f,e);d.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=d.text,this.newSel=SR(f,this.bounds.from)}else{let f=e.observer.selectionRange,d=o&&o.node==f.focusNode&&o.offset==f.focusOffset||!i0(e.contentDOM,f.focusNode)?c.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),m=a&&a.node==f.anchorNode&&a.offset==f.anchorOffset||!i0(e.contentDOM,f.anchorNode)?c.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),g=e.viewport;if((Se.ios||Se.chrome)&&d!=m&&Math.min(d,m)<=c.main.from&&Math.max(d,m)>=c.main.to&&(g.from>0||g.to-1&&c.ranges.length>1)this.newSel=c.replaceRange(re.range(m,d));else if(e.lineWrapping&&m==d&&!(c.main.empty&&c.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 rN(n,e,t,i){if(n.isComposite()){let l=-1,o=-1,a=-1,c=-1;for(let f=0,d=i,m=i;ft)return rN(g,e,t,d);if(b>=e&&l==-1&&(l=f,o=d),d>t&&g.dom.parentNode==n.dom){a=f,c=m;break}m=b,d=b+g.breakAfter}return{from:o,to:c<0?i+n.length:c,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 lN(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:c,to:f}=e.bounds,d=o.from,m=null;(a===8||Se.android&&e.text.length=c&&o.to<=f&&(e.typeOver||g!=e.text)&&g.slice(0,o.from-c)==e.text.slice(0,o.from-c)&&g.slice(o.to-c)==e.text.slice(b=e.text.length-(g.length-(o.to-c)))?t={from:o.from,to:o.to,insert:ot.of(e.text.slice(o.from-c,b).split(Ho))}:(v=sN(g,e.text,d-c,m))&&(Se.chrome&&a==13&&v.toB==v.from+2&&e.text.slice(v.from,v.toB)==Ho+Ho&&v.toB--,t={from:c+v.from,to:c+v.toA,insert:ot.of(e.text.slice(v.from,v.toB).split(Ho))})}else i&&(!n.hasFocus&&l.facet($r)||f0(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 by(n,t,i,a);if(i&&!f0(i,o)){let c=!1,f="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(c=!0),f=n.inputState.lastSelectionOrigin,f=="select.pointer"&&(i=iN(l.facet(au).map(d=>d(n)),i))),n.dispatch({selection:i,scrollIntoView:c,userEvent:f}),!0}else return!1}function by(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,c=()=>a||(a=wR(n,e,t));return n.state.facet(VO).some(f=>f(n,e.from,e.to,o,c))||n.dispatch(c()),!0}function wR(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&&nN(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 c="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,c+=".compose",n.inputState.compositionFirstChange&&(c+=".start",n.inputState.compositionFirstChange=!1)),l.update(i,{userEvent:c,scrollIntoView:!0})}function sN(n,e,t,i){let l=Math.min(n.length,e.length),o=0;for(;o0&&c>0&&n.charCodeAt(a-1)==e.charCodeAt(c-1);)a--,c--;if(i=="end"){let f=Math.max(0,o-Math.min(a,c));t-=a+f-o}if(a=a?o-t:0;o-=f,c=o+(c-a),a=o}else if(c=c?o-t:0;o-=f,a=o+(a-c),c=o}return{from:o,toA:a,toB:c}}function kR(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 xS(t,i)),(l!=t||o!=i)&&e.push(new xS(l,o))),e}function SR(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 f0(n,e){return e.head==n.main.head&&e.anchor==n.main.anchor}class CR{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&&IR(e.contentDOM.ownerDocument)}handleEvent(e){!RR(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=NR(e),i=this.handlers,l=this.view.contentDOM;for(let o in t)if(o!="scroll"){let a=!t[o].handlers.length,c=i[o];c&&a!=!c.handlers.length&&(l.removeEventListener(o,this.handleEvent),c=null),c||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&&aN.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&&(oN.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||TR.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)&&OR(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 OR(n){return n.visualViewport?n.visualViewport.height*n.visualViewport.scale/n.document.documentElement.clientHeight<.85:!1}function yS(n,e){return(t,i)=>{try{return e.call(n,i,t)}catch(l){ni(t.state,l)}}}function NR(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 c in o){let f=o[c];f&&t(c).handlers.push(yS(i.value,f))}if(a)for(let c in a){let f=a[c];f&&t(c).observers.push(yS(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 oN=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],TR="dthko",aN=[16,17,18,20,91,92,224,225],ih=6;function rh(n){return Math.max(0,n)*.7+8}function AR(n,e){return Math.max(Math.abs(n.clientX-e.clientX),Math.abs(n.clientY-e.clientY))}class ER{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)&&MR(e,t),this.dragging=jR(e,t)&&fN(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&&AR(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,i=0,l=0,o=0,a=this.view.win.innerWidth,c=this.view.win.innerHeight;this.scrollParents.x&&({left:l,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:o,bottom:c}=this.scrollParents.y.getBoundingClientRect());let f=yy(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>=c-ih&&(i=rh(e.clientY-c)),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=iN(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 MR(n,e){let t=n.state.facet(IO);return t.length?t[0](e):Se.mac?e.metaKey:e.ctrlKey}function DR(n,e){let t=n.state.facet(UO);return t.length?t[0](e):Se.mac?!e.altKey:!e.ctrlKey}function jR(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 RR(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),cN=Se.ie&&Se.ie_version<15||Se.ios&&Se.webkit_version<604;function _R(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(),uN(n,t.value)},50)}function Bd(n,e,t){for(let i of n.facet(e))t=i(t,n);return t}function uN(n,e){e=Bd(n.state,my,e);let{state:t}=n,i,l=1,o=t.toText(e),a=o.lines==t.selection.ranges.length;if(h0!=null&&t.selection.ranges.every(f=>f.empty)&&h0==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=zR(n,e)),t){let i=!n.hasFocus;n.inputState.startMouseSelection(new ER(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 bS(n,e,t,i){if(i==1)return re.cursor(e,t);if(i==2)return fR(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,c=l?l.posAtEnd:o.to;return cDate.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(wS+1)%3:1}function zR(n,e){let t=n.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),i=fN(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,c){let f=n.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),d,m=bS(n,f.pos,f.assoc,i);if(t.pos!=f.pos&&!a){let g=bS(n,t.pos,t.assoc,i),b=Math.min(g.from,m.from),v=Math.max(g.to,m.to);m=b1&&(d=BR(l,f.pos))?d:c?l.addRange(m):re.create([m])}}}function BR(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",Bd(n.state,py,n.state.sliceDoc(t.from,t.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Wi.dragend=n=>(n.inputState.draggedContent=null,!1);function SS(n,e,t,i){if(t=Bd(n.state,my,t),!t)return;let l=n.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:o}=n.inputState,a=i&&o&&DR(n,e)?{from:o.from,to:o.to}:null,c={from:l,insert:t},f=n.state.changes(a?[a,c]:c);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&&SS(n,e,i.filter(a=>a!=null).join(n.state.lineBreak),!1)};for(let a=0;a{/[\x00-\x08\x0e-\x1f]{2}/.test(c.result)||(i[a]=c.result),o()},c.readAsText(t[a])}return!0}else{let i=e.dataTransfer.getData("Text");if(i)return SS(n,e,i,!0),!0}return!1};Wi.paste=(n,e)=>{if(n.state.readOnly)return!0;n.observer.flush();let t=cN?null:e.clipboardData;return t?(uN(n,t.getData("text/plain")||t.getData("text/uri-list")),!0):(_R(n),!1)};function PR(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 HR(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:Bd(n,py,e.join(n.lineBreak)),ranges:t,linewise:i}}let h0=null;Wi.copy=Wi.cut=(n,e)=>{if(!jc(n.contentDOM,n.observer.selectionRange))return!1;let{text:t,ranges:i,linewise:l}=HR(n.state);if(!t&&!l)return!1;h0=l?t:null,e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let o=cN?null:e.clipboardData;return o?(o.clearData(),o.setData("text/plain",t),!0):(PR(n,t),!1)};const hN=Jr.define();function dN(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:hN.of(!0)}):null}function mN(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=dN(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),mN(n)};Qn.blur=n=>{n.observer.clearSelectionRange(),mN(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 c=a[0],f=n.posAtDOM(c.startContainer,c.startOffset),d=n.posAtDOM(c.endContainer,c.endOffset);return by(n,{from:f,to:d,insert:n.state.toText(o)},null),!0}}let l;if(Se.chrome&&Se.android&&(l=oN.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 CS=new Set;function IR(n){CS.has(n)||(CS.add(n),n.addEventListener("copy",()=>{}),n.addEventListener("cut",()=>{}))}const OS=["pre-wrap","normal","pre-line","break-spaces"];let ha=!1;function NS(){ha=!1}class UR{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 OS.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!=c;if(this.lineWrapping=c,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 c=l.length-1;c>=0;c--){let{fromA:f,toA:d,fromB:m,toB:g}=l[c],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;c>0&&b.from<=l[c-1].toA;)f=l[c-1].fromA,m=l[c-1].fromB,c--,fo*2){let c=e[t-1];c.break?e.splice(--t,1,c.left,null,c.right):e.splice(--t,1,c.left,c.right),i+=1+c.break,l-=c.size}else if(o>l*2){let c=e[i];c.break?e.splice(i,1,c.left,null,c.right):e.splice(i,1,c.left,c.right),i+=2+c.break,o-=c.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 yi extends pN{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 yi||l instanceof kn&&l.flags&4)&&Math.abs(this.length-l.length)<10?(l instanceof kn?l=new yi(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,c=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*o);a=f/o,this.length>o+1&&(c=(this.height-f)/(this.length-o-1))}else a=this.height/o;return{firstLine:i,lastLine:l,perLine:a,perChar:c}}blockAt(e,t,i,l){let{firstLine:o,lastLine:a,perLine:c,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=[],c=Math.max(t,l.from),f=-1;for(l.from>t&&a.push(new kn(l.from-t-1).updateHeight(e,t));c<=o&&l.more;){let m=e.doc.lineAt(c).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 yi(m,g,b);v.outdated=!1,a.push(v),c+=m+1}c<=o&&a.push(null,new kn(o-c).updateHeight(e,c));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 VR 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 ec))return d;let m=t==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?d.join(this.right.lineAt(c,m,i,a,c)):this.left.lineAt(c,m,i,l,o).join(d)}forEachLine(e,t,i,l,o,a){let c=l+this.left.height,f=o+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,t,i,c,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,c,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 c of i)o.push(c);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,c=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<=c+a.length&&l.more?f=a=a.updateHeight(e,c,i,l):a.updateHeight(e,c,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 QR=5;class vy{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 yi?l.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new yi(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=QR)&&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 yi(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 yi)return e;let t=new yi(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 yi)&&!this.isCovered?this.nodes.push(new yi(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),c=Math.max(c,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:c-(t.top+e),bottom:Math.max(c,f)-(t.top+e)}}function YR(n){let e=n.getBoundingClientRect(),t=n.ownerDocument.defaultView||window;return e.left0&&e.top0}function KR(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class Gg{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 UR(i),this.stateDeco=ES(t),this.heightMap=Vn.empty().applyChanges(this.stateDeco,ot.empty,this.heightOracle.setDoc(t.doc),[new ji(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?d0: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(Tc(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=ES(this.state);let l=e.changedRanges,o=ji.extendWithRanges(l,XR(i,this.stateDeco,e?e.changes:ln.empty(this.state.doc.length))),a=this.heightMap.height,c=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);NS(),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),c?(this.scrollAnchorPos=e.changes.mapPos(c.from,-1),this.scrollAnchorHeight=c.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",c=t.getBoundingClientRect(),f=a||this.mustMeasureContent||this.contentDOMHeight!=c.height;this.contentDOMHeight=c.height,this.mustMeasureContent=!1;let d=0,m=0;if(c.width&&c.height){let{scaleX:L,scaleY:D}=TO(t,c);(L>.005&&Math.abs(this.scaleX-L)>.005||D>.005&&Math.abs(this.scaleY-D)>.005)&&(this.scaleX=L,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=jO(this.scrollParent||e.win);let S=(this.printing?KR:GR)(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&&!YR(e.dom))return 0;let M=c.width;if((this.contentDOMWidth!=M||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=c.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),f){let L=e.docView.measureVisibleLineHeights(this.viewport);if(l.mustRefreshForHeights(L)&&(a=!0),a||l.lineWrapping&&Math.abs(M-this.contentDOMWidth)>l.charWidth){let{lineHeight:D,charWidth:j,textHeight:H}=e.docView.measureTextSize();a=D>0&&l.refresh(o,D,j,H,Math.max(5,M/j),L),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)),NS();for(let D of this.viewports){let j=D.from==this.viewport.from?L:e.docView.measureVisibleLineHeights(D);this.heightMap=(a?Vn.empty().applyChanges(this.stateDeco,ot.empty,this.heightOracle,[new ji(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(l,0,a,new FR(D.from,j))}ha&&(d|=2)}let P=!this.viewportIsAppropriate(this.viewport,m)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return P&&(d&2&&(d|=this.updateScaler()),this.viewport=this.getViewport(m,this.scrollTarget),d|=this.updateForViewport()),(d&2||P)&&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:c}=this,f=new lh(l.lineAt(a-i*1e3,Mt.ByHeight,o,0,0).from,l.lineAt(c+(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=c+Math.max(10,Math.min(i,250)))&&l>a-2*1e3&&o>1,a=l<<1;if(this.defaultTextDirection!=kt.LTR&&!i)return[];let c=[],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 Gg(m,g,O,_)}c.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)||Tc(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)||Tc(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 Tc(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 ZR(n,e,t){let i=[],l=n,o=0;return it.spans(t,n,e,{span(){},point(a,c){a>l&&(i.push({from:l,to:a}),o+=a-l),l=c}},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],c=a-o;if(i<=c)return o+i;i-=c}}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 JR(n,e){for(let t of n)if(e(t))return t}const d0={toDOM(n){return n},fromDOM(n){return n},scale:1,eq(n){return n==this}};function ES(n){let e=n.facet(_d).filter(i=>typeof i!="function"),t=n.facet(xy).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,c=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 d0;let f=(7e6-l)/(t.height-l);for(let d of c)d.domTop=a+(d.top-o)*f,a=d.domBottom=d.domTop+(d.bottom-d.top),o=d.bottom;return new nd(f,c)}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 Tc(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=>Tc(l,e)):n._content)}const ah=Te.define({combine:n=>n.join(" ")}),m0=Te.define({combine:n=>n.indexOf(!0)>-1}),p0=Vl.newName(),gN=Vl.newName(),xN=Vl.newName(),yN={"&light":"."+gN,"&dark":"."+xN};function g0(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 e_=g0("."+p0,{"&":{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"}},yN),t_={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Yg=Se.ie&&Se.ie_version<=11;class n_{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Dj,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 r_(e),e.state.facet($r)&&(e.contentDOM.editContext=this.editContext.editContext)),Yg&&(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:!jc(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&&Rc(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&&i_(this.view,t)||t;if(!i||this.selectionRange.eq(i))return!1;let l=jc(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&&jc(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 vR(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=lN(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=MS(t,e.previousSibling||e.target.previousSibling,-1),l=MS(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 MS(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 DS(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 Rc(a.node,a.offset,l,o)&&([t,i,l,o]=[l,o,t,i]),{anchorNode:t,anchorOffset:i,focusNode:l,focusOffset:o}}function i_(n,e){if(e.getComposedRanges){let l=e.getComposedRanges(n.root)[0];if(l)return DS(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?DS(n,t):null}class r_{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,c=this.toEditorPos(i.updateRangeStart),f=this.toEditorPos(i.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:i.updateRangeStart,editorBase:c,drifted:!1});let d=f-c>i.text.length;c==this.from&&othis.to&&(f=o);let m=sN(e.state.sliceDoc(c,f),i.text,(d?l.from:l.to)-c,d?"end":null);if(!m){let b=re.single(this.toEditorPos(i.selectionStart),this.toEditorPos(i.selectionEnd));f0(b,l)||e.dispatch({selection:b,userEvent:"select"});return}let g={from:m.from+c,to:m.toA+c,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:c,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);by(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),c=this.toEditorPos(i.rangeEnd);a{let l=[];for(let o of i.getTextFormats()){let a=o.underlineStyle,c=o.underlineThickness;if(!/none/i.test(a)&&!/none/i.test(c)){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,c,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||jj(e.parent)||document,this.viewState=new AS(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($o).map(l=>new qg(l));for(let l of this.plugins)l.update(this);this.observer=new n_(this),this.inputState=new CR(this),this.inputState.ensureHandlers(this.plugins),this.docView=new pS(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,c=0,f=null;e.some(b=>b.annotation(hN))?(this.inputState.notifiedFocused=a,c=1):a!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=a,f=dN(o,a),f||(c=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|=c;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(Nc)!=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(o0))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&&!lN(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 AS(this,e),this.plugins=e.facet($o).map(i=>new qg(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new pS(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($o),i=e.state.facet($o);if(t!=i){let l=[];for(let o of i){let a=t.indexOf(o);if(a<0)l.push(new qg(o));else{let c=this.plugins[a];c.mustUpdate=e,l.push(c)}}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:c}=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(jO(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}c=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),jS}}),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(o0))f(t)}get themeClasses(){return p0+" "+(this.state.facet(m0)?xN:gN)+" "+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,gy,t);let i=this.observer.ignore(()=>{let l=cS(this.contentDOM,this.contentAttrs,t),o=cS(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(Nc);let e=this.state.facet(Ae.cspNonce);Vl.mount(this.root,this.styleModules.concat(e_).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 $g(this,e,gS(this,e,t,i))}moveByGroup(e,t){return $g(this,e,gS(this,e,t,i=>mR(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 dR(this,e,t,i)}moveVertically(e,t,i){return $g(this,e,pR(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=u0(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),u0(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>l_)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=hS(this,e))))return o.order;i||(i=hS(this,e));let l=Ij(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),Nc.of(g0(`.${i}`,e))];return t&&t.dark&&l.push(m0.of(!0)),l}static baseTheme(e){return Us.lowest(Nc.of(g0("."+p0,e,yN)))}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=Nc;Ae.inputHandler=VO;Ae.clipboardInputFilter=my;Ae.clipboardOutputFilter=py;Ae.scrollHandler=GO;Ae.focusChangeEffect=QO;Ae.perLineTextDirection=XO;Ae.exceptionSink=qO;Ae.updateListener=o0;Ae.editable=$r;Ae.mouseSelectionStyle=FO;Ae.dragMovesSelection=UO;Ae.clickAddsSelectionRange=IO;Ae.decorations=_d;Ae.blockWrappers=WO;Ae.outerDecorations=xy;Ae.atomicRanges=au;Ae.bidiIsolatedRanges=ZO;Ae.cursorScrollMargin=Te.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=eN;Ae.darkTheme=m0;Ae.cspNonce=Te.define({combine:n=>n.length?n[0]:""});Ae.contentAttributes=gy;Ae.editorAttributes=KO;Ae.lineWrapping=Ae.contentAttributes.of({class:"cm-lineWrapping"});Ae.announce=Ke.define();const l_=4096,jS={};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&&fy(a,t)}return t}const s_=Se.mac?"mac":Se.windows?"win":Se.linux?"linux":"key";function o_(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let l,o,a,c;for(let f=0;fi.concat(l),[]))),t}function c_(n,e,t){return vN(bN(n.state),e,n,t)}let zl=null;const u_=4e3;function f_(n,e=s_){let t=Object.create(null),i=Object.create(null),l=(a,c)=>{let f=i[a];if(f==null)i[a]=c;else if(f!=c)throw new Error("Key binding "+a+" is used both as a regular binding and as a multi-stroke prefix")},o=(a,c,f,d,m)=>{var g,b;let v=t[a]||(t[a]=Object.create(null)),w=c.split(/ (?!$)/).map(O=>o_(O,e));for(let O=1;O{let P=zl={view:M,prefix:_,scope:a};return setTimeout(()=>{zl==P&&(zl=null)},u_),!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 c=a.scope?a.scope.split(" "):["editor"];if(a.any)for(let d of c){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,x0))}let f=a[e]||a.key;if(f)for(let d of c)o(d,f,a.run,a.preventDefault,a.stopPropagation),a.shift&&o(d,"Shift-"+f,a.shift,a.preventDefault,a.stopPropagation)}return t}let x0=null;function vN(n,e,t,i){x0=e;let l=Oj(e),o=Jn(l,0),a=yr(o)==l.length&&l!=" ",c="",f=!1,d=!1,m=!1;zl&&zl.view==t&&zl.scope==i&&(c=zl.prefix+" ",aN.indexOf(e.keyCode)<0&&(d=!0,zl=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[c+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[c+ch(w,e,!0)])||e.shiftKey&&(S=Vc[e.keyCode])!=l&&S!=w&&b(v[c+ch(S,e,!1)]))&&(f=!0):a&&e.shiftKey&&b(v[c+ch(l,e,!0)])&&(f=!0),!f&&b(v._any)&&(f=!0)),d&&(f=!0),f&&m&&e.stopPropagation(),x0=null,f}class Rs{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=wN(e);return[new Rs(t,l.left-o.left,l.top-o.top,null,l.bottom-l.top)]}else return h_(e,t,i)}}function wN(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 LS(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,c=n.posAtCoords({x:o.left+1,y:a}),f=n.posAtCoords({x:o.right-1,y:a});return c==null||f==null?i:{from:Math.max(i.from,Math.min(c,f)),to:Math.min(i.to,Math.max(c,f))}}function h_(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,c=a.getBoundingClientRect(),f=wN(n),d=a.querySelector(".cm-line"),m=d&&window.getComputedStyle(d),g=c.left+(m?parseInt(m.paddingLeft)+Math.min(0,parseInt(m.textIndent)):0),b=c.right-(m?parseInt(m.paddingRight):0),v=c0(n,i,1),w=c0(n,l,-1),S=v.type==Nn.Text?v:null,C=w.type==Nn.Text?w:null;if(S&&(n.lineWrapping||v.widgetLineBreaks)&&(S=LS(n,i,1,S)),C&&(n.lineWrapping||w.widgetLineBreaks)&&(C=LS(n,l,-1,C)),S&&C&&S.from==C.from&&S.to==C.to)return _(M(t.from,t.to,S));{let L=S?M(t.from,null,S):P(v,!1),D=C?M(null,t.to,C):P(w,!0),j=[];return(S||v).to<(C||w).from-(S&&C?1:0)||v.widgetLineBreaks>1&&L.bottom+n.defaultLineHeight/2A&&ae.from=$)break;T>ie&&F(Math.max(Y,ie),L==null&&Y<=A,Math.min(T,$),D==null&&T>=ne,J.dir)}if(ie=oe.to+1,ie>=$)break}return I.length==0&&F(A,L==null,ne,D==null,n.textDirection),{top:H,bottom:Z,horizontal:I}}function P(L,D){let j=c.top+(D?L.top:L.bottom);return{top:j,bottom:j,horizontal:[]}}}function d_(n,e){return n.constructor==e.constructor&&n.eq(e)}class m_{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!d_(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=Te.define();function kN(n){return[Qt.define(e=>new m_(e,n)),Bh.of(n)]}const y0=!Se.ios,da=Te.define({combine(n){return Tr(n,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function p_(n={}){return[da.of(n),g_,x_,b_,$O.of(!0)]}function SN(n){return n.startState.facet(da)!=n.state.facet(da)}const g_=kN({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",c=l.empty?l:re.cursor(l.head,l.assoc);for(let f of Rs.forRange(n,a,c))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=SN(n);return t&&zS(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){zS(e.state,n)},class:"cm-cursorLayer"});function zS(n,e){e.style.animationDuration=n.facet(da).cursorBlinkRate+"ms"}const x_=kN({above:!1,markers(n){let e=[],{main:t,ranges:i}=n.state.selection;for(let l of i)if(!l.empty&&(y0||l!=t))for(let o of Rs.forRange(n,"cm-selectionBackground",l))e.push(o);if(Se.ios&&!t.empty&&n.state.facet(da).iosSelectionHandles){for(let l of Rs.forRange(n,"cm-selectionHandle cm-selectionHandle-start",re.cursor(t.from,1)))e.push(l);for(let l of Rs.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||SN(n)},class:"cm-selectionLayer"}),y_=Se.gecko&&Se.gecko_version==153?"#ffffff01":"transparent",b_=Us.highest(Ae.theme({".cm-line":{...y0?{"& ::selection, &::selection":{backgroundColor:`${y_} !important`}}:{},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important",...y0?{"&::selection, & ::selection":{backgroundColor:"Highlight !important"}}:{}}}})),CN=Ke.define({map(n,e){return n==null?null:e.mapPos(n)}}),Ac=jn.define({create(){return null},update(n,e){return n!=null&&(n=e.changes.mapPos(n)),e.effects.reduce((t,i)=>i.is(CN)?i.value:t,n)}}),v_=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:CN.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 w_(){return[Ac,v_]}function BS(n,e,t,i,l){e.lastIndex=0;for(let o=n.iterRange(t,i),a=t,c;!o.next().done;a+=o.value.length)if(!o.lineBreak)for(;c=e.exec(o.value);)l(a+c.index,c)}function k_(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 S_{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=(c,f,d,m)=>l(m,d,d+c[0].length,c,f);else if(typeof i=="function")this.addMatch=(c,f,d,m)=>{let g=i(c,f,d);g&&m(d,d+c[0].length,g)};else if(i)this.addMatch=(c,f,d,m)=>m(d,d+c[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 k_(e,this.maxLength))BS(e.state.doc,this.regexp,l,o,(a,c)=>this.addMatch(c,e,a,i));return t.finish()}updateDeco(e,t){let i=1e9,l=-1;return e.docChanged&&e.changes.iterChanges((o,a,c,f)=>{f>=e.view.viewport.from&&c<=e.view.viewport.to&&(i=Math.min(c,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),c=Math.min(o.to,l);if(c>=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(;cb.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 b0=/x/.unicode!=null?"gu":"g",C_=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,b0),O_={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 Kg=null;function N_(){var n;if(Kg==null&&typeof document<"u"&&document.body){let e=document.body.style;Kg=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Kg||!1}const Ph=Te.define({combine(n){let e=Tr(n,{render:null,specialChars:C_,addSpecialChars:null});return(e.replaceTabs=!N_())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,b0)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,b0)),e}});function T_(n={}){return[Ph.of(n),A_()]}let PS=null;function A_(){return PS||(PS=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 S_({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),c=t.state.tabSize,f=xa(a.text,c,i-a.from);return Ue.replace({widget:new j_((c-f%c)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Ue.replace({widget:new D_(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 E_="•";function M_(n){return n>=32?E_:n==10?"␤":String.fromCharCode(9216+n)}class D_ extends el{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=M_(this.code),i=e.state.phrase("Control character")+" "+(O_[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 j_ 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 R_(){return L_}const __=Ue.line({class:"cm-activeLine"}),L_=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(__.range(l.from)),e=l.from)}return Ue.set(t)}},{decorations:n=>n.decorations}),v0=2e3;function z_(n,e,t){let i=Math.min(e.line,t.line),l=Math.max(e.line,t.line),o=[];if(e.off>v0||t.off>v0||e.col<0||t.col<0){let a=Math.min(e.off,t.off),c=Math.max(e.off,t.off);for(let f=i;f<=l;f++){let d=n.doc.line(f);d.length<=c&&o.push(re.range(d.from+a,d.to+c))}}else{let a=Math.min(e.col,t.col),c=Math.max(e.col,t.col);for(let f=i;f<=l;f++){let d=n.doc.line(f),m=Kx(d.text,a,n.tabSize,!0);if(m<0)o.push(re.cursor(d.to));else{let g=Kx(d.text,c,n.tabSize);o.push(re.range(d.from+m,d.from+g))}}}return o}function B_(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function HS(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>v0?-1:l==i.length?B_(n,e.clientX):xa(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:o,off:l}}function P_(n,e){let t=HS(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 c=HS(n,l);if(!c)return i;let f=z_(n.state,t,c);return f.length?a?re.create(f.concat(i.ranges)):re.create(f):i}}:null}function H_(n){let e=(t=>t.altKey&&t.button==0);return Ae.mouseSelectionStyle.of((t,i)=>e(i)?P_(t,i):null)}const I_={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},U_={style:"cursor: crosshair"};function F_(n={}){let[e,t]=I_[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?U_:null})]}const uh="-10000px";class ON{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=[],c=t?[]:null;for(let f=0;ft[d]=f),t.length=c.length),this.input=l,this.tooltips=o,this.tooltipViews=a,!0}}function NN(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 q_(n){let{left:e,right:t}=NN(n);return{top:0,left:e,right:t,bottom:n.dom.ownerDocument.documentElement.clientHeight}}const Wg=Te.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)||q_}}}),IS=new WeakMap,ky=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(Wg);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 ON(n,Sy,(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(Wg);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 c=a.getBoundingClientRect();t=Math.abs(c.top+1e4)>1||Math.abs(c.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=NN(this.view).left;let l=this.view.scrollDOM.getBoundingClientRect(),o=yy(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,c)=>{let f=this.manager.tooltipViews[c];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(Wg).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 c of this.manager.tooltipViews)c.dom.style.position="absolute"}let{visible:t,space:i,scaleX:l,scaleY:o}=n,a=[];for(let c=0;c=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=IS.get(d))!==null&&e!==void 0?e:b.bottom-b.top,O=d.offset||Q_,_=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),P=this.above[c];!f.strictSide&&(P?g.top-C-w-O.yi.bottom)&&P==i.bottom-g.bottom>g.top-i.top&&(P=this.above[c]=!P);let L=(P?g.top-i.top:i.bottom-g.bottom)-w;if(LM&&H.topD&&(D=P?H.top-C-2-w:H.bottom+w+2);if(this.position=="absolute"?(m.style.top=(D-n.parent.top)/o+"px",US(m,(M-n.parent.left)/l)):(m.style.top=D/o+"px",US(m,(M-n.fixedLeft)/l)),v){let H=g.left+(_?O.x:-O.x)-(M+14-7);v.style.left=H/l+"px"}d.overlap!==!0&&a.push({left:M,top:D,right:j,bottom:D+C}),m.classList.toggle("cm-tooltip-above",P),m.classList.toggle("cm-tooltip-below",!P),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 US(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}const V_=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"}}}),Q_={x:0,y:0},Sy=Te.define({enables:[ky,V_]}),rd=Te.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])});class Pd{static create(e){return new Pd(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new ON(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 X_=Sy.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:Pd.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),TN=Te.define();class $_{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 c=e.bidiSpans(e.state.doc.lineAt(l)).find(d=>d.from<=l&&d.to>=l),f=c&&c.dir==kt.RTL?-1:1;o=t.x{if(c&&!(Array.isArray(c)&&!c.length)){let f=Array.isArray(c)?c:[c];l&&this.locked.set(f,l),e.dispatch({effects:this.setHover.of(f)})}};if(o&&"then"in o){let c=this.pending={pos:t};o.then(f=>{this.pending==c&&(this.pending=null,a(f))},f=>ni(e.state,f,"hover tooltip"))}else a(o)}get tooltip(){let e=this.view.plugin(ky),t=e?e.manager.tooltips.findIndex(i=>i.create==Pd.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&&!G_(o.dom,e)||this.pending){let{pos:a}=l[0]||this.pending,c=(i=(t=l[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:a;(a==c?this.view.posAtCoords(this.lastMove)!=a:!Y_(this.view,a,c,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 G_(n,e){let{left:t,right:i,top:l,bottom:o}=n.getBoundingClientRect(),a;if(a=n.querySelector(".cm-tooltip-arrow")){let c=a.getBoundingClientRect();l=Math.min(c.top,l),o=Math.max(c.bottom,o)}return e.clientX>=t-fh&&e.clientX<=i+fh&&e.clientY>=l-fh&&e.clientY<=o+fh}function Y_(n,e,t,i,l,o){let a=n.scrollDOM.getBoundingClientRect(),c=n.documentTop+n.documentPadding.top+n.contentHeight;if(a.left>i||a.rightl||Math.min(a.bottom,c)=e&&f<=t}function K_(n,e={}){let t=Ke.define(),i=new WeakMap,l=jn.define({create(){return[]},update(a,c){let f=i.get(a);if(a.length&&(e.hideOnChange&&(c.docChanged||c.selection)?a=[]:f&&f(c)?a=[]:e.hideOn&&(a=a.filter(d=>!e.hideOn(c,d)))),c.docChanged&&a.length){let d=[];for(let m of a){let g=c.changes.mapPos(m.pos,-1,qn.TrackDel);if(g!=null){let b=Object.assign(Object.create(null),m);b.pos=g,b.end!=null&&(b.end=c.changes.mapPos(b.end)),d.push(b)}}a=d}for(let d of c.effects)d.is(t)&&(a=d.value,f=void 0),(d.is(Z_)&&!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 $_(a,n,l,i,t,e.hoverTime||300));return{active:l,extension:[l,o,TN.of(o),X_]}}function W_(n,e,t,i={}){var l;let o=n.state.facet(TN).map(a=>n.plugin(a)).filter(a=>!!a);if(i.tooltip&&i.tooltip.active){let a=o.find(c=>c.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 AN(n,e){let t=n.plugin(ky);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const Z_=Ke.define(),FS=Te.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 Hd(n,e){let t=n.plugin(EN),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const EN=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(FS);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(FS);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=[],c=[];for(let f of i){let d=this.specs.indexOf(f),m;d<0?(m=f(n.view),c.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 c)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=qS(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=qS(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 qS(n){let e=n.nextSibling;return n.remove(),e}const Gc=Te.define({enables:EN});function J_(n,e){let t,i=new Promise(a=>t=a),l=a=>tL(a,e,t);n.state.field(Hh,!1)?n.dispatch({effects:MN.of(l)}):n.dispatch({effects:Ke.appendConfig.of(Hh.init(()=>[l]))});let o=DN.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 eL(n,e){let t=n.state.field(Hh,!1)||[];for(let i of t){let l=Hd(n,i);if(l&&l.dom.classList.contains(e))return l}return null}const Hh=jn.define({create(){return[]},update(n,e){for(let t of e.effects)t.is(MN)?n=[t.value].concat(n):t.is(DN)&&(n=n.filter(i=>i!=t.value));return n},provide:n=>Gc.computeN([n],e=>e.field(n))}),MN=Ke.define(),DN=Ke.define();function tL(n,e,t){let i=e.content?e.content(n,()=>c(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(),c(null)):m.keyCode==13&&(m.preventDefault(),c(d))}),d.addEventListener("submit",m=>{m.preventDefault(),c(d)})}let o=wt("div",i,wt("button",{onclick:()=>c(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 c(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 ql{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=qn.TrackBefore;Wr.prototype.startSide=Wr.prototype.endSide=-1;Wr.prototype.point=!0;const Ih=Te.define(),nL=Te.define(),iL={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>it.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Lc=Te.define();function rL(n){return[jN(),Lc.of({...iL,...n})]}const VS=Te.define({combine:n=>n.some(e=>e)});function jN(n){return[lL]}const lL=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 XS(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 sL(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 c of o.type)if(c.type==Nn.Text&&a){w0(t,i,c.from);for(let f of l)f.line(this.view,c,i);a=!1}else if(c.widget)for(let f of l)f.widget(this.view,c)}else if(o.type==Nn.Text){w0(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 XS(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 w0(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class sL{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 c=new RN(e,a,o,i);l.elements.push(c),l.dom.appendChild(c.dom)}else l.elements[this.i].update(e,a,o,i);this.height=t.bottom,this.i++}line(e,t,i){let l=[];w0(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(nL)){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 XS{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 c=e.lineBlockAtHeight(a-e.documentTop);t.domEventHandlers[i](e,c,l)&&l.preventDefault()});this.markers=QS(t.markers(e)),t.initialSpacer&&(this.spacer=new RN(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 RN{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":""),oL(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 c=a,f=oo(c,f,d)||a(c,f,d):a}return i}})}});class Zg extends Wr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Jg(n,e){return n.state.facet(Go).formatNumber(e,n.state)}const uL=Lc.compute([Go],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(aL)},lineMarker(e,t,i){return i.some(l=>l.toDOM)?null:new Zg(Jg(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,i)=>{for(let l of e.state.facet(cL)){let o=l(e,t,i);if(o)return o}return null},lineMarkerChange:e=>e.startState.facet(Go)!=e.state.facet(Go),initialSpacer(e){return new Zg(Jg(e,$S(e.state.doc.lines)))},updateSpacer(e,t){let i=Jg(t.view,$S(t.view.state.doc.lines));return i==e.number?e:new Zg(i)},domEventHandlers:n.facet(Go).domEventHandlers,side:"before"}));function fL(n={}){return[Go.of(n),jN(),uL]}function $S(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(hL.range(l)))}return it.of(e)});function mL(){return dL}const _N=1024;let pL=0;class ex{constructor(e,t){this.from=e,this.to=t}}class et{constructor(e={}){this.id=pL++,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=li.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 gL=Object.create(null);class li{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):gL,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),l=new li(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}}}}li.none=new li("",Object.create(null),0,8);class Cy{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&&(!c&&f.type.isAnonymous||t(f)!==!1)){if(f.firstChild())continue;d=!0}for(;d&&i&&(c||!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:Ty(li.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(li.none,t,i,l)))}static build(e){return vL(e)}}Jt.empty=new Jt(li.none,[],[],0);class Oy{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 Oy(this.buffer,this.index)}}class $l{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return li.none}toString(){let e=[];for(let t=0;t0));f=a[f+3]);return c}slice(e,t,i){let l=this.buffer,o=new Uint16Array(t-e),a=0;for(let c=e,f=0;c=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?c.length:-1;e!=d;e+=t){let m=c[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)&&!LN(l,i,g,g+m.length))){if(m instanceof $l){if(o&Ht.ExcludeBuffers)continue;let v=m.findChild(0,m.buffer.length,t,i-g,l);if(v>-1)return new Pl(new xL(a,m,e,g),null,v)}else if(o&Ht.IncludeAnonymous||!m.type.isAnonymous||Ny(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:c,to:f}of l.overlay)if((t>0||a?c<=o:c=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 YS(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 k0(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 xL{constructor(e,t,i,l){this.parent=e,this.buffer=t,this.index=i,this.start=l}}class Pl extends zN{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 Pl(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 Pl(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 Pl(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 Pl(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 BN(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;ot.from||a.to=e){let c=new Li(a.tree,a.overlay[0].from+o.from,-1,o);(l||(l=[i])).push(Yc(c,e,t,!1))}}return l?BN(l):i}class S0{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 c=i._tree.children[o];if(this.mode&Ht.IncludeAnonymous||c instanceof $l||!c.type.isAnonymous||Ny(c))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 k0(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 Ny(n){return n.children.some(e=>e instanceof $l||!e.type.isAnonymous||Ny(e))}function vL(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:l=_N,reused:o=[],minRepeatType:a=i.types.length}=n,c=Array.isArray(t)?new Oy(t,t.length):t,f=i.types,d=0,m=0;function g(L,D,j,H,Z,I){let{id:F,start:A,end:ne,size:ae}=c,ie=m,$=d;if(ae<0)if(c.next(),ae==-1){let he=o[F];j.push(he),H.push(A-L);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],J,Y,T=A-L;if(ne-A<=l&&(Y=C(c.pos-D,Z))){let he=new Uint16Array(Y.size-Y.skip),ye=c.pos-Y.size,B=he.length;for(;c.pos>ye;)B=O(Y.start,he,B);J=new $l(he,ne-Y.start,i),T=Y.start-L}else{let he=c.pos-ae;c.next();let ye=[],B=[],R=F>=a?F:-1,V=0,ue=ne,pe=ie;for(;c.pos>he;)R>=0&&c.id==R&&c.size>=0?(c.end<=ue-l&&(w(ye,B,A,V,c.end,ue,R,pe,$),V=ye.length,ue=c.end,pe=m),c.next()):I>2500?b(A,he,ye,B):(R>=0&&c.size==-1&&o[c.id].type==i.types[R]&&(V=0&&V>0&&V-1&&V>0){let je=v(oe,$);J=Ty(oe,ye,B,0,ye.length,0,ne-A,je,je)}else J=S(oe,ye,B,ne-A,ie-ne,$)}j.push(J),H.push(T)}function b(L,D,j,H){let Z=[],I=0,F=-1;for(;c.pos>D;){let{id:A,start:ne,end:ae,size:ie}=c;if(ie>4)c.next();else{if(F>-1&&ne=0;ae-=3)A[ie++]=Z[ae],A[ie++]=Z[ae+1]-ne,A[ie++]=Z[ae+2]-ne,A[ie++]=ie;j.push(new $l(A,Z[2]-ne,i)),H.push(ne-L)}}function v(L,D){return(j,H,Z)=>{let I=0,F=j.length-1,A,ne;if(F>=0&&(A=j[F])instanceof Jt){if(!F&&A.type==L&&A.length==Z)return A;(ne=A.prop(et.lookAhead))&&(I=H[F]+A.length+ne-Z)}return S(L,j,H,Z,I,D)}}function w(L,D,j,H,Z,I,F,A,ne){let ae=[],ie=[];for(;L.length>H;)ae.push(L.pop()),ie.push(D.pop()+j-Z);L.push(S(i.types[F],ae,ie,I-Z,A-I,ne)),D.push(Z-j)}function S(L,D,j,H,Z,I,F){if(I){let A=[et.contextHash,I];F=F?[A].concat(F):[A]}if(Z>25){let A=[et.lookAhead,Z];F=F?[A].concat(F):[A]}return new Jt(L,D,j,H,F)}function C(L,D){let j=c.fork(),H=0,Z=0,I=0,F=j.end-l,A={size:0,start:0,skip:0};e:for(let ne=j.pos-L;j.pos>ne;){let ae=j.size;if(j.id==D&&ae>=0){A.size=H,A.start=Z,A.skip=I,I+=4,H+=4,j.next();continue}let ie=j.pos-ae;if(ae<0||ie=a?4:0,oe=j.start;for(j.next();j.pos>ie;){if(j.size<0)if(j.size==-3||j.size==-4)$+=4;else break e;else j.id>=a&&($+=4);j.next()}Z=oe,H+=ae,I+=$}return(D<0||H==L)&&(A.size=H,A.start=Z,A.skip=I),A.size>4?A:void 0}function O(L,D,j){let{id:H,start:Z,end:I,size:F}=c;if(c.next(),F>=0&&H4){let ne=c.pos-(F-4);for(;c.pos>ne;)j=O(L,D,j)}D[--j]=A,D[--j]=I-L,D[--j]=Z-L,D[--j]=H}else F==-3?d=H:F==-4&&(m=H);return j}let _=[],M=[];for(;c.pos>0;)g(n.start||0,n.bufferStart||0,_,M,-1,0);let P=(e=n.length)!==null&&e!==void 0?e:_.length?M[0]+_[0].length:0;return new Jt(f[n.topID],_.reverse(),M.reverse(),P)}const KS=new WeakMap;function Uh(n,e){if(!n.isAnonymous||e instanceof $l||e.type!=n)return 1;let t=KS.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)}KS.set(e,t)}return t}function Ty(n,e,t,i,l,o,a,c,f){let d=0;for(let w=i;w=m)break;D+=j}if(M==P+1){if(D>m){let j=w[P];v(j.children,j.positions,0,j.children.length,S[P]+_);continue}g.push(w[P])}else{let j=S[M-1]+w[M-1].length-L;g.push(Ty(n,w,S,P,M,L,j,null,f))}b.push(L+_-o)}}return v(e,t,i,l,0),(c||f)(g,b,a)}class _s{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 _s(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 c=0,f=0,d=0;;c++){let m=c=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 _s(v,w,b.tree,b.offset+d,c>0,!!m)}if(b&&l.push(b),a.to>g)break;a=onew ex(l.from,l.to)):[new ex(0,0)]:[new ex(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 wL{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 kL=0,Qr=class C0{constructor(e,t,i,l){this.name=e,this.set=t,this.base=i,this.modified=l,this.id=kL++}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 C0&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let l=new C0(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))}},SL=0;class ld{constructor(e){this.name=e,this.instances=[],this.id=SL++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(c=>c.base==e&&CL(t,c.modified));if(i)return i;let l=[],o=new Qr(e.name,l,e,t);for(let c of t)c.instances.push(o);let a=OL(t);for(let c of e.set)if(!c.modified.length)for(let f of a)l.push(ld.get(c,f));return o}}function CL(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function OL(n){let e=[[]];for(let t=0;ti.length-t.length)}function HN(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,c=l;for(let g=0;;){if(c=="..."&&g>0&&g+3==l.length){a=1;break}let b=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(c);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);c=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 IN.add(e)}const IN=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 c of o)for(let f of c.set){let d=t[f.id];if(d){a=a?a+" "+d:d;break}}return a},scope:i}}function NL(n,e){let t=null;for(let i of n){let l=i.style(e);l&&(t=t?t+" "+l:l)}return t}function TL(n,e,t,i=0,l=n.length){let o=new AL(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,l,"",o.highlighters),o.flush(l)}class AL{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:c,to:f}=e;if(c>=i||f<=t)return;a.isTop&&(o=this.highlighters.filter(v=>!v.scope||v.scope(a)));let d=l,m=EL(e)||Kc.empty,g=NL(o,m.tags);if(g&&(d&&(d+=" "),d+=g,m.mode==1&&(l+=(l?" ":"")+g)),this.startSpan(Math.max(t,c),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+c,1),w=this.highlighters.filter(C=>!C.scope||C.scope(b.tree.type)),S=e.firstChild();for(let C=0,O=c;;C++){let _=C=M||!e.nextSibling())););if(!_||M>i)break;O=_.to+c,O>t&&(this.highlightRange(v.cursor(),Math.max(t,_.from+c),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 EL(n){let e=n.type.prop(IN);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const ke=Qr.define,mh=ke(),Rl=ke(),WS=ke(Rl),ZS=ke(Rl),_l=ke(),ph=ke(_l),tx=ke(_l),mr=ke(),ks=ke(mr),hr=ke(),dr=ke(),O0=ke(),yc=ke(O0),gh=ke(),me={comment:mh,lineComment:ke(mh),blockComment:ke(mh),docComment:ke(mh),name:Rl,variableName:ke(Rl),typeName:WS,tagName:ke(WS),propertyName:ZS,attributeName:ke(ZS),className:ke(Rl),labelName:ke(Rl),namespace:ke(Rl),macroName:ke(Rl),literal:_l,string:ph,docString:ke(ph),character:ke(ph),attributeValue:ke(ph),number:tx,integer:ke(tx),float:ke(tx),bool:ke(_l),regexp:ke(_l),escape:ke(_l),color:ke(_l),url:ke(_l),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:O0,separator:ke(O0),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)}UN([{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 nx;const Yo=new et;function ML(n){return Te.define({combine:n?e=>e.concat(n):void 0})}const DL=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=[Gl.of(this),ut.languageData.of((o,a,c)=>{let f=JS(o,a,c),d=f.type.prop(Yo);if(!d)return[];let m=o.facet(d),g=f.type.prop(DL);if(g){let b=f.resolve(a-f.from,c);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 JS(e,t,i).type.prop(Yo)==this.data}findRegions(e){let t=e.facet(Gl);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(Yo)==this.data){i.push({from:a,to:a+o.length});return}let c=o.prop(et.mounted);if(c){if(c.tree.prop(Yo)==this.data){if(c.overlay)for(let f of c.overlay)i.push({from:f.from+a,to:f.to+a});else i.push({from:a,to:a+o.length});return}else if(c.overlay){let f=i.length;if(l(c.tree,c.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 jL{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,c,f){this.parser=e,this.state=t,this.fragments=i,this.tree=l,this.treeLen=o,this.viewport=a,this.skipped=c,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 jL(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(_s.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=e2(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:l,treeLen:o,viewport:a,skipped:c}=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=_s.applyChanges(i,f),l=Jt.empty,o=0,a={from:e.mapPos(a.from,-1),to:e.mapPos(a.to,1)},this.skipped.length){c=[];for(let d of this.skipped){let m=e.mapPos(d.from,1),g=e.mapPos(d.to,-1);me.from&&(this.fragments=e2(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 PN{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(li.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 e2(n,e,t){return _s.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(Gl).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new ma(i)}}Gi.state=jn.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(Gl)!=e.state.facet(Gl)?ma.init(e.state):n.apply(e)}});let FN=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(FN=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ix=typeof navigator<"u"&&(!((nx=navigator.scheduling)===null||nx===void 0)&&nx.isInputPending)?()=>navigator.scheduling.isInputPending():null,RL=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=FN(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndl+1e3,f=o.context.work(()=>ix&&ix()||Date.now()>a,l+(c?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&&!c)&&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()}}}),Gl=Te.define({combine(n){return n.length?n[0]:null},enables:n=>[Gi.state,RL,Ae.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class _L{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const LL=Te.define(),Ay=Te.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(Ay);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function Wc(n,e){let t="",i=n.tabSize,l=n.facet(Ay)[0];if(l==" "){for(;e>=i;)t+=" ",e-=i;l=" "}for(let o=0;o=e?zL(n,t,e):null}class Id{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 qN=new et;function zL(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 VN(i,n,t)}function VN(n,e,t){for(let i=n;i;i=i.next){let l=PL(i.node);if(l)return l(My.create(e,t,i))}return 0}function BL(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function PL(n){let e=n.type.prop(qN);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=>QN(a,!0,1,void 0,o&&!BL(a)?l.from:void 0)}return n.parent==null?HL:null}function HL(){return 0}class My extends Id{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 My(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(IL(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return VN(this.context.next,this.base,this.pos)}}function IL(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function UL(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 c=t.to;;){let f=e.childAfter(c);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}}c=f.to}}function t2({closing:n,align:e=!0,units:t=1}){return i=>QN(i,e,t,n)}function QN(n,e,t,i,l){let o=n.textAfter,a=o.match(/^\s*/)[0].length,c=i&&o.slice(a,a+i.length)==i||l==n.pos+a,f=e?UL(n):null;return f?c?n.column(f.from):n.column(f.to):n.baseIndent+(c?0:n.unit*t)}const FL=200;function qL(){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+FL)return n;let o=t.sliceString(l.from,i);if(!e.some(d=>d.test(o)))return n;let{state:a}=n,c=-1,f=[];for(let{head:d}of a.selection.ranges){let m=a.doc.lineAt(d);if(m.from==c)continue;c=m.from;let g=Ey(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 VL=Te.define(),XN=new et;function QL(n){let e=n.firstChild,t=n.lastChild;return e&&e.tot)continue;if(o&&c.from=e&&d.to>t&&(o=d)}}return o}function $L(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(VL)){let l=i(n,e,t);if(l)return l}return XL(n,e,t)}function $N(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 Ud=Ke.define({map:$N}),cu=Ke.define({map:$N});function GN(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 Hs=jn.define({create(){return Ue.none},update(n,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((i,l)=>n=n2(n,i,l)),n=n.map(e.changes);let t=[];for(let i of e.effects)i.is(Ud)&&!GL(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(WN),l=t.map(o=>(i?Ue.replace({widget:new tz(i(e.state,o))}):i2).range(o.from,o.to));n=n.update({add:l})}return e.selection&&(n=n2(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(Hs,!1))===null||i===void 0||i.between(e,t,(o,a)=>{(!l||l.from>o)&&(l={from:o,to:a})}),l}function GL(n,e,t){let i=!1;return n.between(e,e,(l,o)=>{l==e&&o==t&&(i=!0)}),i}function YN(n,e){return n.field(Hs,!1)?e:e.concat(Ke.appendConfig.of(ZN()))}const YL=n=>{for(let e of GN(n)){let t=cd(n.state,e.from,e.to);if(t)return n.dispatch({effects:YN(n.state,[Ud.of(t),KN(n,t)])}),!0}return!1},KL=n=>{if(!n.state.field(Hs,!1))return!1;let e=[];for(let t of GN(n)){let i=ud(n.state,t.from,t.to);i&&e.push(cu.of(i),KN(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function KN(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 WL=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(Hs,!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},JL=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:YL},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:KL},{key:"Ctrl-Alt-[",run:WL},{key:"Ctrl-Alt-]",run:ZL}],ez={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},WN=Te.define({combine(n){return Tr(n,ez)}});function ZN(n){return[Hs,rz]}function JN(n,e){let{state:t}=n,i=t.facet(WN),l=a=>{let c=n.lineBlockAt(n.posAtDOM(a.target)),f=ud(n.state,c.from,c.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 i2=Ue.replace({widget:new class extends el{toDOM(n){return JN(n,null)}}});class tz extends el{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return JN(e,this.value)}}const nz={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class rx 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 iz(n={}){let e={...nz,...n},t=new rx(e,!0),i=new rx(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(Gl)!=a.state.facet(Gl)||a.startState.field(Hs,!1)!=a.state.field(Hs,!1)||Dn(a.startState)!=Dn(a.state)||e.foldingChanged(a))&&(this.markers=this.buildMarkers(a.view))}buildMarkers(a){let c=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&&c.add(f.from,f.from,d)}return c.finish()}}),{domEventHandlers:o}=e;return[l,rL({class:"cm-foldGutter",markers(a){var c;return((c=a.plugin(l))===null||c===void 0?void 0:c.markers)||it.empty},initialSpacer(){return new rx(e,!1)},domEventHandlers:{...o,click:(a,c,f)=>{if(o.click&&o.click(a,c,f))return!0;let d=ud(a.state,c.from,c.to);if(d)return a.dispatch({effects:cu.of(d)}),!0;let m=cd(a.state,c.from,c.to);return m?(a.dispatch({effects:Ud.of(m)}),!0):!1}}}),ZN()]}const rz=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(c){let f=Vl.newName();return(i||(i=Object.create(null)))["."+f]=c,f}const o=typeof t.all=="string"?t.all:t.all?l(t.all):void 0,a=t.scope;this.scope=a instanceof Gi?c=>c.prop(Yo)==a.data:a?c=>c==a:void 0,this.style=UN(e.map(c=>({tag:c.tag,class:c.class||l(Object.assign({},c,{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 N0=Te.define(),eT=Te.define({combine(n){return n.length?[n[0]]:null}});function lx(n){let e=n.facet(N0);return e.length?e:n.facet(eT)}function tT(n,e){let t=[sz],i;return n instanceof uu&&(n.module&&t.push(Ae.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(eT.of(n)):i?t.push(N0.computeN([Ae.darkTheme],l=>l.facet(Ae.darkTheme)==(i=="dark")?[n]:[])):t.push(N0.of(n)),t}class lz{constructor(e){this.markCache=Object.create(null),this.tree=Dn(e.state),this.decorations=this.buildDeco(e,lx(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Dn(e.state),i=lx(e.state),l=i!=lx(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)TL(this.tree,t,(a,c,f)=>{i.add(a,c,this.markCache[f]||(this.markCache[f]=Ue.mark({class:f})))},l,o);return i.finish()}}const sz=Us.high(Qt.fromClass(lz,{decorations:n=>n.decorations})),oz=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"}]),az=Ae.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),nT=1e4,iT="()[]{}",rT=Te.define({combine(n){return Tr(n,{afterCursor:!0,brackets:iT,maxScanDistance:nT,renderMatch:fz})}}),cz=Ue.mark({class:"cm-matchingBracket"}),uz=Ue.mark({class:"cm-nonmatchingBracket"});function fz(n){let e=[],t=n.matched?cz:uz;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 r2(n){let e=[],t=n.facet(rT);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}),dz=[hz,az];function mz(n={}){return[rT.of(n),dz]}const pz=new et;function T0(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 A0(n){let e=n.type.prop(pz);return e?e(n.node):n}function wr(n,e,t,i={}){let l=i.maxScanDistance||nT,o=i.brackets||iT,a=Dn(n),c=a.resolveInner(e,t);for(let f=c;f;f=f.parent){let d=T0(f.type,t,o);if(d&&f.from0?e>=m.from&&em.from&&e<=m.to))return gz(n,e,t,f,m,d,o)}}return xz(n,e,t,a,c.type,l,o)}function gz(n,e,t,i,l,o,a){let c=i.parent,f={from:l.from,to:l.to},d=0,m=c==null?void 0:c.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 yz=Object.create(null),l2=[li.none],s2=[],o2=Object.create(null),bz=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"]])bz[n]=vz(yz,e);function sx(n,e){s2.indexOf(n)>-1||(s2.push(n),console.warn(e))}function vz(n,e){let t=[];for(let c of e.split(" ")){let f=[];for(let d of c.split(".")){let m=n[d]||me[d];m?typeof m=="function"?f.length?f=f.map(m):sx(d,`Modifier ${d} used at start of tag`):f.length?sx(d,`Tag ${d} used as modifier`):f=Array.isArray(m)?m:[m]:sx(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(c=>c.id),o=o2[l];if(o)return o.id;let a=o2[l]=li.define({id:l2.length,name:i,props:[HN({[i]:t})]});return l2.push(a),a.id}kt.RTL,kt.LTR;const wz=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=jy(n.state,t.from);return i.line?kz(n):i.block?Cz(n):!1};function Dy(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 kz=Dy(Tz,0),Sz=Dy(lT,0),Cz=Dy((n,e)=>lT(n,e,Nz(e)),0);function jy(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const vc=50;function Oz(n,{open:e,close:t},i,l){let o=n.sliceDoc(i-vc,i),a=n.sliceDoc(l,l+vc),c=/\s*$/.exec(o)[0].length,f=/^\s*/.exec(a)[0].length,d=o.length-c;if(o.slice(d-e.length,d)==e&&a.slice(f,f+t.length)==t)return{open:{pos:i-c,margin:c&&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 Nz(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 lT(n,e,t=e.selection.ranges){let i=t.map(o=>jy(e,o.from).block);if(!i.every(o=>o))return null;let l=t.map((o,a)=>Oz(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,c;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:c,token:f,indent:d,empty:m,single:g}of i)(g||!m)&&o.push({from:c.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:c,token:f}of i)if(c>=0){let d=a.from+c,m=d+f.length;a.text[m-a.from]==" "&&m++,o.push({from:d,to:m})}return{changes:o}}return null}const E0=Jr.define(),Az=Jr.define(),Ez=Te.define(),sT=Te.define({combine(n){return Tr(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)})}}),oT=jn.define({create(){return kr.empty},update(n,e){let t=e.state.facet(sT),i=e.annotation(E0);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=uT(m,e.startState.selection),new kr(d==0?i.rest:m,d==0?m:i.rest)}let l=e.annotation(Az);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),c=e.annotation(sn.userEvent);return o?n=n.addChanges(o,a,c,t,e):e.selection&&(n=n.addSelection(e.startState.selection,a,c,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 Mz(n={}){return[oT,sT.of(n),Ae.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?aT:e.inputType=="historyRedo"?M0:null;return i?(e.preventDefault(),i(t)):!1}})]}function Fd(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let l=t.field(oT,!1);if(!l)return!1;let o=l.pop(n,t,e);return o?(i(o),!0):!1}}const aT=Fd(0,!1),M0=Fd(1,!1),Dz=Fd(0,!0),jz=Fd(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=Ri;for(let l of e.startState.facet(Ez)){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,Ri)}static selection(e){return new ii(void 0,Ri,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 Rz(n,e){let t=[],i=!1;return n.iterChangedRanges((l,o)=>t.push(l,o)),e.iterChangedRanges((l,o,a,c)=>{for(let f=0;f=d&&a<=m&&(i=!0)}}),i}function _z(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function cT(n,e){return n.length?e.length?n.concat(e):n:e}const Ri=[],Lz=200;function uT(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-Lz));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 zz(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 ox(n,e){if(!n.length)return n;let t=n.length,i=Ri;for(;t;){let l=Bz(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)]:Ri}function Bz(n,e,t){let i=cT(n.selectionsAfter.length?n.selectionsAfter.map(c=>c.map(e)):Ri,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 Pz=/^(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,c=a[a.length-1];return c&&c.changes&&!c.changes.empty&&e.changes&&(!i||Pz.test(i))&&(!c.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):qd(t,e))}function Rn(n){return n.textDirectionAt(n.state.selection.main.head)==kt.LTR}const hT=n=>fT(n,!Rn(n)),dT=n=>fT(n,Rn(n));function mT(n,e){return Ji(n,t=>t.empty?n.moveByGroup(t,e):qd(t,e))}const Iz=n=>mT(n,!Rn(n)),Uz=n=>mT(n,Rn(n));function Fz(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;Fz(n,d,l)?i=d:f=t?d.to:d.from}let o=i.type.prop(l),a,c;return o&&(a=t?wr(n,i.from,1):wr(n,i.to,-1))&&a.matched?c=t?a.end.to:a.end.from:c=t?i.to:i.from,re.cursor(c,t?-1:1)}const qz=n=>Ji(n,e=>Vd(n.state,e,!Rn(n))),Vz=n=>Ji(n,e=>Vd(n.state,e,Rn(n)));function pT(n,e){return Ji(n,t=>{if(!t.empty)return qd(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const gT=n=>pT(n,!1),xT=n=>pT(n,!0);function yT(n){let e=n.scrollDOM.clientHeighta.empty?n.moveVertically(a,e,t.height):qd(a,e));if(l.eq(i.selection))return!1;let o;if(t.selfScroll){let a=n.coordsAtPos(i.selection.main.head),c=n.scrollDOM.getBoundingClientRect(),f=c.top+t.marginTop,d=c.bottom-t.marginBottom;a&&a.top>f&&a.bottombT(n,!1),D0=n=>bT(n,!0);function Wl(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 Qz=n=>Ji(n,e=>Wl(n,e,!0)),Xz=n=>Ji(n,e=>Wl(n,e,!1)),$z=n=>Ji(n,e=>Wl(n,e,!Rn(n))),Gz=n=>Ji(n,e=>Wl(n,e,Rn(n))),Yz=n=>Ji(n,e=>n.moveToLineBoundary(e,!1,!1)),Kz=n=>Ji(n,e=>n.moveToLineBoundary(e,!0,!1));function Wz(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.headWz(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 vT(n,e){return zi(n,e,t=>n.moveByChar(t,e))}const wT=n=>vT(n,!Rn(n)),kT=n=>vT(n,Rn(n));function ST(n,e){return zi(n,e,t=>n.moveByGroup(t,e))}const Jz=n=>ST(n,!Rn(n)),e6=n=>ST(n,Rn(n)),t6=n=>{let e=!Rn(n);return zi(n,e,t=>Vd(n.state,t,e))},n6=n=>{let e=Rn(n);return zi(n,e,t=>Vd(n.state,t,e))};function CT(n,e){return zi(n,e,t=>n.moveVertically(t,e))}const OT=n=>CT(n,!1),NT=n=>CT(n,!0);function TT(n,e){return zi(n,e,t=>n.moveVertically(t,e,yT(n).height))}const c2=n=>TT(n,!1),u2=n=>TT(n,!0),i6=n=>zi(n,!0,e=>Wl(n,e,!0)),r6=n=>zi(n,!1,e=>Wl(n,e,!1)),l6=n=>{let e=!Rn(n);return zi(n,e,t=>Wl(n,t,e))},s6=n=>{let e=Rn(n);return zi(n,e,t=>Wl(n,t,e))},o6=n=>zi(n,!1,e=>re.cursor(n.lineBlockAt(e.head).from)),a6=n=>zi(n,!0,e=>re.cursor(n.lineBlockAt(e.head).to)),f2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:0})),!0),h2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:n.doc.length})),!0),d2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:n.selection.main.anchor,head:0})),!0),m2=({state:n,dispatch:e})=>(e(Zi(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),c6=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),u6=({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},f6=({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:c}=a;if((c.from=i.to||c.to>i.to&&c.from<=i.from)&&a.next)return re.undirectionalRange(c.from,c.to)}return i});return t.eq(n.selection)?!1:(e(Zi(n,t)),!0)};function AT(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 c=o;;){let f=n.moveVertically(c,e);if(f.heada.to){l.some(d=>d.head==f.head)||l.push(f);break}else{if(f.head==c.head)break;c=f}}}return l.length==i.ranges.length?!1:(n.dispatch(Zi(t,re.create(l,l.length-1))),!0)}const h6=n=>AT(n,!1),d6=n=>AT(n,!0),m6=({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:c}=o;if(a==c){let f=e(o);fa&&(t="delete.forward",f=xh(n,f,!0)),a=Math.min(a,f),c=Math.max(c,f)}else a=xh(n,a,!1),c=xh(n,c,!0);return a==c?{range:o}:{changes:{from:a,to:c},range:re.cursor(a,al(n)))i.between(e,e,(l,o)=>{le&&(e=t?o:l)});return e}const ET=(n,e,t)=>fu(n,i=>{let l=i.from,{state:o}=n,a=o.doc.lineAt(l),c,f;if(t&&!e&&l>a.from&&lET(n,!1,!0),MT=n=>ET(n,!0,!1),DT=(n,e)=>fu(n,t=>{let i=t.head,{state:l}=n,o=l.doc.lineAt(i),a=l.charCategorizer(i);for(let c=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(c!=null&&m!=c)break;(d!=" "||i!=t.head)&&(c=m),i=f}return i}),jT=n=>DT(n,!1),p6=n=>DT(n,!0),g6=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)}),y6=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},v6=({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,c=l==o.to?l+1:hn(o.text,l-o.from,!0)+o.from;return{changes:{from:a,to:c,insert:n.doc.slice(l,c).append(n.doc.slice(a,l))},range:re.cursor(c)}});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 RT(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),c=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+c),Math.min(n.doc.length,f.head+c)))}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-c,f.head-c))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:re.create(l,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const w6=({state:n,dispatch:e})=>RT(n,e,!1),k6=({state:n,dispatch:e})=>RT(n,e,!0);function _T(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 S6=({state:n,dispatch:e})=>_T(n,e,!1),C6=({state:n,dispatch:e})=>_T(n,e,!0),O6=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),c=n.coordsAtPos(l.head,l.assoc||1);c&&(o=a.bottom+n.documentTop-c.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 N6(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 p2=LT(!1),T6=LT(!0);function LT(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(l=>{let{from:o,to:a}=l,c=e.doc.lineAt(o),f=!n&&o==a&&N6(e,o);n&&(o=a=(a<=c.to?c:e.doc.lineAt(a)).to);let d=new Id(e,{simulateBreak:o,simulateDoubleBreak:!!f}),m=Ey(d,o);for(m==null&&(m=xa(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));ac.from&&o{let l=[];for(let a=i.from;a<=i.to;){let c=n.doc.lineAt(a);c.number>t&&(i.empty||i.to>c.from)&&(e(c,l,i),t=c.number),a=c.to+1}let o=n.changes(l);return{changes:l,range:re.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}const A6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Id(n,{overrideIndentation:o=>{let a=t[o];return a??-1}}),l=Ry(n,(o,a,c)=>{let f=Ey(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||c.fromn.readOnly?!1:(e(n.update(Ry(n,(t,i)=>{i.push({from:t.from,insert:n.facet(Ay)})}),{userEvent:"input.indent"})),!0),M6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(Ry(n,(t,i)=>{let l=/^\s*/.exec(t.text)[0];if(!l)return;let o=xa(l,n.tabSize),a=0,c=Wc(n,Math.max(0,o-ad(n)));for(;a(n.setTabFocusMode(),!0),j6=[{key:"Ctrl-b",run:hT,shift:wT,preventDefault:!0},{key:"Ctrl-f",run:dT,shift:kT},{key:"Ctrl-p",run:gT,shift:OT},{key:"Ctrl-n",run:xT,shift:NT},{key:"Ctrl-a",run:Yz,shift:o6},{key:"Ctrl-e",run:Kz,shift:a6},{key:"Ctrl-d",run:MT},{key:"Ctrl-h",run:j0},{key:"Ctrl-k",run:g6},{key:"Ctrl-Alt-h",run:jT},{key:"Ctrl-o",run:b6},{key:"Ctrl-t",run:v6},{key:"Ctrl-v",run:D0}],R6=[{key:"ArrowLeft",run:hT,shift:wT,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Iz,shift:Jz,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:$z,shift:l6,preventDefault:!0},{key:"ArrowRight",run:dT,shift:kT,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Uz,shift:e6,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Gz,shift:s6,preventDefault:!0},{key:"ArrowUp",run:gT,shift:OT,preventDefault:!0},{mac:"Cmd-ArrowUp",run:f2,shift:d2},{mac:"Ctrl-ArrowUp",run:a2,shift:c2},{key:"ArrowDown",run:xT,shift:NT,preventDefault:!0},{mac:"Cmd-ArrowDown",run:h2,shift:m2},{mac:"Ctrl-ArrowDown",run:D0,shift:u2},{key:"PageUp",run:a2,shift:c2},{key:"PageDown",run:D0,shift:u2},{key:"Home",run:Xz,shift:r6,preventDefault:!0},{key:"Mod-Home",run:f2,shift:d2},{key:"End",run:Qz,shift:i6,preventDefault:!0},{key:"Mod-End",run:h2,shift:m2},{key:"Enter",run:p2,shift:p2},{key:"Mod-a",run:c6},{key:"Backspace",run:j0,shift:j0,preventDefault:!0},{key:"Delete",run:MT,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:jT,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:p6,preventDefault:!0},{mac:"Mod-Backspace",run:x6,preventDefault:!0},{mac:"Mod-Delete",run:y6,preventDefault:!0}].concat(j6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),_6=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:qz,shift:t6},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Vz,shift:n6},{key:"Alt-ArrowUp",run:w6},{key:"Shift-Alt-ArrowUp",run:S6},{key:"Alt-ArrowDown",run:k6},{key:"Shift-Alt-ArrowDown",run:C6},{key:"Mod-Alt-ArrowUp",run:h6},{key:"Mod-Alt-ArrowDown",run:d6},{key:"Escape",run:m6},{key:"Mod-Enter",run:T6},{key:"Alt-l",mac:"Ctrl-l",run:u6},{key:"Mod-i",run:f6,preventDefault:!0},{key:"Mod-[",run:M6},{key:"Mod-]",run:E6},{key:"Mod-Alt-\\",run:A6},{key:"Shift-Mod-k",run:O6},{key:"Shift-Mod-\\",run:Zz},{key:"Mod-/",run:wz},{key:"Alt-A",mac:"Ctrl-A",run:Sz},{key:"Ctrl-m",mac:"Shift-Alt-m",run:D6}].concat(R6),g2=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?c=>o(g2(c)):g2,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=sy(e),i=this.bufferStart+this.bufferPos;this.bufferPos+=yr(e);let l=this.normalize(t);if(l.length)for(let o=0,a=i,c=!0;;o++){let f=l.charCodeAt(o),d=this.match(f,a,c,this.bufferPos+this.bufferStart,o==l.length-1);if(d)return this.value=d,this;if(o==l.length-1)break;c&&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 c=new na(t,e.sliceString(t,i));return ax.set(e,c),c}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"&&(BT.prototype[Symbol.iterator]=PT.prototype[Symbol.iterator]=function(){return this});function L6(n){try{return new RegExp(n,_y),!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 z6=n=>{let e=eL(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}=J_(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 c=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!c){n.dispatch({effects:l});return}let f=t.doc.lineAt(t.selection.main.head),[,d,m,g,b]=c,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},B6={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},P6=Te.define({combine(n){return Tr(n,B6,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function H6(n){return[V6,q6]}const I6=Ue.mark({class:"cm-selectionMatch"}),U6=Ue.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function x2(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 F6(n,e,t,i){return n(e.sliceDoc(t,t+1))==_t.Word&&n(e.sliceDoc(i-1,i))==_t.Word}const q6=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(P6),{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),!(x2(a,t,l.from,l.to)&&F6(a,t,l.from,l.to)))return Ue.none}else if(o=t.sliceDoc(l.from,l.to),!o)return Ue.none}let c=[];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||x2(a,t,m,g))&&(l.empty&&m<=l.from&&g>=l.to?c.push(U6.range(m,g)):(m>=l.to||g<=l.from)&&c.push(I6.range(m,g)),c.length>e.maxMatches))return Ue.none}}return Ue.set(c)}},{decorations:n=>n.decorations}),V6=Ae.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Q6=({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 X6(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,c=new pa(n.doc,e,i[i.length-1].to);;)if(c.next(),c.done){if(a)return null;c=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==c.value.from))continue;if(o){let f=n.wordAt(c.value.from);if(!f||f.from!=c.value.from||f.to!=c.value.to)continue}return c.value}}const $6=({state:n,dispatch:e})=>{let{ranges:t}=n.selection;if(t.some(o=>o.from===o.to))return Q6({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=X6(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=Te.define({combine(n){return Tr(n,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new oB(e),scrollToMatch:e=>Ae.scrollIntoView(e)})}});class HT{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||L6(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 J6(this):new K6(this)}getCursor(e,t=0,i){let l=e.doc?e:ut.create({doc:e});return i==null&&(i=l.doc.length),this.regexp?Uo(this,l,t,i):Io(this,l,t,i)}}class IT{constructor(e){this.spec=e}}function G6(n,e,t){return(i,l,o,a)=>{if(t&&!t(i,l,o,a))return!1;let c=i>=a&&l<=a+o.length?o.slice(i-a,l-a):e.doc.sliceString(i,l);return n(c,e,i,l)}}function Io(n,e,t,i){let l;return n.wholeWord&&(l=Y6(e.doc,e.charCategorizer(e.selection.main.head))),n.test&&(l=G6(n.test,e,l)),new pa(e.doc,n.unquoted,t,i,n.caseSensitive?void 0:o=>o.toLowerCase(),l)}function Y6(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=Io(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 W6(n,e,t){return(i,l,o)=>(!t||t(i,l,o))&&n(o[0],e,i,l)}function Uo(n,e,t,i){let l;return n.wholeWord&&(l=Z6(e.charCategorizer(e.selection.main.head))),n.test&&(l=W6(n.test,e,l)),new BT(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 Z6(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 J6 extends IT{nextMatch(e,t,i){let l=Uo(this.spec,e,i,e.doc.length).next();return l.done&&(l=Uo(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=Uo(this.spec,e,o,i),c=null;for(;!a.next().done;)c=a.value;if(c&&(o==t||c.from>o+10))return c;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=Uo(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(),Ly=Ke.define(),Ul=jn.define({create(n){return new cx(R0(n).create(),null)},update(n,e){for(let t of e.effects)t.is(Zc)?n=new cx(t.value.create(),n.panel):t.is(Ly)&&(n=new cx(n.query,t.value?zy:null));return n},provide:n=>Gc.from(n,e=>e.panel)});class cx{constructor(e,t){this.query=e,this.panel=t}}const eB=Ue.mark({class:"cm-searchMatch"}),tB=Ue.mark({class:"cm-searchMatch cm-searchMatch-selected"}),nB=Qt.fromClass(class{constructor(n){this.view=n,this.decorations=this.highlight(n.state.field(Ul))}update(n){let e=n.state.field(Ul);(e!=n.startState.field(Ul)||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,c,f,(d,m)=>{let g=t.state.selection.ranges.some(b=>b.from==d&&b.to==m);i.add(d,m,g?tB:eB)})}return i.finish()}},{decorations:n=>n.decorations});function hu(n){return e=>{let t=e.state.field(Ul,!1);return t&&t.query.spec.valid?n(e,t):qT(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:[By(n,i),o.scrollToMatch(l.main,n)],userEvent:"select.search"}),FT(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:[By(n,l),a.scrollToMatch(o.main,n)],userEvent:"select.search"}),FT(n),!0}),iB=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)}),rB=({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 c=new pa(n.doc,n.sliceDoc(i,l));!c.next().done;){if(o.length>1e3)return!1;c.value.from==i&&(a=o.length),o.push(re.range(c.value.from,c.value.to))}return e(n.update({selection:re.create(o,a),userEvent:"select.search.matches"})),!0},y2=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,c=[],f,d,m=[];a.precise?a.from==i&&a.to==l&&(d=t.toText(e.getReplacement(a)),c.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(c);return a&&(f=re.single(a.from,a.to).map(g),m.push(By(n,a)),m.push(t.facet(ba).scrollToMatch(f.main,n))),n.dispatch({changes:g,selection:f,effects:m,userEvent:"input.replace"}),!0}),lB=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:c}=l;c&&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 zy(n){return n.state.facet(ba).createPanel(n)}function R0(n,e){var t,i,l,o,a;let c=n.selection.main,f=c.empty||c.to>c.from+100?"":n.sliceDoc(c.from,c.to);if(e&&!f)return e;let d=n.facet(ba);return new HT({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 UT(n){let e=Hd(n,zy);return e&&e.dom.querySelector("[main-field]")}function FT(n){let e=UT(n);e&&e==n.root.activeElement&&e.select()}const qT=n=>{let e=n.state.field(Ul,!1);if(e&&e.panel){let t=UT(n);if(t&&t!=n.root.activeElement){let i=R0(n.state,e.query.spec);i.valid&&n.dispatch({effects:Zc.of(i)}),t.focus(),t.select()}}else n.dispatch({effects:[Ly.of(!0),e?Zc.of(R0(n.state,e.query.spec)):Ke.appendConfig.of(cB)]});return!0},VT=n=>{let e=n.state.field(Ul,!1);if(!e||!e.panel)return!1;let t=Hd(n,zy);return t&&t.dom.contains(n.root.activeElement)&&n.focus(),n.dispatch({effects:Ly.of(!1)}),!0},sB=[{key:"Mod-f",run:qT,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:VT,scope:"editor search-panel"},{key:"Mod-Shift-l",run:rB},{key:"Mod-Alt-g",run:z6},{key:"Mod-d",run:$6,preventDefault:!0}];class oB{constructor(e){this.view=e;let t=this.query=e.state.field(Ul).query.spec;this.commit=this.commit.bind(this),this.searchField=wt("input",{value:t.search,placeholder:pi(e,"Find"),"aria-label":pi(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:pi(e,"Replace"),"aria-label":pi(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),[pi(e,"next")]),i("prev",()=>gd(e),[pi(e,"previous")]),i("select",()=>iB(e),[pi(e,"all")]),wt("label",null,[this.caseField,pi(e,"match case")]),wt("label",null,[this.reField,pi(e,"regexp")]),wt("label",null,[this.wordField,pi(e,"by word")]),...e.state.readOnly?[]:[wt("br"),this.replaceField,i("replace",()=>y2(e),[pi(e,"replace")]),i("replaceAll",()=>lB(e),[pi(e,"replace all")])],wt("button",{name:"close",onclick:()=>VT(e),"aria-label":pi(e,"close"),type:"button"},["×"])])}commit(){let e=new HT({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){c_(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(),y2(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 pi(n,e){return n.state.phrase(e)}const yh=30,bh=/[\s\.,:;?!]/;function By(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),c=n.state.sliceDoc(o,a);if(o!=i.from){for(let f=0;fc.length-yh;f--)if(!bh.test(c[f-1])&&bh.test(c[f])){c=c.slice(0,f);break}}return Ae.announce.of(`${n.state.phrase("current match")}. ${c} ${n.state.phrase("on line")} ${i.number}.`)}const aB=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"}}),cB=[Ul,Us.low(nB),aB];class QT{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(XT(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 b2(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 uB(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+$/]:uB(e);return l=>{let o=l.matchBefore(i);return o||l.explicit?{from:o?o.from:l.pos,options:e,validFor:t}:null}}class v2{constructor(e,t,i,l){this.completion=e,this.source=t,this.match=i,this.score=l}}function Ls(n){return n.selection.main.from}function XT(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 $T=Jr.define();function hB(n,e,t,i){let{main:l}=n.selection,o=t-l.from,a=i-l.from;return{...n.changeByRange(c=>{if(c!=l&&t!=i&&n.sliceDoc(c.from+o,c.from+a)!=n.sliceDoc(t,i))return{range:c};let f=n.toText(e);return{changes:{from:c.from+o,to:i==l.from?c.to:c.from+a,insert:f},range:re.cursor(c.from+o+f.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}const w2=new WeakMap;function dB(n){if(!Array.isArray(n))return n;let e=w2.get(n);return e||w2.set(n,e=fB(n)),e}const xd=Ke.define(),Jc=Ke.define();class mB{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&&L<=57||L>=97&&L<=122?2:L>=65&&L<=90?1:0:(D=sy(L))!=D.toLowerCase()?1:D!=D.toUpperCase()?2:0;(!_||j==1&&C||P==0&&j!=0)&&(t[g]==L||i[g]==L&&(b=!0)?a[g++]=_:a.length&&(O=!1)),P=j,_+=yr(L)}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]):c>-1?this.ret(-700-e.length,[c,c+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 c=a+(this.astral?yr(Jn(i,a)):1);o&&l[o-1]==a?l[o-1]=c:(l[o++]=a,l[o++]=c)}return this.ret(e-i.length,l)}}class pB{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:gB,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=>k2(e(i),t(i)),optionClass:(e,t)=>i=>k2(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function k2(n,e){return n?e?n+" "+e:n:e}function gB(n,e,t,i,l,o){let a=n.textDirection==kt.RTL,c=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(c&&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":c?"left":"right")}}const Py=Ke.define();function xB(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 c=t.displayLabel||t.label,f=0;for(let d=0;df&&a.appendChild(document.createTextNode(c.slice(f,m)));let b=a.appendChild(document.createElement("span"));b.appendChild(document.createTextNode(c.slice(m,g))),b.className="cm-completionMatchedText",f=g}return ft.position-i.position).map(t=>t.render)}function ux(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 yB{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,c=e.state.facet(fn);this.optionContent=xB(c),this.optionClass=c.optionClass,this.tooltipClass=c.tooltipClass,this.range=ux(o.length,a,c.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:Py.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:c}=i.open;(!l.open||l.open.options!=o)&&(this.range=ux(o.length,a,e.state.facet(fn).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),c!=((t=l.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!c)}}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=ux(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(c=>{c&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(c,l)}).catch(c=>ni(this.view.state,c,"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&&vB(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(c);g&&(m.className=g);for(let b of this.optionContent){let v=b(c,this.view.state,this.view,f);v&&m.appendChild(v)}}return i.from&&l.classList.add("cm-completionListIncompleteTop"),i.tonew yB(t,n,e)}function vB(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 S2(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function wB(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 v2(b,m.source,g?g(b):[],1e9-t.length));else{let b=e.sliceDoc(m.from,m.to),v,w=a.filterStrict?new pB(b):new mB(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 v2(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?c.push(m):S2(m.completion)>S2(f)&&(c[c.length-1]=m),f=m.completion}return c}class Ko{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 Ko(this.options,C2(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 c=wB(e,t);if(!c.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:TB,above:o.aboveCursor},l?l.timestamp:Date.now(),f,!1)}map(e){return new Ko(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ko(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(OB,"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",Ls(t)).map(dB)).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,c=e.effects.some(f=>f.is(Hy));a&&e.docChanged&&(a=a.map(e.changes)),e.selection||o.some(f=>f.hasResult()&&e.changes.touchesRange(f.from,f.to))||!kB(o,this.active)||c?a=Ko.build(o,t,this.id,a,i,c):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(Py)&&(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?SB:CB}}function kB(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const OB=[];function GT(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation($T);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=GT(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(Hy))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(Ls(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),c=Ls(e.state);if(c>a||!l||t&2&&(Ls(e.startState)==this.from||ct.map(e))}}),ei=jn.define({create(){return yd.start()},update(n,e){return n.update(e)},provide:n=>[Sy.from(n,e=>e.tooltip),Ae.contentAttributes.from(n,e=>e.attrs)]});function Iy(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({...hB(n.state,t,i.from,i.to),annotations:$T.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}const TB=bB(ei,Iy);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 c<0?c=e=="page"?0:a-1:c>=a&&(c=e=="page"?a-1:0),t.dispatch({effects:Py.of(c)}),!0}}const AB=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,EB=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 MB{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const DB=50,jB=1e3,RB=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=GT(o,t);return a&8||(o.selection||o.docChanged)&&!(a&3)});for(let o=0;oDB&&Date.now()-a.time>jB){for(let c of a.context.abortListeners)try{c()}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=Ls(e),i=new QT(e,t,n.explicit,this.view),l=new MB(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;lc.source==o.active.source);if(a&&a.isPending)if(o.done==null){let c=new _i(o.active.source,0);for(let f of o.updates)c=c.update(f,t);c.isPending||e.push(c)}else this.startQuery(a)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:Hy.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&&AN(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}}}),_B=typeof navigator=="object"&&/Win/.test(navigator.platform),LB=Us.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&&!(_B&&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&&Iy(e,i),!1}})),zB=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,qn.TrackAfter);return t??void 0}}),Uy=new class extends ql{};Uy.startSide=1;Uy.endSide=-1;const YT=jn.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:[Uy.range(t.value,t.value+1)]}));return n}});function BB(){return[HB,YT]}const hx="()[]{}<>«»»«[]{}";function KT(n){for(let e=0;e{if((PB?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=FB(n.state,i);return o?(n.dispatch(o),!0):!1}),IB=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=WT(n,n.selection.main.head).brackets||eu.brackets,l=null,o=n.changeByRange(a=>{if(a.empty){let c=qB(n.doc,a.head);for(let f of i)if(f==c&&Xd(n.doc,a.head)==KT(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},UB=[{key:"Backspace",run:IB}];function FB(n,e){let t=WT(n,n.selection.main.head),i=t.brackets||eu.brackets;for(let l of i){let o=KT(Jn(l,0));if(e==l)return o==l?XB(n,l,i.indexOf(l+l+l)>-1,t):VB(n,l,o,t.before||eu.before);if(e==o&&ZT(n,n.selection.main.from))return QB(n,l,o)}return null}function ZT(n,e){let t=!1;return n.field(YT).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function Xd(n,e){let t=n.sliceString(e,e+2);return t.slice(0,yr(Jn(t,0)))}function qB(n,e){let t=n.sliceString(e-2,e);return yr(Jn(t,0))==t.length?t:t.slice(1)}function VB(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 c=Xd(n.doc,a.head);return!c||/\s/.test(c)||i.indexOf(c)>-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 QB(n,e,t){let i=null,l=n.changeByRange(o=>o.empty&&Xd(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 XB(n,e,t,i){let l=i.stringPrefixes||eu.stringPrefixes,o=null,a=n.changeByRange(c=>{if(!c.empty)return{changes:[{insert:e,from:c.from},{insert:e,from:c.to}],effects:Ds.of(c.to+e.length),range:re.range(c.anchor+e.length,c.head+e.length)};let f=c.head,d=Xd(n.doc,f),m;if(d==e){if(O2(n,f))return{changes:{insert:e+e,from:f},effects:Ds.of(f+e.length),range:re.cursor(f+e.length)};if(ZT(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=N2(n,f-2*e.length,l))>-1&&O2(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&&N2(n,f,l)>-1&&!$B(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=c}});return o?null:n.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function O2(n,e){let t=Dn(n).resolveInner(e+1);return t.parent&&t.from==e}function $B(n,e,t,i){let l=Dn(n).resolveInner(e,-1),o=i.reduce((a,c)=>Math.max(a,c.length),0);for(let a=0;a<5;a++){let c=n.sliceDoc(l.from,Math.min(l.to,l.from+t.length+o)),f=c.indexOf(t);if(!f||f>-1&&i.indexOf(c.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 N2(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 GB(n={}){return[LB,ei,fn.of(n),RB,YB,zB]}const JT=[{key:"Ctrl-Space",run:fx},{mac:"Alt-`",run:fx},{mac:"Alt-i",run:fx},{key:"Escape",run:EB},{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:AB}],YB=Us.highest(wy.computeN([fn],n=>n.facet(fn).defaultKeymap?[JT]:[]));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,c=[],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&&!c.length)break;let S,C;if(c.length)S=f,C=c.reduce((M,P)=>Math.min(M,P.to),w&&w.from>S?w.from:1e8);else{if(S=w.from,S>g)break;C=w.to,c.push(w),v++}for(;vM.from||M.to==S))c.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(c.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 P=S;;){if(P>=C){O=!0;break}if(!d.lineBreak&&m+d.value.length>P)break;P=m+d.value.length,m+=d.value.length,d.next()}}let _=a9(c);if(O)a.add(S,S,Ue.widget({widget:new r9(_),diagnostics:c.slice()}));else{let M=c.reduce((P,L)=>L.markClass?P+" "+L.markClass:P,"");a.add(S,C,Ue.mark({class:"cm-lintRange cm-lintRange-"+_+M,diagnostics:c.slice(),inclusiveEnd:c.some(P=>P.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 KB(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 WB(n,e){return n.field(bi,!1)?e:e.concat(Ke.appendConfig.of(c9))}const eA=Ke.define(),Fy=Ke.define(),tA=Ke.define(),bi=jn.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=Yl(t,n.selected.diagnostic,o)||Yl(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(Fy)?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)]}),ZB=Ue.mark({class:"cm-lintRange cm-lintRange-active"});function JB(n,e,t){let{diagnostics:i}=n.state.field(bi),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 t9=n=>{let e=n.state.field(bi,!1);(!e||!e.panel)&&n.dispatch({effects:WB(n.state,[Fy.of(!0)])});let t=Hd(n,nu.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},A2=n=>{let e=n.state.field(bi,!1);return!e||!e.panel?!1:(n.dispatch({effects:Fy.of(!1)}),!0)},n9=n=>{let e=n.state.field(bi,!1);if(!e)return!1;let t=n.state.selection.main,i=Yl(e.diagnostics,null,t.to+1);return!i&&(i=Yl(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}),W_(n,i.from,1,{tooltip:rA,until:l=>l.docChanged||l.newSelection.main.headi.to}),!0)},i9=[{key:"Mod-Shift-m",run:t9,preventDefault:!0},{key:"F8",run:n9}],tu=Te.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Tr(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:E2,tooltipFilter:E2,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 E2(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 c=!1,f=v=>{if(v.preventDefault(),c)return;c=!0;let w=Yl(n.state.field(bi).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 r9 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 M2{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)A2(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 c=0;c{for(let o=0;oA2(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(bi).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:c,panel:f})=>{let d=f.height/this.list.offsetHeight;c.topf.bottom&&(this.list.scrollTop+=(c.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(bi),i=Yl(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 l9(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function wh(n){return l9(``,'width="6" height="3"')}const s9=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 o9(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function a9(n){let e="hint",t=1;for(let i of n){let l=o9(i.severity);l>t&&(t=l,e=i.severity)}return e}const rA=K_(JB,{hideOn:KB}),c9=[bi,Ae.decorations.compute([bi],n=>{let{selected:e,panel:t}=n.field(bi);return!e||!t||e.from==e.to?Ue.none:Ue.set([ZB.range(e.from,e.to)])}),rA,s9],u9=[fL(),mL(),T_(),Mz(),iz(),p_(),w_(),ut.allowMultipleSelections.of(!0),qL(),tT(oz,{fallback:!0}),mz(),BB(),GB(),H_(),F_(),R_(),H6(),wy.of([...UB,..._6,...sB,...Hz,...JL,...JT,...i9])];var D2={};class bd{constructor(e,t,i,l,o,a,c,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=c,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 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 c=!1;for(let f=a;f>0&&this.buffer[f-2]>i;f-=4)if(this.buffer[f-1]>=0){c=!0;break}if(c)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 c=a.stateFlag(o,1);!c&&(l>i||t<=a.maxNode)&&(this.reducePos=l),this.pushState(o,c?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 f9(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&&c==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 c=(a>>19)-o;if(c>1){let f=a&65535,d=this.stack.length-c*3;if(d>=0&&e.getGoto(this.stack[d],f,!1)>=0)return c<<19|65536|f}}else{let c=i(a,o+1);if(c!=null)return c}})};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 f9{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,c=!0),o+=f,c)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 h9{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&&ic.to&&(this.chunk2=this.chunk2.slice(0,c.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;d9(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 $d{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function d9(n,e,t,i,l,o){let a=0,c=1<0){let w=n[v];if(f.allows(w)&&(e.token.value==-1||e.token.value==w||m9(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 _2(n,e,t){for(let i=e,l;(l=n[i])!=65535;i++)if(l==t)return i-e;return-1}function m9(n,e,t,i){let l=_2(t,i,e);return l<0||_2(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 p9{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?L2(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?L2(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 c=a>this.lastRepeatPos&&o.type.id>=this.minRepeat;if(a==e||c){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 g9{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),c=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(c>>1)){(c&1)==0?e.value=c>>1:e.extended=c>>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 p9(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(c);else{if(this.advanceStack(c,i,e))continue;{l||(l=[],o=[]),l.push(c);let f=this.tokens.getMainToken(c);o.push(f.value,f.end)}}break}}if(!i.length){let a=l&&v9(l);if(a)return gi&&console.log("Finish with "+this.stackID(a)),this.stackToTree(a);if(this.parser.strict)throw gi&&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 gi&&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((c,f)=>f.score-c.score);i.length>a;)i.pop();i.some(c=>c.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let a=0;a500&&d.buffer.length>500)if((c.score-d.score||c.buffer.length-d.buffer.length)>0)i.splice(f--,1);else{i.splice(a--,1);continue e}}}i.length>12&&(i.sort((a,c)=>c.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,c,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=gi?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(c),gi&&console.log(a+this.stackID(e)+` (via always-reduce ${o.getName(c&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 z2(e,t),!0}}runRecovery(e,t,i){let l=null,o=!1;for(let a=0;a ":"";if(c.deadEnd&&(o||(o=!0,c.restart(),gi&&console.log(m+this.stackID(c)+" (restarted)"),this.advanceFully(c,i))))continue;let g=c.split(),b=m;for(let v=0;v<10&&g.forceReduce()&&(gi&&console.log(b+this.stackID(g)+" (via force-reduce)"),!this.advanceFully(g,i));v++)gi&&(b=this.stackID(g)+" -> ");for(let v of c.recoverByInsert(f))gi&&console.log(m+this.stackID(v)+" (via recover-insert)"),this.advanceFully(v,i);this.stream.end>c.pos?(d==c.pos&&(d++,f=0),c.recoverByDelete(f,d),gi&&console.log(m+this.stackID(c)+` (via recover-delete ${this.parser.getName(f)})`),z2(c,i)):(!l||l.scoren;class b9{constructor(e){this.start=e.start,this.shift=e.shift||mx,this.reduce=e.reduce||mx,this.reuse=e.reuse||mx,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class wd extends PN{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 c=0;ce.topRules[c][1]),l=[];for(let c=0;c=0)o(m,f,c[d++]);else{let g=c[d+-m];for(let b=-m;b>0;b--)o(c[d++],f,g);d++}}}this.nodeSet=new Cy(t.map((c,f)=>li.define({name:f>=this.minRepeatTerm?void 0:c,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=_N;let a=kh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let c=0;ctypeof c=="number"?new ra(a,c):c),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 x9(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++],c=a&1,f=l[o++];if(c&&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(c=>c.from==i.external);if(!o)return i;let a=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[l]=B2(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 Fo=63,P2=64,w9=1,k9=2,lA=3,S9=4,sA=5,C9=6,O9=7,oA=65,N9=66,T9=8,A9=9,E9=10,M9=11,D9=12,aA=13,j9=19,R9=20,_9=29,L9=33,z9=34,B9=47,P9=0,qy=1,_0=2,iu=3,L0=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,P9);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 z0(n){return n==32||n==9}function Zr(n){return n==10||n==13}function cA(n){return z0(n)||Zr(n)}function js(n){return n<0||cA(n)}const H9=new b9({start:Es.top,reduce(n,e){return n.type==iu&&(e==R9||e==z9)?n.parent:n},shift(n,e,t,i){if(e==lA)return new Es(n,Bc(i,i.pos),qy);if(e==oA||e==sA)return new Es(n,Bc(i,i.pos),_0);if(e==Fo)return n.parent;if(e==j9||e==L9)return new Es(n,0,iu);if(e==aA&&n.type==L0)return n.parent;if(e==B9){let l=/[1-9]/.exec(i.read(i.pos,t.pos));if(l)return new Es(n,n.depth+ +l[0],L0)}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&&js(n.peek(t+3))}const I9=new $d((n,e)=>{if(n.next==-1&&e.canShift(P2))return n.acceptToken(P2);let t=n.peek(-1);if((Zr(t)||t<0)&&e.context.type!=iu){if(ga(n,45))if(e.canShift(Fo))n.acceptToken(Fo);else return n.acceptToken(w9,3);if(ga(n,46))if(e.canShift(Fo))n.acceptToken(Fo);else return n.acceptToken(k9,3);let i=0;for(;n.next==32;)i++,n.advance();(i{if(e.context.type==iu){n.next==63&&(n.advance(),js(n.next)&&n.acceptToken(O9));return}if(n.next==45)n.advance(),js(n.next)&&n.acceptToken(e.context.type==qy&&e.context.depth==Bc(n,n.pos-1)?S9:lA);else if(n.next==63)n.advance(),js(n.next)&&n.acceptToken(e.context.type==_0&&e.context.depth==Bc(n,n.pos-1)?C9:sA);else{let t=n.pos;for(;;)if(z0(n.next)){if(n.pos==t)return;n.advance()}else if(n.next==33)uA(n);else if(n.next==38)B0(n);else if(n.next==42){B0(n);break}else if(n.next==39||n.next==34){if(Vy(n,!0))break;return}else if(n.next==91||n.next==123){if(!q9(n))return;break}else{fA(n,!0,!1,0);break}for(;z0(n.next);)n.advance();if(n.next==58){if(n.pos==t&&e.canShift(_9))return;let i=n.peek(1);js(i)&&n.acceptTokenTo(e.context.type==_0&&e.context.depth==Bc(n,t)?N9:oA,t)}}},{contextual:!0});function F9(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 H2(n){return n>=48&&n<=57||n>=97&&n<=102||n>=65&&n<=70}function I2(n,e){return n.next==37?(n.advance(),H2(n.next)&&n.advance(),H2(n.next)&&n.advance(),!0):F9(n.next)||e&&n.next==44?(n.advance(),!0):!1}function uA(n){if(n.advance(),n.next==60){for(n.advance();;)if(!I2(n,!0)){n.next==62&&n.advance();break}}else for(;I2(n,!1););}function B0(n){for(n.advance();!js(n.next)&&kd(n.next)!="f";)n.advance()}function Vy(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 q9(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(!Vy(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 V9="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function kd(n){return n<33?"u":n>125?"s":V9[n-33]}function px(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)&&px(n.peek(1),t))n.advance();else return!1;let l=n.pos;for(;;){let o=n.next,a=0,c=i+1;for(;cA(o);){if(Zr(o)){if(e)return!1;c=0}else c++;o=n.peek(++a)}if(!(o>=0&&(o==58?px(n.peek(a+1),t):o==35?n.peek(a-1)!=32:px(o,t)))||!t&&c<=i||c==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 Q9=new $d((n,e)=>{if(n.next==33)uA(n),n.acceptToken(D9);else if(n.next==38||n.next==42){let t=n.next==38?E9:M9;B0(n),n.acceptToken(t)}else n.next==39||n.next==34?(Vy(n,!1),n.acceptToken(A9)):fA(n,!1,e.context.type==iu,e.context.depth)&&n.acceptToken(T9)}),X9=new $d((n,e)=>{let t=e.context.type==L0?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:H9,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[$9],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:[I9,U9,Q9,X9,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Y9=sd.define({name:"yaml",parser:G9.configure({props:[qN.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:t2({closing:"}"}),FlowSequence:t2({closing:"]"})}),XN.add({"FlowMapping FlowSequence":QL,"Item Pair BlockLiteral":(n,e)=>({from:e.doc.lineAt(n.from).to,to:n.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function K9(){return new _L(Y9)}const U2='button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], video[tabindex], [tabindex]:not([tabindex="-1"])';function tl({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 c=(i==null?void 0:i.current)??((f=t.current)==null?void 0:f.querySelector(U2))??t.current;c==null||c.focus()}),a=c=>{if(c.key!=="Tab")return;const f=t.current;if(!f)return;const d=Array.from(f.querySelectorAll(U2));if(!d.length)return;const m=d[0],g=d[d.length-1],b=document.activeElement;if(!(b instanceof Node&&f.contains(b))){c.preventDefault(),(c.shiftKey?g:m).focus();return}c.shiftKey&&(b===m||b===f)?(c.preventDefault(),g.focus()):!c.shiftKey&&(b===g||b===f)&&(c.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 Wo({isOpen:n,title:e,message:t,confirmLabel:i="Confirm",cancelLabel:l="Cancel",danger:o=!1,onConfirm:a,onCancel:c}){const f=E.useRef(null),d=E.useRef(null),m=tl({isOpen:n,onClose:c,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:c,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(Dd,{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:c,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 W9=qC();const gr=8,Hl=8,Z9=400,F2={top:"bottom",bottom:"top",left:"right",right:"left"},J9={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"},e8={top:"border-b border-r",bottom:"border-t border-l",left:"border-t border-r",right:"border-b border-l"},q2=(n,e,t)=>{switch(n){case"top":return e.top-Hl-t.h>=gr;case"bottom":return e.bottom+Hl+t.h<=window.innerHeight-gr;case"left":return e.left-Hl-t.w>=gr;default:return e.right+Hl+t.w<=window.innerWidth-gr}},t8=(n,e,t)=>{if(n==="top"||n==="bottom"){const a=e.left+e.width/2-t.w/2,c=window.innerWidth-t.w-gr;return{x:Math.min(Math.max(a,gr),Math.max(gr,c))-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),c=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,j=a.current;if(!D||!j)return;const H=D.getBoundingClientRect(),Z={w:j.offsetWidth,h:j.offsetHeight},I=q2(i,H,Z)?i:q2(F2[i],H,Z)?F2[i]:i,F=t8(I,H,Z);b(I),w(F);const A=H.left+H.width/2,ne=H.top+H.height/2;C(I==="top"?{left:A,top:H.top-Hl-Z.h}:I==="bottom"?{left:A,top:H.bottom+Hl}:I==="left"?{left:H.left-Hl-Z.w,top:ne}:{left:H.right+Hl,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 j=()=>{_(),m(!0)};D?j():f.current=window.setTimeout(j,Z9)},P=()=>{O(),m(!1)};E.useEffect(()=>{if(!d)return;const D=j=>{j.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 j=new MutationObserver(()=>{D()&&m(!1)});return j.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["role","aria-modal","open","class"]}),()=>j.disconnect()},[d]);const L={onMouseEnter:()=>M(!1),onMouseLeave:P,onFocus:()=>M(!0),onBlur:P,"aria-describedby":c};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:P,onFocus:()=>M(!0),onBlur:P,children:[E.cloneElement(e,L),W9.createPortal(y.jsxs("span",{ref:a,id:c,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 ${J9[g]} ${e8[g]}`,style:g==="top"||g==="bottom"?{left:`calc(50% - ${v.x}px)`}:void 0})]}),document.body)]})},n8=[".profiles",".profiles.yaml"];function i8(n){const e=n.trim();if(!e)return null;const t=e.toLowerCase(),i=n8.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 r8({open:n,onCancel:e,onConfirm:t}){const[i,l]=E.useState(null),[o,a]=E.useState(""),[c,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),P=E.useCallback(async H=>{b(!0),w(null);try{const Z=await QC(H);l(Z),a(Z.current_path)}catch(Z){w(Z instanceof Error?Z.message:String(Z))}finally{b(!1)}},[]);E.useEffect(()=>{if(!n)return;f(""),m(null),C(null),P(o);const H=requestAnimationFrame(()=>{var Z;return(Z=_.current)==null?void 0:Z.focus()});return()=>cancelAnimationFrame(H)},[n]);const L=tl({isOpen:n,onClose:e,dialogRef:O,initialFocusRef:_});function D(){if(!i)return;const H=i8(c);if(H===null){m("Not a ProFiles configuration file. Allowed extensions: .profiles, .profiles.yaml");return}m(null);const Z=o.trim()||i.current_path;if(o.trim()===i.current_path&&i.items.some(A=>!A.is_dir&&A.name===H)){C({filename:H,directory:Z});return}t({filename:H,directory:Z,overwrite:!1})}if(!n)return null;const j=(i==null?void 0:i.items.filter(H=>H.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:L,onClick:H=>H.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:H=>a(H.target.value),onKeyDown:H=>{H.key==="Enter"&&P(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 P(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 P(""),"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 P(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 P(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:[j.map(H=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>void P(H.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:H.name})]})},H.path)),j.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(Il,{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:c,onChange:H=>{f(H.target.value),m(null)},onKeyDown:H=>{H.key==="Enter"&&c.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:!c.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(Wo,{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 H=S;C(null),H&&t({...H,overwrite:!0})},onCancel:()=>C(null)})]})}const l8=800,s8=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)"}}),o8=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 gx(n){return n.replace(/\r\n?/g,` +`)}function Sh(n,e){return n!==null&&n.state.doc.toString()!==e}function a8(n){return n instanceof ny&&Array.isArray(n.detail)?{text:n.message,issues:n.detail}:{text:n instanceof Error?n.message:String(n),issues:[]}}function c8({open:n,onClose:e,onApplied:t,onLoadConfig:i,reloadKey:l=0}){const[o,a]=E.useState({status:"loading"}),[c,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,P]=E.useState({line:1,col:1}),[L,D]=E.useState(null),[j,H]=E.useState(null),[Z,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(""),J=E.useRef(null),Y=E.useRef(0),T=E.useRef(new Map),he=E.useRef(null),ye=E.useRef(null),B=E.useRef(!1),R=E.useRef(()=>{}),V=E.useRef(()=>{});B.current=j!==null||Z!==null||F!==null;const ue=tl({isOpen:n,onClose:Ne,dialogRef:ne});E.useEffect(()=>{if(!n){oe.current="",J.current=null,ie.current=null,a({status:"loading"}),f(!1),m(!1),b(null),w([]),C({kind:"unknown"}),_(!1),P({line:1,col:1}),D(null),H(null),I(null),A(null),he.current!==null&&(clearTimeout(he.current),he.current=null),ye.current=null,Y.current+=1,T.current.clear();return}let ce=!1;return Rk().then(xe=>{if(ce)return;const Le=gx(xe.content);oe.current=Le,J.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)},[]),je=E.useCallback(ce=>{B.current||ce!==ye.current&&(pe(),he.current=window.setTimeout(()=>{if(he.current=null,T.current.has("test")){V.current(ce);return}R.current()},l8))},[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:[u9,K9(),tT(o8),s8,Ae.updateListener.of(Le=>{if(Le.selectionSet||Le.docChanged){const we=Le.state.selection.main.head,pt=Le.state.doc.lineAt(we);P({line:pt.number,col:we-pt.from+1})}Le.docChanged&&(f(Sh(Le.view,oe.current)),b(null),w([]),C({kind:"unknown"}),_(!1),je(Le.state.doc.toString()))})],parent:ce});return ie.current=xe,()=>{xe.destroy(),ie.current=null,pe()}},[n,o]);function Ne(){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(T.current.has(ce))return;const Le=++Y.current;T.current.set(ce,Le);try{await xe(Le)}finally{T.current.get(ce)===Le&&T.current.delete(ce)}},[]),jt=E.useCallback(()=>Ee("new",async ce=>{b(null),w([]);try{const xe=await EM();if(ce!==Y.current)return;const Le=gx(xe.content);oe.current=Le,J.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 Rk();if(ce!==Y.current)return;const Le=gx(xe.content);oe.current=Le,J.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}jt()}function zt(){if(Sh(ie.current,oe.current)){D("revert");return}Ut()}const mt=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 _k(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]);R.current=()=>void mt(),V.current=je;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=>{H({issues:ce,resolve:Le=>{H(null),xe(Le)}})}),[]),Tn=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,J.current=Le,f(!1),w([]),C({kind:"unknown"}),H(null),I(null),ce.config_path){const we=ce.config_path.split(/[\\/]/).pop()||ce.title||"configuration";a(pt=>pt.status!=="ready"||!(pt.data.filename!==we||pt.data.config_path!==ce.config_path||pt.data.session_trial)?pt:{status:"ready",data:{...pt.data,filename:we,config_path:ce.config_path,session_trial:!1,content:xe}})}t==null||t(ce)},[t]),Ce=E.useCallback(ce=>{const xe=a8(ce);H(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 pt=await _k(xe,we);if(Le!==Y.current)return;let An=!1;if(pt.valid)C({kind:"valid"});else{if(C({kind:"invalid",count:pt.issues.length}),w(pt.issues),_(!0),An=await Xt(pt.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 Tn();if(Le!==Y.current||mn===null)return;const Tt=await MM({content:we,filename:mn.filename,directory:mn.directory,force:An,overwrite:mn.overwrite});if(Le!==Y.current)return;tn(Tt.config,we,Tt.contentHash),b({kind:"ok",text:`Configuration saved as ${mn.filename}.`})}else{let mn;try{mn=await Lk(we,An,{baselineHash:J.current})}catch(Tt){if(!(Tt instanceof ny)||Tt.status!==409)throw Tt;const ht=await en();if(Le!==Y.current)return;if(!ht){Ut();return}mn=await Lk(we,An,{baselineHash:J.current,overwriteChanges:!0})}if(Le!==Y.current)return;tn(mn.config,we,mn.contentHash),b({kind:"ok",text:`Configuration saved to ${xe}.`})}}catch(pt){if(Le!==Y.current)return;Ce(pt)}}),[Xt,Tn,en,o,tn,Ce,Ut,Ee]),Ve=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]),te=E.useRef(()=>{});if(te.current=()=>{o.status==="ready"&&(j!==null||Z!==null||F!==null||d||L!==null||(o.data.config_path!==null?Ve():$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(),te.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)&&Ne()},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(D4,{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(L4,{className:"h-3.5 w-3.5"}),"New"]}),y.jsxs("button",{type:"button",onClick:()=>void mt(),disabled:ze,title:"Validate the editor content in memory",className:"btn btn-secondary px-2.5 py-1.5",children:[y.jsx(H4,{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(fD,{className:"h-3.5 w-3.5"}),"Revert"]}),Dt&&y.jsxs("button",{type:"button",onClick:()=>void Ve(),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(dD,{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(Fl,{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(Vo,{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(iy,{className:"h-3.5 w-3.5"}),"Open in OS"]}),y.jsx("button",{type:"button",onClick:Ne,"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(ri,{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(ri,{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(Dd,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}):y.jsx(ry,{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(h4,{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"]}),c&&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(m4,{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(Wo,{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(Wo,{isOpen:L!==null,title:"Replace current edits?",message:L==="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=L;D(null),ce==="new"?jt():ce==="revert"&&Ut()},onCancel:()=>D(null)}),y.jsx(Wo,{isOpen:j!==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:j==null?void 0:j.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:()=>j==null?void 0:j.resolve(!0),onCancel:()=>j==null?void 0:j.resolve(!1)}),y.jsx(Wo,{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(r8,{open:Z!==null,onCancel:()=>Z==null?void 0:Z.resolve(null),onConfirm:ce=>Z==null?void 0:Z.resolve(ce)})]})}function u8({position:n,onClose:e,onLaunch:t,onLaunchWithArgs:i,onReveal:l,onOpenFolder:o,onOpenTerminal:a,onScanDirectory:c,onFilterFolder:f,onFilterExtension:d,onCopyPath:m,onCopyFilename:g,onCopyUri:b,onComputeHash:v,onVerifyHash:w,onProperties:S,onClearFile:C,onGenerateBarcode:O,showToast:_}){const[M,P]=E.useState(!1),[L,D]=E.useState(""),j=E.useRef(null),H=E.useRef(null),Z=E.useRef(null),[I,F]=E.useState(null);if(E.useEffect(()=>{var Y;M&&((Y=H.current)==null||Y.showModal())},[M]),E.useLayoutEffect(()=>{if(!n){F(null);return}const Y=()=>{const T=j.current;if(!T)return;const he=T.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;Z.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const Y=window.requestAnimationFrame(()=>{var T,he;(he=(T=j.current)==null?void 0:T.querySelector("[role='menuitem']"))==null||he.focus()});return()=>{var T;window.cancelAnimationFrame(Y),(T=Z.current)==null||T.focus()}},[n]),!n)return null;const{file:A,x:ne,y:ae}=n,ie=()=>{i(A,L),P(!1),e()},$=Y=>{const T=Y.lastIndexOf(".");return T!==-1?Y.slice(T):""},oe=Y=>{const T=Math.max(Y.lastIndexOf("/"),Y.lastIndexOf("\\"));return T!==-1?Y.slice(0,T):Y},J=Y=>{const T=Math.max(Y.lastIndexOf("/"),Y.lastIndexOf("\\"));return T!==-1?Y.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:Y=>{Y.preventDefault(),e()},"aria-hidden":"true"}),y.jsxs("div",{ref:j,role:"menu","aria-label":`Actions for ${A.filename}`,tabIndex:0,onKeyDown:Y=>{var ye,B,R,V;["Escape","ArrowDown","ArrowUp","Home","End"].includes(Y.key)&&Y.stopPropagation();const T=Array.from(((ye=j.current)==null?void 0:ye.querySelectorAll("[role='menuitem']"))??[]),he=T.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;(B=T[(he+ue+T.length)%T.length])==null||B.focus()}else Y.key==="Home"?(Y.preventDefault(),(R=T[0])==null||R.focus()):Y.key==="End"&&(Y.preventDefault(),(V=T.at(-1))==null||V.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(Fl,{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:()=>{P(!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(Fl,{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(zx,{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(Il,{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(ly,{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);c(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(Il,{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=J(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(Bx,{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(Bx,{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(Fn,{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(Fn,{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(Fn,{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(Fn,{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(T){_==null||_(`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(Fn,{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(Fn,{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(Qo,{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(Qo,{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(Qo,{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(Qo,{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(zx,{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:H,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===H.current&&P(!1)},onCancel:Y=>{Y.preventDefault(),P(!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:L,onChange:Y=>D(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&ie(),Y.key==="Escape"&&P(!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:()=>P(!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 f8({isOpen:n,initialPath:e,onClose:t,onSelect:i}){const[l,o]=E.useState(null),[a,c]=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 L;if(!n){(L=C.current)==null||L.focus();return}C.current=document.activeElement instanceof HTMLElement?document.activeElement:null,v(null),O(e||"");const P=requestAnimationFrame(()=>{var D;return(D=S.current)==null?void 0:D.focus()});return()=>{var D;cancelAnimationFrame(P),(D=C.current)==null||D.focus()}},[n]);const O=async P=>{g(!0),v(null);try{const L=await fetch(`/api/fs/browse?path=${encodeURIComponent(P)}`);if(!L.ok)throw new Error("Failed to browse directory");const D=await L.json();o(D),c(D.current_path),d(D.current_path)}catch(L){v(L.message||"Navigation failed")}finally{g(!1)}},_=()=>{const P=f.trim()||a;P&&(i(P),t())},M=P=>{var H;if(P.key==="Escape"){P.preventDefault(),t();return}if(P.key!=="Tab")return;const L=(H=w.current)==null?void 0:H.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(L!=null&&L.length))return;const D=L[0],j=L[L.length-1];P.shiftKey&&document.activeElement===D?(P.preventDefault(),j.focus()):!P.shiftKey&&document.activeElement===j&&(P.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:P=>P.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(Il,{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(ri,{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:P=>d(P.target.value),onKeyDown:P=>{P.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(P=>P.is_dir).map(P=>y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>O(P.path),onDoubleClick:()=>{d(P.path),i(P.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===P.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:P.name})]}),a===P.path&&y.jsx(Sr,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},P.path)),(l==null?void 0:l.items.filter(P=>P.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(Il,{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(Il,{className:"h-4 w-4"}),"Select folder"]})]})]})]})}):null}function h8({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(Vo,{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 P0({id:n,ariaLabel:e,value:t,options:i,onChange:l,placeholder:o,className:a="",inputClassName:c="",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,P]=E.useState(null),L=i.filter(F=>f(F).toLocaleLowerCase().includes(S.toLocaleLowerCase())),D=O>=0&&L[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 j=()=>{C(""),_(-1),w(!0)},H=F=>{P(null),l(F)},Z=F=>{H(F),C(""),_(-1),w(!1)},I=F=>{if(F.key==="ArrowDown"){if(F.preventDefault(),!v){j(),_(0);return}_(A=>Math.min(A+1,L.length-1))}else if(F.key==="ArrowUp"){if(F.preventDefault(),!v){j(),_(L.length-1);return}_(A=>A<=0?L.length-1:A-1)}else F.key==="Enter"&&v&&L[O]!==void 0?(F.preventDefault(),F.stopPropagation(),Z(L[O])):F.key==="Enter"&&m==="deferred"&&M!==null&&M!==t?(F.preventDefault(),F.stopPropagation(),H(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&&H(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"?P(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 ${c}`}),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):j(),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(o4,{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:L.length>0?L.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:()=>Z(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 d8(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 m8({title:n,release:e,directories:t,activeDirectory:i,onDirectoryChange:l,onBrowseDirectory:o,onGoToParentDirectory:a,onGoToHomeDirectory:c,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",d8(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(P0,{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(KM,{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(Il,{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"})})}),c&&y.jsx(Xe,{text:"Set directory to your home folder",block:!1,children:y.jsx("button",{type:"button",onClick:c,"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 p8({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(Fn,{className:"h-3.5 w-3.5"})})]})}function g8({open:n,systemInfo:e,showToast:t,onConfirmed:i,onClose:l}){const[o,a]=E.useState(null),[c,f]=E.useState(null),[d,m]=E.useState(null),[g,b]=E.useState(null),v=E.useRef(null),w=E.useRef(null),S=E.useRef(0),C=E.useRef(!1);E.useEffect(()=>{C.current=n},[n]),E.useEffect(()=>{n&&(S.current+=1,a(null),f(null))},[n]);const O=window.location.port,_=e?`http://${e.hostname}:${O}`:null,M=e?`http://${e.ip}:${O}`:null,P=`http://127.0.0.1:${O}`,L=(e==null?void 0:e.lan_enabled)===!0;E.useEffect(()=>{if(!n||!M)return;let Z=!1;return m(null),b(null),Lx({content:M}).then(I=>{Z||m(I.image)}).catch(I=>{Z||b(I instanceof Error?I.message:"Failed to generate the QR code")}),()=>{Z=!0}},[n,M]);const D=tl({isOpen:n,onClose:l,dialogRef:v,initialFocusRef:w});if(!n)return null;const j=async()=>{try{await navigator.clipboard.writeText(P),t("URL copied to clipboard.")}catch{t("Failed to copy URL.","error")}},H=async Z=>{const I=++S.current;f(null),a(Z?"enable":"disable");try{await CM(Z);const F=await OM(Z);if(F&&i(F),I!==S.current)return;a(null),(F==null?void 0:F.lan_enabled)===Z?C.current||t(Z?"ProFiles is now reachable on the local network.":"ProFiles is restricted to this machine.","info"):(f("Failed to update LAN binding — the previous address is still active."),C.current||t("Failed to update LAN binding — the previous address is still active.","error"))}catch(F){const A=F instanceof Error?F.message:"Failed to update LAN binding";if(I!==S.current)return;a(null),f(`Failed to update LAN binding: ${A}`);const ne=await Qh();i(ne),C.current||t(`Failed to update LAN binding: ${A}`,"error")}};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",onClick:l,children:y.jsxs("div",{ref:v,role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",onKeyDown:D,onClick:Z=>Z.stopPropagation(),className:"animate-modal-in w-[480px] max-w-full rounded-2xl border border-frame-line glass-panel p-5",children:[y.jsxs("div",{className:"mb-4 flex items-center gap-2.5",children:[y.jsx("span",{className:`grid h-9 w-9 shrink-0 place-items-center rounded-lg ${o!==null?"bg-status-warning-bg text-status-warning-text":L?"bg-status-success-bg text-status-success-text":"bg-elevated text-ink-muted"}`,children:o==="disable"||!L&&o===null?y.jsx(AD,{className:"h-5 w-5"}):y.jsx(MD,{className:"h-5 w-5"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h2",{id:"lan-modal-title",className:"text-sm font-semibold tracking-tight text-ink",children:"LAN Access"}),y.jsx("p",{role:"status",className:`mt-0.5 flex items-center gap-1.5 text-xs font-medium ${o!==null?"text-status-warning-text":L?"text-status-success-text":"text-ink-muted"}`,children:o!==null?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"h-2.5 w-2.5 shrink-0 animate-spin rounded-full border-2 border-current border-t-transparent","aria-hidden":"true"}),"Updating the LAN binding…"]}):L?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"h-[7px] w-[7px] shrink-0 rounded-full bg-current","aria-hidden":"true"}),"Reachable on this network"]}):y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"h-[7px] w-[7px] shrink-0 rounded-full bg-current","aria-hidden":"true"}),"Restricted to the host machine"]})})]}),y.jsx("button",{type:"button",onClick:l,"aria-label":"Close",title:"Close",className:"focus-ring rounded-md p-1 text-ink-muted hover:bg-elevated hover:text-ink",children:y.jsx(ri,{className:"h-4 w-4"})})]}),y.jsxs("div",{className:"flex items-start gap-4",children:[y.jsxs("div",{className:"flex w-40 shrink-0 flex-col items-center gap-1.5",children:[y.jsx("div",{className:"h-40 w-40 overflow-hidden rounded-lg border border-line bg-white p-2",children:d?y.jsx("img",{src:d,alt:"QR code of the LAN address",className:"h-full w-full object-contain"}):g?y.jsx("span",{role:"alert",className:"flex h-full items-center justify-center px-1 text-center text-[10px] text-status-danger-text",children:g}):y.jsx("span",{className:"flex h-full items-center justify-center text-[10px] text-ink-faint","aria-hidden":"true",children:"…"})}),y.jsx("p",{className:"text-center text-[10px] text-ink-faint",children:"Scans the IP address"})]}),y.jsxs("div",{className:"min-w-0 flex-1 text-xs text-ink-secondary",children:[o===null&&c&&y.jsx("div",{role:"alert",className:"mb-2.5 rounded-md border border-status-danger-border bg-status-danger-bg p-2.5 text-status-danger-text",children:c}),y.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink-muted",children:"For other devices"}),M&&y.jsx(V2,{url:M,label:"Copy IP URL",className:"mt-1.5 rounded-lg bg-elevated/40 px-2 py-1.5",onCopied:()=>t("URL copied to clipboard."),onCopyError:()=>t("Failed to copy URL.","error")}),_&&y.jsx(V2,{url:_,label:"Copy hostname URL",className:"mt-1.5 rounded-lg bg-elevated/40 px-2 py-1.5",onCopied:()=>t("URL copied to clipboard."),onCopyError:()=>t("Failed to copy URL.","error")}),y.jsx("p",{className:"mt-3 text-[10px] font-semibold uppercase tracking-wider text-ink-muted",children:"This machine"}),y.jsxs("span",{className:"mt-1.5 flex items-center gap-1.5 rounded-lg bg-elevated/40 px-2 py-1.5",children:[y.jsx(iy,{className:"h-3.5 w-3.5 shrink-0 text-ink-faint","aria-hidden":"true"}),y.jsx("a",{href:P,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 break-all font-mono text-[11px] text-ink underline decoration-line underline-offset-2 hover:text-indigo-400",children:P}),y.jsx("button",{type:"button","aria-label":"Copy loopback URL",title:"Copy loopback URL",onClick:()=>void j(),className:"focus-ring shrink-0 rounded p-1 text-ink-faint transition-colors hover:bg-elevated hover:text-ink",children:y.jsx(Fn,{className:"h-3.5 w-3.5"})})]})]})]}),!L&&o===null&&y.jsxs("div",{className:"mt-3.5 flex items-center gap-2 rounded-lg border border-status-warning-border bg-status-warning-bg p-2.5 text-[11.5px] font-medium text-status-warning-text",children:[y.jsx(Dd,{className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),"If Enabled, ProFiles will be reachable by anyone on this network."]}),y.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[y.jsx("button",{ref:w,type:"button",onClick:l,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:o!==null,onClick:()=>void H(!L),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 disabled:cursor-not-allowed disabled:opacity-50 ${L?"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:L?"Disable LAN":"Enable LAN"})]})]})})}const Q2=/"([^"]*)"|(\S+)/g,X2=/"([^"]*)"/g,x8="Unmatched quote";function y8(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;X2.lastIndex=0;let o;for(;(o=X2.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('"')?x8:null}}function hA(n){const e=n.trim();if(!e)return{error:null,groups:[]};const{terms:t,error:i}=y8(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 b8=256,Ss=new Map;function $2(n){return n.toLowerCase()}function v8(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($2),excludes:l.excludes.map($2)}))};if(Ss.size>=b8){const l=Ss.keys().next().value;l!==void 0&&Ss.delete(l)}return Ss.set(n,i),i}function w8(n,e){return e.includes.every(t=>n.includes(t))&&!e.excludes.some(t=>n.includes(t))}function k8(n,e){const{groups:t}=v8(e);if(t.length===0)return!0;const i=n.toLowerCase();return t.some(l=>w8(i,l))}function S8({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 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 C8({extensions:n,activeExtension:e,onExtensionChange:t,filterOptions:i,filterText:l,onFilterTextChange:o,recursive:a,onRecursiveChange:c,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,P]=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:G2,suppress:O,children:y.jsxs("div",{className:"relative min-w-0 flex-1 basis-64",onFocusCapture:L=>{L.target.tagName==="INPUT"&&C(!0)},onBlurCapture:L=>{L.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(P0,{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:L=>L||"(No filter)"}),y.jsx(S8,{query:l,visible:S&&!O&&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(P0,{id:"extension-combobox",ariaLabel:"Extension filter",value:e,options:n,onChange:t,commitOn:"deferred",onOpenChange:P,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:L=>c(L.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(Fl,{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(ly,{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(YC,{className:"h-3.5 w-3.5"})})})]})}const O8=2e3,N8=500,T8=[{value:null,label:"ALL"},{value:"DEBUG",label:"DEBUG"},{value:"INFO",label:"INFO"},{value:"WARNING",label:"WARNING"},{value:"ERROR",label:"ERROR"},{value:"CRITICAL",label:"CRITICAL"}],Y2={DEBUG:{icon:t4,className:"text-chip-sky-text"},INFO:{icon:ry,className:"text-status-success-text"},WARNING:{icon:Dd,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 A8({isOpen:n,onClose:e,onOpenExternally:t}){const[i,l]=E.useState([]),[o,a]=E.useState("profiles.log"),[c,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,P]=E.useState(!0),L=E.useRef(null),D=E.useRef(null),j=E.useRef(null),H=E.useRef(null),Z=E.useRef(S),I=E.useRef({level:d,search:g}),F=E.useRef(0),A=E.useRef(!0);Z.current=S,I.current={level:d,search:g};const ne=E.useCallback(async()=>{const J=++F.current,{level:Y,search:T}=I.current;w(!0);try{const he=await SM({limit:N8,level:Y,search:T});if(F.current!==J)return;l(he.entries),a(he.path),f(he.size_bytes),_(null)}catch(he){if(F.current!==J)return;_((he==null?void 0:he.message)||"Failed to read the log file")}finally{F.current===J&&w(!1)}},[]);E.useEffect(()=>{n&&ne()},[n,ne]),E.useEffect(()=>{if(!n||!S)return;const J=window.setInterval(()=>{ne()},O8);return()=>window.clearInterval(J)},[n,S,ne]),E.useEffect(()=>{if(!n){A.current=!0;return}if(A.current){A.current=!1;return}const J=window.setTimeout(()=>void ne(),250);return()=>window.clearTimeout(J)},[n,d,g,ne]),E.useEffect(()=>{if(!M)return;const J=j.current;J&&(J.scrollTop=J.scrollHeight)},[i,M]),E.useEffect(()=>{if(!n)return;const J=document.activeElement instanceof HTMLElement?document.activeElement:null,Y=requestAnimationFrame(()=>{var T;return(T=D.current)==null?void 0:T.focus()});return()=>{cancelAnimationFrame(Y),J==null||J.focus()}},[n]);const ae=J=>{var ye;if(J.key==="Escape"){J.preventDefault(),e();return}if(J.key!=="Tab")return;const Y=(ye=L.current)==null?void 0:ye.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(Y!=null&&Y.length))return;const T=Y[0],he=Y[Y.length-1];J.shiftKey&&document.activeElement===T?(J.preventDefault(),he.focus()):!J.shiftKey&&document.activeElement===he&&(J.preventDefault(),T.focus())},ie=()=>{const J=j.current;if(!J)return;const Y=J.scrollHeight-J.scrollTop-J.clientHeight<24;P(Y)},$=async()=>{try{await navigator.clipboard.writeText(i.map(J=>J.raw).join(` +`))}catch{}},oe=E.useMemo(()=>{const J=new Map;for(const Y of i)J.set(Y.level,(J.get(Y.level)??0)+1);return J},[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:L,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:J=>J.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:[" · ",K2(c)]})]})]})]}),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:H,type:"search",value:g,onChange:J=>b(J.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(J=>!J),"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(Fn,{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(iy,{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(ri,{className:"h-4 w-4","aria-hidden":"true"})})})]})]}),y.jsxs("div",{ref:j,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((J,Y)=>{const T=Y2[J.level]??Y2.UNKNOWN,he=T.icon,ye=J.level==="ERROR"||J.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:T.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:J.timestamp}),y.jsx("span",{className:`w-[52px] shrink-0 text-[10px] font-semibold ${T.className}`,children:J.level}),y.jsx("span",{className:"w-[150px] shrink-0 truncate text-ink-faint",title:J.source,children:J.source}),y.jsx("span",{className:"min-w-0 flex-1 break-words text-ink-secondary",children:J.message})]},`${Y}-${J.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 ${K2(c)} 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:T8.map(J=>{const Y=d===J.value,T=J.value?oe.get(J.value)??0:i.length;return y.jsxs("button",{type:"button",onClick:()=>m(J.value),"aria-pressed":Y,title:J.value?`Show ${J.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:[J.label,y.jsx("span",{className:Y?"text-chip-indigo-text":"text-ink-faint",children:T})]},J.label)})}),y.jsx(Xe,{text:"Scroll to the newest entry",block:!1,children:y.jsxs("button",{type:"button",onClick:()=>P(!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(GC,{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 K2(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function E8({isOpen:n,onClose:e}){const t=E.useRef(null),i=tl({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 + K",desc:"Open the LAN access modal"},{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(ri,{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 M8({isOpen:n,activeConfigPath:e,configExists:t=!0,onClose:i,onLoaded:l}){const[o,a]=E.useState(null),[c,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),_=t===!1;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 j=e??"",H=Math.max(j.lastIndexOf("/"),j.lastIndexOf("\\")),Z=H>0?j.slice(0,H):"";M(Z);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,e]);const M=async j=>{b(!0),w(null);try{const H=await DM(j);a(H),f(H.current_path),e&&H.items.some(Z=>Z.path===e)?m(e):m(null)}catch(H){w(H.message||"Navigation failed")}finally{b(!1)}},P=j=>{var F;if(j.key==="Escape"){j.preventDefault(),i();return}if(j.key!=="Tab")return;const H=(F=S.current)==null?void 0:F.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])');if(!(H!=null&&H.length))return;const Z=H[0],I=H[H.length-1];j.shiftKey&&document.activeElement===Z?(j.preventDefault(),I.focus()):!j.shiftKey&&document.activeElement===I&&(j.preventDefault(),Z.focus())},L=async()=>{var H;const j=d||(((H=o==null?void 0:o.items.find(Z=>Z.is_config))==null?void 0:H.path)??null);if(!j){w("Select a configuration file to load.");return}try{b(!0);const Z=await NM(j);l(Z),i()}catch(Z){w(Z.message||"Unable to load configuration")}finally{b(!1)}},D=async()=>{const j=(c||(o==null?void 0:o.current_path)||"").trim();if(!j){w("Choose a directory before creating a configuration.");return}try{b(!0);const H=await AM(j);l(H),i()}catch(H){w(H.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:P,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:j=>j.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(Vo,{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(ri,{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:c,onChange:j=>f(j.target.value),onKeyDown:j=>{j.key==="Enter"&&M(c.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(c.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(c||(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(j=>{if(j.is_dir)return y.jsx("li",{children:y.jsx("button",{onClick:()=>M(j.path),onDoubleClick:()=>M(j.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"}),j.name]})})},j.path);const H=d===j.path;return y.jsx("li",{children:y.jsxs("button",{type:"button",onClick:()=>m(j.path),"aria-pressed":H,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 ${H?"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:j.name})]}),j.is_config&&y.jsx(Vo,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"}),H&&y.jsx(Sr,{className:"h-4 w-4 shrink-0 text-chip-indigo-text"})]})},j.path)}),(o==null?void 0:o.items.filter(j=>j.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||c,children:d||c||"—"})]}),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:!c.trim(),className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Vo,{className:"h-4 w-4"}),"Create configuration"]}):y.jsxs("button",{type:"button",onClick:L,disabled:!d,className:"btn btn-primary min-h-10 rounded-lg px-4 text-sm font-semibold",children:[y.jsx(Vo,{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,c]=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),[P,L]=E.useState(null),D=E.useRef(null),j=E.useRef(0),H=E.useRef(null),Z=tl({isOpen:n,onClose:e,dialogRef:D});E.useEffect(()=>{n||H.current!==null&&(window.clearTimeout(H.current),H.current=null)},[n]),E.useEffect(()=>{if(!n)return;async function T(){if(t){g(!0);try{const he=await Lx({filePath:t});o(he.image),c(he.content),I(he.content)}catch(he){v(he.message)}finally{g(!1)}}}T()},[n,t]);const I=T=>{const he=T.split(";").map(ye=>{const B=ye.split("=");return{key:B[0]||"",value:B[1]||""}}).filter(ye=>ye.key||ye.value);d(he)},F=async T=>{const he=++j.current;try{const ye=await Lx({content:T});if(j.current!==he)return;o(ye.image),S(null)}catch(ye){if(j.current!==he)return;S(ye instanceof Error?ye.message:"Failed to generate the barcode")}},A=T=>{const he=T.filter(ye=>ye.key.trim()).map(ye=>`${ye.key.trim()}=${ye.value.trim()}`).join(";");if(c(he),H.current!==null&&(window.clearTimeout(H.current),H.current=null),!he){j.current+=1,o(null),S(null);return}H.current=window.setTimeout(()=>void F(he),250)},ne=(T,he,ye)=>{const B=[...f];B[T][he]=ye,d(B),A(B)},ae=()=>{const T=[...f,{key:"",value:""}];d(T)},ie=T=>{const he=f.filter((ye,B)=>B!==T);d(he),A(he)},$=()=>{if(!i||f.some(he=>he.key.toLowerCase()==="md5"))return;const T=[...f,{key:"md5",value:i}];d(T),A(T)},oe=async()=>{if(l){L("Saving…");try{const T=await BM(l,`profiles-qr-${Date.now()}.png`);L(T.path||T.message)}catch(T){L(`Save failed: ${(T==null?void 0:T.message)??T}`)}finally{setTimeout(()=>L(null),6e3)}}},J=async()=>{try{await navigator.clipboard.writeText(a),O(!0),setTimeout(()=>O(!1),2e3)}catch(T){console.error("Copy failed",T)}},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(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:D,role:"dialog","aria-modal":"true","aria-label":"QR Code Settings",onKeyDown:Z,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(ri,{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(Fn,{className:"h-3.5 w-3.5"}),_?"Copied":"Copy Image"]})})]}),y.jsxs("div",{className:"flex w-full gap-2",children:[y.jsxs("button",{onClick:J,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(Fn,{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(KC,{className:"h-3.5 w-3.5"}),"Save Image"]})]}),P&&y.jsx("p",{className:"break-all text-center text-[11px] text-ink-muted",role:"status",children:P}),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:$,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(Qo,{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(lD,{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,he)=>y.jsxs("div",{className:"flex gap-2 items-center slide-in",children:[y.jsx("input",{type:"text",placeholder:"key",value:T.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:T.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 W2=["Bytes","KB","MB","GB","TB"];function mA(n){if(n===0)return"0 Bytes";const e=1024,t=Math.max(0,Math.min(W2.length-1,Math.floor(Math.log(n)/Math.log(e))));return parseFloat((n/Math.pow(e,t)).toFixed(2))+" "+W2[t]}function D8(n){const e=Math.max(n.lastIndexOf("\\"),n.lastIndexOf("/"));return e===-1?"":n.slice(0,e)}function j8(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 xx(n,e,t){return n.length<=e+t+1?n:`${n.slice(0,e)}…${n.slice(-t)}`}function R8(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 _8=[{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 Z2(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 _8){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 P.current=A,o(null),O(null),c(!0),d(null),(async()=>{try{const ne=await LM(e.path,A.signal);if(P.current!==A)return;o(ne)}catch(ne){if(P.current!==A||ne instanceof DOMException&&ne.name==="AbortError")return;d(ne instanceof Error?ne.message:"Failed to load properties")}finally{P.current===A&&c(!1)}})(),()=>{P.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],J=document.activeElement instanceof HTMLElement?document.activeElement:null;ne.shiftKey?(J===$||!ae.contains(J))&&(ne.preventDefault(),oe.focus()):J===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 L=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)}},j=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"}`,H=(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:()=>L(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(Fn,{className:"h-3.5 w-3.5 text-ink-muted"})})})]}),Z=(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 L(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:R8(l.path)}),m==="path"?y.jsx(Sr,{className:"text-status-success-text h-3.5 w-3.5"}):y.jsx(Fn,{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(Pg,{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&&L(j8(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(Fn,{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(ly,{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(ri,{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:Z2(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:Z2(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:xx(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(Y4,{className:"h-3 w-3"})," Symlink"]})]}),I(),y.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[Z("Hashes",y.jsx(Qo,{className:"text-chip-purple-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[H("MD5",l.md5,"md5",!0,xx(l.md5,10,6)),H("SHA256",l.sha256,"sha256",!0,xx(l.sha256,10,6))]})),Z("Timestamps",y.jsx(i4,{className:"text-chip-sky-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[H("Created",l.created,"created",!0),H("Modified",l.modified,"modified",!0)]})),Z("Identity",y.jsx(Pg,{className:"text-chip-indigo-text h-3.5 w-3.5"}),y.jsxs("div",{className:"space-y-0.5",children:[H("Type",l.type,"type"),l.attributes.stem&&H("Stem",l.attributes.stem,"attrStem"),H("Extension",l.name.includes(".")?l.name.slice(l.name.lastIndexOf(".")):"None","extension"),H("Directory",D8(l.path)||"None","directory",!0)]})),Z("System",y.jsx(Pg,{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(Z4,{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(N4,{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:[H("File Type",l.attributes.is_file?"Regular File":l.attributes.is_dir?"Directory":"Other","fileType"),l.attributes.permissions&&H("Permissions",l.attributes.permissions,"permissions",!0),l.attributes.owner_uid!==void 0&&H("Owner UID",String(l.attributes.owner_uid),"ownerUid"),l.attributes.group_gid!==void 0&&H("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",()=>XC(F.path)),disabled:w!==null,className:j("reveal"),children:[y.jsx(zx,{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:j("launch"),children:[y.jsx(Fl,{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",()=>_x(F.path)),disabled:w!==null,className:j("folder"),children:[y.jsx(Il,{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 z8=["qr_code","code_128","code_39","ean_13","ean_8","upc_a","upc_e","data_matrix"],B8=250,P8=400,H8=.7;function I8(n,e=P8,t=H8){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 c=a.getContext("2d");if(!c)return null;c.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 U8(n,e){const t=n.intervalMs??B8;let i=!1,l=!1;const o=()=>{i=!0,clearInterval(a)},a=setInterval(()=>{if(i||l)return;const c=n.capture();c&&(l=!0,n.decode(c).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 F8=8e3;function q8({isOpen:n,onClose:e,onDetected:t}){const i=E.useRef(null),l=E.useRef(null),o=tl({isOpen:n,onClose:e,dialogRef:l}),a=E.useRef(null),c=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),c.current&&(cancelAnimationFrame(c.current),c.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,P,L,D,j;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 _=((P=(M=navigator.mediaDevices)==null?void 0:M.getUserMedia)==null?void 0:P.bind(navigator.mediaDevices))||((L=navigator.getUserMedia)==null?void 0:L.bind(navigator))||((D=navigator.webkitGetUserMedia)==null?void 0:D.bind(navigator))||((j=navigator.mozGetUserMedia)==null?void 0:j.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 H;const Z=await Promise.race([_({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}}),new Promise((I,F)=>{H=window.setTimeout(()=>F(new DOMException("Camera did not start in time","TimeoutError")),F8)})]).finally(()=>{H!==void 0&&window.clearTimeout(H)});if(!C){Z.getTracks().forEach(I=>I.stop());return}a.current=Z,i.current&&(i.current.srcObject=Z,await i.current.play()),"BarcodeDetector"in window?S():w()}catch(H){if(!C)return;console.error("Camera access error:",H),m(H.name==="NotAllowedError"||H.name==="PermissionDeniedError"?"Camera permission denied. Please allow camera access in your browser settings.":H.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: ${H.message||"Unknown error"}`)}}return O(),()=>{C=!1,v()}},[n]);const w=()=>{b(!0),f.current=U8({capture:()=>i.current?I8(i.current):null,decode:C=>_M({imageBase64:C,formats:[...z8]})},{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){c.current=requestAnimationFrame(_);return}try{const M=await O.detect(i.current);if(M&&M.length>0){const P=M[0].rawValue;if(P){v(),t(P);return}}}catch(M){console.debug("Frame detection error:",M)}c.current=requestAnimationFrame(_)};c.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(YC,{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(ri,{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 V8({isOpen:n,file:e,onConfirm:t,onDismiss:i}){const l=E.useRef(null);return E.useEffect(()=>{var o;if(n){const a=c=>{c.key==="Enter"?(c.preventDefault(),t()):c.key==="Escape"&&(c.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(jD,{className:"h-4 w-4 text-chip-purple-text"}):y.jsx(Fl,{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(ri,{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(Fl,{className:"h-3 w-3 fill-current"}),"Launch (Enter)"]})]})]})})}function Q8({systemInfo:n,fileCount:e,theme:t,onToggleTheme:i,onOpenLog:l,onOpenConfig:o,onShowShortcuts:a,onReloadConfig:c,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(OD,{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(nD,{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:"|"}),c&&y.jsx(Xe,{text:"Reload configuration from disk",block:!1,children:y.jsxs("button",{onClick:c,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(KC,{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(q4,{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(xD,{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(bD,{className:"h-3 w-3 text-status-warning-text"}):y.jsx(eD,{className:"h-3 w-3 text-chip-indigo-text"}),y.jsx("span",{children:t==="dark"?"Light":"Dark"})]})})]})]})}const X8=[{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 $8({isOpen:n,currentInterval:e,onClose:t,onSetInterval:i}){const l=E.useRef(null),o=tl({isOpen:n,onClose:t,dialogRef:l});if(!n)return null;const a=e>0,c=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(ri,{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(y4,{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(g4,{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:X8.map(m=>y.jsx("button",{onClick:()=>c(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(w4,{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 G8(n,e){const t={};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const Y8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,K8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,W8={};function J2(n,e){return(W8.jsx?K8:Y8).test(n)}const Z8=/[ \t\n\f\r]/g;function J8(n){return typeof n=="object"?n.type==="text"?eC(n.value):!1:eC(n)}function eC(n){return n.replace(Z8,"")===""}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 H0(n){return n.toLowerCase()}class si{constructor(e,t){this.attribute=t,this.property=e}}si.prototype.attribute="";si.prototype.booleanish=!1;si.prototype.boolean=!1;si.prototype.commaOrSpaceSeparated=!1;si.prototype.commaSeparated=!1;si.prototype.defined=!1;si.prototype.mustUseProperty=!1;si.prototype.number=!1;si.prototype.overloadedBoolean=!1;si.prototype.property="";si.prototype.spaceSeparated=!1;si.prototype.space=void 0;let eP=0;const Qe=Fs(),Zt=Fs(),I0=Fs(),ge=Fs(),Ct=Fs(),zs=Fs(),xi=Fs();function Fs(){return 2**++eP}const U0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:Zt,commaOrSpaceSeparated:xi,commaSeparated:zs,number:ge,overloadedBoolean:I0,spaceSeparated:Ct},Symbol.toStringTag,{value:"Module"})),yx=Object.keys(U0);class Qy extends si{constructor(e,t,i,l){let o=-1;if(super(e,t),tC(this,"space",l),typeof i=="number")for(;++o4&&t.slice(0,4)==="data"&&lP.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(nC,aP);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!nC.test(o)){let a=o.replace(rP,oP);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}l=Qy}return new l(i,e)}function oP(n){return"-"+n.toLowerCase()}function aP(n){return n.charAt(1).toUpperCase()}const cP=pA([gA,tP,bA,vA,wA],"html"),Xy=pA([gA,nP,bA,vA,wA],"svg");function uP(n){return n.join(" ").trim()}var iC=/\/\*(?:[^*]|\*(?!\/))*\*\//g,fP=/\n/g,hP=/^\s*/,dP=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,mP=/^:\s*/,pP=/^((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|url\((?:'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|[^)]*)\)|[^};])+)/,gP=/^[;\s]*/,xP=` +`,rC="/",lC="*",wc="",yP="comment",bP="declaration";function vP(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(fP);S&&(t+=S.length);var C=w.lastIndexOf(xP);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 c(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(hP)}function m(w){for(var S;S=g();)w.push(S);return w}function g(){var w=o();if(!(rC!=n.charAt(0)||lC!=n.charAt(1))){for(var S=2;wc!=n.charAt(S)&&(lC!=n.charAt(S)||rC!=n.charAt(S+1));)++S;if(S+=2,wc===n.charAt(S-1))return c("End of comment missing");var C=n.slice(2,S-2);return i+=2,l(C),n=n.slice(S),i+=2,w({type:yP,comment:C})}}function b(){var w=o(),S=f(dP);if(S){if(g(),!f(mP))return c("property missing ':'");var C=f(pP),O=w({type:bP,property:S[0].replace(iC,wc).trim(),value:C?C[0].replace(iC,wc).trim():wc});return f(gP),O}}function v(){var w=[];m(w);for(var S;S=b();)w.push(S),m(w);return w}return d(),v()}function wP(n,e){let t=null;if(!n||typeof n!="string")return t;const i=vP(n),l=typeof e=="function";return i.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:c}=o;l?e(a,c,o):c&&(t=t??{},t[a]=c)}),t}const kA=SA("end"),$y=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 kP(n){const e=$y(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?sC(n.position):"start"in n||"end"in n?sC(n):"line"in n||"column"in n?F0(n):""}function F0(n){return oC(n&&n.line)+":"+oC(n&&n.column)}function sC(n){return F0(n&&n.start)+"-"+F0(n&&n.end)}function oC(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 c=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=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=l,this.line=c?c.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 Gy={}.hasOwnProperty,SP=new Map,CP=/[A-Z]/g,OP=/-([a-z])/g,NP=new Set(["table","tbody","thead","tfoot","tr"]),TP=new Set(["td","th"]),CA="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function AP(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=zP(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=LP(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"?Xy:cP,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 EP(n,e,t);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return MP(n,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return jP(n,e,t);if(e.type==="mdxjsEsm")return DP(n,e);if(e.type==="root")return RP(n,e,t);if(e.type==="text")return _P(n,e)}function EP(n,e,t){const i=n.schema;let l=i;e.tagName.toLowerCase()==="svg"&&i.space==="html"&&(l=Xy,n.schema=l),n.ancestors.push(e);const o=TA(n,e.tagName,!1),a=BP(n,e);let c=Ky(n,e);return NP.has(e.tagName)&&(c=c.filter(function(f){return typeof f=="string"?!J8(f):!0})),NA(n,a,o,e),Yy(a,c),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function MP(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 DP(n,e){if(e.data&&e.data.estree&&n.evaluater)return n.evaluater.evaluateProgram(e.data.estree);ru(n,e.position)}function jP(n,e,t){const i=n.schema;let l=i;e.name==="svg"&&i.space==="html"&&(l=Xy,n.schema=l),n.ancestors.push(e);const o=e.name===null?n.Fragment:TA(n,e.name,!0),a=PP(n,e),c=Ky(n,e);return NA(n,a,o,e),Yy(a,c),n.ancestors.pop(),n.schema=i,n.create(e,o,a,t)}function RP(n,e,t){const i={};return Yy(i,Ky(n,e)),n.create(e,n.Fragment,i,t)}function _P(n,e){return e.value}function NA(n,e,t,i){typeof t!="string"&&t!==n.Fragment&&n.passNode&&(e.node=i)}function Yy(n,e){if(e.length>0){const t=e.length>1?e:e[0];t&&(n.children=t)}}function LP(n,e,t){return i;function i(l,o,a,c){const d=Array.isArray(a.children)?t:e;return c?d(o,a,c):d(o,a)}}function zP(n,e){return t;function t(i,l,o,a){const c=Array.isArray(o.children),f=$y(i);return e(l,o,a,c,{columnNumber:f?f.column-1:void 0,fileName:n,lineNumber:f?f.line:void 0},void 0)}}function BP(n,e){const t={};let i,l;for(l in e.properties)if(l!=="children"&&Gy.call(e.properties,l)){const o=HP(n,l,e.properties[l]);if(o){const[a,c]=o;n.tableCellAlignToStyle&&a==="align"&&typeof c=="string"&&TP.has(e.tagName)?i=c:t[a]=c}}if(i){const o=t.style||(t.style={});o[n.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return t}function PP(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 c=a.properties[0];c.type,Object.assign(t,n.evaluater.evaluateExpression(c.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 c=i.value.data.estree.body[0];c.type,o=n.evaluater.evaluateExpression(c.expression)}else ru(n,e.position);else o=i.value===null?!0:i.value;t[l]=o}return t}function Ky(n,e){const t=[];let i=-1;const l=n.passKeys?new Map:SP;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 uC={}.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]/),YP=Zl(/[#-'*+\--9=?A-Z^-~]/);function Sd(n){return n!==null&&(n<32||n===127)}const q0=Zl(/\d/),KP=Zl(/[\dA-Fa-f]/),DA=Zl(/[!-/:-@[-`{-~]/);function He(n){return n!==null&&n<-2}function Nt(n){return n!==null&&(n<0||n===32)}function Je(n){return n===-2||n===-1||n===32}const Gd=Zl(new RegExp("\\p{P}|\\p{S}","u")),Is=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 c=n.charCodeAt(t+1);o<56320&&c>56319&&c<57344?(a=String.fromCharCode(o,c),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),c(f)):e(f)}function c(f){return Je(f)&&o++=l?e(m):t(m)}}const WP={tokenize:ZP};function ZP(n){const e=n.attempt(this.parser.constructs.contentInitial,i,l);let t;return e;function i(c){if(c===null){n.consume(c);return}return n.enter("lineEnding"),n.consume(c),n.exit("lineEnding"),ft(n,e,"linePrefix")}function l(c){return n.enter("paragraph"),o(c)}function o(c){const f=n.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=f),t=f,a(c)}function a(c){if(c===null){n.exit("chunkText"),n.exit("paragraph"),n.consume(c);return}return He(c)?(n.consume(c),n.exit("chunkText"),o):(n.consume(c),a)}}let Cd=class{constructor(){this.index=new Map,this.map=[]}add(e,t,i){fC(this,e,t,i,!1)}addBefore(e,t,i){fC(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 fC(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 JP={tokenize:eH},hC={tokenize:tH};function eH(n){const e=this,t=[];let i=0,l,o,a;return c;function c(M){if(ia))return;const j=e.events.length;let H=j,Z,I;for(;H--;)if(e.events[H][0]==="exit"&&e.events[H][1].type==="chunkFlow"){if(Z){I=e.events[H][1].end;break}Z=!0}for(O(i),D=j;DM;){const L=t[P];e.containerState=L[1],L[0].exit.call(e,n)}t.length=M}function _(){l.write([null]),o=void 0,l=void 0,e.containerState._closeFlow=void 0}}function tH(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 Kl(n){if(n===null||Nt(n)||Is(n))return 1;if(Gd(n))return 2}function Yd(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},c={...n[t][1].start};dC(a,-o),dC(c,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:c},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,Yd(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(Q0,S,P)(D):(n.enter("codeFlowValue"),M(D))}function M(D){return D===null||He(D)?(n.exit("codeFlowValue"),_(D)):(n.consume(D),M)}function P(D){return n.exit("codeFenced"),e(D)}function L(D,j,H){let Z=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===c?(D.enter("codeFencedFenceSequence"),ne(ie)):H(ie)}function ne(ie){return ie===c?(Z++,D.consume(ie),ne):Z>=a?(D.exit("codeFencedFenceSequence"),Je(ie)?ft(D,ae,"whitespace")(ie):ae(ie)):H(ie)}function ae(ie){return ie===null||He(ie)?(D.exit("codeFencedFence"),j(ie)):H(ie)}}}const vx={name:"codeIndented",tokenize:pH},mH={partial:!0,tokenize:gH};function pH(n,e,t){return i;function i(c){return n.enter("codeIndented"),jA(n,l,t,"linePrefix",4,4)(c)}function l(c){return c===null?a(c):He(c)?n.attempt(mH,l,a)(c):(n.enter("codeFlowValue"),o(c))}function o(c){return c===null||He(c)?(n.exit("codeFlowValue"),l(c)):(n.consume(c),o)}function a(c){return n.exit("codeIndented"),e(c)}}function gH(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):jA(n,e,o,"linePrefix",4,4)(a)}function o(a){return He(a)?l(a):t(a)}}const xH={name:"codeText",previous:bH,resolve:yH,tokenize:vH};function yH(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,c,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(c),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(c),n.enter("chunkString",{contentType:"string"}),v(O))}function v(O){return O===62?(n.exit("chunkString"),n.exit(c),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||Nt(O))?(n.exit("chunkString"),n.exit(c),n.exit(a),n.exit(i),e(O)):m999||v===null||v===91||v===93&&!f||v===94&&!c&&"_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)||c++>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),c++,g):g(v)}}function HA(n,e,t,i,l,o){let a;return c;function c(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 AH={name:"definition",tokenize:MH},EH={partial:!0,tokenize:DH};function MH(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,c,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function c(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 Nt(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(EH,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 DH(n,e,t){return i;function i(c){return Nt(c)?Hc(n,l)(c):t(c)}function l(c){return HA(n,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return Je(c)?ft(n,a,"whitespace")(c):a(c)}function a(c){return c===null||He(c)?e(c):t(c)}}const jH={name:"hardBreakEscape",tokenize:RH};function RH(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 _H={name:"headingAtx",resolve:LH,tokenize:zH};function LH(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 zH(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||Nt(m)?(n.exit("atxHeadingSequence"),c(m)):t(m)}function c(m){return m===35?(n.enter("atxHeadingSequence"),f(m)):m===null||He(m)?(n.exit("atxHeading"),e(m)):Je(m)?ft(n,c,"whitespace")(m):(n.enter("atxHeadingText"),d(m))}function f(m){return m===35?(n.consume(m),f):(n.exit("atxHeadingSequence"),c(m))}function d(m){return m===null||m===35||Nt(m)?(n.exit("atxHeadingText"),c(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"],X0=["pre","script","style","textarea"],BH={concrete:!0,name:"htmlFlow",resolveTo:HH,tokenize:IH},PH={partial:!0,tokenize:UH};function HH(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 IH(n,e,t){const i=this;let l,o,a,c,f;return d;function d(B){return m(B)}function m(B){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(B),g}function g(B){return B===33?(n.consume(B),b):B===47?(n.consume(B),o=!0,S):B===63?(n.consume(B),l=3,i.interrupt?e:T):Cn(B)?(n.consume(B),a=String.fromCharCode(B),C):t(B)}function b(B){return B===45?(n.consume(B),l=2,v):B===91?(n.consume(B),l=5,c=0,w):Cn(B)?(n.consume(B),l=4,i.interrupt?e:T):t(B)}function v(B){return B===45?(n.consume(B),i.interrupt?e:T):t(B)}function w(B){const R="CDATA[";return B===R.charCodeAt(c++)?(n.consume(B),c===R.length?i.interrupt?e:A:w):t(B)}function S(B){return Cn(B)?(n.consume(B),a=String.fromCharCode(B),C):t(B)}function C(B){if(B===null||B===47||B===62||Nt(B)){const R=B===47,V=a.toLowerCase();return!R&&!o&&X0.includes(V)?(l=1,i.interrupt?e(B):A(B)):IA.includes(a.toLowerCase())?(l=6,R?(n.consume(B),O):i.interrupt?e(B):A(B)):(l=7,i.interrupt&&!i.parser.lazy[i.now().line]?t(B):o?_(B):M(B))}return B===45||On(B)?(n.consume(B),a+=String.fromCharCode(B),C):t(B)}function O(B){return B===62?(n.consume(B),i.interrupt?e:A):t(B)}function _(B){return Je(B)?(n.consume(B),_):I(B)}function M(B){return B===47?(n.consume(B),I):B===58||B===95||Cn(B)?(n.consume(B),P):Je(B)?(n.consume(B),M):I(B)}function P(B){return B===45||B===46||B===58||B===95||On(B)?(n.consume(B),P):L(B)}function L(B){return B===61?(n.consume(B),D):Je(B)?(n.consume(B),L):M(B)}function D(B){return B===null||B===60||B===61||B===62||B===96?t(B):B===34||B===39?(n.consume(B),f=B,j):Je(B)?(n.consume(B),D):H(B)}function j(B){return B===f?(n.consume(B),f=null,Z):B===null||He(B)?t(B):(n.consume(B),j)}function H(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Nt(B)?L(B):(n.consume(B),H)}function Z(B){return B===47||B===62||Je(B)?M(B):t(B)}function I(B){return B===62?(n.consume(B),F):t(B)}function F(B){return B===null||He(B)?A(B):Je(B)?(n.consume(B),F):t(B)}function A(B){return B===45&&l===2?(n.consume(B),$):B===60&&l===1?(n.consume(B),oe):B===62&&l===4?(n.consume(B),he):B===63&&l===3?(n.consume(B),T):B===93&&l===5?(n.consume(B),Y):He(B)&&(l===6||l===7)?(n.exit("htmlFlowData"),n.check(PH,ye,ne)(B)):B===null||He(B)?(n.exit("htmlFlowData"),ne(B)):(n.consume(B),A)}function ne(B){return n.check(Q0,ae,ye)(B)}function ae(B){return n.enter("lineEnding"),n.consume(B),n.exit("lineEnding"),ie}function ie(B){return B===null||He(B)?ne(B):(n.enter("htmlFlowData"),A(B))}function $(B){return B===45?(n.consume(B),T):A(B)}function oe(B){return B===47?(n.consume(B),a="",J):A(B)}function J(B){if(B===62){const R=a.toLowerCase();return X0.includes(R)?(n.consume(B),he):A(B)}return Cn(B)&&a.length<8?(n.consume(B),a+=String.fromCharCode(B),J):A(B)}function Y(B){return B===93?(n.consume(B),T):A(B)}function T(B){return B===62?(n.consume(B),he):B===45&&l===2?(n.consume(B),T):A(B)}function he(B){return B===null||He(B)?(n.exit("htmlFlowData"),ye(B)):(n.consume(B),he)}function ye(B){return n.exit("htmlFlow"),e(B)}}function UH(n,e,t){return i;function i(l){return n.enter("lineEnding"),n.consume(l),n.exit("lineEnding"),n.attempt(mu,e,t)}}const FH={name:"htmlText",tokenize:qH};function qH(n,e,t){const i=this;let l,o,a;return c;function c(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),L):T===63?(n.consume(T),M):Cn(T)?(n.consume(T),H):t(T)}function d(T){return T===45?(n.consume(T),m):T===91?(n.consume(T),o=0,w):Cn(T)?(n.consume(T),_):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):He(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?$(T):T===45?b(T):g(T)}function w(T){const he="CDATA[";return T===he.charCodeAt(o++)?(n.consume(T),o===he.length?S:w):t(T)}function S(T){return T===null?t(T):T===93?(n.consume(T),C):He(T)?(a=S,oe(T)):(n.consume(T),S)}function C(T){return T===93?(n.consume(T),O):S(T)}function O(T){return T===62?$(T):T===93?(n.consume(T),O):S(T)}function _(T){return T===null||T===62?$(T):He(T)?(a=_,oe(T)):(n.consume(T),_)}function M(T){return T===null?t(T):T===63?(n.consume(T),P):He(T)?(a=M,oe(T)):(n.consume(T),M)}function P(T){return T===62?$(T):M(T)}function L(T){return Cn(T)?(n.consume(T),D):t(T)}function D(T){return T===45||On(T)?(n.consume(T),D):j(T)}function j(T){return He(T)?(a=j,oe(T)):Je(T)?(n.consume(T),j):$(T)}function H(T){return T===45||On(T)?(n.consume(T),H):T===47||T===62||Nt(T)?Z(T):t(T)}function Z(T){return T===47?(n.consume(T),$):T===58||T===95||Cn(T)?(n.consume(T),I):He(T)?(a=Z,oe(T)):Je(T)?(n.consume(T),Z):$(T)}function I(T){return T===45||T===46||T===58||T===95||On(T)?(n.consume(T),I):F(T)}function F(T){return T===61?(n.consume(T),A):He(T)?(a=F,oe(T)):Je(T)?(n.consume(T),F):Z(T)}function A(T){return T===null||T===60||T===61||T===62||T===96?t(T):T===34||T===39?(n.consume(T),l=T,ne):He(T)?(a=A,oe(T)):Je(T)?(n.consume(T),A):(n.consume(T),ae)}function ne(T){return T===l?(n.consume(T),l=void 0,ie):T===null?t(T):He(T)?(a=ne,oe(T)):(n.consume(T),ne)}function ae(T){return T===null||T===34||T===39||T===60||T===61||T===96?t(T):T===47||T===62||Nt(T)?Z(T):(n.consume(T),ae)}function ie(T){return T===47||T===62||Nt(T)?Z(T):t(T)}function $(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"),J}function J(T){return Je(T)?ft(n,Y,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):Y(T)}function Y(T){return n.enter("htmlTextData"),a(T)}}const Jy={name:"labelEnd",resolveAll:$H,resolveTo:GH,tokenize:YH},VH={tokenize:KH},QH={tokenize:WH},XH={tokenize:ZH};function $H(n){let e=-1;const t=[];for(;++e0&&l[l.length-1]._balanced;)l.pop();o=l[l.length-1]}return c;function c(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(VH,m,a?m:g)(b):b===91?n.attempt(QH,m,a?d:g)(b):a?m(b):g(b)}function d(b){return n.attempt(XH,m,g)(b)}function m(b){return l.pop(),e(b)}function g(b){return o._balanced=!0,t(b)}}function KH(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 Nt(g)?Hc(n,o)(g):o(g)}function o(g){return g===41?m(g):BA(n,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function a(g){return Nt(g)?Hc(n,f)(g):m(g)}function c(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 Nt(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 WH(n,e,t){const i=this;return l;function l(c){return PA.call(i,n,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return i.parser.defined.includes(Ki(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(c):t(c)}function a(c){return t(c)}}function ZH(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 JH={name:"labelStartImage",resolveAll:Jy.resolveAll,tokenize:e7};function e7(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"),c):t(f)}function c(f){return f===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(f):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(f))}}const t7={name:"labelStartLink",resolveAll:Jy.resolveAll,tokenize:n7};function n7(n,e,t){const i=this;let l;return o;function o(c){return n.enter("labelLink"),n.enter("labelMarker"),n.consume(c),n.exit("labelMarker"),l=n.exit("labelLink"),a}function a(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?t(c):(i._labelStarts=i._labelStarts||[],i._labelStarts.push(l),e(c))}}const wx={name:"lineEnding",tokenize:i7};function i7(n,e){return t;function t(i){return n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),ft(n,e,"linePrefix")}}const qh={name:"thematicBreak",tokenize:r7};function r7(n,e,t){let i=0,l;return o;function o(d){return n.enter("thematicBreak"),a(d)}function a(d){return l=d,c(d)}function c(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,c,"whitespace")(d):c(d))}}const Zn={continuation:{tokenize:a7},exit:u7,name:"list",tokenize:o7},l7={partial:!0,tokenize:f7},s7={partial:!0,tokenize:c7};function o7(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 c;function c(v){const w=i.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||v===i.containerState.marker:q0(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(qh,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 q0(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(l7,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 a7(n,e,t){const i=this;return i.containerState._closeFlow=void 0,n.check(mu,l,o);function l(c){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,ft(n,e,"listItemIndent",i.containerState.size+1)(c)}function o(c){return i.containerState.furtherBlankLines||!Je(c)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(c)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,n.attempt(s7,e,a)(c))}function a(c){return i.containerState._closeFlow=!0,i.interrupt=void 0,ft(n,n.attempt(Zn,e,t),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function c7(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 u7(n){n.exit(this.containerState.type)}function f7(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 pC={name:"setextUnderline",resolveTo:h7,tokenize:d7};function h7(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 c={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",c,e]]),t.add(a+1,0,[["exit",n[l][1],e]]),n[l][1].end={...n[a][1].end}):n[l][1]=c,t.add(n.length,0,[["exit",c,e]]),t.consume(n),n}function d7(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"),c(d)}function c(d){return d===l?(n.consume(d),c):(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 m7={tokenize:p7};function p7(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(SH,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 g7={resolveAll:FA()},x7=UA("string"),y7=UA("text");function UA(n){return{resolveAll:FA(n==="text"?b7:void 0),tokenize:e};function e(t){const i=this,l=this.parser.constructs[n],o=t.attempt(l,a,c);return a;function a(m){return d(m)?o(m):c(m)}function c(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 c=a[0];typeof c=="string"?a[0]=c.slice(i):a.shift()}o>0&&a.push(n[l].slice(0,o))}return a}function j7(n,e){let t=-1;const i=[];let l;for(;++t0&&l(e.beforeEnter,{..._e,sliceSerialize:te[ce][2].sliceSerialize},te[ce][1]),qA.call(xe,te[ce][1].type)&&xe[te[ce][1].type].call({..._e,sliceSerialize:te[ce][2].sliceSerialize},te[ce][1]),te[ce][0]==="exit"&&e.afterExit.length>0&&l(e.afterExit,{..._e,sliceSerialize:te[ce][2].sliceSerialize},te[ce][1])}if(_e.tokenStack.length>0){const xe=_e.tokenStack[_e.tokenStack.length-1];(xe[1]||xC).call(_e,void 0,xe[0])}for(fe.position={start:jl(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:jl(te.length>0?te[te.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 X7(n,e){const t={type:"element",tagName:"del",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function $7(n,e){const t={type:"element",tagName:"em",properties:{},children:n.all(e)};return n.patch(e,t),n.applyData(e,t)}function G7(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,c=n.footnoteCounts.get(i);c===void 0?(c=0,n.footnoteOrder.push(i),a=n.footnoteOrder.length):a=o+1,c+=1,n.footnoteCounts.set(i,c);const f={type:"element",tagName:"a",properties:{href:"#"+t+"fn-"+l,id:t+"fnref-"+l+(c>1?"-"+c:""),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 Y7(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 K7(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 W7(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 Z7(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 J7(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 eI(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 tI(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 nI(n,e,t){const i=n.all(e),l=t?iI(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 c=-1;for(;++c1}function rI(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)},c=$y(e.children[1]),f=kA(e.children[e.children.length-1]);c&&f&&(a.position={start:c,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 cI(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,c=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(vC(e.slice(l),l>0,!1)),o.join("")}function vC(n,e,t){let i=0,l=n.length;if(e){let o=n.codePointAt(i);for(;o===yC||o===bC;)i++,o=n.codePointAt(i)}if(t){let o=n.codePointAt(l-1);for(;o===yC||o===bC;)l--,o=n.codePointAt(l-1)}return l>i?n.slice(i,l):""}function hI(n,e){const t={type:"text",value:fI(String(e.value))};return n.patch(e,t),n.applyData(e,t)}function dI(n,e){const t={type:"element",tagName:"hr",properties:{},children:[]};return n.patch(e,t),n.applyData(e,t)}const mI={blockquote:q7,break:V7,code:Q7,delete:X7,emphasis:$7,footnoteReference:G7,heading:Y7,html:K7,imageReference:W7,image:Z7,inlineCode:J7,linkReference:eI,link:tI,listItem:nI,list:rI,paragraph:lI,root:sI,strong:oI,table:aI,tableCell:uI,tableRow:cI,text:hI,thematicBreak:dI,toml:Ch,yaml:Ch,definition:Ch,footnoteDefinition:Ch};function Ch(){}const $A=-1,Kd=0,Ic=1,Od=2,eb=3,tb=4,nb=5,ib=6,GA=7,YA=8,{defineProperty:pI}=Object,KA=typeof self=="object"?self:globalThis,wC=(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)},gI=(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 Kd:case $A:return t(a,l);case Ic:{const c=t([],l);for(const f of a)c.push(i(f));return c}case Od:{const c=t({},l);for(const[f,d]of a){const m=i(f),g=i(d);m==="__proto__"?pI(c,m,{value:g,configurable:!0,enumerable:!0,writable:!0}):c[m]=g}return c}case eb:return t(new Date(a),l);case tb:{const{source:c,flags:f}=a;return t(new RegExp(c,f),l)}case nb:{const c=t(new Map,l);for(const[f,d]of a)c.set(i(f),i(d));return c}case ib:{const c=t(new Set,l);for(const f of a)c.add(i(f));return c}case GA:{const{name:c,message:f}=a;return t(typeof KA[c]=="function"?wC(c,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:c}=new Uint8Array(a);return t(new DataView(c),a)}case"-0":return-0}return t(wC(o,a),l)};return i},kC=n=>gI(new Map,n)(0),Ns="",{toString:xI}={},{keys:yI,is:bI}=Object,Sc=n=>{const e=typeof n;if(e!=="object"||!n)return[Kd,e];const t=xI.call(n).slice(8,-1);switch(t){case"Array":return[Ic,Ns];case"Object":return[Od,Ns];case"Date":return[eb,Ns];case"RegExp":return[tb,Ns];case"Map":return[nb,Ns];case"Set":return[ib,Ns];case"DataView":return[Ic,t]}return t.includes("Array")?[Ic,t]:n instanceof Error?[GA,n.name||"Error"]:[Od,t]},Oh=([n,e])=>n===Kd&&(e==="function"||e==="symbol"),vI=(n,e,t,i)=>{const l=(a,c)=>{const f=i.push(a)-1;return t.set(c,f),f},o=a=>{if(t.has(a))return t.get(a);let[c,f]=Sc(a);switch(c){case Kd:{let m=a;switch(f){case"bigint":c=YA,m=a.toString();break;case"number":if(!a&&bI(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([c,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([c,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([c,m],a);for(const b of yI(a))(n||!Oh(Sc(a[b])))&&m.push([o(b),o(a[b])]);return g}case eb:return l([c,isNaN(a.getTime())?Ns:a.toISOString()],a);case tb:{const{source:m,flags:g}=a;return l([c,{source:m,flags:g}],a)}case nb:{const m=[],g=l([c,m],a);for(const[b,v]of a)(n||!(Oh(Sc(b))||Oh(Sc(v))))&&m.push([o(b),o(v)]);return g}case ib:{const m=[],g=l([c,m],a);for(const b of a)(n||!Oh(Sc(b)))&&m.push(o(b));return g}}const{message:d}=a;return l([c,{name:f,message:d}],a)};return o},SC=(n,{json:e,lossy:t}={})=>{const i=[];return vI(!(e||t),!!e,new Map,i)(n),i},Nd=typeof structuredClone=="function"?(n,e)=>e&&("json"in e||"lossy"in e)?kC(SC(n,e)):structuredClone(n):(n,e)=>kC(SC(n,e));function wI(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 kI(n,e){return"Back to reference "+(n+1)+(e>1?"-"+e:"")}function SI(n){const e=typeof n.options.clobberPrefix=="string"?n.options.clobberPrefix:"user-content-",t=n.options.footnoteBackContent||wI,i=n.options.footnoteBackLabel||kI,l=n.options.footnoteLabel||"Footnotes",o=n.options.footnoteLabelTagName||"h2",a=n.options.footnoteLabelProperties||{className:["sr-only"]},c=[];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),c.push(O)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Nd(a),id:"footnote-label"},children:[{type:"text",value:l}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:n.wrap(c,!0)},{type:"text",value:` +`}]}}const Wd=(function(n){if(n==null)return TI;if(typeof n=="function")return Zd(n);if(typeof n=="object")return Array.isArray(n)?CI(n):OI(n);if(typeof n=="string")return NI(n);throw new Error("Expected function, string, or object as test")});function CI(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(c&&O&&(_=CC(c(b,w,v)),_[0]===Vh))return _;if("children"in b&&b.children){const M=b;if(M.children&&_[0]!==$0){let P=(l?-1:M.children.length)+m;const L=[...w,M];for(;P>-1&&P0&&t.push({type:"text",value:` +`}),t}function OC(n){let e=0,t=n.charCodeAt(e);for(;t===9||t===32;)e++,t=n.charCodeAt(e);return n.slice(e)}function NC(n,e){const t=jI(n,e),i=t.one(n,void 0),l=SI(t),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return l&&o.children.push({type:"text",value:` +`},l),o}function BI(n,e){return n&&"run"in n?async function(t,i){const l=NC(t,{file:i,...e});await n.run(l,i)}:function(t,i){return NC(t,{file:i,...n||e})}}function TC(n){if(n)throw n}var kx,AC;function PI(){if(AC)return kx;AC=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},c=function(d,m){if(m==="__proto__")if(n.call(d,m)){if(i)return i(d,m).value}else return;return d[m]};return kx=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;c&&a.push(l);try{f=n.apply(this,a)}catch(d){const m=d;if(c&&t)throw m;return l(m)}c||(f&&f.then&&typeof f.then=="function"?f.then(o,l):f instanceof Error?l(f):o(f))}function l(a,...c){t||(t=!0,e(a,...c))}function o(a){l(null,a)}}const pr={basename:FI,dirname:qI,extname:VI,join:QI,sep:"/"};function FI(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,c=e.length-1;for(;l--;)if(n.codePointAt(l)===47){if(o){t=l+1;break}}else a<0&&(o=!0,a=l+1),c>-1&&(n.codePointAt(l)===e.codePointAt(c--)?c<0&&(i=l):(c=-1,i=a));return t===i?i=a:i<0&&(i=n.length),n.slice(t,i)}function qI(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 VI(n){pu(n);let e=n.length,t=-1,i=0,l=-1,o=0,a;for(;e--;){const c=n.codePointAt(e);if(c===47){if(a){i=e+1;break}continue}t<0&&(a=!0,t=e+1),c===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 QI(...n){let e=-1,t;for(;++e0&&n.codePointAt(n.length-1)===47&&(t+="/"),e?"/"+t:t}function $I(n,e){let t="",i=0,l=-1,o=0,a=-1,c,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 c===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 GI={cwd:YI};function YI(){return"/"}function Z0(n){return!!(n!==null&&typeof n=="object"&&"href"in n&&n.href&&"protocol"in n&&n.protocol&&n.auth===void 0)}function KI(n){if(typeof n=="string")n=new URL(n);else if(!Z0(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 WI(n)}function WI(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];W0(S)&&W0(v)&&(v=Sx(!0,S,v)),i[b]=[d,v,...w]}}}}const tU=new lb().freeze();function Tx(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `parser`")}function Ax(n,e){if(typeof e!="function")throw new TypeError("Cannot `"+n+"` without `compiler`")}function Ex(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 MC(n){if(!W0(n)||typeof n.type!="string")throw new TypeError("Expected node, got `"+n+"`")}function DC(n,e,t){if(!t)throw new Error("`"+n+"` finished async. Use `"+e+"` instead")}function Nh(n){return nU(n)?n:new ZA(n)}function nU(n){return!!(n&&typeof n=="object"&&"message"in n&&"messages"in n)}function iU(n){return typeof n=="string"||rU(n)}function rU(n){return!!(n&&typeof n=="object"&&"byteLength"in n&&"byteOffset"in n)}const lU="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",jC=[],RC={allowDangerousHtml:!0},sU=/^(https?|ircs?|mailto|xmpp)$/i,oU=[{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 aU(n){const e=cU(n),t=uU(n);return fU(e.runSync(e.parse(t),t),n)}function cU(n){const e=n.rehypePlugins||jC,t=n.remarkPlugins||jC,i=n.remarkRehypeOptions?{...n.remarkRehypeOptions,...RC}:RC;return tU().use(F7).use(t).use(BI,i).use(e)}function uU(n){const e=n.children||"",t=new ZA;return typeof e=="string"&&(t.value=e),t}function fU(n,e){const t=e.allowedElements,i=e.allowElement,l=e.components,o=e.disallowedElements,a=e.skipHtml,c=e.unwrapDisallowed,f=e.urlTransform||hU;for(const m of oU)Object.hasOwn(e,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+lU+m.id,void 0);return rb(n,d),AP(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 bx)if(Object.hasOwn(bx,v)&&Object.hasOwn(m.properties,v)){const w=m.properties[v],S=bx[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 c&&m.children?b.children.splice(g,1,...m.children):b.children.splice(g,1),g}}}function hU(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||sU.test(n.slice(0,e))?n:""}function dU(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=Wd((t||{}).ignore||[]),o=mU(e);let a=-1;for(;++a0?{type:"text",value:D}:void 0),D===!1)v.lastIndex=P+1;else{if(S!==P&&M({type:"text",value:d.value.slice(S,P)}),Array.isArray(D))for(const j of D)M(j);else D&&M(D);S=P+_[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=_C(n,"(");let o=_C(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||Is(t)||Gd(t))&&(!e||t!==47)}tE.peek=IU;function jU(){this.buffer()}function RU(n){this.enter({type:"footnoteReference",identifier:"",label:""},n)}function _U(){this.buffer()}function LU(n){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},n)}function zU(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 BU(n){this.exit(n)}function PU(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 HU(n){this.exit(n)}function IU(){return"["}function tE(n,e,t,i){const l=t.createTracker(i);let o=l.move("[^");const a=t.enter("footnoteReference"),c=t.enter("reference");return o+=l.move(t.safe(t.associationId(n),{after:"]",before:o})),c(),a(),o+=l.move("]"),o}function UU(){return{enter:{gfmFootnoteCallString:jU,gfmFootnoteCall:RU,gfmFootnoteDefinitionLabelString:_U,gfmFootnoteDefinition:LU},exit:{gfmFootnoteCallString:zU,gfmFootnoteCall:BU,gfmFootnoteDefinitionLabelString:PU,gfmFootnoteDefinition:HU}}}function FU(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 c=o.createTracker(a);let f=c.move("[^");const d=o.enter("footnoteDefinition"),m=o.enter("label");return f+=c.move(o.safe(o.associationId(i),{before:f,after:"]"})),m(),f+=c.move("]:"),i.children&&i.children.length>0&&(c.shift(4),f+=c.move((e?` +`:" ")+o.indentLines(o.containerFlow(i,c.current()),e?nE:qU))),d(),f}}function qU(n,e,t){return e===0?n:nE(n,e,t)}function nE(n,e,t){return(t?"":" ")+n}const VU=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];sb.attention=YU;sb.peek=KU;function QU(){return{canContainEols:["delete"],enter:{strikethrough:$U},exit:{strikethrough:GU}}}function XU(){return{handlers:{delete:sb},unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:VU}]}}function $U(n){this.enter({type:"delete",children:[],position:void 0},n)}function GU(n){this.exit(n)}function sb(n,e,t,i){const l=t.createTracker(i),o=t.stack.includes("strikethrough")?"~":"~~",a=t.enter("strikethrough");let c=l.move(o);return c+=t.containerPhrasing(n,{...l.current(),before:c,after:"~"}),c+=l.move(o),a(),c}function YU(){return{construct:"strikethrough",markers:["~"],sizes:[2,1]}}function KU(){return"~"}function WU(n){return n.length}function ZU(n,e){const t=e||{},i=(t.align||[]).concat(),l=t.stringLength||WU,o=[],a=[],c=[],f=[];let d=0,m=-1;for(;++md&&(d=n[m].length);++Of[O])&&(f[O]=M)}S.push(_)}a[m]=S,c[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),c.splice(1,0,v),m=-1;const w=[];for(;++m "),o.shift(2);const a=t.indentLines(t.containerFlow(n,o.current()),nF);return l(),a}function nF(n,e,t){return">"+(t?"":" ")+n}function iF(n,e){return zC(n,e.inConstruct,!0)&&!zC(n,e.notInConstruct,!1)}function zC(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 lF(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 sF(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 oF(n,e,t,i){const l=sF(t),o=n.value||"";if(lF(n,t)){const g=t.enter("codeIndented"),b=t.indentLines(o,aF);return g(),b}const a=t.createTracker(i),c=l.repeat(Math.max(rF(o,l)+1,3)),f=t.enter("codeFenced"),d=l==="`"?"GraveAccent":"Tilde";let m=a.move(c);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(c),f(),m}function aF(n,e,t){return(t?"":" ")+n}function ob(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 cF(n,e,t,i){const l=ob(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("definition");let c=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("]: "),c(),!n.url||/[\0- \u007F]/.test(n.url)?(c=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(c=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":` +`,...f.current()}))),c(),n.title&&(c=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),c()),a(),d}function uF(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 Td(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 PC(n,e,t){const i=Kl(n),l=Kl(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 fF(n){if(n.charCodeAt(0)!==60)return;const e=n.charCodeAt(1);if(e===33){const c=n.charCodeAt(2);return c===45?2:c===91?5:Cn(c)?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&&X0.includes(a)?1:IA.includes(a)?6:7}const hF=new Map([["*",!1],["_",!0]]);function dF(n,e,t){const i=new Set;for(const o of n){const a=t.get(o);if(a&&o.attention&&e.some(c=>c.attention===o.attention))for(const c of a.tokens)i.add(c.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 pF(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=c.markers.slice(c.end-m,c.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)}}c.end-=m,i.start+=m,c.start===c.end&&o.splice(a,1),a=o.length}i.open&&i.start0?w[0].value:"",C=PC(b.charCodeAt(b.length-1),S.charCodeAt(0),m);C.inside&&Th(w,!0);const O=w.length>0?la(w[w.length-1].value):"",_=PC(v.charCodeAt(0),O.charCodeAt(O.length-1),m);_.inside&&Th(w,!1),C.outside&&b!==` +`&&b!=="\r"&&Th(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 Jd(n,e,t){let i=new Map;const l=cb(n,i,e,t);let o=l,a=rE(o,e,t);for(;a;){const f=mF(n,i,a,e,t);if(!f){o=l;break}i=f.chosen,o=f.tokens,a=f.mistake}let c="";for(const f of o)c+=f.value;return c}ub.attention=lE;ub.peek=yF;function ub(n,e,t,i){const l=t.enter("phrasing"),o=ab(n,lE,t,t.createTracker(i)),a=Jd([o],i.before,i.after);return l(),a}function lE(n,e){return{construct:"emphasis",markers:uF(e)==="*"?["*","_"]:["_","*"],sizes:[1]}}function yF(n,e,t){return t.options.emphasis||"*"}function bF(n,e){let t=!1;return rb(n,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return t=!0,Vh}),!!((!n.depth||n.depth<3)&&Wy(n)&&(e.options.setext||t))}function vF(n,e,t,i){const l=Math.max(Math.min(6,n.depth||1),1),o=t.createTracker(i);if(bF(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),c=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(),c(),d}sE.peek=wF;function sE(n){return n.value||""}function wF(){return"<"}oE.peek=kF;function oE(n,e,t,i){const l=ob(t),o=l==='"'?"Quote":"Apostrophe",a=t.enter("image");let c=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("]("),c(),!n.url&&n.title||/[\0- \u007F]/.test(n.url)?(c=t.enter("destinationLiteral"),d+=f.move("<"),d+=f.move(t.safe(n.url,{before:d,after:">",...f.current()})),d+=f.move(">")):(c=t.enter("destinationRaw"),d+=f.move(t.safe(n.url,{before:d,after:n.title?" ":")",...f.current()}))),c(),n.title&&(c=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),c()),d+=f.move(")"),a(),d}function kF(){return"!"}aE.peek=SF;function aE(n,e,t,i){const l=n.referenceType,o=t.enter("imageReference");let a=t.enter("label");const c=t.createTracker(i);let f=c.move("![");const d=t.safe(n.alt,{before:f,after:"]",...c.current()});f+=c.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:"]",...c.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=c.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=c.move("]"),f}function SF(){return"!"}cE.peek=CF;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=OF;function fE(n,e,t,i){const l=ob(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 c=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(")"),c(),d}function OF(n,e,t){return uE(n,t)?"<":"["}hE.peek=NF;function hE(n,e,t,i){const l=n.referenceType,o=t.enter("linkReference");let a=t.enter("label");const c=t.createTracker(i);let f=c.move("[");const d=t.containerPhrasing(n,{before:f,after:"]",...c.current()});f+=c.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:"]",...c.current()});return a(),t.stack=m,o(),l==="full"||!d||d!==g?f+=c.move(g+"]"):l==="shortcut"?f=f.slice(0,-1):f+=c.move("]"),f}function NF(){return"["}function fb(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 TF(n){const e=fb(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 AF(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 EF(n,e,t,i){const l=t.enter("list"),o=t.bulletCurrent;let a=n.ordered?AF(t):fb(t);const c=n.ordered?a==="."?")":".":TF(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 c=t.createTracker(i);c.move(o+" ".repeat(a-o.length)),c.shift(a);const f=t.enter("listItem"),d=t.indentLines(t.containerFlow(n,c.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 jF(n,e,t,i){const l=t.enter("paragraph"),o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),l(),a}function RF(n,e,t,i){if(!n.children.some(function(c){return eF(c)}))return t.containerFlow(n,i);const o=t.enter("phrasing"),a=t.containerPhrasing(n,i);return o(),a}function _F(n){const e=n.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}hb.attention=mE;hb.peek=LF;function hb(n,e,t,i){const l=t.enter("phrasing"),o=ab(n,mE,t,t.createTracker(i)),a=Jd([o],i.before,i.after);return l(),a}function mE(n,e){return{construct:"strong",markers:_F(e)==="*"?["*","_"]:["_","*"],sizes:[2]}}function LF(n,e,t){return t.options.strong||"*"}function zF(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 BF(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 PF(n,e,t){const i=(dE(t)+(t.options.ruleSpaces?" ":"")).repeat(BF(t));return t.options.ruleSpaces?i.slice(0,-1):i}const pE={blockquote:tF,break:BC,code:oF,definition:cF,emphasis:ub,hardBreak:BC,heading:vF,html:sE,image:oE,imageReference:aE,inlineCode:cE,link:fE,linkReference:hE,list:EF,listItem:DF,paragraph:jF,root:RF,strong:hb,text:zF,thematicBreak:PF};function HF(){return{enter:{table:IF,tableData:HC,tableHeader:HC,tableRow:FF},exit:{codeText:qF,table:UF,tableData:Rx,tableHeader:Rx,tableRow:Rx}}}function IF(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 UF(n){this.exit(n),this.data.inTable=void 0}function FF(n){this.enter({type:"tableRow",children:[]},n)}function Rx(n){this.exit(n)}function HC(n){this.enter({type:"tableCell",children:[]},n)}function qF(n){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,VF));const t=this.stack[this.stack.length-1];t.type,t.value=e,this.exit(n)}function VF(n,e){return e==="|"?e:n}function QF(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:c}};function a(v,w,S,C){return d(m(v,S,C),v.align)}function c(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 ZU(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 cq={tokenize:xq,partial:!0};function uq(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:mq,continuation:{tokenize:pq},exit:gq}},text:{91:{name:"gfmFootnoteCall",tokenize:dq},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:fq,resolveTo:hq}}}}function fq(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 c;function c(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 hq(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)},c=[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,...c),n}function dq(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,a;return c;function c(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||Nt(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 Nt(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 mq(n,e,t){const i=this,l=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,a=0,c;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&&!c||w===null||w===91||Nt(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 Nt(w)||(c=!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 pq(n,e,t){return n.check(mu,e,n.attempt(cq,e,t))}function gq(n){n.exit("gfmFootnoteDefinition")}function xq(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 yq(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,c){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=Kl(w);return C._open=!O||O===2&&!!S,C._close=!S||S===2&&!!O,c(w)}}}class bq{constructor(){this.map=[],this.index=new Map}add(e,t,i){vq(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 vq(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 wq(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||Nt(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):L(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)?P(I):L(I)}function O(I){return I===45?(n.enter("tableDelimiterFiller"),_(I)):L(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,P,"whitespace")(I):P(I)}function P(I){return I===124?w(I):I===null||He(I)?!a||l!==o?L(I):(n.exit("tableDelimiterRow"),n.exit("tableHead"),e(I)):L(I)}function L(I){return t(I)}function D(I){return n.enter("tableRow"),j(I)}function j(I){return I===124?(n.enter("tableCellDivider"),n.consume(I),n.exit("tableCellDivider"),j):I===null||He(I)?(n.exit("tableRow"),e(I)):Je(I)?ft(n,j,"whitespace")(I):(n.enter("data"),H(I))}function H(I){return I===null||I===124||Nt(I)?(n.exit("data"),j(I)):(n.consume(I),I===92?Z:H)}function Z(I){return I===92||I===124?(n.consume(I),H):H(I)}}function Cq(n,e){let t=-1,i=!0,l=0,o=[0,0,0,0],a=[0,0,0,0],c=!1,f=0,d,m,g;const b=new bq;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 UC(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 Oq={name:"tasklistCheck",tokenize:Tq};function Nq(){return{text:{91:Oq}}}function Tq(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 Nt(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"),c):t(f)}function c(f){return He(f)?e(f):Je(f)?n.check({tokenize:Aq},e,t)(f):t(f)}}function Aq(n,e,t){return ft(n,i,"whitespace");function i(l){return l===null?t(l):e(l)}}function Eq(n){return EA([eq(),uq(),yq(n),kq(),Nq()])}const Mq={};function Dq(n){const e=this,t=n||Mq,i=e.data(),l=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),a=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);l.push(Eq(t)),o.push(KF()),a.push(WF(t))}function jq(n){return n.replace(/\\n/g,` +`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}const Rq={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(aU,{remarkPlugins:[Dq,bU],components:Rq,children:jq(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 FC(n){!n||CE(n.status)||IM(n.session_id).catch(()=>{})}const _q={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(Fn,{className:"h-3.5 w-3.5"})})}function Lq({isOpen:n,onClose:e,directory:t,filename:i,release:l,args:o,onFinished:a}){var ye,B;const[c,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),P=E.useRef(!1),L=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 R=!0;return m(!0),b(null),C(!1),w(null),PM({directory:t,filename:i,release:l,args:o}).then(V=>{R&&(f(V),m(!1),(V.status==="completed"||V.status==="aborted"||V.status==="failed")&&(a==null||a(V.status,V.final_message||"")))}).catch(V=>{R&&((V==null?void 0:V.status)===404&&C(!0),b(V.message||"Failed to start workflow"),m(!1))}),()=>{R=!1}},[n,t,i,l,o,O]);const j=async R=>{if(!(!c||P.current)){P.current=!0,m(!0);try{const V=await HM(c.session_id,R);f(V),(V.status==="completed"||V.status==="aborted"||V.status==="failed")&&(a==null||a(V.status,V.final_message||""))}catch(V){(V==null?void 0:V.status)===404?(C(!0),b(V.message||"Workflow session on the server has expired.")):b(V.message||"Failed to process workflow response")}finally{P.current=!1,m(!1)}}},H=E.useRef(c);H.current=c;const Z=E.useRef(j);Z.current=j;const I=E.useRef(v);I.current=v;const F=E.useRef([]),A=(R,V)=>{var je,Ne;if(R.key!=="ArrowDown"&&R.key!=="ArrowUp"&&R.key!=="Home"&&R.key!=="End")return;R.preventDefault();const ue=((je=H.current)==null?void 0:je.steps.length)??0;if(ue===0)return;const pe=R.key==="ArrowDown"?(V+1)%ue:R.key==="ArrowUp"?(V-1+ue)%ue:R.key==="Home"?0:ue-1;w(pe),(Ne=F.current[pe])==null||Ne.focus()};E.useEffect(()=>()=>FC(H.current),[]);const ne=()=>{D.current||(D.current=!0,FC(H.current),e())},ae=()=>{f(null),b(null),C(!1),w(null),D.current=!1,_(R=>R+1)},ie=tl({isOpen:n,onClose:ne,dialogRef:M,initialFocusRef:L});if(E.useEffect(()=>{if(!n)return;const R=V=>{var Ee,jt,Ut;if(V.key==="Escape"){V.preventDefault(),ne();return}const ue=H.current;if(!ue)return;if(CE(ue.status)){V.key==="Enter"&&!V.repeat&&!V.ctrlKey&&!V.metaKey&&!V.altKey&&!P.current&&((Ee=V.target)==null?void 0:Ee.tagName)!=="BUTTON"&&((jt=document.activeElement)==null?void 0:jt.tagName)!=="BUTTON"&&(V.preventDefault(),ne());return}if(P.current||V.repeat||V.ctrlKey||V.metaKey||V.altKey)return;const pe=V.target;if((pe==null?void 0:pe.tagName)==="INPUT"||(pe==null?void 0:pe.tagName)==="TEXTAREA"||pe!=null&&pe.isContentEditable)return;const je=I.current,Ne=je===null||je===ue.current_index,Pe=ue.status==="waiting_ask"?"yes":ue.status==="waiting_notify"||ue.status==="waiting_notice"?"ack":null;if(!Ne||Pe===null)return;if(V.key==="Enter"){const Ft=V.target;if((Ft==null?void 0:Ft.tagName)==="BUTTON"||((Ut=document.activeElement)==null?void 0:Ut.tagName)==="BUTTON")return;V.preventDefault(),Z.current(Pe);return}if(ue.status!=="waiting_ask")return;const ve=V.key.toLowerCase();ve==="y"?(V.preventDefault(),Z.current("yes")):ve==="s"?(V.preventDefault(),Z.current("skip")):ve==="n"&&(V.preventDefault(),Z.current("no"))};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n,e]),E.useEffect(()=>{if(!n||!c)return;const R=requestAnimationFrame(()=>{var V;return(V=L.current)==null?void 0:V.focus()});return()=>cancelAnimationFrame(R)},[n,c==null?void 0:c.status]),!n)return null;const $=v!==null?c==null?void 0:c.steps[v]:c==null?void 0:c.steps[c.current_index],oe=(c==null?void 0:c.status)==="completed"||(c==null?void 0:c.status)==="aborted"||(c==null?void 0:c.status)==="failed",J=!!c&&!oe&&!S&&(((ye=c.status)==null?void 0:ye.startsWith("waiting"))??!1),Y=(((B=c==null?void 0:c.steps[(c==null?void 0:c.current_index)??-1])==null?void 0:B.phase)??"pre")==="post",he=!S&&(v===null||v===(c==null?void 0:c.current_index))&&($!=null&&$.command)&&((c==null?void 0:c.status)==="waiting_notify"||(c==null?void 0:c.status)==="waiting_notice"||(c==null?void 0:c.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," ",c!=null&&c.pattern?`• Pattern: ${c.pattern}`:""]})]})]}),y.jsxs("div",{className:"flex items-center gap-1.5",children:[c&&!oe&&!S&&y.jsxs("button",{type:"button",disabled:!J||d,onClick:()=>j("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(cD,{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(ri,{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)"}),c&&c.steps.length>0?y.jsx("ul",{role:"list",className:"flex flex-col gap-2",children:c.steps.map((R,V)=>{const ue=c.current_index===V&&!oe,pe=v===V||v===null&&ue,je=_q[R.status];return y.jsx("li",{children:y.jsxs("button",{ref:Ne=>{F.current[V]=Ne},type:"button",tabIndex:pe?0:-1,"aria-current":pe?"step":void 0,onKeyDown:Ne=>A(Ne,V),onClick:()=>w(V),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:[R.status==="running"&&y.jsx(Yr,{className:"h-4 w-4 animate-spin text-chip-indigo-text"}),R.status==="completed"&&y.jsx(Uk,{className:"h-4 w-4 text-status-success-text"}),R.status==="skipped"&&y.jsx(E4,{className:"h-4 w-4 text-status-warning-text"}),R.status==="failed"&&y.jsx(Ec,{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," · ",je]})]}),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:($==null?void 0:$.action)||(c==null?void 0:c.status)}),y.jsx("span",{className:"text-xs text-ink-muted",children:$?`Step ${$.index} of ${c==null?void 0:c.steps.length}`:"Status"}),v!==null&&v!==(c==null?void 0:c.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===(c==null?void 0:c.current_index))&&(c==null?void 0:c.status)==="waiting_notify"&&c.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:c.notify_message})}),he]}),(v===null||v===(c==null?void 0:c.current_index))&&(c==null?void 0:c.status)==="waiting_notice"&&c.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:c.notice_message})}),he,y.jsx("p",{className:"text-[11px] text-ink-faint",children:"The command will run when you continue."})]}),(v===null||v===(c==null?void 0:c.current_index))&&(c==null?void 0:c.status)==="waiting_ask"&&c.ask_prompt&&y.jsxs("div",{className:"space-y-2",children:[c.ask_message&&y.jsx("div",{className:"rounded-lg border border-line bg-surface-strong p-4 text-ink",children:y.jsx(Eh,{text:c.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:c.ask_prompt}),he]}),oe&&v===null&&y.jsxs("div",{className:`rounded-xl border p-8 text-center space-y-4 ${(c==null?void 0:c.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:(c==null?void 0:c.status)==="completed"?y.jsx(Uk,{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:(c==null?void 0:c.status)==="completed"?"Workflow Finished":"Workflow Terminated"}),y.jsx("p",{className:"text-xs text-ink-secondary max-w-md mx-auto",children:(c==null?void 0:c.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&&(c==null?void 0:c.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:c.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:c.last_output})]})]}),!S&&!(oe&&v===null)&&!((v===null||v===(c==null?void 0:c.current_index))&&((c==null?void 0:c.status)==="waiting_notify"||(c==null?void 0:c.status)==="waiting_ask"||(c==null?void 0:c.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.":(c==null?void 0:c.status)==="waiting_ask"&&(v===null||v===c.current_index)?"Action required to proceed:":(c==null?void 0:c.status)==="waiting_notify"&&(v===null||v===c.current_index)?"Acknowledge message to proceed:":(c==null?void 0:c.status)==="waiting_notice"&&(v===null||v===c.current_index)?"Continue to run the command:":oe?"Session terminated.":"Step in progress..."}),y.jsxs("div",{className:"flex items-center gap-2",children:[!S&&(c==null?void 0:c.status)==="waiting_notice"&&(v===null||v===c.current_index)&&y.jsxs("button",{type:"button",ref:L,disabled:d,onClick:()=>j("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Run Command",y.jsx(Cc,{label:"↵"})]}),!S&&(c==null?void 0:c.status)==="waiting_notify"&&(v===null||v===c.current_index)&&y.jsxs("button",{type:"button",ref:L,disabled:d,onClick:()=>j("ack"),className:"btn btn-primary px-5 py-2 font-semibold shadow-sm",children:["Continue Workflow",y.jsx(Cc,{label:"↵"})]}),!S&&(c==null?void 0:c.status)==="waiting_ask"&&(v===null||v===c.current_index)&&y.jsxs(y.Fragment,{children:[y.jsxs("button",{type:"button",disabled:d,onClick:()=>j("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:()=>j("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:L,disabled:d,onClick:()=>j("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:L,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 zq(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 c=e.length>0?e:["filename","path","rel_path"];l.push(c.map(Oc).join(","));for(const m of n){const g=c.map(b=>b in m?Oc(String(m[b]??"")):Oc(m.column_values[b]??""));l.push(g.join(","))}return l.join(`\r +`)}function Bq(n){const e=n.replace(/\\/g,"/"),t=e.startsWith("//"),i=Hq(e.replace(/^\/+/,""));return t?`file://${i}`:`file:///${i}`}const Pq=/[A-Za-z0-9\-._~!$&'()*+,;=:@]/;function Hq(n){return[...n].map(e=>e==="/"||Pq.test(e)?e:Iq(e)).join("")}function Iq(n){return Array.from(new TextEncoder().encode(n),e=>`%${e.toString(16).toUpperCase().padStart(2,"0")}`).join("")}const Uq=120;function Fq(){const{theme:n,applyTheme:e,toggleTheme:t}=GD(),[i,l]=E.useState(null),[o,a]=E.useState(null),[c,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,P]=E.useState(0),[L,D]=E.useState(""),[j,H]=E.useState(null),[Z,I]=E.useState(!1),{toastMessage:F,showToast:A,dismissToast:ne}=PD(),[ae,ie]=E.useState(!1),[$,oe]=E.useState("en"),[J,Y]=E.useState(!1),[T,he]=E.useState(!1),[ye,B]=E.useState(!1),[R,V]=E.useState(0),[ue,pe]=E.useState(!1),[je,Ne]=E.useState(null),[Pe,ve]=E.useState(null),[Ee,jt]=E.useState(!1),[Ut,Ft]=E.useState(!1),[zt,mt]=E.useState(!1),[$e,Xt]=E.useState(null),[Tn,en]=E.useState(!1),[tn,Ce]=E.useState(void 0),[Fe,Ve]=E.useState(null),[at,te]=E.useState(""),[fe,_e]=E.useState(!1),[ze,Dt]=E.useState(null),ce=K=>{mt(!0)},xe=E.useRef(null),Le=()=>({directory:c,extension:d,filter_text:g,recursive:v}),we=BD({showToast:A,getScanParams:Le,onFreshResults:()=>{xe.current=null,P(0)}}),{barcodeMode:pt,setBarcodeMode:An,handleBarcodeToggle:mn,handleCameraDetected:Tt}=XD({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),Uq);return()=>window.clearTimeout(K)},[g]);const ht=E.useMemo(()=>L.trim()===""?we.files:we.files.filter(K=>k8(K.rel_path,L)),[we.files,L]),Bi=g.trim()&&we.files.length{const K=xe.current,de=K?ht.findIndex(Oe=>Oe.path===K):-1;if(de>=0){P(Oe=>de!==Oe?de:Oe);return}P(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(Bg(Oe.theme),{persist:!1});const We=Oe.active_directory||c,$t=Oe.extensions[0]??"",Xn=Oe.filters[0]??"";We&&f(We),m($t),b(Xn),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:Xn,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(Bg(K.theme),{persist:!1});const Oe=K.active_directory||c||(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:em,resetDrop:gu,applyConfigFile:tm}=ZD({onConfigLoaded:Er,showToast:A});ID({onConfigApplied:async()=>{const K=await Dk();await Er(K)},showToast:A});const nm=()=>{Y(!0)},Jl=async K=>{const de=we.beginScan();Y(!1),f(K),A(`Directory selected: ${K}`);let Oe;try{Oe=await jk(K),a(Oe)}catch(Xn){console.error("select-directory failed:",Xn)}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(Bg(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(!0),Oe)try{await we.runScan(de,{directory:Oe,extension:We,filter_text:$t,recursive:K.recursive_search})}catch(Xn){we.isCurrentScan(de)&&A(`Initial scan failed: ${Xn.message}`,"error")}},Pi=async()=>{const K=we.claimGeneration();C(null),_(!0);try{const de=await Qh();l(de);const Oe=await Dk();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 jk(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:c,extension:d,filter_text:g,recursive:v},{errorPrefix:"Scan failed"})},{autoRescanInterval:xu,handleTimerSet:im}=FD({scan:()=>{qs()},showToast:A}),Vs=K=>{b(K),we.scheduleDeferredRescan()},Qs=K=>{w(K),we.scheduleDeferredRescan()},Xs=K=>{m(K),we.scheduleDeferredRescan()},Mr=async()=>{b(""),await we.scanWith({directory:c,extension:d,filter_text:"",recursive:v},{errorPrefix:"Scan failed"})},$s=async()=>{w(!1),await we.scanWith({directory:c,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 jM({directory:c,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])},rm=K=>{var de;xe.current=((de=ht[K])==null?void 0:de.path)??null,P(K)},yu=async(K,de)=>{vi(K,de)},Sa=async K=>{try{await XC(K.path),A("Revealed in file manager.")}catch(de){A(`Error: ${de.message}`,"error")}},es=async K=>{try{await _x(K.path),A("Folder opened in file manager.")}catch(de){A(`Error: ${de.message}`,"error")}},lm=async K=>{try{const de=await Pk(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:c,extension:d,filter_text:K,recursive:v},{errorPrefix:"Scan failed"})},wu=K=>{m(K),we.scanWith({directory:c,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 Hk(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=Bq(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 Hk(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{te(""),Ve({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)},il=K=>{Ne(K)},Cu=async()=>{const K=je;if(Ne(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")}},sm=K=>{Ce(K.path),en(!0)},Ou=async()=>{if(c)try{await _x(c),A("Directory opened in file manager.")}catch(K){A(`Error: ${K.message}`,"error")}},Nu=async K=>{if(K)try{await Pk(K),A("Terminal opened in directory.")}catch(de){A(`Error: ${de.message}`,"error")}},rl=async()=>{try{await on("~"),A("Directory set to home folder.")}catch(K){A(`Error: ${K.message}`,"error")}},Gs=async()=>{if(c)try{const K=await QC(c);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")}},Ys=async()=>{if(we.files.length===0){A("No files to export.");return}try{const K=zq(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 zM(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 UD({anyModalOpen:!!(j||Z||J||T||ue||Ee||Ut||Tn||fe||ze||$e||je),visibleFiles:ht,selectedIndex:M,activeDirectory:c,activeExtension:d,filterText:g,recursive:v,barcodeMode:pt,onEscape:()=>{H(null),I(!1),jt(!1),Ft(!1),gu()},onContextMenu:H,onExecute:ka,onScan:qs,onReloadConfig:Ln,onGoHome:rl,onProperties:pn,onToggleTheme:()=>t({persist:!0}),setShowLogViewer:jt,setShowShortcuts:I,setShowTimerModal:Ft,setShowConfigEditor:B,setShowLanModal:mt,setBarcodeMode:An,setShowCameraScanner:_e,moveSelection:K=>{P(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(m8,{title:(o==null?void 0:o.title)||"",release:(o==null?void 0:o.release)||"",directories:(o==null?void 0:o.directories)||[],activeDirectory:c,onDirectoryChange:on,onBrowseDirectory:nm,onGoToParentDirectory:Gs,onGoToHomeDirectory:rl,onOpenActiveDirectory:Ou,onOpenTerminal:Nu}),y.jsx(C8,{extensions:(o==null?void 0:o.extensions)||[],activeExtension:d,onExtensionChange:Xs,filterOptions:(o==null?void 0:o.filters)||[],filterText:g,onFilterTextChange:Vs,recursive:v,onRecursiveChange:Qs,onScan:qs,scanning:we.scanning,barcodeMode:pt,onBarcodeToggle:mn,onCameraBarcodeClick:()=>_e(!0),autoRescanActive:xu>0,onTimerClick:()=>Ft(!0)}),S?y.jsx(p8,{message:S,onRetry:()=>void Pi(),retrying:O}):y.jsx(LD,{files:ht,totalCount:we.totalCount,rawLoadedCount:we.files.length,onLoadMore:we.handleLoadMore,loadingMore:we.loadingMore,scanning:we.scanning,hasScanned:we.hasScanned,activeDirectory:c,recursive:v,onDisableRecursive:$s,onOpenDirectory:Ou,onLoadConfig:()=>he(!0),filterText:g,onClearFilter:Mr,columnHeaders:(o==null?void 0:o.column_headers)||[],columnNames:(o==null?void 0:o.column_names)||[],selectedIndex:M,onSelectIndex:rm,prefilterNote:Bi,onLaunch:vi,onContextMenu:(K,de,Oe)=>{K.preventDefault(),xe.current=de.path,P(Oe),H({x:K.clientX,y:K.clientY,file:de})},rowColors:(o==null?void 0:o.row_colors)||[],sort:we.sort,onSortChange:we.applySort}),y.jsx(nj,{onExecute:ka,scanning:we.scanning,scanningDirectory:c,hasSelection:ht.length>0,fileCount:ht.length,totalCount:we.totalCount,toastMessage:F,onToastDismiss:ne}),y.jsx(Q8,{systemInfo:i,fileCount:we.totalCount,theme:n,onToggleTheme:()=>t({persist:!0}),onOpenLog:()=>jt(!0),onOpenConfig:()=>B(!0),onShowShortcuts:()=>I(!0),onReloadConfig:Ln,onExport:Ys,exportDisabled:we.files.length===0||we.scanning,language:$,onLanguageChange:oe,lanEnabled:(i==null?void 0:i.lan_enabled)??null,onToggleLan:ce})]}),y.jsx(c8,{open:ye,onClose:()=>B(!1),onApplied:Er,onLoadConfig:()=>he(!0),reloadKey:R}),y.jsx(M8,{isOpen:T,activeConfigPath:o==null?void 0:o.config_path,configExists:o==null?void 0:o.config_exists,onClose:()=>he(!1),onLoaded:K=>{Er(K),V(de=>de+1)}}),y.jsx(h8,{visible:em,onFileSelected:tm}),y.jsx(f8,{isOpen:J,initialPath:c,onClose:()=>Y(!1),onSelect:Jl}),y.jsx(u8,{position:j,onClose:()=>H(null),onLaunch:vi,onLaunchWithArgs:yu,onReveal:Sa,onOpenFolder:es,onOpenTerminal:lm,onScanDirectory:bu,onFilterFolder:vu,onFilterExtension:wu,onCopyPath:Ca,onCopyFilename:Oa,onCopyUri:Su,onComputeHash:ku,onVerifyHash:nn,onProperties:pn,onClearFile:il,onGenerateBarcode:sm,showToast:A}),y.jsx(E8,{isOpen:Z,onClose:()=>I(!1)}),y.jsx(L8,{isOpen:ue,file:Pe,onLaunch:vi,onClose:()=>{pe(!1),ve(null)}}),y.jsx($8,{isOpen:Ut,currentInterval:xu,onClose:()=>Ft(!1),onSetInterval:im}),y.jsx(A8,{isOpen:Ee,onClose:()=>jt(!1),onOpenExternally:()=>{kM().then(K=>A(K.message)).catch(K=>A(K instanceof Error?K.message:"Failed to open the log file","error"))}}),y.jsx(Lq,{isOpen:!!$e,onClose:()=>Xt(null),directory:c,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:Tn,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:()=>Ve(null),children:y.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"verify-hash-title",onKeyDown:K=>{K.key==="Escape"&&(K.preventDefault(),K.stopPropagation(),Ve(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=>te(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:()=>Ve(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;Ve(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(q8,{isOpen:fe,onClose:()=>_e(!1),onDetected:Tt}),y.jsx(Wo,{isOpen:!!je,title:"Delete file",message:`Delete this file? + +${(je==null?void 0:je.path)??""} + +This action cannot be undone.`,confirmLabel:"Delete",danger:!0,onConfirm:Cu,onCancel:()=>Ne(null)}),y.jsx(g8,{open:zt,systemInfo:i,showToast:A,onConfirmed:l,onClose:()=>mt(!1)}),y.jsx(V8,{isOpen:!!ze,file:ze,onConfirm:()=>{if(ze){const K=ze;Dt(null),vi(K)}},onDismiss:()=>Dt(null)})]})}class qq 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(qq,{children:y.jsx(Fq,{})})})); diff --git a/src/profiles/web/dist/index.html b/src/profiles/web/dist/index.html index 6cd0e01..03b6d7c 100644 --- a/src/profiles/web/dist/index.html +++ b/src/profiles/web/dist/index.html @@ -5,8 +5,8 @@ ProFiles - - + +
diff --git a/src/profiles/web/dist/sw.js b/src/profiles/web/dist/sw.js index c8314dc..2b6d202 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:"55fcdf5c43b6ba8ea01b44d84bd93537"},{url:"assets/index-Dsvw1NQU.js",revision:null},{url:"assets/index-DTCv5-8y.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/api/client.test.ts b/src/profiles/web/src/api/client.test.ts index 3c9a753..609afc8 100644 --- a/src/profiles/web/src/api/client.test.ts +++ b/src/profiles/web/src/api/client.test.ts @@ -7,6 +7,7 @@ import { fetchConfigContent, fetchConfigTemplate, fetchNotifications, + postClientLog, reloadConfig, saveConfigFile, saveConfigFileAs, @@ -434,3 +435,38 @@ describe("saveConfigFileAs", () => { expect(err.message).toContain("already exists"); }); }); + +describe("postClientLog", () => { + afterEach(() => { + vi.unstubAllGlobals(); + }); + + it("POSTs the toast to /api/logs/client", async () => { + const fetchMock = vi.fn( + async () => new Response(JSON.stringify({ status: "ok" }), { status: 200 }), + ); + vi.stubGlobal("fetch", fetchMock); + + postClientLog("URL copied to clipboard.", "info"); + + expect(fetchMock).toHaveBeenCalledWith("/api/logs/client", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ message: "URL copied to clipboard.", kind: "info" }), + }); + }); + + it("swallows fetch rejections — logging must never break the UI", async () => { + vi.stubGlobal( + "fetch", + vi.fn(async () => { + throw new Error("server unreachable"); + }), + ); + + expect(() => postClientLog("Boom", "error")).not.toThrow(); + + // Flush the microtask queue: an unhandled rejection would fail the run. + await new Promise((resolve) => setTimeout(resolve, 0)); + }); +}); diff --git a/src/profiles/web/src/api/client.ts b/src/profiles/web/src/api/client.ts index 01433ec..f2b7d95 100644 --- a/src/profiles/web/src/api/client.ts +++ b/src/profiles/web/src/api/client.ts @@ -60,6 +60,23 @@ export async function fetchNotifications(afterId: number): Promise<{ events: Ext return res.json(); } +/** + * Mirror a UI toast into the server log at DEBUG (issue #194). + * + * Fire-and-forget by contract: telemetry must never break the UI, so the + * call is not awaited and every failure is swallowed silently — a toast + * already served its purpose on screen before this fires. + */ +export function postClientLog(message: string, kind: "info" | "error"): void { + void fetch("/api/logs/client", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ message, kind }), + }).catch(() => { + // Server unreachable — nothing to recover; the log record is best-effort. + }); +} + export async function openLogFile(): Promise<{ status: string; message: string }> { const res = await fetch("/api/actions/open-log", { method: "POST", diff --git a/src/profiles/web/src/hooks/useExternalEvents.test.tsx b/src/profiles/web/src/hooks/useExternalEvents.test.tsx index 4975f22..414ed99 100644 --- a/src/profiles/web/src/hooks/useExternalEvents.test.tsx +++ b/src/profiles/web/src/hooks/useExternalEvents.test.tsx @@ -83,8 +83,8 @@ describe("useExternalEvents", () => { expect(fetchNotificationsSpy).toHaveBeenCalledTimes(1); expect(fetchNotificationsSpy).toHaveBeenNthCalledWith(1, 0); expect(showToast).toHaveBeenCalledTimes(2); - expect(showToast).toHaveBeenNthCalledWith(1, "First handoff"); - expect(showToast).toHaveBeenNthCalledWith(2, "Second handoff"); + expect(showToast).toHaveBeenNthCalledWith(1, "First handoff", "info", { mirror: false }); + expect(showToast).toHaveBeenNthCalledWith(2, "Second handoff", "info", { mirror: false }); // The interval re-arms: the next tick polls again (4000ms later). fetchNotificationsSpy.mockResolvedValueOnce({ events: [] }); @@ -156,7 +156,7 @@ describe("useExternalEvents", () => { await vi.advanceTimersByTimeAsync(4000); }); expect(showToast).toHaveBeenCalledTimes(1); - expect(showToast).toHaveBeenCalledWith("Recovered"); + expect(showToast).toHaveBeenCalledWith("Recovered", "info", { mirror: false }); }); it("onConfigApplied failures are swallowed; the toast still fires", async () => { @@ -172,7 +172,7 @@ describe("useExternalEvents", () => { }); expect(onConfigApplied).toHaveBeenCalledTimes(1); expect(showToast).toHaveBeenCalledTimes(1); - expect(showToast).toHaveBeenCalledWith("Applied anyway"); + expect(showToast).toHaveBeenCalledWith("Applied anyway", "info", { mirror: false }); }); it("uses the latest onConfigApplied identity without re-subscribing", async () => { @@ -204,7 +204,7 @@ describe("useExternalEvents", () => { // The LATEST identity is the one invoked. expect(latestApply).toHaveBeenCalledTimes(1); expect(firstApply).not.toHaveBeenCalled(); - expect(latestToast).toHaveBeenCalledWith("Handoff"); + expect(latestToast).toHaveBeenCalledWith("Handoff", "info", { mirror: false }); setIntervalSpy.mockRestore(); }); diff --git a/src/profiles/web/src/hooks/useExternalEvents.ts b/src/profiles/web/src/hooks/useExternalEvents.ts index 1019cfd..38e0fa6 100644 --- a/src/profiles/web/src/hooks/useExternalEvents.ts +++ b/src/profiles/web/src/hooks/useExternalEvents.ts @@ -1,6 +1,7 @@ import { useEffect, useRef } from "react"; import { fetchNotifications } from "../api/client"; import type { ExternalEvent } from "../api/types"; +import type { ShowToast } from "./useToast"; /** Poll interval for server-side UI events (config handoff toasts). */ const NOTIFICATION_POLL_MS = 4000; @@ -20,7 +21,7 @@ const NOTIFICATION_POLL_MS = 4000; */ export function useExternalEvents(deps: { onConfigApplied: () => Promise; - showToast: (msg: string, kind?: "info" | "error") => void; + showToast: ShowToast; }): void { const lastEventIdRef = useRef(0); // Latest deps for the interval callback (avoids stale closures — the @@ -48,7 +49,10 @@ export function useExternalEvents(deps: { // Re-applying is best-effort; the toast still explains what happened. } } - depsRef.current.showToast(evt.message); + // mirror: false — the server already logged this event as a TOAST + // record at the record_external_event choke point (issue #194); + // relaying it back through POST /api/logs/client would duplicate it. + depsRef.current.showToast(evt.message, "info", { mirror: false }); } }; const id = setInterval(() => void poll(), NOTIFICATION_POLL_MS); diff --git a/src/profiles/web/src/hooks/useToast.test.tsx b/src/profiles/web/src/hooks/useToast.test.tsx index 5184c6d..b45eeaa 100644 --- a/src/profiles/web/src/hooks/useToast.test.tsx +++ b/src/profiles/web/src/hooks/useToast.test.tsx @@ -1,5 +1,5 @@ // @vitest-environment jsdom -import { afterEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { act, cleanup, renderHook } from "@testing-library/react"; /** @@ -8,9 +8,21 @@ import { act, cleanup, renderHook } from "@testing-library/react"; * auto-dismiss, the error toast's longer 10000ms lifetime, the empty-message * guard (never blank an existing toast), the pending-timer replacement when a * new toast arrives, the immediate `dismissToast` clearing, and the default - * `info` kind. + * `info` kind. Issue #194 adds the profiles.log mirror: every toast is + * relayed to `POST /api/logs/client` unless suppressed with `mirror: false`. */ import { useToast } from "./useToast"; +import { postClientLog } from "../api/client"; + +vi.mock("../api/client", () => ({ + postClientLog: vi.fn(), +})); + +const postClientLogSpy = vi.mocked(postClientLog); + +beforeEach(() => { + vi.clearAllMocks(); +}); afterEach(() => { cleanup(); @@ -105,4 +117,33 @@ describe("useToast", () => { act(() => result.current.showToast("Default")); expect(result.current.toastMessage).toEqual({ message: "Default", kind: "info" }); }); + + // ----------------------------------------------------------------- + // profiles.log mirror (issue #194) + // ----------------------------------------------------------------- + + it("showToast mirrors to the client-log endpoint", () => { + const { result } = renderHook(() => useToast()); + act(() => result.current.showToast("Logged please")); + expect(postClientLogSpy).toHaveBeenCalledWith("Logged please", "info"); + }); + + it("error toasts are mirrored with their kind", () => { + const { result } = renderHook(() => useToast()); + act(() => result.current.showToast("Boom", "error")); + expect(postClientLogSpy).toHaveBeenCalledWith("Boom", "error"); + }); + + it("mirror is suppressed with { mirror: false } (server-originated toasts)", () => { + const { result } = renderHook(() => useToast()); + act(() => result.current.showToast("Handoff", "info", { mirror: false })); + expect(result.current.toastMessage).toEqual({ message: "Handoff", kind: "info" }); + expect(postClientLogSpy).not.toHaveBeenCalled(); + }); + + it("empty messages are not mirrored", () => { + const { result } = renderHook(() => useToast()); + act(() => result.current.showToast("")); + expect(postClientLogSpy).not.toHaveBeenCalled(); + }); }); diff --git a/src/profiles/web/src/hooks/useToast.ts b/src/profiles/web/src/hooks/useToast.ts index 3116995..0863b3b 100644 --- a/src/profiles/web/src/hooks/useToast.ts +++ b/src/profiles/web/src/hooks/useToast.ts @@ -1,6 +1,24 @@ import { useRef, useState } from "react"; -export type ToastMessage = { message: string; kind: "info" | "error" }; +import { postClientLog } from "../api/client"; + +export type ToastKind = "info" | "error"; + +export type ToastMessage = { message: string; kind: ToastKind }; + +/** Options for showToast; `mirror: false` skips the profiles.log relay. */ +export interface ShowToastOptions { + mirror?: boolean; +} + +/** + * The one toast entry point, injected into every component/hook that needs + * it. Issue #194: each call is mirrored to `POST /api/logs/client` (DEBUG + * TOAST record in profiles.log) unless the caller passes `mirror: false` — + * reserved for server-originated toasts, which the server already logged + * at the `record_external_event` choke point. + */ +export type ShowToast = (msg: string, kind?: ToastKind, opts?: ShowToastOptions) => void; /** * Transient toast above the action bar (moved verbatim from `App.tsx`, @@ -11,7 +29,7 @@ export type ToastMessage = { message: string; kind: "info" | "error" }; */ export function useToast(): { toastMessage: ToastMessage | null; - showToast: (msg: string, kind?: "info" | "error") => void; + showToast: ShowToast; dismissToast: () => void; } { const [toastMessage, setToastMessage] = useState(null); @@ -24,9 +42,11 @@ export function useToast(): { * Info toasts auto-dismiss after 3.5s; error toasts stay a little longer and * carry an inline dismiss button, so they never vanish before being read. */ - const showToast = (msg: string, kind: "info" | "error" = "info") => { + const showToast: ShowToast = (msg, kind = "info", opts) => { if (!msg) return; // never blank an existing toast with an empty message setToastMessage({ message: msg, kind }); + // Mirror to profiles.log (issue #194); fire-and-forget, never awaited. + if (opts?.mirror !== false) postClientLog(msg, kind); if (toastTimerRef.current) clearTimeout(toastTimerRef.current); toastTimerRef.current = setTimeout( () => setToastMessage(null), diff --git a/src/profiles/web/tsconfig.tsbuildinfo b/src/profiles/web/tsconfig.tsbuildinfo index 262f229..4f010fc 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/lanmodal.test.tsx","./src/components/lanmodal.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..ffb25dc 100644 --- a/tests/AGENTS.md +++ b/tests/AGENTS.md @@ -92,6 +92,7 @@ tests/ ├── server/ │ ├── test_app.py # ← server/app.py (FastAPI factory + client telemetry) │ ├── test_barcode_integration.py # cross-cutting server integration (exception) +│ ├── test_state.py # ← server/state.py (external-event buffer + TOAST telemetry, #194) │ ├── test_static.py # ← server/static.py │ └── routes/ │ ├── test_actions.py # ← server/routes/actions.py @@ -123,7 +124,7 @@ tests/ - `tests/server/test_barcode_integration.py` — end-to-end server integration (app + state + routes). **Known coverage gaps (mirrored test file does not exist yet):** -`core/telemetry/log_viewer.py`, `server/state.py` — `server/state.py` is partially exercised through `tests/server/test_app.py`. +`core/telemetry/log_viewer.py`. ## Writing Tests diff --git a/tests/README.md b/tests/README.md index 9f932cb..4e570fd 100644 --- a/tests/README.md +++ b/tests/README.md @@ -69,6 +69,7 @@ Highlights: | tests/launch/test_{context,creation,resolution}.py | profiles.launch.* | launch context detection, shortcut creation, resolution | | tests/packaging/ | (cross-cutting) | entry-point stub, packaging dependency rules, ProFiles.pyw stub | | tests/server/test_app.py | profiles.server.app | FastAPI factory, client connection telemetry | +| tests/server/test_state.py | profiles.server.state | external-event buffer, TOAST DEBUG telemetry (issue #194) | | tests/server/routes/test_*.py | profiles.server.routes.* | actions/config/fs/logs/scan/system/workflow endpoints | | tests/utils/test_*.py | profiles.utils.* | file_utils, network, search_parser, shortcut | | tests/web/test_build{,_hook}.py | profiles.web.* | web build CLI and Briefcase build hook | diff --git a/tests/core/telemetry/test_events.py b/tests/core/telemetry/test_events.py index e572449..7b6c22d 100644 --- a/tests/core/telemetry/test_events.py +++ b/tests/core/telemetry/test_events.py @@ -43,6 +43,7 @@ scan_complete, scan_failed, theme_switched, + toast, wcag_contrast_faint, web_client, web_client_left, @@ -733,6 +734,56 @@ def test_left(self, caplog: pytest.LogCaptureFixture) -> None: assert 'WEB_CLIENT event="disconnected" ip="192.168.1.50" idle_s=135' in caplog.text +class TestToast: + """TOAST — UI toasts mirrored to the log at DEBUG (issue #194).""" + + def test_server_source_with_applied(self, caplog: pytest.LogCaptureFixture) -> None: + logger = logging.getLogger("test_toast_server") + with caplog.at_level(logging.DEBUG, logger=logger.name): + toast( + logger, + source="server", + kind="config_handoff", + message="Configuration 'X' applied by a new ProFiles launch", + applied=True, + ) + assert ( + "TOAST source=server kind=config_handoff applied=true " + "msg=\"Configuration 'X' applied by a new ProFiles launch\"" in caplog.text + ) + assert caplog.records[0].levelname == "DEBUG" + + def test_server_source_not_applied(self, caplog: pytest.LogCaptureFixture) -> None: + logger = logging.getLogger("test_toast_server_failed") + with caplog.at_level(logging.DEBUG, logger=logger.name): + toast( + logger, + source="server", + kind="config_handoff_failed", + message="Could not apply 'X'", + applied=False, + ) + assert ( + "TOAST source=server kind=config_handoff_failed applied=false msg=\"Could not apply 'X'\"" + in caplog.text + ) + + def test_web_source_has_no_applied_part(self, caplog: pytest.LogCaptureFixture) -> None: + logger = logging.getLogger("test_toast_web") + with caplog.at_level(logging.DEBUG, logger=logger.name): + toast(logger, source="web", kind="error", message="Failed to reload configuration") + assert 'TOAST source=web kind=error msg="Failed to reload configuration"' in caplog.text + assert "applied=" not in caplog.text + + def test_quoting_follows_house_rules(self, caplog: pytest.LogCaptureFixture) -> None: + logger = logging.getLogger("test_toast_quoting") + with caplog.at_level(logging.DEBUG, logger=logger.name): + toast(logger, source="web", kind="info", message="Ready") + toast(logger, source="web", kind="info", message="URL copied to clipboard.") + assert "kind=info msg=Ready" in caplog.text + assert 'msg="URL copied to clipboard."' in caplog.text + + class TestBindChanged: def test_lan_on(self, caplog: pytest.LogCaptureFixture) -> None: logger = logging.getLogger("test_bind_lan") diff --git a/tests/server/routes/test_logs.py b/tests/server/routes/test_logs.py index c3318d0..6e5b574 100644 --- a/tests/server/routes/test_logs.py +++ b/tests/server/routes/test_logs.py @@ -2,6 +2,7 @@ from __future__ import annotations +import logging from pathlib import Path import pytest @@ -159,3 +160,87 @@ async def test_get_logs_honours_limit(log_state: ServerState) -> None: response = await client.get("/api/logs?limit=2") assert response.json()["total_returned"] == 2 + + +# --------------------------------------------------------------------------- +# POST /api/logs/client — frontend toast mirror (issue #194) +# --------------------------------------------------------------------------- + + +@pytest.mark.anyio +async def test_post_client_log_emits_toast_debug( + log_state: ServerState, caplog: pytest.LogCaptureFixture +) -> None: + app = create_app(log_state) + + with caplog.at_level(logging.DEBUG, logger="profiles"): + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/logs/client", + json={"message": "Failed to reload configuration", "kind": "error"}, + ) + + assert response.status_code == 200 + assert response.json() == {"status": "ok"} + assert 'TOAST source=web kind=error msg="Failed to reload configuration"' in caplog.text + toast_records = [r for r in caplog.records if r.message.startswith("TOAST")] + assert toast_records and toast_records[0].levelname == "DEBUG" + + +@pytest.mark.anyio +async def test_post_client_log_defaults_to_info_kind( + log_state: ServerState, caplog: pytest.LogCaptureFixture +) -> None: + app = create_app(log_state) + + with caplog.at_level(logging.DEBUG, logger="profiles"): + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post("/api/logs/client", json={"message": "URL copied"}) + + assert response.status_code == 200 + assert 'TOAST source=web kind=info msg="URL copied"' in caplog.text + + +@pytest.mark.anyio +async def test_post_client_log_rejects_empty_message(log_state: ServerState) -> None: + app = create_app(log_state) + + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post("/api/logs/client", json={"message": ""}) + + assert response.status_code == 422 + + +@pytest.mark.anyio +async def test_post_client_log_rejects_oversized_message(log_state: ServerState) -> None: + app = create_app(log_state) + + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post("/api/logs/client", json={"message": "x" * 501}) + + assert response.status_code == 422 + + +@pytest.mark.anyio +async def test_post_client_log_rejects_unknown_kind(log_state: ServerState) -> None: + app = create_app(log_state) + + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + response = await client.post( + "/api/logs/client", json={"message": "hello", "kind": "verbose"} + ) + + assert response.status_code == 422 + + +@pytest.mark.anyio +async def test_post_client_log_never_buffers_notifications(log_state: ServerState) -> None: + """No feedback loop (issue #194): client logs must not enqueue UI events.""" + app = create_app(log_state) + + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client: + await client.post("/api/logs/client", json={"message": "loop?", "kind": "error"}) + response = await client.get("/api/notifications") + + assert response.status_code == 200 + assert response.json()["events"] == [] diff --git a/tests/server/test_state.py b/tests/server/test_state.py new file mode 100644 index 0000000..9438f7b --- /dev/null +++ b/tests/server/test_state.py @@ -0,0 +1,102 @@ +"""Tests for ServerState: external-event buffer and toast telemetry (issue #194).""" + +from __future__ import annotations + +import logging +from pathlib import Path + +import pytest + +from profiles.core.config.models import AppConfig +from profiles.server.state import ServerState + + +@pytest.fixture(autouse=True) +def _reset_profiles_logger() -> None: + """The ``profiles`` logger is global — start and leave it handler-free.""" + logger = logging.getLogger("profiles") + logger.handlers.clear() + yield + logger.handlers.clear() + + +@pytest.fixture +def state(tmp_path: Path) -> ServerState: + return ServerState(config=AppConfig(title="Test Bench", search_dir=str(tmp_path))) + + +class TestExternalEventBuffer: + def test_ids_are_monotonic_and_payload_complete(self, state: ServerState) -> None: + first = state.record_external_event("config_handoff", "first", config_applied=True) + second = state.record_external_event("config_handoff_failed", "second") + + assert first == 1 + assert second == 2 + assert state.external_events_after(0) == [ + { + "id": 1, + "kind": "config_handoff", + "message": "first", + "config_applied": True, + }, + { + "id": 2, + "kind": "config_handoff_failed", + "message": "second", + "config_applied": False, + }, + ] + + def test_external_events_after_filters_by_id(self, state: ServerState) -> None: + state.record_external_event("info", "first") + state.record_external_event("info", "second") + + remaining = state.external_events_after(1) + + assert [event["message"] for event in remaining] == ["second"] + + def test_buffer_is_capped(self, state: ServerState) -> None: + for i in range(60): # over the 50-event cap + state.record_external_event("info", f"event {i}") + + events = state.external_events_after(0) + + assert len(events) == 50 + assert events[0]["message"] == "event 10" + assert events[-1]["message"] == "event 59" + + +class TestExternalEventTelemetry: + """Every external event mirrors a TOAST record at DEBUG (issue #194).""" + + def test_emits_toast_with_applied_true( + self, caplog: pytest.LogCaptureFixture, state: ServerState + ) -> None: + with caplog.at_level(logging.DEBUG, logger="profiles"): + state.record_external_event( + "config_handoff", "Configuration 'X' applied", config_applied=True + ) + + assert ( + "TOAST source=server kind=config_handoff applied=true " + "msg=\"Configuration 'X' applied\"" in caplog.text + ) + + def test_applied_defaults_to_false( + self, caplog: pytest.LogCaptureFixture, state: ServerState + ) -> None: + with caplog.at_level(logging.DEBUG, logger="profiles"): + state.record_external_event("config_handoff_failed", "Could not apply 'X'") + + assert "TOAST source=server kind=config_handoff_failed applied=false" in caplog.text + + def test_default_log_level_stays_quiet( + self, caplog: pytest.LogCaptureFixture, state: ServerState + ) -> None: + """DEBUG by design: the default (INFO) log must not gain toast noise.""" + with caplog.at_level(logging.INFO, logger="profiles"): + state.record_external_event( + "config_handoff", "Configuration 'X' applied", config_applied=True + ) + + assert "TOAST" not in caplog.text