From 06bc02fbedb23454a37fb3f102e687a7ab3fc53c Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:00:22 -0700 Subject: [PATCH 01/11] local: SQLite WAL+FK pragmas, auth-disabled config flag, env-driven host/port Foundation for the single-process self-host path: - db.py: file-backed SQLite now runs in WAL with PRAGMA foreign_keys=ON and a 5s busy_timeout (FK-off-by-default would break ON DELETE CASCADE locally). - config.py: add field_notes_auth_disabled + field_notes_data_dir (default off, so networked/Heroku deploys stay locked). - __main__.py: FIELD_NOTES_HOST + $PORT/FIELD_NOTES_PORT instead of hardcoded 0.0.0.0:8000. All additive/backward-compatible. 168 passed. --- apps/api/field_notes_api/__main__.py | 17 ++++-- apps/api/field_notes_api/config.py | 7 +++ apps/api/field_notes_api/db.py | 34 ++++++++++- apps/api/tests/test_local_foundation.py | 78 +++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 5 deletions(-) create mode 100644 apps/api/tests/test_local_foundation.py diff --git a/apps/api/field_notes_api/__main__.py b/apps/api/field_notes_api/__main__.py index 679556c..6341fc5 100644 --- a/apps/api/field_notes_api/__main__.py +++ b/apps/api/field_notes_api/__main__.py @@ -4,14 +4,23 @@ def main() -> None: - """Run the FastAPI app under uvicorn.""" - # TODO: Chunk 2 — wire env-driven host/port/log-level via pydantic-settings. + """Run the FastAPI app under uvicorn. + + Host/port come from env: FIELD_NOTES_HOST (default 0.0.0.0 for container + deploys) and $PORT (Heroku) / FIELD_NOTES_PORT (default 8000). The local + single-process path uses `field-notes serve` instead, which binds loopback. + """ + import os + import uvicorn + host = os.getenv("FIELD_NOTES_HOST", "0.0.0.0") + port = int(os.getenv("PORT") or os.getenv("FIELD_NOTES_PORT") or "8000") + uvicorn.run( "field_notes_api.main:app", - host="0.0.0.0", - port=8000, + host=host, + port=port, reload=False, ) diff --git a/apps/api/field_notes_api/config.py b/apps/api/field_notes_api/config.py index 701b696..1e6ea29 100644 --- a/apps/api/field_notes_api/config.py +++ b/apps/api/field_notes_api/config.py @@ -25,6 +25,13 @@ def _normalize_pg_url(cls, v: str) -> str: field_notes_cors_origins: list[str] = Field(default_factory=lambda: ["http://localhost:5173"]) # SSE keepalive interval. Overridable in tests so we don't wait 25s for a keepalive assertion. field_notes_sse_keepalive_seconds: float = 25.0 + # Local single-process self-host: when true, the API key + SSE token checks + # become no-ops. Set automatically by `field-notes serve` on a loopback bind + # with no key. Default stays False so Heroku/networked deploys stay locked. + field_notes_auth_disabled: bool = Field(default=False) + # Where the local install keeps its SQLite DB + managed media (resolved by + # the serve CLI; unused by the networked deploy). + field_notes_data_dir: str | None = Field(default=None) @lru_cache diff --git a/apps/api/field_notes_api/db.py b/apps/api/field_notes_api/db.py index 45e5101..0200ac4 100644 --- a/apps/api/field_notes_api/db.py +++ b/apps/api/field_notes_api/db.py @@ -9,6 +9,7 @@ from collections.abc import AsyncIterator +from sqlalchemy import event from sqlalchemy.ext.asyncio import ( AsyncEngine, AsyncSession, @@ -21,18 +22,49 @@ _engine: AsyncEngine | None = None _sessionmaker: async_sessionmaker[AsyncSession] | None = None +# Wait this long for a lock before raising "database is locked" (ms). Lets the +# local single-process server ride out brief write contention from concurrent +# MCP writes instead of erroring. +_SQLITE_BUSY_TIMEOUT_MS = 5000 + + +def _is_memory_sqlite(url: str) -> bool: + return ":memory:" in url or url.rstrip("/").endswith("sqlite+aiosqlite:") + + +def _register_sqlite_pragmas(engine: AsyncEngine, *, wal: bool) -> None: + """Set per-connection SQLite pragmas. + + FK enforcement is OFF by default in SQLite, so the models' ON DELETE CASCADE + (cell→verdict) would silently not cascade locally without this. WAL only + applies to file-backed DBs (an in-memory DB can't use it). + """ + + @event.listens_for(engine.sync_engine, "connect") + def _set_pragmas(dbapi_conn, _record): # noqa: ANN001 — DBAPI types are untyped + cur = dbapi_conn.cursor() + try: + cur.execute("PRAGMA foreign_keys=ON") + cur.execute(f"PRAGMA busy_timeout={_SQLITE_BUSY_TIMEOUT_MS}") + if wal: + cur.execute("PRAGMA journal_mode=WAL") + finally: + cur.close() + def _build_engine(url: str) -> AsyncEngine: # SQLite in-memory requires StaticPool so all connections see the same DB. if url.startswith("sqlite"): from sqlalchemy.pool import StaticPool - return create_async_engine( + engine = create_async_engine( url, future=True, connect_args={"check_same_thread": False}, poolclass=StaticPool, ) + _register_sqlite_pragmas(engine, wal=not _is_memory_sqlite(url)) + return engine return create_async_engine(url, future=True, pool_pre_ping=True) diff --git a/apps/api/tests/test_local_foundation.py b/apps/api/tests/test_local_foundation.py new file mode 100644 index 0000000..2418b27 --- /dev/null +++ b/apps/api/tests/test_local_foundation.py @@ -0,0 +1,78 @@ +"""Foundation for the local single-process self-host path. + +Covers SQLite durability pragmas (WAL + foreign keys + busy_timeout), the new +local config flags, and env-driven host/port for the bare API entrypoint. +""" + +from __future__ import annotations + +from field_notes_api.config import Settings +from field_notes_api.db import _build_engine +from sqlalchemy import text + +# --- SQLite pragmas ------------------------------------------------------- + + +async def test_file_sqlite_enables_wal_fk_and_busy_timeout(tmp_path): + """A file-backed SQLite engine must run in WAL with FK enforcement on and a + non-trivial busy_timeout, so concurrent MCP writes don't instantly lock and + ON DELETE CASCADE actually cascades locally.""" + db = tmp_path / "fn.db" + eng = _build_engine(f"sqlite+aiosqlite:///{db}") + try: + async with eng.connect() as conn: + journal = (await conn.execute(text("PRAGMA journal_mode"))).scalar() + fk = (await conn.execute(text("PRAGMA foreign_keys"))).scalar() + busy = (await conn.execute(text("PRAGMA busy_timeout"))).scalar() + assert str(journal).lower() == "wal" + assert int(fk) == 1 + assert int(busy) >= 1000 + finally: + await eng.dispose() + + +async def test_memory_sqlite_enforces_fk(tmp_path): + """In-memory SQLite (tests) can't use WAL, but FK enforcement must still be + on so cascade behaviour matches production.""" + eng = _build_engine("sqlite+aiosqlite:///:memory:") + try: + async with eng.connect() as conn: + fk = (await conn.execute(text("PRAGMA foreign_keys"))).scalar() + assert int(fk) == 1 + finally: + await eng.dispose() + + +# --- Local config flags --------------------------------------------------- + + +def test_auth_disabled_defaults_false(monkeypatch): + monkeypatch.delenv("FIELD_NOTES_AUTH_DISABLED", raising=False) + assert Settings().field_notes_auth_disabled is False + + +def test_auth_disabled_parses_from_env(monkeypatch): + monkeypatch.setenv("FIELD_NOTES_AUTH_DISABLED", "1") + assert Settings().field_notes_auth_disabled is True + + +# --- Env-driven host/port for the bare API entrypoint --------------------- + + +def test_main_reads_host_and_port_from_env(monkeypatch): + """`field-notes-api` honours FIELD_NOTES_HOST + $PORT (Heroku) instead of + hardcoding 0.0.0.0:8000.""" + import field_notes_api.__main__ as entry + + captured: dict = {} + + def fake_run(_app, *args, **kwargs): + captured.update(kwargs) + + monkeypatch.setattr("uvicorn.run", fake_run) + monkeypatch.setenv("FIELD_NOTES_HOST", "127.0.0.1") + monkeypatch.setenv("PORT", "9123") + entry.main() + + assert captured["host"] == "127.0.0.1" + assert captured["port"] == 9123 From 32e8a2f33914d6487ab65d5c96142659676530ff Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:01:50 -0700 Subject: [PATCH 02/11] local: auth bypass when FIELD_NOTES_AUTH_DISABLED Both require_api_key (header) and require_api_key_query (SSE token) short-circuit to a no-op when field_notes_auth_disabled is set, so the loopback serve path doesn't lock the owner out and the MCP connects with no key. Default stays enforced. 172 passed. --- apps/api/field_notes_api/auth.py | 8 +++-- apps/api/tests/test_local_auth.py | 57 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 apps/api/tests/test_local_auth.py diff --git a/apps/api/field_notes_api/auth.py b/apps/api/field_notes_api/auth.py index 05b39f2..41a37aa 100644 --- a/apps/api/field_notes_api/auth.py +++ b/apps/api/field_notes_api/auth.py @@ -72,8 +72,10 @@ def _verify_sse_token(token: str) -> bool: async def require_api_key(x_field_notes_key: str | None = Header(default=None)) -> None: """Header-based auth dependency for normal JSON endpoints.""" - expected = get_settings().field_notes_key - if not x_field_notes_key or not hmac.compare_digest(x_field_notes_key, expected): + settings = get_settings() + if settings.field_notes_auth_disabled: + return + if not x_field_notes_key or not hmac.compare_digest(x_field_notes_key, settings.field_notes_key): raise HTTPException( status_code=status.HTTP_401_UNAUTHORIZED, detail="missing or invalid api key", @@ -90,6 +92,8 @@ async def require_api_key_query( - `?token=...`: HMAC-signed short-lived token from POST /sse-token (preferred) - `?key=...`: raw shared secret (DEPRECATED — leaks via Heroku router logs) """ + if get_settings().field_notes_auth_disabled: + return if token: if _verify_sse_token(token): return diff --git a/apps/api/tests/test_local_auth.py b/apps/api/tests/test_local_auth.py new file mode 100644 index 0000000..8ba9d01 --- /dev/null +++ b/apps/api/tests/test_local_auth.py @@ -0,0 +1,57 @@ +"""Local single-process auth bypass. + +When FIELD_NOTES_AUTH_DISABLED is set (the `field-notes serve` loopback path), +both the header auth and the SSE-token auth become no-ops so the owner isn't +locked out of their own notebook and the MCP can connect with no key. The +default (unset) must stay fully enforced for networked/Heroku deploys. +""" + +from __future__ import annotations + +import pytest +from fastapi import HTTPException +from field_notes_api import auth +from field_notes_api.config import get_settings + + +@pytest.fixture(autouse=True) +def _isolate_settings_cache(): + get_settings.cache_clear() + yield + get_settings.cache_clear() + + +# --- header auth ---------------------------------------------------------- + + +async def test_header_auth_bypassed_when_disabled(monkeypatch): + monkeypatch.setenv("FIELD_NOTES_AUTH_DISABLED", "1") + get_settings.cache_clear() + # No key supplied, yet must not raise. + await auth.require_api_key(x_field_notes_key=None) + + +async def test_header_auth_enforced_by_default(monkeypatch): + monkeypatch.delenv("FIELD_NOTES_AUTH_DISABLED", raising=False) + get_settings.cache_clear() + with pytest.raises(HTTPException) as exc: + await auth.require_api_key(x_field_notes_key=None) + assert exc.value.status_code == 401 + + +# --- SSE query/token auth ------------------------------------------------- + + +async def test_sse_auth_bypassed_when_disabled(monkeypatch): + monkeypatch.setenv("FIELD_NOTES_AUTH_DISABLED", "1") + get_settings.cache_clear() + # Neither token nor key, yet must not raise. + await auth.require_api_key_query(key=None, token=None) + + +async def test_sse_auth_enforced_by_default(monkeypatch): + monkeypatch.delenv("FIELD_NOTES_AUTH_DISABLED", raising=False) + get_settings.cache_clear() + with pytest.raises(HTTPException) as exc: + await auth.require_api_key_query(key=None, token=None) + assert exc.value.status_code == 401 From 9d26b58dd7d4918355a298aba635e373dde0cea4 Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:08:41 -0700 Subject: [PATCH 03/11] local: field-notes serve CLI (migrate -> uvicorn -> browser) New cli.py with argparse subcommands. serve resolves a data dir (default ~/.field-notes), sets SQLite/media/static env (honouring power-user overrides), disables auth on loopback-without-key (refuses a public bind without --key), runs alembic upgrade head in-process, then serves the existing app. - env.py: collapse sqlite+aiosqlite -> sqlite so in-process migrations work. - pyproject: register `field-notes` script; move aiosqlite to RUNTIME deps (local serve needs the driver; was dev-only -> fresh installs would crash). Verified e2e: serve boots on a temp dir, 5 migrations stamp 0005, WAL on, keyless /projects 200 + POST 201, data persists to disk. 184 passed. --- apps/api/alembic/env.py | 4 + apps/api/field_notes_api/cli.py | 188 +++++++++++++++++++++++++++++ apps/api/pyproject.toml | 4 +- apps/api/tests/test_local_serve.py | 111 +++++++++++++++++ uv.lock | 4 +- 5 files changed, 308 insertions(+), 3 deletions(-) create mode 100644 apps/api/field_notes_api/cli.py create mode 100644 apps/api/tests/test_local_serve.py diff --git a/apps/api/alembic/env.py b/apps/api/alembic/env.py index 5ce47fd..281a58f 100644 --- a/apps/api/alembic/env.py +++ b/apps/api/alembic/env.py @@ -27,6 +27,10 @@ database_url = database_url.replace("postgres://", "postgresql://", 1) if database_url.startswith("postgresql+asyncpg://"): database_url = database_url.replace("postgresql+asyncpg://", "postgresql://", 1) +# Local single-process self-host uses sqlite+aiosqlite (async); Alembic needs a +# sync driver, so collapse it to the stdlib sqlite dialect. +if database_url.startswith("sqlite+aiosqlite://"): + database_url = database_url.replace("sqlite+aiosqlite://", "sqlite://", 1) if database_url: config.set_main_option("sqlalchemy.url", database_url) diff --git a/apps/api/field_notes_api/cli.py b/apps/api/field_notes_api/cli.py new file mode 100644 index 0000000..ecb832e --- /dev/null +++ b/apps/api/field_notes_api/cli.py @@ -0,0 +1,188 @@ +"""`field-notes` command-line interface for the local single-process self-host. + +Subcommands: + serve run migrations on a file-backed SQLite DB and start the server + add-media copy media files into the managed media root (see media.py) + verify-media report cell media URLs missing from the media root (see media.py) + import-db copy a remote DB (e.g. Heroku Postgres) into local SQLite (transfer.py) + fetch-media download the baked media tarballs into the media root (transfer.py) + info print the resolved local paths + auth mode + +The pure helpers (`_is_loopback`, `build_serve_env`, `run_migrations`) are kept +side-effect-free so they can be unit-tested without binding a socket. +""" + +from __future__ import annotations + +import argparse +import contextlib +import os +from collections.abc import Mapping +from pathlib import Path + +from .config import get_settings + +DEFAULT_DATA_DIR = "~/.field-notes" +DEFAULT_HOST = "127.0.0.1" +DEFAULT_PORT = 8000 + +_LOOPBACK_HOSTS = {"127.0.0.1", "localhost", "::1", "0:0:0:0:0:0:0:1"} + + +def _is_loopback(host: str) -> bool: + return host.strip("[]").lower() in _LOOPBACK_HOSTS + + +def build_serve_env( + *, + data_dir: Path, + host: str, + key: str | None = None, + static_dir: str | None = None, + existing: Mapping[str, str] | None = None, +) -> dict[str, str]: + """Compute the env vars `serve` should set, honouring power-user overrides. + + Path vars (DATABASE_URL / media / data dir / static) are only filled when + absent from `existing`, so e.g. `DATABASE_URL=postgres://…` still wins. + + Auth: an explicit `key` enables key auth; otherwise a loopback bind disables + auth (local single-user); a public bind without a key is refused. + """ + existing = existing or {} + data_dir = Path(data_dir) + env: dict[str, str] = {} + + if "DATABASE_URL" not in existing: + env["DATABASE_URL"] = f"sqlite+aiosqlite:///{data_dir / 'field-notes.db'}" + if "FIELD_NOTES_MEDIA_DIR" not in existing: + env["FIELD_NOTES_MEDIA_DIR"] = str(data_dir / "media") + if "FIELD_NOTES_DATA_DIR" not in existing: + env["FIELD_NOTES_DATA_DIR"] = str(data_dir) + if static_dir and "FIELD_NOTES_STATIC_DIR" not in existing: + env["FIELD_NOTES_STATIC_DIR"] = str(static_dir) + + if key: + env["FIELD_NOTES_KEY"] = key + elif _is_loopback(host): + env["FIELD_NOTES_AUTH_DISABLED"] = "1" + else: + raise ValueError( + f"refusing to bind {host} without a key — pass --key to require auth, " + "or bind a loopback host (127.0.0.1) for a private local notebook" + ) + return env + + +def _find_alembic() -> tuple[Path, Path]: + """Return (alembic.ini, script_location). Works from the source tree and + from a wheel where the migrations are bundled under the package as _alembic/.""" + pkg = Path(__file__).resolve().parent + candidates = [ + (pkg / "_alembic" / "alembic.ini", pkg / "_alembic" / "alembic"), # packaged + (pkg.parent / "alembic.ini", pkg.parent / "alembic"), # source: apps/api/ + ] + for ini, script in candidates: + if ini.is_file() and script.is_dir(): + return ini, script + raise FileNotFoundError("could not locate Alembic migrations (alembic.ini + alembic/)") + + +def run_migrations(database_url: str) -> None: + """Run `alembic upgrade head` in-process. `env.py` normalises the URL to a + sync driver (sqlite+aiosqlite → sqlite, postgres+asyncpg → postgresql).""" + from alembic import command + from alembic.config import Config + + ini, script_location = _find_alembic() + cfg = Config(str(ini)) + cfg.set_main_option("script_location", str(script_location)) + os.environ["DATABASE_URL"] = database_url + command.upgrade(cfg, "head") + + +def resolve_static_dir() -> str | None: + """Locate the built SPA: an explicit FIELD_NOTES_STATIC_DIR, else the + packaged _web/ dir if it shipped with the wheel.""" + explicit = os.environ.get("FIELD_NOTES_STATIC_DIR") + if explicit: + return explicit + packaged = Path(__file__).resolve().parent / "_web" + if (packaged / "index.html").is_file(): + return str(packaged) + return None + + +def _cmd_serve(args: argparse.Namespace) -> int: + import webbrowser + + import uvicorn + + data_dir = Path(args.data_dir).expanduser() + (data_dir / "media").mkdir(parents=True, exist_ok=True) + + env = build_serve_env( + data_dir=data_dir, + host=args.host, + key=args.key, + static_dir=resolve_static_dir(), + existing=dict(os.environ), + ) + os.environ.update(env) + get_settings.cache_clear() + + run_migrations(os.environ["DATABASE_URL"]) + + auth_mode = "DISABLED (local, loopback)" if env.get("FIELD_NOTES_AUTH_DISABLED") else "key required" + url = f"http://{args.host}:{args.port}" + print(f"field-notes: data dir {data_dir}") + print(f"field-notes: auth {auth_mode}") + print(f"field-notes: serving at {url}") + + if not args.no_browser: + # Headless boxes have no browser; never let that abort serving. + with contextlib.suppress(Exception): + webbrowser.open(url) + + from .main import app + + uvicorn.run(app, host=args.host, port=args.port) + return 0 + + +def _cmd_info(args: argparse.Namespace) -> int: + data_dir = Path(args.data_dir).expanduser() + print(f"data dir: {data_dir}") + print(f"database: {data_dir / 'field-notes.db'}") + print(f"media root: {data_dir / 'media'}") + print(f"static SPA: {resolve_static_dir() or '(not bundled — run from source or build _web)'}") + return 0 + + +def build_parser() -> argparse.ArgumentParser: + parser = argparse.ArgumentParser(prog="field-notes", description="Field Notes local self-host") + sub = parser.add_subparsers(dest="command", required=True) + + p_serve = sub.add_parser("serve", help="run the local single-process server") + p_serve.add_argument("--data-dir", default=DEFAULT_DATA_DIR, help=f"default {DEFAULT_DATA_DIR}") + p_serve.add_argument("--host", default=DEFAULT_HOST, help=f"default {DEFAULT_HOST}") + p_serve.add_argument("--port", type=int, default=DEFAULT_PORT, help=f"default {DEFAULT_PORT}") + p_serve.add_argument("--key", default=None, help="require this API key (else loopback runs keyless)") + p_serve.add_argument("--no-browser", action="store_true", help="don't open a browser tab") + p_serve.set_defaults(func=_cmd_serve) + + p_info = sub.add_parser("info", help="print resolved local paths") + p_info.add_argument("--data-dir", default=DEFAULT_DATA_DIR) + p_info.set_defaults(func=_cmd_info) + + return parser + + +def main(argv: list[str] | None = None) -> int: + parser = build_parser() + args = parser.parse_args(argv) + return args.func(args) + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/apps/api/pyproject.toml b/apps/api/pyproject.toml index 5b5be9d..7f30c33 100644 --- a/apps/api/pyproject.toml +++ b/apps/api/pyproject.toml @@ -13,11 +13,14 @@ dependencies = [ "python-dotenv>=1.0", "httpx>=0.27", "sse-starlette>=2.1", + # Runtime driver for the local single-process self-host (sqlite+aiosqlite). + "aiosqlite>=0.20", "field-notes-schema", ] [project.scripts] field-notes-api = "field_notes_api.__main__:main" +field-notes = "field_notes_api.cli:main" [dependency-groups] dev = [ @@ -25,7 +28,6 @@ dev = [ "pytest-asyncio>=0.24", "pytest-cov>=5.0", "ruff>=0.8", - "aiosqlite>=0.20", "psycopg2-binary>=2.9.12", ] diff --git a/apps/api/tests/test_local_serve.py b/apps/api/tests/test_local_serve.py new file mode 100644 index 0000000..0b3209d --- /dev/null +++ b/apps/api/tests/test_local_serve.py @@ -0,0 +1,111 @@ +"""`field-notes serve` CLI: env resolution, in-process migrations, wiring. + +Side-effecting steps (uvicorn, browser) are monkeypatched; the pure env/auth +logic and the real Alembic-on-SQLite migration are exercised directly. +""" + +from __future__ import annotations + +import os +import sqlite3 +from pathlib import Path + +import pytest +from field_notes_api import cli +from field_notes_api.config import get_settings + + +@pytest.fixture(autouse=True) +def _env_sandbox(): + """Snapshot + restore os.environ since serve() mutates it in place.""" + saved = dict(os.environ) + get_settings.cache_clear() + yield + os.environ.clear() + os.environ.update(saved) + get_settings.cache_clear() + + +# --- loopback detection --------------------------------------------------- + + +@pytest.mark.parametrize("host", ["127.0.0.1", "localhost", "::1"]) +def test_is_loopback_true(host): + assert cli._is_loopback(host) is True + + +@pytest.mark.parametrize("host", ["0.0.0.0", "192.168.1.5", "example.com"]) +def test_is_loopback_false(host): + assert cli._is_loopback(host) is False + + +# --- env resolution ------------------------------------------------------- + + +def test_build_serve_env_loopback_no_key_disables_auth(tmp_path): + env = cli.build_serve_env(data_dir=tmp_path, host="127.0.0.1", key=None) + assert env["FIELD_NOTES_AUTH_DISABLED"] == "1" + assert "FIELD_NOTES_KEY" not in env + assert str(tmp_path / "field-notes.db") in env["DATABASE_URL"] + assert env["DATABASE_URL"].startswith("sqlite+aiosqlite://") + assert env["FIELD_NOTES_MEDIA_DIR"] == str(tmp_path / "media") + assert env["FIELD_NOTES_DATA_DIR"] == str(tmp_path) + + +def test_build_serve_env_with_key_keeps_auth_enabled(tmp_path): + env = cli.build_serve_env(data_dir=tmp_path, host="127.0.0.1", key="s3cret") + assert env.get("FIELD_NOTES_AUTH_DISABLED") != "1" + assert env["FIELD_NOTES_KEY"] == "s3cret" + + +def test_build_serve_env_public_bind_without_key_refuses(tmp_path): + with pytest.raises(ValueError, match="without a key"): + cli.build_serve_env(data_dir=tmp_path, host="0.0.0.0", key=None) + + +def test_build_serve_env_respects_existing_database_url(tmp_path): + env = cli.build_serve_env( + data_dir=tmp_path, + host="127.0.0.1", + key=None, + existing={"DATABASE_URL": "postgresql+asyncpg://u@h/db"}, + ) + assert "DATABASE_URL" not in env # power-user override preserved + + +# --- in-process migration (Risk #4: aiosqlite must become a sync driver) -- + + +def test_run_migrations_creates_schema_on_file_sqlite(tmp_path): + db = tmp_path / "fn.db" + cli.run_migrations(f"sqlite+aiosqlite:///{db}") + con = sqlite3.connect(db) + try: + names = {r[0] for r in con.execute("SELECT name FROM sqlite_master WHERE type='table'")} + finally: + con.close() + assert {"projects", "cells", "verdicts", "events", "alembic_version"} <= names + + +# --- serve wiring --------------------------------------------------------- + + +def test_serve_wires_uvicorn_loopback_and_skips_browser(tmp_path, monkeypatch): + # Start from a clean shell: conftest globally pins DATABASE_URL to :memory:, + # which serve's "respect existing override" would otherwise inherit. + monkeypatch.delenv("DATABASE_URL", raising=False) + monkeypatch.delenv("FIELD_NOTES_AUTH_DISABLED", raising=False) + calls: dict = {} + monkeypatch.setattr(cli, "run_migrations", lambda url: calls.__setitem__("migrated", url)) + monkeypatch.setattr("uvicorn.run", lambda _app, **kw: calls.update(kw)) + monkeypatch.setattr("webbrowser.open", lambda url: calls.__setitem__("browser", url)) + + cli.main(["serve", "--data-dir", str(tmp_path), "--no-browser", "--port", "8123"]) + + assert Path(calls["migrated"].split("///")[-1]).name == "field-notes.db" + assert calls["host"] == "127.0.0.1" + assert calls["port"] == 8123 + assert "browser" not in calls + assert os.environ["FIELD_NOTES_AUTH_DISABLED"] == "1" + # data dir + media dir created on disk + assert (tmp_path / "media").is_dir() diff --git a/uv.lock b/uv.lock index 519e3d4..17b95a9 100644 --- a/uv.lock +++ b/uv.lock @@ -405,6 +405,7 @@ name = "field-notes-api" version = "0.1.0" source = { editable = "apps/api" } dependencies = [ + { name = "aiosqlite" }, { name = "alembic" }, { name = "asyncpg" }, { name = "fastapi" }, @@ -420,7 +421,6 @@ dependencies = [ [package.dev-dependencies] dev = [ - { name = "aiosqlite" }, { name = "psycopg2-binary" }, { name = "pytest" }, { name = "pytest-asyncio" }, @@ -430,6 +430,7 @@ dev = [ [package.metadata] requires-dist = [ + { name = "aiosqlite", specifier = ">=0.20" }, { name = "alembic", specifier = ">=1.13" }, { name = "asyncpg", specifier = ">=0.29" }, { name = "fastapi", specifier = ">=0.115" }, @@ -445,7 +446,6 @@ requires-dist = [ [package.metadata.requires-dev] dev = [ - { name = "aiosqlite", specifier = ">=0.20" }, { name = "psycopg2-binary", specifier = ">=2.9.12" }, { name = "pytest", specifier = ">=8.0" }, { name = "pytest-asyncio", specifier = ">=0.24" }, From 85af531dfa13a7c8df65ae74b6bbcbf3b0d1f09a Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:10:54 -0700 Subject: [PATCH 04/11] local: add-media + verify-media subcommands media.py: copy files into the managed media root (media//) with byte-hash dedup (skip identical, refuse silent overwrite of different content); scan cell text for /media/ refs and report any missing from the root. CLI wires both; verify-media reads the local SQLite cells table directly. 191 passed. --- apps/api/field_notes_api/cli.py | 51 ++++++++++++++ apps/api/field_notes_api/media.py | 73 ++++++++++++++++++++ apps/api/tests/test_local_media.py | 103 +++++++++++++++++++++++++++++ 3 files changed, 227 insertions(+) create mode 100644 apps/api/field_notes_api/media.py create mode 100644 apps/api/tests/test_local_media.py diff --git a/apps/api/field_notes_api/cli.py b/apps/api/field_notes_api/cli.py index ecb832e..4ebefe5 100644 --- a/apps/api/field_notes_api/cli.py +++ b/apps/api/field_notes_api/cli.py @@ -150,6 +150,47 @@ def _cmd_serve(args: argparse.Namespace) -> int: return 0 +def _cmd_add_media(args: argparse.Namespace) -> int: + from . import media + + media_root = Path(args.data_dir).expanduser() / "media" + results = media.add_media([Path(p) for p in args.files], task=args.task, media_root=media_root) + for url, status in results: + print(f"{status:8} {url}") + return 0 + + +def _cmd_verify_media(args: argparse.Namespace) -> int: + import sqlite3 + + from . import media + + data_dir = Path(args.data_dir).expanduser() + db = data_dir / "field-notes.db" + media_root = data_dir / "media" + if not db.is_file(): + print(f"no database at {db}") + return 1 + + refs: set[str] = set() + con = sqlite3.connect(db) + try: + for row in con.execute("SELECT video, body, visual, deep FROM cells"): + blob = " ".join(str(c) for c in row if c is not None) + refs |= media.collect_media_refs(blob) + finally: + con.close() + + missing = media.missing_media(media_root, refs) + if missing: + print(f"{len(missing)} referenced media file(s) MISSING from {media_root}:") + for m in missing: + print(f" {m}") + return 1 + print(f"all {len(refs)} referenced /media path(s) present in {media_root}") + return 0 + + def _cmd_info(args: argparse.Namespace) -> int: data_dir = Path(args.data_dir).expanduser() print(f"data dir: {data_dir}") @@ -171,6 +212,16 @@ def build_parser() -> argparse.ArgumentParser: p_serve.add_argument("--no-browser", action="store_true", help="don't open a browser tab") p_serve.set_defaults(func=_cmd_serve) + p_addm = sub.add_parser("add-media", help="copy media files into the managed media root") + p_addm.add_argument("files", nargs="+", help="media files to copy in") + p_addm.add_argument("--task", required=True, help="subfolder under media/ (the in /media//...)") + p_addm.add_argument("--data-dir", default=DEFAULT_DATA_DIR) + p_addm.set_defaults(func=_cmd_add_media) + + p_vfy = sub.add_parser("verify-media", help="report cell media URLs missing from the media root") + p_vfy.add_argument("--data-dir", default=DEFAULT_DATA_DIR) + p_vfy.set_defaults(func=_cmd_verify_media) + p_info = sub.add_parser("info", help="print resolved local paths") p_info.add_argument("--data-dir", default=DEFAULT_DATA_DIR) p_info.set_defaults(func=_cmd_info) diff --git a/apps/api/field_notes_api/media.py b/apps/api/field_notes_api/media.py new file mode 100644 index 0000000..8d9d188 --- /dev/null +++ b/apps/api/field_notes_api/media.py @@ -0,0 +1,73 @@ +"""Managed media root helpers for the local self-host. + +Cells reference media by relative `/media//` URLs (the API mounts +FIELD_NOTES_MEDIA_DIR at /media). `add_media` copies files into that root with +byte-hash dedup; `missing_media` reports referenced paths the root lacks so a +post-transition check surfaces gaps instead of silent blank cells. +""" + +from __future__ import annotations + +import hashlib +import re +import shutil +from collections.abc import Iterable +from pathlib import Path + +# Managed media paths only; data: URIs are inline and external http(s) URLs are +# not ours to fetch, so both are ignored by the scan. +_MEDIA_REF = re.compile(r"/media/[A-Za-z0-9._\-/]+") + + +def _sha256(path: Path) -> str: + h = hashlib.sha256() + with path.open("rb") as fh: + for chunk in iter(lambda: fh.read(1 << 20), b""): + h.update(chunk) + return h.hexdigest() + + +def add_media(files: Iterable[Path], *, task: str, media_root: Path) -> list[tuple[str, str]]: + """Copy each file into `media_root//` and return (url, status) pairs. + + status: "copied" (new), "skipped" (byte-identical already there). A name + collision with *different* bytes raises FileExistsError rather than silently + clobbering — the caller renames instead of losing data. + """ + dest_dir = Path(media_root) / task + dest_dir.mkdir(parents=True, exist_ok=True) + results: list[tuple[str, str]] = [] + for src in files: + src = Path(src) + dest = dest_dir / src.name + url = f"/media/{task}/{src.name}" + if dest.exists(): + if _sha256(dest) == _sha256(src): + results.append((url, "skipped")) + continue + raise FileExistsError( + f"{dest} already exists with different content; rename {src.name} to avoid overwriting" + ) + shutil.copy2(src, dest) + results.append((url, "copied")) + return results + + +def collect_media_refs(blob: str) -> set[str]: + """Return every managed `/media/...` reference found in a text blob (a cell's + serialized video/body/visual/deep fields).""" + return set(_MEDIA_REF.findall(blob)) + + +def missing_media(media_root: Path, urls: Iterable[str]) -> list[str]: + """Return the sorted managed `/media/...` URLs that have no file under + media_root. data: and external URLs are ignored.""" + root = Path(media_root) + missing: set[str] = set() + for url in urls: + if not url or not url.startswith("/media/"): + continue + rel = url[len("/media/") :] + if not (root / rel).is_file(): + missing.add(url) + return sorted(missing) diff --git a/apps/api/tests/test_local_media.py b/apps/api/tests/test_local_media.py new file mode 100644 index 0000000..8b76e46 --- /dev/null +++ b/apps/api/tests/test_local_media.py @@ -0,0 +1,103 @@ +"""Managed media root: copy-in with dedup + missing-reference scan.""" + +from __future__ import annotations + +import pytest +from field_notes_api import media + +# --- add_media ------------------------------------------------------------ + + +def test_add_media_copies_and_returns_relative_url(tmp_path): + root = tmp_path / "media" + src = tmp_path / "clip.mp4" + src.write_bytes(b"video-bytes") + + results = media.add_media([src], task="demo", media_root=root) + + assert results == [("/media/demo/clip.mp4", "copied")] + assert (root / "demo" / "clip.mp4").read_bytes() == b"video-bytes" + + +def test_add_media_skips_byte_identical_file(tmp_path): + root = tmp_path / "media" + src = tmp_path / "clip.mp4" + src.write_bytes(b"same") + + media.add_media([src], task="demo", media_root=root) + results = media.add_media([src], task="demo", media_root=root) + + assert results == [("/media/demo/clip.mp4", "skipped")] + + +def test_add_media_refuses_silent_overwrite_of_different_content(tmp_path): + root = tmp_path / "media" + (root / "demo").mkdir(parents=True) + (root / "demo" / "clip.mp4").write_bytes(b"original") + + src = tmp_path / "clip.mp4" + src.write_bytes(b"DIFFERENT") + + with pytest.raises(FileExistsError): + media.add_media([src], task="demo", media_root=root) + + +# --- reference scanning --------------------------------------------------- + + +def test_collect_media_refs_finds_video_url_and_inline_paths(): + blob = '{"video": {"url": "/media/demo/a.mp4"}} see also /media/demo/b.png and https://x/c' + refs = media.collect_media_refs(blob) + assert "/media/demo/a.mp4" in refs + assert "/media/demo/b.png" in refs + # external URL is not a managed /media path + assert not any("https://x" in r for r in refs) + + +def test_missing_media_reports_only_absent_managed_paths(tmp_path): + root = tmp_path / "media" + (root / "demo").mkdir(parents=True) + (root / "demo" / "a.mp4").write_bytes(b"x") + + urls = [ + "/media/demo/a.mp4", # present + "/media/demo/b.mp4", # missing + "data:video/mp4;base64,AAAA", # inline, ignore + "https://cdn/c.mp4", # external, ignore + ] + missing = media.missing_media(root, urls) + assert missing == ["/media/demo/b.mp4"] + + +# --- CLI wiring ----------------------------------------------------------- + + +def test_cli_add_media_copies_into_managed_root(tmp_path): + from field_notes_api import cli + + src = tmp_path / "v.mp4" + src.write_bytes(b"x") + rc = cli.main(["add-media", str(src), "--task", "t", "--data-dir", str(tmp_path)]) + assert rc == 0 + assert (tmp_path / "media" / "t" / "v.mp4").is_file() + + +def test_cli_verify_media_flags_missing_reference(tmp_path): + """Exercises the real cells-table column read against a minimal SQLite DB.""" + import sqlite3 + + from field_notes_api import cli + + (tmp_path / "media").mkdir() + db = tmp_path / "field-notes.db" + con = sqlite3.connect(db) + con.execute("CREATE TABLE cells (video TEXT, body TEXT, visual TEXT, deep TEXT)") + con.execute( + "INSERT INTO cells VALUES (?,?,?,?)", + ('{"url":"/media/t/missing.mp4"}', None, None, None), + ) + con.commit() + con.close() + + rc = cli.main(["verify-media", "--data-dir", str(tmp_path)]) + assert rc == 1 # /media/t/missing.mp4 is referenced but absent From 001a4d16e8ec1de7b80e801314d91af46b090a2e Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:15:20 -0700 Subject: [PATCH 05/11] local: import-db (PG->SQLite, non-destructive) + fetch-media transfer.py: import_db copies every table source->dest in FK-dependency order, preserving PKs/FKs/JSON/timestamps. Refuses on Alembic revision mismatch (column drift would drop data) and on a non-empty dest unless overwrite=True; source is never written. Verified SQLite->SQLite (same path runs asyncpg->aiosqlite). fetch_media downloads the Dockerfile-declared tarballs into the media root (tarfile data filter blocks path traversal). CLI: import-db + fetch-media. alembic.ini: add path_separator=os (silences in-process migration warning). 196 passed. --- apps/api/alembic.ini | 1 + apps/api/field_notes_api/cli.py | 52 ++++++++++ apps/api/field_notes_api/transfer.py | 114 ++++++++++++++++++++++ apps/api/tests/test_local_transfer.py | 132 ++++++++++++++++++++++++++ 4 files changed, 299 insertions(+) create mode 100644 apps/api/field_notes_api/transfer.py create mode 100644 apps/api/tests/test_local_transfer.py diff --git a/apps/api/alembic.ini b/apps/api/alembic.ini index bf076db..f3f0ca8 100644 --- a/apps/api/alembic.ini +++ b/apps/api/alembic.ini @@ -1,6 +1,7 @@ [alembic] script_location = alembic prepend_sys_path = . +path_separator = os version_path_separator = os # sqlalchemy.url is set programmatically in alembic/env.py from DATABASE_URL. sqlalchemy.url = diff --git a/apps/api/field_notes_api/cli.py b/apps/api/field_notes_api/cli.py index 4ebefe5..55e7288 100644 --- a/apps/api/field_notes_api/cli.py +++ b/apps/api/field_notes_api/cli.py @@ -191,6 +191,46 @@ def _cmd_verify_media(args: argparse.Namespace) -> int: return 0 +def _cmd_import_db(args: argparse.Namespace) -> int: + import asyncio + + from . import transfer + + data_dir = Path(args.data_dir).expanduser() + (data_dir / "media").mkdir(parents=True, exist_ok=True) + dest_url = f"sqlite+aiosqlite:///{data_dir / 'field-notes.db'}" + run_migrations(dest_url) # ensure local schema + alembic stamp before copy + + counts = asyncio.run(transfer.import_db(args.source, dest_url, overwrite=args.overwrite)) + for table, n in counts.items(): + print(f" {n:6} {table}") + print(f"imported into {data_dir / 'field-notes.db'}") + print("next: run `field-notes fetch-media` so /media references resolve, then `field-notes verify-media`") + return 0 + + +def _locate_dockerfile() -> Path | None: + repo_dockerfile = Path(__file__).resolve().parents[3] / "Dockerfile" + return repo_dockerfile if repo_dockerfile.is_file() else None + + +def _cmd_fetch_media(args: argparse.Namespace) -> int: + from . import transfer + + media_root = Path(args.data_dir).expanduser() / "media" + urls = list(args.url) + if not urls: + dockerfile = Path(args.dockerfile) if args.dockerfile else _locate_dockerfile() + if not dockerfile or not dockerfile.is_file(): + print("no --url given and no Dockerfile found; pass --url or --dockerfile") + return 1 + urls = transfer.parse_media_urls(dockerfile.read_text()) + print(f"fetching {len(urls)} media tarball(s) into {media_root} ...") + transfer.fetch_media(media_root, urls) + print(f"done — {len(urls)} tarball(s) extracted") + return 0 + + def _cmd_info(args: argparse.Namespace) -> int: data_dir = Path(args.data_dir).expanduser() print(f"data dir: {data_dir}") @@ -222,6 +262,18 @@ def build_parser() -> argparse.ArgumentParser: p_vfy.add_argument("--data-dir", default=DEFAULT_DATA_DIR) p_vfy.set_defaults(func=_cmd_verify_media) + p_imp = sub.add_parser("import-db", help="copy a remote DB (e.g. Heroku Postgres) into local SQLite") + p_imp.add_argument("--source", required=True, help="source DATABASE_URL (postgres://… or sqlite://…)") + p_imp.add_argument("--data-dir", default=DEFAULT_DATA_DIR) + p_imp.add_argument("--overwrite", action="store_true", help="replace existing local rows instead of refusing") + p_imp.set_defaults(func=_cmd_import_db) + + p_fm = sub.add_parser("fetch-media", help="download the baked media tarballs into the media root") + p_fm.add_argument("--data-dir", default=DEFAULT_DATA_DIR) + p_fm.add_argument("--url", action="append", default=[], help="tarball URL (repeatable); else from Dockerfile") + p_fm.add_argument("--dockerfile", default=None, help="Dockerfile to parse URLs from (default: repo Dockerfile)") + p_fm.set_defaults(func=_cmd_fetch_media) + p_info = sub.add_parser("info", help="print resolved local paths") p_info.add_argument("--data-dir", default=DEFAULT_DATA_DIR) p_info.set_defaults(func=_cmd_info) diff --git a/apps/api/field_notes_api/transfer.py b/apps/api/field_notes_api/transfer.py new file mode 100644 index 0000000..59a6fc3 --- /dev/null +++ b/apps/api/field_notes_api/transfer.py @@ -0,0 +1,114 @@ +"""Transition an existing deployment into the local self-host without data loss. + +`import_db` copies every row from a source DB (e.g. Heroku Postgres) into the +local SQLite, preserving primary keys, foreign keys and timestamps. Both sides +run the identical cross-dialect schema, so the copy is a straight table-by-table +transfer in FK-dependency order. It is non-destructive (source untouched) and +refuses to clobber a non-empty dest unless `overwrite=True`. + +`fetch_media` pulls the baked media tarballs (URLs declared in the Dockerfile) +into the managed media root so `/media/...` references resolve locally. +""" + +from __future__ import annotations + +import re +import tarfile +import tempfile +import urllib.request +from pathlib import Path + +from sqlalchemy import func, select, text + +from .db import _build_engine +from .models import Base + +_TARBALL_URL = re.compile(r"https://\S+?\.tar\.gz") + + +def _to_async_url(url: str) -> str: + """Normalise any DB URL to an async driver create_async_engine understands.""" + if url.startswith("postgres://"): + return url.replace("postgres://", "postgresql+asyncpg://", 1) + if url.startswith("postgresql://"): + return url.replace("postgresql://", "postgresql+asyncpg://", 1) + if url.startswith("sqlite://") and "+aiosqlite" not in url: + return url.replace("sqlite://", "sqlite+aiosqlite://", 1) + return url + + +async def _read_revision(conn) -> str | None: # noqa: ANN001 — AsyncConnection + try: + return (await conn.execute(text("SELECT version_num FROM alembic_version"))).scalar() + except Exception: + return None + + +async def import_db(source_url: str, dest_url: str, *, overwrite: bool = False) -> dict[str, int]: + """Copy all rows source → dest. Returns {table: rows_copied}. + + Raises if the two DBs are at different Alembic revisions (column drift would + silently drop data) or if dest is non-empty and overwrite is False. + """ + src = _build_engine(_to_async_url(source_url)) + dst = _build_engine(_to_async_url(dest_url)) + try: + async with src.connect() as sc: + src_rev = await _read_revision(sc) + async with dst.connect() as dc: + dst_rev = await _read_revision(dc) + if src_rev != dst_rev: + raise RuntimeError( + f"Alembic revision mismatch: source={src_rev} dest={dst_rev}. " + "Migrate both to the same head before importing." + ) + + counts: dict[str, int] = {} + tables = list(Base.metadata.sorted_tables) # FK-dependency order: parents first + async with src.connect() as sc, dst.begin() as dc: + # Pre-flight + clear in reverse (child→parent) so FK constraints hold. + for table in reversed(tables): + existing = (await dc.execute(select(func.count()).select_from(table))).scalar() + if existing: + if not overwrite: + raise RuntimeError( + f"dest table {table.name} is not empty ({existing} rows); " + "pass overwrite=True to replace" + ) + await dc.execute(table.delete()) + # Copy forward (parent→child). + for table in tables: + rows = [dict(r._mapping) for r in (await sc.execute(table.select())).all()] + if rows: + await dc.execute(table.insert(), rows) + counts[table.name] = len(rows) + return counts + finally: + await src.dispose() + await dst.dispose() + + +def parse_media_urls(dockerfile_text: str) -> list[str]: + """Return the media tarball URLs declared in the Dockerfile, de-duplicated + in first-seen order.""" + seen: dict[str, None] = {} + for url in _TARBALL_URL.findall(dockerfile_text): + seen.setdefault(url, None) + return list(seen) + + +def fetch_media(media_root: Path, urls: list[str]) -> list[str]: + """Download + extract each tarball into media_root. Returns the URLs fetched. + + Uses tarfile's `data` filter to reject path-traversal / absolute members. + """ + root = Path(media_root) + root.mkdir(parents=True, exist_ok=True) + fetched: list[str] = [] + for url in urls: + with tempfile.NamedTemporaryFile(suffix=".tar.gz") as tmp: + urllib.request.urlretrieve(url, tmp.name) # noqa: S310 — fixed https HF URLs + with tarfile.open(tmp.name, "r:gz") as tar: + tar.extractall(root, filter="data") + fetched.append(url) + return fetched diff --git a/apps/api/tests/test_local_transfer.py b/apps/api/tests/test_local_transfer.py new file mode 100644 index 0000000..919c43e --- /dev/null +++ b/apps/api/tests/test_local_transfer.py @@ -0,0 +1,132 @@ +"""Data transition: PK/FK-preserving DB copy + media tarball URL parsing. + +The DB copy is exercised SQLite→SQLite; the same code path runs Postgres→SQLite +(asyncpg→aiosqlite) and is verified manually against the live Heroku DB. +""" + +from __future__ import annotations + +import os +import sqlite3 +import uuid + +import pytest +from field_notes_api import cli, transfer +from field_notes_api.db import _build_engine +from field_notes_api.models import Cell, Event, Project, VerdictRow + + +@pytest.fixture(autouse=True) +def _env_sandbox(): + saved = dict(os.environ) + yield + os.environ.clear() + os.environ.update(saved) + + +async def _seed(url: str, pid: uuid.UUID, cid: uuid.UUID) -> None: + eng = _build_engine(url) + async with eng.begin() as c: + await c.execute(Project.__table__.insert(), [{"id": pid, "name": "Proj", "position": 0}]) + await c.execute( + Cell.__table__.insert(), + [{"id": cid, "project_id": pid, "kind": "agent", "position": 0, "metrics": [{"k": "x", "v": 1}]}], + ) + await c.execute(VerdictRow.__table__.insert(), [{"cell_id": cid, "state": "accept", "note": "ok", "by": "you"}]) + await c.execute(Event.__table__.insert(), [{"id": uuid.uuid4(), "kind": "created", "project_id": pid}]) + await eng.dispose() + + +# --- DB copy -------------------------------------------------------------- + + +async def test_import_db_preserves_pks_fks_and_json(tmp_path): + src_url = f"sqlite+aiosqlite:///{tmp_path / 'src.db'}" + dst_url = f"sqlite+aiosqlite:///{tmp_path / 'dst.db'}" + cli.run_migrations(src_url) + cli.run_migrations(dst_url) + + pid, cid = uuid.uuid4(), uuid.uuid4() + await _seed(src_url, pid, cid) + + counts = await transfer.import_db(src_url, dst_url) + assert counts["projects"] == 1 and counts["cells"] == 1 and counts["verdicts"] == 1 and counts["events"] == 1 + + deng = _build_engine(dst_url) + async with deng.connect() as c: + proj = (await c.execute(Project.__table__.select())).one() + cell = (await c.execute(Cell.__table__.select())).one() + await deng.dispose() + assert proj.id == pid and proj.name == "Proj" # PK preserved + assert cell.id == cid and cell.project_id == pid # FK link preserved + assert cell.metrics == [{"k": "x", "v": 1}] # JSON round-trips + + +async def test_import_db_rejects_revision_mismatch(tmp_path): + src_url = f"sqlite+aiosqlite:///{tmp_path / 'src.db'}" + dst_path = tmp_path / "dst.db" + dst_url = f"sqlite+aiosqlite:///{dst_path}" + cli.run_migrations(src_url) + cli.run_migrations(dst_url) + + con = sqlite3.connect(dst_path) + con.execute("UPDATE alembic_version SET version_num='OLD'") + con.commit() + con.close() + + with pytest.raises(RuntimeError, match="revision"): + await transfer.import_db(src_url, dst_url) + + +async def test_import_db_guards_nonempty_dest(tmp_path): + src_url = f"sqlite+aiosqlite:///{tmp_path / 'src.db'}" + dst_url = f"sqlite+aiosqlite:///{tmp_path / 'dst.db'}" + cli.run_migrations(src_url) + cli.run_migrations(dst_url) + pid, cid = uuid.uuid4(), uuid.uuid4() + await _seed(src_url, pid, cid) + await _seed(dst_url, uuid.uuid4(), uuid.uuid4()) # dest already has data + + with pytest.raises(RuntimeError, match="not empty"): + await transfer.import_db(src_url, dst_url) + + counts = await transfer.import_db(src_url, dst_url, overwrite=True) + assert counts["projects"] == 1 # overwrite replaces, not appends + + +# --- media tarball URL parsing -------------------------------------------- + + +def test_parse_media_urls_from_dockerfile(): + text = ( + "ARG LIFTBARRIER_MEDIA_URL=https://huggingface.co/datasets/x/resolve/main/liftbarrier_media.tar.gz\n" + 'RUN curl -fsSL "$LIFTBARRIER_MEDIA_URL" | tar -xz -C /repo/apps/api/media\n' + "ARG MEMER_MEDIA_URL=https://huggingface.co/datasets/x/resolve/main/memer_media.tar.gz\n" + ) + urls = transfer.parse_media_urls(text) + assert urls == [ + "https://huggingface.co/datasets/x/resolve/main/liftbarrier_media.tar.gz", + "https://huggingface.co/datasets/x/resolve/main/memer_media.tar.gz", + ] + + +# --- CLI wiring ----------------------------------------------------------- + + +def test_cli_import_db_into_local_data_dir(tmp_path): + import asyncio + + src_url = f"sqlite+aiosqlite:///{tmp_path / 'src.db'}" + cli.run_migrations(src_url) + asyncio.run(_seed(src_url, uuid.uuid4(), uuid.uuid4())) + + data_dir = tmp_path / "local" + rc = cli.main(["import-db", "--source", src_url, "--data-dir", str(data_dir)]) + assert rc == 0 + + con = sqlite3.connect(data_dir / "field-notes.db") + try: + assert con.execute("SELECT count(*) FROM projects").fetchone()[0] == 1 + assert con.execute("SELECT count(*) FROM cells").fetchone()[0] == 1 + finally: + con.close() From 74126dd553edfec27ff3302f6747c9da1f7ae7da Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:19:25 -0700 Subject: [PATCH 06/11] local: bundle migrations (+ built SPA) as package data hatchling force-include ships apps/api/alembic -> field_notes_api/_alembic so `field-notes serve`/import-db can migrate from an installed wheel. The built SPA at field_notes_api/_web (produced by `make build-web`, committed so uvx-from-git serves the UI with no Node) is picked up by default package inclusion. cli: _package_dir() indirection for testability. Verified: wheel bundles _alembic (ini + 5 migrations) and _web; builds cleanly with _web absent (API-only fallback); run_migrations works from the bundled layout. 201 passed. --- Makefile | 11 +++- apps/api/field_notes_api/cli.py | 10 +++- apps/api/pyproject.toml | 8 +++ apps/api/tests/test_local_packaging.py | 80 ++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 apps/api/tests/test_local_packaging.py diff --git a/Makefile b/Makefile index 62581a4..7f5068b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: dev build restart stop status logs update test lint format fmt web-dev api-dev seed clean +.PHONY: dev build build-web restart stop status logs update test lint format fmt web-dev api-dev seed clean # ---- Always-on local stack (Option B: native mamba Postgres + native uvicorn) ---- @@ -6,6 +6,15 @@ build: cd apps/web && npm run build +# Build the SPA AND stage it inside the API package so it ships in the wheel. +# Run this (on a machine with Node) before committing frontend changes or +# building a release — `uvx --from git+ field-notes` serves this _web/. +build-web: + cd apps/web && npm ci && npm run build + rm -rf apps/api/field_notes_api/_web + cp -r apps/web/dist apps/api/field_notes_api/_web + @echo "staged apps/web/dist -> apps/api/field_notes_api/_web (commit it so uvx-from-git serves the UI)" + # Restart the always-on API (after backend code changes or rebuilding the web). restart: @PIDFILE=data/api.pid; \ diff --git a/apps/api/field_notes_api/cli.py b/apps/api/field_notes_api/cli.py index 55e7288..a91f5d4 100644 --- a/apps/api/field_notes_api/cli.py +++ b/apps/api/field_notes_api/cli.py @@ -74,10 +74,16 @@ def build_serve_env( return env +def _package_dir() -> Path: + """Directory of the installed field_notes_api package (where _web/ and + _alembic/ are bundled in a wheel). Indirected so tests can point elsewhere.""" + return Path(__file__).resolve().parent + + def _find_alembic() -> tuple[Path, Path]: """Return (alembic.ini, script_location). Works from the source tree and from a wheel where the migrations are bundled under the package as _alembic/.""" - pkg = Path(__file__).resolve().parent + pkg = _package_dir() candidates = [ (pkg / "_alembic" / "alembic.ini", pkg / "_alembic" / "alembic"), # packaged (pkg.parent / "alembic.ini", pkg.parent / "alembic"), # source: apps/api/ @@ -107,7 +113,7 @@ def resolve_static_dir() -> str | None: explicit = os.environ.get("FIELD_NOTES_STATIC_DIR") if explicit: return explicit - packaged = Path(__file__).resolve().parent / "_web" + packaged = _package_dir() / "_web" if (packaged / "index.html").is_file(): return str(packaged) return None diff --git a/apps/api/pyproject.toml b/apps/api/pyproject.toml index 7f30c33..e0e9ff8 100644 --- a/apps/api/pyproject.toml +++ b/apps/api/pyproject.toml @@ -37,3 +37,11 @@ build-backend = "hatchling.build" [tool.hatch.build.targets.wheel] packages = ["field_notes_api"] + +# Bundle the Alembic migrations under the package so `field-notes serve` / +# `import-db` can run `alembic upgrade head` from an installed wheel (cli.py +# looks for field_notes_api/_alembic/). The built SPA at field_notes_api/_web/ +# (produced by `make build-web`) is picked up by the default package include. +[tool.hatch.build.targets.wheel.force-include] +"alembic" = "field_notes_api/_alembic/alembic" +"alembic.ini" = "field_notes_api/_alembic/alembic.ini" diff --git a/apps/api/tests/test_local_packaging.py b/apps/api/tests/test_local_packaging.py new file mode 100644 index 0000000..280ad86 --- /dev/null +++ b/apps/api/tests/test_local_packaging.py @@ -0,0 +1,80 @@ +"""Packaged-layout resolution: the wheel bundles _web/ (SPA) and _alembic/. + +These verify the runtime *finds* the bundled assets given the wheel layout; the +actual bundling is asserted by inspecting a built wheel in CI / the dev flow. +""" + +from __future__ import annotations + +import os + +import pytest +from field_notes_api import cli + + +@pytest.fixture(autouse=True) +def _clear_static_env(monkeypatch): + monkeypatch.delenv("FIELD_NOTES_STATIC_DIR", raising=False) + + +def test_resolve_static_dir_finds_bundled_web(tmp_path, monkeypatch): + web = tmp_path / "_web" + web.mkdir() + (web / "index.html").write_text("") + monkeypatch.setattr(cli, "_package_dir", lambda: tmp_path) + + assert cli.resolve_static_dir() == str(web) + + +def test_resolve_static_dir_none_when_web_absent(tmp_path, monkeypatch): + monkeypatch.setattr(cli, "_package_dir", lambda: tmp_path) + assert cli.resolve_static_dir() is None + + +def test_resolve_static_dir_env_wins_over_bundle(tmp_path, monkeypatch): + monkeypatch.setenv("FIELD_NOTES_STATIC_DIR", "/explicit/dir") + monkeypatch.setattr(cli, "_package_dir", lambda: tmp_path) + assert cli.resolve_static_dir() == "/explicit/dir" + + +def test_find_alembic_prefers_packaged_layout(tmp_path, monkeypatch): + alembic = tmp_path / "_alembic" / "alembic" + alembic.mkdir(parents=True) + (tmp_path / "_alembic" / "alembic.ini").write_text("[alembic]\n") + monkeypatch.setattr(cli, "_package_dir", lambda: tmp_path) + + ini, script = cli._find_alembic() + assert ini == tmp_path / "_alembic" / "alembic.ini" + assert script == tmp_path / "_alembic" / "alembic" + + +def test_run_migrations_uses_bundled_alembic_then_migrates(tmp_path, monkeypatch): + """End-to-end: stage a wheel-style _alembic/ next to a fake package dir and + confirm run_migrations finds + applies it on a fresh SQLite DB.""" + import shutil + import sqlite3 + from pathlib import Path + + # Stage the real migrations under a wheel-style _alembic/ in a temp pkg dir. + src_ini, src_script = cli._find_alembic() # the source-tree copy + pkg = tmp_path / "pkg" + (pkg / "_alembic").mkdir(parents=True) + shutil.copy(src_ini, pkg / "_alembic" / "alembic.ini") + shutil.copytree(src_script, pkg / "_alembic" / "alembic") + monkeypatch.setattr(cli, "_package_dir", lambda: pkg) + + db = tmp_path / "fn.db" + saved = dict(os.environ) + try: + cli.run_migrations(f"sqlite+aiosqlite:///{db}") + finally: + os.environ.clear() + os.environ.update(saved) + + con = sqlite3.connect(db) + try: + names = {r[0] for r in con.execute("SELECT name FROM sqlite_master WHERE type='table'")} + finally: + con.close() + assert {"projects", "cells", "alembic_version"} <= names + assert Path(pkg / "_alembic" / "alembic").is_dir() # used the bundled copy From e5bc41a02faa82ea0f8180073be97f61646a94a2 Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 16:22:36 -0700 Subject: [PATCH 07/11] oss: MIT license + local-self-host README + env note MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - LICENSE: MIT (holder: Mikul Rai — adjust if desired). - README: 'Run it yourself' uvx-from-git quickstart, MCP config (throwaway FIELD_NOTES_KEY=local since the loopback API ignores it), and a no-data-loss migration recipe (import-db -> fetch-media -> verify-media). - Makefile build-web: bake VITE_DEFAULT_KEY=local so the bundled SPA skips the key gate locally. - .env.example: note the local path needs none of these vars. --- .env.example | 5 +++++ LICENSE | 21 +++++++++++++++++++++ Makefile | 6 +++++- README.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/.env.example b/.env.example index 7eadb19..2ebdd69 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,8 @@ +# Local single-process self-host (`field-notes serve`) needs NONE of this — it +# defaults to a file-backed SQLite under ~/.field-notes and disables auth on a +# loopback bind. The vars below are for the Postgres / networked dev stack +# (docker-compose, Heroku/Fly) only. + FIELD_NOTES_KEY=changeme DATABASE_URL=postgresql+asyncpg://field_notes:field_notes@localhost:5432/field_notes POSTGRES_USER=field_notes diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1e62543 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Mikul Rai + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile index 7f5068b..edd015d 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,12 @@ build: # Build the SPA AND stage it inside the API package so it ships in the wheel. # Run this (on a machine with Node) before committing frontend changes or # building a release — `uvx --from git+ field-notes` serves this _web/. +# +# VITE_DEFAULT_KEY=local bakes a throwaway key into the local bundle so the UI +# skips the "enter your key" gate; the loopback server has auth disabled and +# ignores it. (A networked deploy builds its own dist without this.) build-web: - cd apps/web && npm ci && npm run build + cd apps/web && npm ci && VITE_DEFAULT_KEY=local npm run build rm -rf apps/api/field_notes_api/_web cp -r apps/web/dist apps/api/field_notes_api/_web @echo "staged apps/web/dist -> apps/api/field_notes_api/_web (commit it so uvx-from-git serves the UI)" diff --git a/README.md b/README.md index d7f9d23..ee13b32 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,55 @@ ML research notebook with MCP-driven agents. Cells (agent, markdown, empty) live inside projects; humans verify / reject / lock; agents push results via the MCP server and observe what the human did. +## Run it yourself (local, no setup) + +One command — needs only [uv](https://docs.astral.sh/uv/). No Node, no Docker, +no database server: + +```bash +uvx --from git+https://github.com/themikulrai/field-notes field-notes serve +``` + +This creates `~/.field-notes/` (a SQLite DB + a `media/` folder), runs the +migrations, and opens the notebook at . **Your data is +that one folder** — back it up by copying it. It binds to loopback with auth +disabled, so there's no key to manage; to expose it on a network pass +`--host 0.0.0.0 --key `. + +Point an MCP host (Claude Code, etc.) at the local API. The `local` key is a +throwaway — the loopback server ignores it: + +```json +{ + "mcpServers": { + "field-notes": { + "command": "uvx", + "args": ["--from", "git+https://github.com/themikulrai/field-notes", "field-notes-mcp"], + "env": { "FIELD_NOTES_API_URL": "http://127.0.0.1:8000", "FIELD_NOTES_KEY": "local" } + } + } +} +``` + +### Bring your existing notes (no data loss) + +Migrate a hosted instance into your local copy. It's a **copy** — the source +DB is never written: + +```bash +# 1. copy projects / cells / verdicts / events (preserves IDs + links) +field-notes import-db --source "postgres://…your DATABASE_URL…" +# 2. download the baked media tarballs so /media/... references resolve +field-notes fetch-media +# 3. report any media a cell references but the local copy is missing +field-notes verify-media +# 4. open it +field-notes serve +``` + +If you outgrow SQLite (heavy parallel agent writes), point at Postgres with the +same code: `DATABASE_URL=postgres://… field-notes serve`. + ## Architecture ``` From 60edcb7fcc0a1e2ac64b359d6624316ffffcbc0e Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:05:01 -0700 Subject: [PATCH 08/11] local: commit built SPA bundle (field_notes_api/_web) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Built with VITE_DEFAULT_KEY=local so the loopback UI skips the key gate. With this committed, `field-notes serve` (from source or wheel) serves the full UI at / — no Node needed at run time. Rebuild via `make build-web` after frontend changes. Verified: GET / -> 200, title 'Field Notes', JS asset 200. --- .../_web/assets/embed-S92vvM1_.js | 201 ++++++++++++++++++ .../_web/assets/index-Cgs-dOlY.css | 1 + .../_web/assets/index-CyAub9oQ.js | 63 ++++++ apps/api/field_notes_api/_web/index.html | 19 ++ 4 files changed, 284 insertions(+) create mode 100644 apps/api/field_notes_api/_web/assets/embed-S92vvM1_.js create mode 100644 apps/api/field_notes_api/_web/assets/index-Cgs-dOlY.css create mode 100644 apps/api/field_notes_api/_web/assets/index-CyAub9oQ.js create mode 100644 apps/api/field_notes_api/_web/index.html diff --git a/apps/api/field_notes_api/_web/assets/embed-S92vvM1_.js b/apps/api/field_notes_api/_web/assets/embed-S92vvM1_.js new file mode 100644 index 0000000..83e1112 --- /dev/null +++ b/apps/api/field_notes_api/_web/assets/embed-S92vvM1_.js @@ -0,0 +1,201 @@ +var gI=Object.defineProperty;var T_=e=>{throw TypeError(e)};var pI=(e,t,n)=>t in e?gI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var I=(e,t,n)=>pI(e,typeof t!="symbol"?t+"":t,n),N_=(e,t,n)=>t.has(e)||T_("Cannot "+n);var R_=(e,t,n)=>(N_(e,t,"read from private field"),n?n.call(e):t.get(e)),O_=(e,t,n)=>t.has(e)?T_("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Qm=(e,t,n,i)=>(N_(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n);const mI=/("(?:[^\\"]|\\.)*")|[:,]/g;function Zm(e,t={}){const n=JSON.stringify([1],void 0,t.indent===void 0?2:t.indent).slice(2,-3),i=n===""?1/0:t.maxLength===void 0?80:t.maxLength;let{replacer:r}=t;return function o(s,a,u){s&&typeof s.toJSON=="function"&&(s=s.toJSON());const l=JSON.stringify(s,r);if(l===void 0)return l;const c=i-a.length-u;if(l.length<=c){const f=l.replace(mI,(d,h)=>h||`${d} `);if(f.length<=c)return f}if(r!=null&&(s=JSON.parse(l),r=void 0),typeof s=="object"&&s!==null){const f=a+n,d=[];let h=0,g,p;if(Array.isArray(s)){g="[",p="]";const{length:m}=s;for(;h0)return[g,n+d.join(`, +${f}`),p].join(` +${a}`)}return l}(e,"",0)}function kn(e,t,n){return Object.assign(e,{fields:t||[],fname:n})}function Ze(e){return e==null?null:e.fname}function qt(e){return e==null?null:e.fields}function yF(e){return e.length===1?yI(e[0]):bI(e)}const yI=e=>function(t){return t[e]},bI=e=>{const t=e.length;return function(n){for(let i=0;is?l():s=a+1:u==="["?(a>s&&l(),r=s=a+1):u==="]"&&(r||O("Access path missing open bracket: "+e),r>0&&l(),r=0,s=a+1)}return r&&O("Access path missing closing bracket: "+e),i&&O("Access path missing closing quote: "+e),a>s&&(a++,l()),t}function ei(e,t,n){const i=dr(e),r=i.length===1?i[0]:e;return kn((n&&n.get||yF)(i),[r],t||r)}const uf=ei("id"),vn=kn(e=>e,[],"identity"),_o=kn(()=>0,[],"zero"),Ku=kn(()=>1,[],"one"),ti=kn(()=>!0,[],"true"),po=kn(()=>!1,[],"false"),ov=new Set([...Object.getOwnPropertyNames(Object.prototype).filter(e=>typeof Object.prototype[e]=="function"),"__proto__"]);function vI(e,t,n){const i=[t,...n];console[e](...i)}const bF=0,sv=1,av=2,vF=3,xF=4;function Yg(e,t,n=vI){let i=e||bF;return{level(r){return arguments.length?(i=+r,this):i},error(...r){return i>=sv&&n(t||"error","ERROR",r),this},warn(...r){return i>=av&&n(t||"warn","WARN",r),this},info(...r){return i>=vF&&n(t||"log","INFO",r),this},debug(...r){return i>=xF&&n(t||"log","DEBUG",r),this}}}const P=Array.isArray;function K(e){return e===Object(e)}const D_=e=>e!=="__proto__"&&e!=="constructor"&&e!=="prototype";function Ju(...e){return e.reduce((t,n)=>{for(const i in n)if(i==="signals")t.signals=xI(t.signals,n.signals);else{const r=i==="legend"?{layout:1}:i==="style"?!0:null;Qu(t,i,n[i],r)}return t},{})}function Qu(e,t,n,i){if(!D_(t))return;let r,o;if(K(n)&&!P(n)){const s=n;o=K(e[t])?e[t]:e[t]={};for(r in s)i&&(i===!0||i[r])?Qu(o,r,s[r]):D_(r)&&(o[r]=s[r])}else e[t]=n}function xI(e,t){if(e==null)return t;if(t==null)return e;const n={},i=[];function r(o){n[o.name]||(n[o.name]=1,i.push(o))}return t.forEach(r),e.forEach(r),i}function _e(e){return e[e.length-1]}function nn(e){return e==null||e===""?null:+e}function wF(e){return e.length>0}const EF=e=>t=>e*Math.exp(t),_F=e=>t=>Math.log(e*t),SF=e=>t=>Math.sign(t)*Math.log1p(Math.abs(t/e)),$F=e=>t=>Math.sign(t)*Math.expm1(Math.abs(t))*e,hh=e=>t=>t<0?-Math.pow(-t,e):Math.pow(t,e),kF=e=>nn(e)??0,AF=e=>e;function Vg(e,t,n,i){wF(e)||O("Domain array must not be empty");const r=n(e[0]),o=n(_e(e)),s=(o-r)*t;return[i(r-s),i(o-s)]}function CF(e,t){return Vg(e,t,kF,AF)}function FF(e,t){const n=Math.sign(e[0]);return Vg(e,t,_F(n),EF(n))}function MF(e,t,n){return Vg(e,t,hh(n),hh(1/n))}function TF(e,t,n){return Vg(e,t,SF(n),$F(n))}function Xg(e,t,n,i,r){wF(e)||O("Domain array must not be empty");const o=i(e[0]),s=i(_e(e)),a=t!=null?i(t):(o+s)/2;return[r(a+(o-a)*n),r(a+(s-a)*n)]}function uv(e,t,n){return Xg(e,t,n,kF,AF)}function lv(e,t,n){const i=Math.sign(e[0]);return Xg(e,t,n,_F(i),EF(i))}function gh(e,t,n,i){return Xg(e,t,n,hh(i),hh(1/i))}function cv(e,t,n,i){return Xg(e,t,n,SF(i),$F(i))}function NF(e){return 1+~~(new Date(e).getMonth()/3)}function RF(e){return 1+~~(new Date(e).getUTCMonth()/3)}function Q(e){return e!=null?P(e)?e:[e]:[]}function OF(e,t,n){let i=e[0],r=e[1],o;return r=n-t?[t,n]:[i=Math.min(Math.max(i,t),n-o),i+o]}function de(e){return typeof e=="function"}const wI="descending";function fv(e,t,n){const i=n||{},r=Q(t)||[],o=[],s=[],a={},u=i.comparator||EI;return Q(e).forEach((l,c)=>{if(l==null)return;o.push(r[c]===wI?-1:1);const f=de(l)?l:ei(l,void 0,i);s.push(f),(qt(f)||[]).forEach(d=>a[d]=1)}),s.length===0?null:kn(u(s,o),Object.keys(a))}const Zu=(e,t)=>{let n=e,i=t;return(ni||i==null)&&n!=null?1:(i=i instanceof Date?+i:i,(n=n instanceof Date?+n:n)!==n&&i===i?-1:i!==i&&n===n?1:0)},EI=(e,t)=>e.length===1?_I(e[0],t[0]):SI(e,t,e.length),_I=(e,t)=>function(n,i){return Zu(e(n),e(i))*t},SI=(e,t,n)=>(t.push(0),function(i,r){let o,s=0,a=-1;for(;s===0&&++ae}function dv(e,t){let n=null;return i=>{n&&clearTimeout(n),n=setTimeout(()=>(t(i),n=null),e)}}function pe(e,...t){for(const n of t)for(const i in n)e[i]=n[i];return e}function ir(e,t){let n=0,i,r,o,s;if(e&&(i=e.length))if(t==null){for(r=e[n];ns&&(s=r))}else{for(r=t(e[n]);ns&&(s=r))}return[o,s]}function DF(e,t){const n=e.length;let i=-1,r,o,s,a,u;if(t==null){for(;++i=a){s=u=a;break}if(i===n)return[-1,-1];for(r=o=i;++ia&&(s=a,r=i),u=a){s=u=a;break}if(i===n)return[-1,-1];for(r=o=i;++ia&&(s=a,r=i),u{r.set(o,e[o])}),r}function LF(e,t,n,i,r,o){if(!n&&n!==0)return o;const s=+n;let a=e[0],u=_e(e),l;if(u===void 0)return o;uo&&(s=r,r=o,o=s),n=n===void 0||n,i=i===void 0||i,(n?r<=e:ru.replace(/\\(.)/g,"$1")):Q(e):void 0,r=i==null?void 0:i.length,o=n&&n.get||yF,s=u=>o(t?[u]:dr(u));let a;if(!r||!i)a=function(){return""};else if(r===1){const u=s(i[0]);a=function(l){return""+u(l)}}else{const u=i.map(s);a=function(l){let c=""+u[0](l),f=0;for(;++f{t={},n={},i=0},o=(s,a)=>(++i>e&&(n=t,t={},i=1),t[s]=a);return r(),{clear:r,has:s=>Z(t,s)||Z(n,s),get:s=>Z(t,s)?t[s]:Z(n,s)?o(s,n[s]):void 0,set:(s,a)=>Z(t,s)?t[s]=a:o(s,a)}}function kI(e){return e===Array||typeof e=="function"&&e.prototype&&ArrayBuffer.isView(e.prototype)}function BF(e,t,n,i){const r=t.length,o=n.length;if(!o)return t;if(!r)return n;const s=t.constructor,a=i||(kI(s)?new s(r+o):new Array(r+o));let u=0,l=0,c=0;for(;u0?n[l++]:t[u++];for(;u=0;)n+=e;return n}function UF(e,t,n,i){const r=n||" ",o=e+"",s=t-o.length;return s<=0?o:i==="left"?Vl(r,s)+o:i==="center"?Vl(r,~~(s/2))+o+Vl(r,Math.ceil(s/2)):o+Vl(r,s)}function lf(e){return e&&_e(e)-e[0]||0}function G(e){return P(e)?`[${e.map(t=>t===null?"null":G(t))}]`:K(e)||J(e)?JSON.stringify(e).replaceAll("\u2028","\\u2028").replaceAll("\u2029","\\u2029"):e}function pv(e){return e==null||e===""?null:!e||e==="false"||e==="0"?!1:!!e}const AI=e=>ke(e)||Ro(e)?e:Date.parse(e);function mv(e,t){return t=t||AI,e==null||e===""?null:t(e)}function yv(e){return e==null||e===""?null:e+""}function $i(e){const t={},n=e.length;for(let i=0;i9999?"+"+hn(e,6):hn(e,4)}function MI(e){var t=e.getUTCHours(),n=e.getUTCMinutes(),i=e.getUTCSeconds(),r=e.getUTCMilliseconds();return isNaN(e)?"Invalid Date":FI(e.getUTCFullYear())+"-"+hn(e.getUTCMonth()+1,2)+"-"+hn(e.getUTCDate(),2)+(r?"T"+hn(t,2)+":"+hn(n,2)+":"+hn(i,2)+"."+hn(r,3)+"Z":i?"T"+hn(t,2)+":"+hn(n,2)+":"+hn(i,2)+"Z":n||t?"T"+hn(t,2)+":"+hn(n,2)+"Z":"")}function TI(e){var t=new RegExp('["'+e+` +\r]`),n=e.charCodeAt(0);function i(f,d){var h,g,p=r(f,function(m,y){if(h)return h(m,y-1);g=m,h=d?CI(m,d):qF(m)});return p.columns=g||[],p}function r(f,d){var h=[],g=f.length,p=0,m=0,y,b=g<=0,v=!1;f.charCodeAt(g-1)===_l&&--g,f.charCodeAt(g-1)===n0&&--g;function x(){if(b)return e0;if(v)return v=!1,L_;var _,w=p,S;if(f.charCodeAt(w)===t0){for(;p++=g?b=!0:(S=f.charCodeAt(p++))===_l?v=!0:S===n0&&(v=!0,f.charCodeAt(p)===_l&&++p),f.slice(w+1,_-1).replace(/""/g,'"')}for(;p1)i=zI(e,t,n);else for(r=0,i=new Array(o=e.arcs.length);rt?1:e>=t?0:NaN}function BI(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function tl(e){let t,n,i;e.length!==2?(t=Ur,n=(a,u)=>Ur(e(a),u),i=(a,u)=>e(a)-u):(t=e===Ur||e===BI?e:UI,n=e,i=e);function r(a,u,l=0,c=a.length){if(l>>1;n(a[f],u)<0?l=f+1:c=f}while(l>>1;n(a[f],u)<=0?l=f+1:c=f}while(ll&&i(a[f-1],u)>-i(a[f],u)?f-1:f}return{left:r,center:s,right:o}}function UI(){return 0}function HF(e){return e===null?NaN:+e}function*jI(e,t){if(t===void 0)for(let n of e)n!=null&&(n=+n)>=n&&(yield n);else{let n=-1;for(let i of e)(i=t(i,++n,e))!=null&&(i=+i)>=i&&(yield i)}}const GF=tl(Ur),zo=GF.right,qI=GF.left;tl(HF).center;function WI(e,t){let n=0,i,r=0,o=0;if(t===void 0)for(let s of e)s!=null&&(s=+s)>=s&&(i=s-r,r+=i/++n,o+=i*(s-r));else{let s=-1;for(let a of e)(a=t(a,++s,e))!=null&&(a=+a)>=a&&(i=a-r,r+=i/++n,o+=i*(a-r))}if(n>1)return o/(n-1)}function HI(e,t){const n=WI(e,t);return n&&Math.sqrt(n)}class sn{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const n=this._partials;let i=0;for(let r=0;r0){for(s=t[--n];n>0&&(i=s,r=t[--n],s=i+r,o=r-(s-i),!o););n>0&&(o<0&&t[n-1]<0||o>0&&t[n-1]>0)&&(r=o*2,i=s+r,r==i-s&&(s=i))}return s}}class z_ extends Map{constructor(t,n=XF){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const[i,r]of t)this.set(i,r)}get(t){return super.get(q1(this,t))}has(t){return super.has(q1(this,t))}set(t,n){return super.set(YF(this,t),n)}delete(t){return super.delete(VF(this,t))}}class ph extends Set{constructor(t,n=XF){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),t!=null)for(const i of t)this.add(i)}has(t){return super.has(q1(this,t))}add(t){return super.add(YF(this,t))}delete(t){return super.delete(VF(this,t))}}function q1({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):n}function YF({_intern:e,_key:t},n){const i=t(n);return e.has(i)?e.get(i):(e.set(i,n),n)}function VF({_intern:e,_key:t},n){const i=t(n);return e.has(i)&&(n=e.get(i),e.delete(i)),n}function XF(e){return e!==null&&typeof e=="object"?e.valueOf():e}function GI(e,t){return Array.from(t,n=>e[n])}function YI(e=Ur){if(e===Ur)return KF;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,n)=>{const i=e(t,n);return i||i===0?i:(e(n,n)===0)-(e(t,t)===0)}}function KF(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et?1:0)}const VI=Math.sqrt(50),XI=Math.sqrt(10),KI=Math.sqrt(2);function mh(e,t,n){const i=(t-e)/Math.max(0,n),r=Math.floor(Math.log10(i)),o=i/Math.pow(10,r),s=o>=VI?10:o>=XI?5:o>=KI?2:1;let a,u,l;return r<0?(l=Math.pow(10,-r)/s,a=Math.round(e*l),u=Math.round(t*l),a/lt&&--u,l=-l):(l=Math.pow(10,r)*s,a=Math.round(e/l),u=Math.round(t/l),a*lt&&--u),u0))return[];if(e===t)return[e];const i=t=r))return[];const a=o-r+1,u=new Array(a);if(i)if(s<0)for(let l=0;l=i)&&(n=i);else{let i=-1;for(let r of e)(r=t(r,++i,e))!=null&&(n=r)&&(n=r)}return n}function G1(e,t){let n;if(t===void 0)for(const i of e)i!=null&&(n>i||n===void 0&&i>=i)&&(n=i);else{let i=-1;for(let r of e)(r=t(r,++i,e))!=null&&(n>r||n===void 0&&r>=r)&&(n=r)}return n}function JF(e,t,n=0,i=1/0,r){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),i=Math.floor(Math.min(e.length-1,i)),!(n<=t&&t<=i))return e;for(r=r===void 0?KF:YI(r);i>n;){if(i-n>600){const u=i-n+1,l=t-n+1,c=Math.log(u),f=.5*Math.exp(2*c/3),d=.5*Math.sqrt(c*f*(u-f)/u)*(l-u/2<0?-1:1),h=Math.max(n,Math.floor(t-l*f/u+d)),g=Math.min(i,Math.floor(t+(u-l)*f/u+d));JF(e,t,h,g,r)}const o=e[t];let s=n,a=i;for(Sl(e,n,t),r(e[i],o)>0&&Sl(e,n,i);s0;)--a}r(e[n],o)===0?Sl(e,n,a):(++a,Sl(e,a,i)),a<=t&&(n=a+1),t<=a&&(i=a-1)}return e}function Sl(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function Y1(e,t,n){if(e=Float64Array.from(jI(e,n)),!(!(i=e.length)||isNaN(t=+t))){if(t<=0||i<2)return G1(e);if(t>=1)return Ls(e);var i,r=(i-1)*t,o=Math.floor(r),s=Ls(JF(e,o).subarray(0,o+1)),a=G1(e.subarray(o+1));return s+(a-s)*(r-o)}}function QF(e,t,n=HF){if(!(!(i=e.length)||isNaN(t=+t))){if(t<=0||i<2)return+n(e[0],0,e);if(t>=1)return+n(e[i-1],i-1,e);var i,r=(i-1)*t,o=Math.floor(r),s=+n(e[o],o,e),a=+n(e[o+1],o+1,e);return s+(a-s)*(r-o)}}function JI(e,t){let n=0,i=0;if(t===void 0)for(let r of e)r!=null&&(r=+r)>=r&&(++n,i+=r);else{let r=-1;for(let o of e)(o=t(o,++r,e))!=null&&(o=+o)>=o&&(++n,i+=o)}if(n)return i/n}function ZF(e,t){return Y1(e,.5,t)}function*QI(e){for(const t of e)yield*t}function eM(e){return Array.from(QI(e))}function Nn(e,t,n){e=+e,t=+t,n=(r=arguments.length)<2?(t=e,e=0,1):r<3?1:+n;for(var i=-1,r=Math.max(0,Math.ceil((t-e)/n))|0,o=new Array(r);++i=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function yh(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),i=e.slice(0,n);return[i.length>1?i[0]+i.slice(2):i,+e.slice(n+1)]}function hu(e){return e=yh(Math.abs(e)),e?e[1]:NaN}function i4(e,t){return function(n,i){for(var r=n.length,o=[],s=0,a=e[0],u=0;r>0&&a>0&&(u+a+1>i&&(a=Math.max(1,i-u)),o.push(n.substring(r-=a,r+a)),!((u+=a+1)>i));)a=e[s=(s+1)%e.length];return o.reverse().join(t)}}function r4(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var o4=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Gs(e){if(!(t=o4.exec(e)))throw new Error("invalid format: "+e);var t;return new bv({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}Gs.prototype=bv.prototype;function bv(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}bv.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function s4(e){e:for(var t=e.length,n=1,i=-1,r;n0&&(i=0);break}return i>0?e.slice(0,i)+e.slice(r+1):e}var bh;function a4(e,t){var n=yh(e,t);if(!n)return bh=void 0,e.toPrecision(t);var i=n[0],r=n[1],o=r-(bh=Math.max(-8,Math.min(8,Math.floor(r/3)))*3)+1,s=i.length;return o===s?i:o>s?i+new Array(o-s+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+yh(e,Math.max(0,t+o-1))[0]}function B_(e,t){var n=yh(e,t);if(!n)return e+"";var i=n[0],r=n[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")}const U_={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:n4,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>B_(e*100,t),r:B_,s:a4,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function j_(e){return e}var q_=Array.prototype.map,W_=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nM(e){var t=e.grouping===void 0||e.thousands===void 0?j_:i4(q_.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",i=e.currency===void 0?"":e.currency[1]+"",r=e.decimal===void 0?".":e.decimal+"",o=e.numerals===void 0?j_:r4(q_.call(e.numerals,String)),s=e.percent===void 0?"%":e.percent+"",a=e.minus===void 0?"−":e.minus+"",u=e.nan===void 0?"NaN":e.nan+"";function l(f,d){f=Gs(f);var h=f.fill,g=f.align,p=f.sign,m=f.symbol,y=f.zero,b=f.width,v=f.comma,x=f.precision,E=f.trim,_=f.type;_==="n"?(v=!0,_="g"):U_[_]||(x===void 0&&(x=12),E=!0,_="g"),(y||h==="0"&&g==="=")&&(y=!0,h="0",g="=");var w=(d&&d.prefix!==void 0?d.prefix:"")+(m==="$"?n:m==="#"&&/[boxX]/.test(_)?"0"+_.toLowerCase():""),S=(m==="$"?i:/[%p]/.test(_)?s:"")+(d&&d.suffix!==void 0?d.suffix:""),$=U_[_],A=/[defgprs%]/.test(_);x=x===void 0?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,x)):Math.max(0,Math.min(20,x));function F(T){var N=w,C=S,k,M,D;if(_==="c")C=$(T)+C,T="";else{T=+T;var B=T<0||1/T<0;if(T=isNaN(T)?u:$(Math.abs(T),x),E&&(T=s4(T)),B&&+T==0&&p!=="+"&&(B=!1),N=(B?p==="("?p:a:p==="-"||p==="("?"":p)+N,C=(_==="s"&&!isNaN(T)&&bh!==void 0?W_[8+bh/3]:"")+C+(B&&p==="("?")":""),A){for(k=-1,M=T.length;++kD||D>57){C=(D===46?r+T.slice(k+1):T.slice(k))+C,T=T.slice(0,k);break}}}v&&!y&&(T=t(T,1/0));var z=N.length+T.length+C.length,X=z>1)+N+T+C+X.slice(z);break;default:T=X+N+T+C;break}return o(T)}return F.toString=function(){return f+""},F}function c(f,d){var h=Math.max(-8,Math.min(8,Math.floor(hu(d)/3)))*3,g=Math.pow(10,-h),p=l((f=Gs(f),f.type="f",f),{suffix:W_[8+h/3]});return function(m){return p(g*m)}}return{format:l,formatPrefix:c}}var td,Kg,vv;u4({thousands:",",grouping:[3],currency:["$",""]});function u4(e){return td=nM(e),Kg=td.format,vv=td.formatPrefix,td}function iM(e){return Math.max(0,-hu(Math.abs(e)))}function rM(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(hu(t)/3)))*3-hu(Math.abs(e)))}function oM(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,hu(t)-hu(e))+1}const i0=new Date,r0=new Date;function ht(e,t,n,i){function r(o){return e(o=arguments.length===0?new Date:new Date(+o)),o}return r.floor=o=>(e(o=new Date(+o)),o),r.ceil=o=>(e(o=new Date(o-1)),t(o,1),e(o),o),r.round=o=>{const s=r(o),a=r.ceil(o);return o-s(t(o=new Date(+o),s==null?1:Math.floor(s)),o),r.range=(o,s,a)=>{const u=[];if(o=r.ceil(o),a=a==null?1:Math.floor(a),!(o0))return u;let l;do u.push(l=new Date(+o)),t(o,a),e(o);while(lht(s=>{if(s>=s)for(;e(s),!o(s);)s.setTime(s-1)},(s,a)=>{if(s>=s)if(a<0)for(;++a<=0;)for(;t(s,-1),!o(s););else for(;--a>=0;)for(;t(s,1),!o(s););}),n&&(r.count=(o,s)=>(i0.setTime(+o),r0.setTime(+s),e(i0),e(r0),Math.floor(n(i0,r0))),r.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?r.filter(i?s=>i(s)%o===0:s=>r.count(0,s)%o===0):r)),r}const gu=ht(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);gu.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?ht(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):gu);gu.range;const Dr=1e3,Vn=Dr*60,Lr=Vn*60,Xr=Lr*24,xv=Xr*7,H_=Xr*30,o0=Xr*365,Pr=ht(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*Dr)},(e,t)=>(t-e)/Dr,e=>e.getUTCSeconds());Pr.range;const Jg=ht(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Dr)},(e,t)=>{e.setTime(+e+t*Vn)},(e,t)=>(t-e)/Vn,e=>e.getMinutes());Jg.range;const Qg=ht(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Vn)},(e,t)=>(t-e)/Vn,e=>e.getUTCMinutes());Qg.range;const Zg=ht(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*Dr-e.getMinutes()*Vn)},(e,t)=>{e.setTime(+e+t*Lr)},(e,t)=>(t-e)/Lr,e=>e.getHours());Zg.range;const ep=ht(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*Lr)},(e,t)=>(t-e)/Lr,e=>e.getUTCHours());ep.range;const jr=ht(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Vn)/Xr,e=>e.getDate()-1);jr.range;const Oo=ht(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Xr,e=>e.getUTCDate()-1);Oo.range;const sM=ht(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Xr,e=>Math.floor(e/Xr));sM.range;function ma(e){return ht(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Vn)/xv)}const nl=ma(0),vh=ma(1),l4=ma(2),c4=ma(3),pu=ma(4),f4=ma(5),d4=ma(6);nl.range;vh.range;l4.range;c4.range;pu.range;f4.range;d4.range;function ya(e){return ht(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/xv)}const il=ya(0),xh=ya(1),h4=ya(2),g4=ya(3),mu=ya(4),p4=ya(5),m4=ya(6);il.range;xh.range;h4.range;g4.range;mu.range;p4.range;m4.range;const Tc=ht(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());Tc.range;const Nc=ht(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());Nc.range;const rr=ht(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());rr.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:ht(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});rr.range;const or=ht(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());or.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:ht(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});or.range;function aM(e,t,n,i,r,o){const s=[[Pr,1,Dr],[Pr,5,5*Dr],[Pr,15,15*Dr],[Pr,30,30*Dr],[o,1,Vn],[o,5,5*Vn],[o,15,15*Vn],[o,30,30*Vn],[r,1,Lr],[r,3,3*Lr],[r,6,6*Lr],[r,12,12*Lr],[i,1,Xr],[i,2,2*Xr],[n,1,xv],[t,1,H_],[t,3,3*H_],[e,1,o0]];function a(l,c,f){const d=cm).right(s,d);if(h===s.length)return e.every(Bo(l/o0,c/o0,f));if(h===0)return gu.every(Math.max(Bo(l,c,f),1));const[g,p]=s[d/s[h-1][2](e[t]=1+n,e),{});function Ev(e){const t=Q(e).slice(),n={};return t.length||O("Missing time unit."),t.forEach(r=>{Z(s0,r)?n[r]=1:O(`Invalid time unit: ${r}.`)}),(n[lt]||n[Ut]?1:0)+(n[xn]||n[Wt]||n[wn]?1:0)+(n[sr]?1:0)>1&&O(`Incompatible time units: ${e}`),t.sort((r,o)=>s0[r]-s0[o]),t}const w4={[Tt]:"%Y ",[xn]:"Q%q ",[Wt]:"%b ",[wn]:"%d ",[lt]:"W%U ",[Ut]:"%a ",[sr]:"%j ",[Bn]:"%H:00",[Un]:"00:%M",[ni]:":%S",[ki]:".%L",[`${Tt}-${Wt}`]:"%Y-%m ",[`${Tt}-${Wt}-${wn}`]:"%Y-%m-%d ",[`${Bn}-${Un}`]:"%H:%M"};function uM(e,t){const n=pe({},w4,t),i=Ev(e),r=i.length;let o="",s=0,a,u;for(s=0;ss;--a)if(u=i.slice(s,a).join("-"),n[u]!=null){o+=n[u],s=a;break}return o.trim()}const As=new Date;function _v(e){return As.setFullYear(e),As.setMonth(0),As.setDate(1),As.setHours(0,0,0,0),As}function lM(e){return fM(new Date(e))}function cM(e){return V1(new Date(e))}function fM(e){return jr.count(_v(e.getFullYear())-1,e)}function V1(e){return nl.count(_v(e.getFullYear())-1,e)}function X1(e){return _v(e).getDay()}function E4(e,t,n,i,r,o,s){if(0<=e&&e<100){const a=new Date(-1,t,n,i,r,o,s);return a.setFullYear(e),a}return new Date(e,t,n,i,r,o,s)}function dM(e){return gM(new Date(e))}function hM(e){return K1(new Date(e))}function gM(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Oo.count(t-1,e)}function K1(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return il.count(t-1,e)}function J1(e){return As.setTime(Date.UTC(e,0,1)),As.getUTCDay()}function _4(e,t,n,i,r,o,s){if(0<=e&&e<100){const a=new Date(Date.UTC(-1,t,n,i,r,o,s));return a.setUTCFullYear(n.y),a}return new Date(Date.UTC(e,t,n,i,r,o,s))}function pM(e,t,n,i,r){const o=t||1,s=_e(e),a=(y,b,v)=>(v=v||y,S4(n[v],i[v],y===s&&o,b)),u=new Date,l=$i(e),c=l[Tt]?a(Tt):Yt(2012),f=l[Wt]?a(Wt):l[xn]?a(xn):_o,d=l[lt]&&l[Ut]?a(Ut,1,lt+Ut):l[lt]?a(lt,1):l[Ut]?a(Ut,1):l[wn]?a(wn,1):l[sr]?a(sr,1):Ku,h=l[Bn]?a(Bn):_o,g=l[Un]?a(Un):_o,p=l[ni]?a(ni):_o,m=l[ki]?a(ki):_o;return function(y){u.setTime(+y);const b=c(u);return r(b,f(u),d(u,b),h(u),g(u),p(u),m(u))}}function S4(e,t,n,i){const r=n<=1?e:i?(o,s)=>i+n*Math.floor((e(o,s)-i)/n):(o,s)=>n*Math.floor(e(o,s)/n);return t?(o,s)=>t(r(o,s),s):r}function yu(e,t,n){return t+e*7-(n+6)%7}const $4={[Tt]:e=>e.getFullYear(),[xn]:e=>Math.floor(e.getMonth()/3),[Wt]:e=>e.getMonth(),[wn]:e=>e.getDate(),[Bn]:e=>e.getHours(),[Un]:e=>e.getMinutes(),[ni]:e=>e.getSeconds(),[ki]:e=>e.getMilliseconds(),[sr]:e=>fM(e),[lt]:e=>V1(e),[lt+Ut]:(e,t)=>yu(V1(e),e.getDay(),X1(t)),[Ut]:(e,t)=>yu(1,e.getDay(),X1(t))},k4={[xn]:e=>3*e,[lt]:(e,t)=>yu(e,0,X1(t))};function mM(e,t){return pM(e,t||1,$4,k4,E4)}const A4={[Tt]:e=>e.getUTCFullYear(),[xn]:e=>Math.floor(e.getUTCMonth()/3),[Wt]:e=>e.getUTCMonth(),[wn]:e=>e.getUTCDate(),[Bn]:e=>e.getUTCHours(),[Un]:e=>e.getUTCMinutes(),[ni]:e=>e.getUTCSeconds(),[ki]:e=>e.getUTCMilliseconds(),[sr]:e=>gM(e),[lt]:e=>K1(e),[Ut]:(e,t)=>yu(1,e.getUTCDay(),J1(t)),[lt+Ut]:(e,t)=>yu(K1(e),e.getUTCDay(),J1(t))},C4={[xn]:e=>3*e,[lt]:(e,t)=>yu(e,0,J1(t))};function yM(e,t){return pM(e,t||1,A4,C4,_4)}const F4={[Tt]:rr,[xn]:Tc.every(3),[Wt]:Tc,[lt]:nl,[wn]:jr,[Ut]:jr,[sr]:jr,[Bn]:Zg,[Un]:Jg,[ni]:Pr,[ki]:gu},M4={[Tt]:or,[xn]:Nc.every(3),[Wt]:Nc,[lt]:il,[wn]:Oo,[Ut]:Oo,[sr]:Oo,[Bn]:ep,[Un]:Qg,[ni]:Pr,[ki]:gu};function rl(e){return F4[e]}function ol(e){return M4[e]}function bM(e,t,n){return e?e.offset(t,n):void 0}function vM(e,t,n){return bM(rl(e),t,n)}function xM(e,t,n){return bM(ol(e),t,n)}function wM(e,t,n,i){return e?e.range(t,n,i):void 0}function EM(e,t,n,i){return wM(rl(e),t,n,i)}function _M(e,t,n,i){return wM(ol(e),t,n,i)}const Xl=1e3,Kl=Xl*60,Jl=Kl*60,tp=Jl*24,T4=tp*7,G_=tp*30,Q1=tp*365,SM=[Tt,Wt,wn,Bn,Un,ni,ki],Ql=SM.slice(0,-1),Zl=Ql.slice(0,-1),ec=Zl.slice(0,-1),N4=ec.slice(0,-1),R4=[Tt,lt],Y_=[Tt,Wt],$M=[Tt],$l=[[Ql,1,Xl],[Ql,5,5*Xl],[Ql,15,15*Xl],[Ql,30,30*Xl],[Zl,1,Kl],[Zl,5,5*Kl],[Zl,15,15*Kl],[Zl,30,30*Kl],[ec,1,Jl],[ec,3,3*Jl],[ec,6,6*Jl],[ec,12,12*Jl],[N4,1,tp],[R4,1,T4],[Y_,1,G_],[Y_,3,3*G_],[$M,1,Q1]];function kM(e){const t=e.extent,n=e.maxbins||40,i=Math.abs(lf(t))/n;let r=tl(a=>a[2]).right($l,i),o,s;return r===$l.length?(o=$M,s=Bo(t[0]/Q1,t[1]/Q1,n)):r?(r=$l[i/$l[r-1][2]<$l[r][2]/i?r-1:r],o=r[0],s=r[1]):(o=SM,s=Math.max(Bo(t[0],t[1],n),1)),{units:o,step:s}}function a0(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function u0(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function kl(e,t,n){return{y:e,m:t,d:n,H:0,M:0,S:0,L:0}}function AM(e){var t=e.dateTime,n=e.date,i=e.time,r=e.periods,o=e.days,s=e.shortDays,a=e.months,u=e.shortMonths,l=Al(r),c=Cl(r),f=Al(o),d=Cl(o),h=Al(s),g=Cl(s),p=Al(a),m=Cl(a),y=Al(u),b=Cl(u),v={a:D,A:B,b:z,B:X,c:null,d:Z_,e:Z_,f:nz,g:dz,G:gz,H:Z4,I:ez,j:tz,L:CM,m:iz,M:rz,p:le,q:se,Q:nS,s:iS,S:oz,u:sz,U:az,V:uz,w:lz,W:cz,x:null,X:null,y:fz,Y:hz,Z:pz,"%":tS},x={a:he,A:Ie,b:ge,B:Ot,c:null,d:eS,e:eS,f:vz,g:Fz,G:Tz,H:mz,I:yz,j:bz,L:MM,m:xz,M:wz,p:ds,q:ho,Q:nS,s:iS,S:Ez,u:_z,U:Sz,V:$z,w:kz,W:Az,x:null,X:null,y:Cz,Y:Mz,Z:Nz,"%":tS},E={a:A,A:F,b:T,B:N,c:C,d:J_,e:J_,f:X4,g:K_,G:X_,H:Q_,I:Q_,j:H4,L:V4,m:W4,M:G4,p:$,q:q4,Q:J4,s:Q4,S:Y4,u:I4,U:z4,V:B4,w:P4,W:U4,x:k,X:M,y:K_,Y:X_,Z:j4,"%":K4};v.x=_(n,v),v.X=_(i,v),v.c=_(t,v),x.x=_(n,x),x.X=_(i,x),x.c=_(t,x);function _(ee,me){return function(ve){var H=[],St=-1,Ne=0,pt=ee.length,Dt,$r,M_;for(ve instanceof Date||(ve=new Date(+ve));++St53)return null;"w"in H||(H.w=1),"Z"in H?(Ne=u0(kl(H.y,0,1)),pt=Ne.getUTCDay(),Ne=pt>4||pt===0?xh.ceil(Ne):xh(Ne),Ne=Oo.offset(Ne,(H.V-1)*7),H.y=Ne.getUTCFullYear(),H.m=Ne.getUTCMonth(),H.d=Ne.getUTCDate()+(H.w+6)%7):(Ne=a0(kl(H.y,0,1)),pt=Ne.getDay(),Ne=pt>4||pt===0?vh.ceil(Ne):vh(Ne),Ne=jr.offset(Ne,(H.V-1)*7),H.y=Ne.getFullYear(),H.m=Ne.getMonth(),H.d=Ne.getDate()+(H.w+6)%7)}else("W"in H||"U"in H)&&("w"in H||(H.w="u"in H?H.u%7:"W"in H?1:0),pt="Z"in H?u0(kl(H.y,0,1)).getUTCDay():a0(kl(H.y,0,1)).getDay(),H.m=0,H.d="W"in H?(H.w+6)%7+H.W*7-(pt+5)%7:H.w+H.U*7-(pt+6)%7);return"Z"in H?(H.H+=H.Z/100|0,H.M+=H.Z%100,u0(H)):a0(H)}}function S(ee,me,ve,H){for(var St=0,Ne=me.length,pt=ve.length,Dt,$r;St=pt)return-1;if(Dt=me.charCodeAt(St++),Dt===37){if(Dt=me.charAt(St++),$r=E[Dt in V_?me.charAt(St++):Dt],!$r||(H=$r(ee,ve,H))<0)return-1}else if(Dt!=ve.charCodeAt(H++))return-1}return H}function $(ee,me,ve){var H=l.exec(me.slice(ve));return H?(ee.p=c.get(H[0].toLowerCase()),ve+H[0].length):-1}function A(ee,me,ve){var H=h.exec(me.slice(ve));return H?(ee.w=g.get(H[0].toLowerCase()),ve+H[0].length):-1}function F(ee,me,ve){var H=f.exec(me.slice(ve));return H?(ee.w=d.get(H[0].toLowerCase()),ve+H[0].length):-1}function T(ee,me,ve){var H=y.exec(me.slice(ve));return H?(ee.m=b.get(H[0].toLowerCase()),ve+H[0].length):-1}function N(ee,me,ve){var H=p.exec(me.slice(ve));return H?(ee.m=m.get(H[0].toLowerCase()),ve+H[0].length):-1}function C(ee,me,ve){return S(ee,t,me,ve)}function k(ee,me,ve){return S(ee,n,me,ve)}function M(ee,me,ve){return S(ee,i,me,ve)}function D(ee){return s[ee.getDay()]}function B(ee){return o[ee.getDay()]}function z(ee){return u[ee.getMonth()]}function X(ee){return a[ee.getMonth()]}function le(ee){return r[+(ee.getHours()>=12)]}function se(ee){return 1+~~(ee.getMonth()/3)}function he(ee){return s[ee.getUTCDay()]}function Ie(ee){return o[ee.getUTCDay()]}function ge(ee){return u[ee.getUTCMonth()]}function Ot(ee){return a[ee.getUTCMonth()]}function ds(ee){return r[+(ee.getUTCHours()>=12)]}function ho(ee){return 1+~~(ee.getUTCMonth()/3)}return{format:function(ee){var me=_(ee+="",v);return me.toString=function(){return ee},me},parse:function(ee){var me=w(ee+="",!1);return me.toString=function(){return ee},me},utcFormat:function(ee){var me=_(ee+="",x);return me.toString=function(){return ee},me},utcParse:function(ee){var me=w(ee+="",!0);return me.toString=function(){return ee},me}}}var V_={"-":"",_:" ",0:"0"},_t=/^\s*\d+/,O4=/^%/,D4=/[\\^$*+?|[\]().{}]/g;function Ae(e,t,n){var i=e<0?"-":"",r=(i?-e:e)+"",o=r.length;return i+(o[t.toLowerCase(),n]))}function P4(e,t,n){var i=_t.exec(t.slice(n,n+1));return i?(e.w=+i[0],n+i[0].length):-1}function I4(e,t,n){var i=_t.exec(t.slice(n,n+1));return i?(e.u=+i[0],n+i[0].length):-1}function z4(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.U=+i[0],n+i[0].length):-1}function B4(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.V=+i[0],n+i[0].length):-1}function U4(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.W=+i[0],n+i[0].length):-1}function X_(e,t,n){var i=_t.exec(t.slice(n,n+4));return i?(e.y=+i[0],n+i[0].length):-1}function K_(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.y=+i[0]+(+i[0]>68?1900:2e3),n+i[0].length):-1}function j4(e,t,n){var i=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return i?(e.Z=i[1]?0:-(i[2]+(i[3]||"00")),n+i[0].length):-1}function q4(e,t,n){var i=_t.exec(t.slice(n,n+1));return i?(e.q=i[0]*3-3,n+i[0].length):-1}function W4(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.m=i[0]-1,n+i[0].length):-1}function J_(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.d=+i[0],n+i[0].length):-1}function H4(e,t,n){var i=_t.exec(t.slice(n,n+3));return i?(e.m=0,e.d=+i[0],n+i[0].length):-1}function Q_(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.H=+i[0],n+i[0].length):-1}function G4(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.M=+i[0],n+i[0].length):-1}function Y4(e,t,n){var i=_t.exec(t.slice(n,n+2));return i?(e.S=+i[0],n+i[0].length):-1}function V4(e,t,n){var i=_t.exec(t.slice(n,n+3));return i?(e.L=+i[0],n+i[0].length):-1}function X4(e,t,n){var i=_t.exec(t.slice(n,n+6));return i?(e.L=Math.floor(i[0]/1e3),n+i[0].length):-1}function K4(e,t,n){var i=O4.exec(t.slice(n,n+1));return i?n+i[0].length:-1}function J4(e,t,n){var i=_t.exec(t.slice(n));return i?(e.Q=+i[0],n+i[0].length):-1}function Q4(e,t,n){var i=_t.exec(t.slice(n));return i?(e.s=+i[0],n+i[0].length):-1}function Z_(e,t){return Ae(e.getDate(),t,2)}function Z4(e,t){return Ae(e.getHours(),t,2)}function ez(e,t){return Ae(e.getHours()%12||12,t,2)}function tz(e,t){return Ae(1+jr.count(rr(e),e),t,3)}function CM(e,t){return Ae(e.getMilliseconds(),t,3)}function nz(e,t){return CM(e,t)+"000"}function iz(e,t){return Ae(e.getMonth()+1,t,2)}function rz(e,t){return Ae(e.getMinutes(),t,2)}function oz(e,t){return Ae(e.getSeconds(),t,2)}function sz(e){var t=e.getDay();return t===0?7:t}function az(e,t){return Ae(nl.count(rr(e)-1,e),t,2)}function FM(e){var t=e.getDay();return t>=4||t===0?pu(e):pu.ceil(e)}function uz(e,t){return e=FM(e),Ae(pu.count(rr(e),e)+(rr(e).getDay()===4),t,2)}function lz(e){return e.getDay()}function cz(e,t){return Ae(vh.count(rr(e)-1,e),t,2)}function fz(e,t){return Ae(e.getFullYear()%100,t,2)}function dz(e,t){return e=FM(e),Ae(e.getFullYear()%100,t,2)}function hz(e,t){return Ae(e.getFullYear()%1e4,t,4)}function gz(e,t){var n=e.getDay();return e=n>=4||n===0?pu(e):pu.ceil(e),Ae(e.getFullYear()%1e4,t,4)}function pz(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Ae(t/60|0,"0",2)+Ae(t%60,"0",2)}function eS(e,t){return Ae(e.getUTCDate(),t,2)}function mz(e,t){return Ae(e.getUTCHours(),t,2)}function yz(e,t){return Ae(e.getUTCHours()%12||12,t,2)}function bz(e,t){return Ae(1+Oo.count(or(e),e),t,3)}function MM(e,t){return Ae(e.getUTCMilliseconds(),t,3)}function vz(e,t){return MM(e,t)+"000"}function xz(e,t){return Ae(e.getUTCMonth()+1,t,2)}function wz(e,t){return Ae(e.getUTCMinutes(),t,2)}function Ez(e,t){return Ae(e.getUTCSeconds(),t,2)}function _z(e){var t=e.getUTCDay();return t===0?7:t}function Sz(e,t){return Ae(il.count(or(e)-1,e),t,2)}function TM(e){var t=e.getUTCDay();return t>=4||t===0?mu(e):mu.ceil(e)}function $z(e,t){return e=TM(e),Ae(mu.count(or(e),e)+(or(e).getUTCDay()===4),t,2)}function kz(e){return e.getUTCDay()}function Az(e,t){return Ae(xh.count(or(e)-1,e),t,2)}function Cz(e,t){return Ae(e.getUTCFullYear()%100,t,2)}function Fz(e,t){return e=TM(e),Ae(e.getUTCFullYear()%100,t,2)}function Mz(e,t){return Ae(e.getUTCFullYear()%1e4,t,4)}function Tz(e,t){var n=e.getUTCDay();return e=n>=4||n===0?mu(e):mu.ceil(e),Ae(e.getUTCFullYear()%1e4,t,4)}function Nz(){return"+0000"}function tS(){return"%"}function nS(e){return+e}function iS(e){return Math.floor(+e/1e3)}var Oa,Sv,NM,$v,RM;Rz({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function Rz(e){return Oa=AM(e),Sv=Oa.format,NM=Oa.parse,$v=Oa.utcFormat,RM=Oa.utcParse,Oa}function tc(e){const t={};return n=>t[n]||(t[n]=e(n))}function Oz(e,t){return n=>{const i=e(n),r=i.indexOf(t);if(r<0)return i;let o=Dz(i,r);const s=or;)if(i[o]!=="0"){++o;break}return i.slice(0,o)+s}}function Dz(e,t){let n=e.lastIndexOf("e"),i;if(n>0)return n;for(n=e.length;--n>t;)if(i=e.charCodeAt(n),i>=48&&i<=57)return n+1}function OM(e){const t=tc(e.format),n=e.formatPrefix;return{format:t,formatPrefix:n,formatFloat(i){const r=Gs(i||",");if(r.precision==null){switch(r.precision=12,r.type){case"%":r.precision-=2;break;case"e":r.precision-=1;break}return Oz(t(r),t(".1f")(1)[1])}else return t(r)},formatSpan(i,r,o,s){s=Gs(s??",f");const a=Bo(i,r,o),u=Math.max(Math.abs(i),Math.abs(r));let l;if(s.precision==null)switch(s.type){case"s":return isNaN(l=rM(a,u))||(s.precision=l),n(s,u);case"":case"e":case"g":case"p":case"r":{isNaN(l=oM(a,u))||(s.precision=l-(s.type==="e"));break}case"f":case"%":{isNaN(l=iM(a))||(s.precision=l-(s.type==="%")*2);break}}return t(s)}}}let Z1;DM();function DM(){return Z1=OM({format:Kg,formatPrefix:vv})}function LM(e){return OM(nM(e))}function wh(e){return arguments.length?Z1=LM(e):Z1}function rS(e,t,n){n=n||{},K(n)||O(`Invalid time multi-format specifier: ${n}`);const i=t(ni),r=t(Un),o=t(Bn),s=t(wn),a=t(lt),u=t(Wt),l=t(xn),c=t(Tt),f=e(n[ki]||".%L"),d=e(n[ni]||":%S"),h=e(n[Un]||"%I:%M"),g=e(n[Bn]||"%I %p"),p=e(n[wn]||n[Ut]||"%a %d"),m=e(n[lt]||"%b %d"),y=e(n[Wt]||"%B"),b=e(n[xn]||"%B"),v=e(n[Tt]||"%Y");return x=>(i(x)J(i)?t(i):rS(t,rl,i),utcFormat:i=>J(i)?n(i):rS(n,ol,i),timeParse:tc(e.parse),utcParse:tc(e.utcParse)}}let ey;IM();function IM(){return ey=PM({format:Sv,parse:NM,utcFormat:$v,utcParse:RM})}function zM(e){return PM(AM(e))}function Rc(e){return arguments.length?ey=zM(e):ey}const ty=(e,t)=>pe({},e,t);function BM(e,t){const n=e?LM(e):wh(),i=t?zM(t):Rc();return ty(n,i)}function kv(e,t){const n=arguments.length;return n&&n!==2&&O("defaultLocale expects either zero or two arguments."),n?ty(wh(e),Rc(t)):ty(wh(),Rc())}function Lz(){return DM(),IM(),kv()}const Pz=/^(data:|([A-Za-z]+:)?\/\/)/,Iz=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,zz=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,oS="file://";function Bz(e){return t=>({options:t||{},sanitize:jz,load:Uz,fileAccess:!1,file:qz(),http:Hz})}async function Uz(e,t){const n=await this.sanitize(e,t),i=n.href;return n.localFile?this.file(i):this.http(i,t==null?void 0:t.http)}async function jz(e,t){t=pe({},this.options,t);const n=this.fileAccess,i={href:null};let r,o,s;const a=Iz.test(e.replace(zz,""));(e==null||typeof e!="string"||!a)&&O("Sanitize failure, invalid URI: "+G(e));const u=Pz.test(e);return(s=t.baseURL)&&!u&&(!e.startsWith("/")&&!s.endsWith("/")&&(e="/"+e),e=s+e),o=(r=e.startsWith(oS))||t.mode==="file"||t.mode!=="http"&&!u&&n,r?e=e.slice(oS.length):e.startsWith("//")&&(t.defaultProtocol==="file"?(e=e.slice(2),o=!0):e=(t.defaultProtocol||"http")+":"+e),Object.defineProperty(i,"localFile",{value:!!o}),i.href=e,t.target&&(i.target=t.target+""),t.rel&&(i.rel=t.rel+""),t.context==="image"&&t.crossOrigin&&(i.crossOrigin=t.crossOrigin+""),i}function qz(e){return Wz}async function Wz(){O("No file system access.")}async function Hz(e,t){const n=pe({},this.options.http,t),i=t&&t.response,r=await fetch(e,n);return r.ok?de(r[i])?r[i]():r.text():O(r.status+""+r.statusText)}const Gz=e=>e!=null&&e===e,Yz=e=>e==="true"||e==="false"||e===!0||e===!1,Vz=e=>!Number.isNaN(Date.parse(e)),UM=e=>!Number.isNaN(+e)&&!(e instanceof Date),Xz=e=>UM(e)&&Number.isInteger(+e),ny={boolean:pv,integer:nn,number:nn,date:mv,string:yv,unknown:vn},nd=[Yz,Xz,UM,Vz],Kz=["boolean","integer","number","date"];function jM(e,t){if(!e||!e.length)return"unknown";const n=e.length,i=nd.length,r=nd.map((o,s)=>s+1);for(let o=0,s=0,a,u;oo===0?s:o,0)-1]}function qM(e,t){return t.reduce((n,i)=>(n[i]=jM(e,i),n),{})}function sS(e){const t=function(n,i){const r={delimiter:e};return Av(n,i?pe(i,r):r)};return t.responseType="text",t}function Av(e,t){return t.header&&(e=t.header.map(G).join(t.delimiter)+` +`+e),TI(t.delimiter).parse(e+"")}Av.responseType="text";function Jz(e){return typeof Buffer=="function"&&de(Buffer.isBuffer)?Buffer.isBuffer(e):!1}function Cv(e,t){const n=t&&t.property?ei(t.property):vn;return K(e)&&!Jz(e)?Qz(n(e),t):n(JSON.parse(e))}Cv.responseType="json";function Qz(e,t){return!P(e)&&PF(e)&&(e=[...e]),t&&t.copy?JSON.parse(JSON.stringify(e)):e}const Zz={interior:(e,t)=>e!==t,exterior:(e,t)=>e===t};function WM(e,t){let n,i,r,o;return e=Cv(e,t),t&&t.feature?(n=DI,r=t.feature):t&&t.mesh?(n=PI,r=t.mesh,o=Zz[t.filter]):O("Missing TopoJSON feature or mesh parameter."),i=(i=e.objects[r])?n(e,i,o):O("Invalid TopoJSON object: "+r),i&&i.features||[i]}WM.responseType="json";const Ud={dsv:Av,csv:sS(","),tsv:sS(" "),json:Cv,topojson:WM};function Fv(e,t){return arguments.length>1?(Ud[e]=t,this):Z(Ud,e)?Ud[e]:null}function HM(e){const t=Fv(e);return t&&t.responseType||"text"}function GM(e,t,n,i){t=t||{};const r=Fv(t.type||"json");return r||O("Unknown data format type: "+t.type),e=r(e,t),t.parse&&e8(e,t.parse,n,i),Z(e,"columns")&&delete e.columns,e}function e8(e,t,n,i){if(!e.length)return;const r=Rc();n=n||r.timeParse,i=i||r.utcParse;let o=e.columns||Object.keys(e[0]),s,a,u,l,c,f;t==="auto"&&(t=qM(e,o)),o=Object.keys(t);const d=o.map(h=>{const g=t[h];let p,m;if(g&&(g.startsWith("date:")||g.startsWith("utc:")))return p=g.split(/:(.+)?/,2),m=p[1],(m[0]==="'"&&m[m.length-1]==="'"||m[0]==='"'&&m[m.length-1]==='"')&&(m=m.slice(1,-1)),(p[0]==="utc"?i:n)(m);if(!ny[g])throw Error("Illegal format pattern: "+h+":"+g);return ny[g]});for(u=0,c=e.length,f=o.length;u{const o=t(r);return i[o]||(i[o]=1,n.push(r)),n},n.remove=r=>{const o=t(r);if(i[o]){i[o]=0;const s=n.indexOf(r);s>=0&&n.splice(s,1)}return n},n}async function jd(e,t){try{await t(e)}catch(n){e.error(n)}}const YM=Symbol("vega_id");let t8=1;function rp(e){return!!(e&&re(e))}function re(e){return e[YM]}function VM(e,t){return e[YM]=t,e}function Fe(e){const t=e===Object(e)?e:{data:e};return re(t)?t:VM(t,t8++)}function Mv(e){return op(e,Fe({}))}function op(e,t){for(const n in e)t[n]=e[n];return t}function XM(e,t){return VM(t,re(e))}function ba(e,t){return e?t?(n,i)=>e(n,i)||re(t(n))-re(t(i)):(n,i)=>e(n,i)||re(n)-re(i):null}function KM(e){return e&&e.constructor===va}function va(){const e=[],t=[],n=[],i=[],r=[];let o=null,s=!1;return{constructor:va,insert(a){const u=Q(a),l=u.length;for(let c=0;c{g(b)&&(l[re(b)]=-1)});for(f=0,d=e.length;f0&&(y(p,g,h.value),a.modifies(g));for(f=0,d=r.length;f{g(b)&&l[re(b)]>0&&y(b,h.field,h.value)}),a.modifies(h.field);if(s)a.mod=t.length||i.length?u.filter(b=>l[re(b)]>0):u.slice();else for(m in c)a.mod.push(c[m]);return(o||o==null&&(t.length||i.length))&&a.clean(!0),a}}}const qd="_:mod:_";function sp(){Object.defineProperty(this,qd,{writable:!0,value:{}})}sp.prototype={set(e,t,n,i){const r=this,o=r[e],s=r[qd];return t!=null&&t>=0?(o[t]!==n||i)&&(o[t]=n,s[t+":"+e]=-1,s[e]=-1):(o!==n||i)&&(r[e]=n,s[e]=P(n)?1+n.length:-1),r},modified(e,t){const n=this[qd];if(arguments.length){if(P(e)){for(let i=0;i=0?t+1{h instanceof ze?(h!==this&&(t&&h.targets().add(this),o.push(h)),r.push({op:h,name:f,index:d})):i.set(f,d,h)};for(s in e)if(a=e[s],s===i8)Q(a).forEach(f=>{f instanceof ze?f!==this&&(f.targets().add(this),o.push(f)):O("Pulse parameters must be operator instances.")}),this.source=a;else if(P(a))for(i.set(s,-1,Array(u=a.length)),l=0;l{const n=Date.now();return n-t>e?(t=n,1):0})},debounce(e){const t=mo();return this.targets().add(mo(null,null,dv(e,n=>{const i=n.dataflow;t.receive(n),i&&i.run&&i.run()}))),t},between(e,t){let n=!1;return e.targets().add(mo(null,null,()=>n=!0)),t.targets().add(mo(null,null,()=>n=!1)),this.filter(()=>n)},detach(){this._filter=ti,this._targets=null}};function c8(e,t,n,i){const r=this,o=mo(n,i),s=function(l){l.dataflow=r;try{o.receive(l)}catch(c){r.error(c)}finally{r.run()}};let a;typeof e=="string"&&typeof document<"u"?a=document.querySelectorAll(e):a=Q(e);const u=a.length;for(let l=0;lt=i);return n.requests=0,n.done=()=>{--n.requests===0&&(e._pending=null,t(e))},e._pending=n}const m8={skip:!0};function y8(e,t,n,i,r){return(e instanceof ze?v8:b8)(this,e,t,n,i,r),this}function b8(e,t,n,i,r,o){const s=pe({},o,m8);let a,u;de(n)||(n=Yt(n)),i===void 0?a=l=>e.touch(n(l)):de(i)?(u=new ze(null,i,r,!1),a=l=>{u.evaluate(l);const c=n(l),f=u.value;KM(f)?e.pulse(c,f,o):e.update(c,f,s)}):a=l=>e.update(n(l),i,s),t.apply(a)}function v8(e,t,n,i,r,o){if(i===void 0)t.targets().add(n);else{const s=o||{},a=new ze(null,x8(n,i),r,!1);a.modified(s.force),a.rank=t.rank,t.targets().add(a),n&&(a.skip(!0),a.value=n.value,a.targets().add(n),e.connect(n,[a]))}}function x8(e,t){return t=de(t)?t:Yt(t),e?function(n,i){const r=t(n,i);return e.skip()||(e.skip(r!==this.value).value=r),r}:t}function w8(e){e.rank=++this._rank}function E8(e){const t=[e];let n,i,r;for(;t.length;)if(this.rank(n=t.pop()),i=n._targets)for(r=i.length;--r>=0;)t.push(n=i[r]),n===e&&O("Cycle detected in dataflow graph.")}const Eh={},Wi=1,vo=2,Mr=4,_8=Wi|vo,uS=Wi|Mr,Da=Wi|vo|Mr,lS=8,Fl=16,cS=32,fS=64;function Do(e,t,n){this.dataflow=e,this.stamp=t??-1,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=n||null}function l0(e,t){const n=[];return bo(e,t,i=>n.push(i)),n}function dS(e,t){const n={};return e.visit(t,i=>{n[re(i)]=1}),i=>n[re(i)]?null:i}function id(e,t){return e?(n,i)=>e(n,i)&&t(n,i):t}Do.prototype={StopPropagation:Eh,ADD:Wi,REM:vo,MOD:Mr,ADD_REM:_8,ADD_MOD:uS,ALL:Da,REFLOW:lS,SOURCE:Fl,NO_SOURCE:cS,NO_FIELDS:fS,fork(e){return new Do(this.dataflow).init(this,e)},clone(){const e=this.fork(Da);return e.add=e.add.slice(),e.rem=e.rem.slice(),e.mod=e.mod.slice(),e.source&&(e.source=e.source.slice()),e.materialize(Da|Fl)},addAll(){let e=this;return!e.source||e.add===e.rem||!e.rem.length&&e.source.length===e.add.length||(e=new Do(this.dataflow).init(this),e.add=e.source,e.rem=[]),e},init(e,t){const n=this;return n.stamp=e.stamp,n.encode=e.encode,e.fields&&!(t&fS)&&(n.fields=e.fields),t&Wi?(n.addF=e.addF,n.add=e.add):(n.addF=null,n.add=[]),t&vo?(n.remF=e.remF,n.rem=e.rem):(n.remF=null,n.rem=[]),t&Mr?(n.modF=e.modF,n.mod=e.mod):(n.modF=null,n.mod=[]),t&cS?(n.srcF=null,n.source=null):(n.srcF=e.srcF,n.source=e.source,e.cleans&&(n.cleans=e.cleans)),n},runAfter(e){this.dataflow.runAfter(e)},changed(e){const t=e||Da;return t&Wi&&this.add.length||t&vo&&this.rem.length||t&Mr&&this.mod.length},reflow(e){if(e)return this.fork(Da).reflow();const t=this.add.length,n=this.source&&this.source.length;return n&&n!==t&&(this.mod=this.source,t&&this.filter(Mr,dS(this,Wi))),this},clean(e){return arguments.length?(this.cleans=!!e,this):this.cleans},modifies(e){const t=this.fields||(this.fields={});return P(e)?e.forEach(n=>t[n]=!0):t[e]=!0,this},modified(e,t){const n=this.fields;return(t||this.mod.length)&&n?arguments.length?P(e)?e.some(i=>n[i]):n[e]:!!n:!1},filter(e,t){const n=this;return e&Wi&&(n.addF=id(n.addF,t)),e&vo&&(n.remF=id(n.remF,t)),e&Mr&&(n.modF=id(n.modF,t)),e&Fl&&(n.srcF=id(n.srcF,t)),n},materialize(e){e=e||Da;const t=this;return e&Wi&&t.addF&&(t.add=l0(t.add,t.addF),t.addF=null),e&vo&&t.remF&&(t.rem=l0(t.rem,t.remF),t.remF=null),e&Mr&&t.modF&&(t.mod=l0(t.mod,t.modF),t.modF=null),e&Fl&&t.srcF&&(t.source=t.source.filter(t.srcF),t.srcF=null),t},visit(e,t){const n=this,i=t;if(e&Fl)return bo(n.source,n.srcF,i),n;e&Wi&&bo(n.add,n.addF,i),e&vo&&bo(n.rem,n.remF,i),e&Mr&&bo(n.mod,n.modF,i);const r=n.source;if(e&lS&&r){const o=n.add.length+n.mod.length;o===r.length||(o?bo(r,dS(n,uS),i):bo(r,n.srcF,i))}return n}};function Tv(e,t,n,i){const r=this;let o=0;this.dataflow=e,this.stamp=t,this.fields=null,this.encode=i||null,this.pulses=n;for(const s of n)if(s.stamp===t){if(s.fields){const a=r.fields||(r.fields={});for(const u in s.fields)a[u]=1}s.changed(r.ADD)&&(o|=r.ADD),s.changed(r.REM)&&(o|=r.REM),s.changed(r.MOD)&&(o|=r.MOD)}this.changes=o}Y(Tv,Do,{fork(e){const t=new Do(this.dataflow).init(this,e&this.NO_FIELDS);return e!==void 0&&(e&t.ADD&&this.visit(t.ADD,n=>t.add.push(n)),e&t.REM&&this.visit(t.REM,n=>t.rem.push(n)),e&t.MOD&&this.visit(t.MOD,n=>t.mod.push(n))),t},changed(e){return this.changes&e},modified(e){const t=this,n=t.fields;return n&&t.changes&t.MOD?P(e)?e.some(i=>n[i]):n[e]:0},filter(){O("MultiPulse does not support filtering.")},materialize(){O("MultiPulse does not support materialization.")},visit(e,t){const n=this,i=n.pulses,r=i.length;let o=0;if(e&n.SOURCE)for(;oi._enqueue(c,!0)),i._touched=ip(uf);let s=0,a,u,l;try{for(;i._heap.size()>0;){if(a=i._heap.pop(),a.rank!==a.qrank){i._enqueue(a,!0);continue}u=a.run(i._getPulse(a,e)),u.then?u=await u:u.async&&(r.push(u.async),u=Eh),u!==Eh&&a._targets&&a._targets.forEach(c=>i._enqueue(c)),++s}}catch(c){i._heap.clear(),l=c}if(i._input={},i._pulse=null,i.debug(`Pulse ${o}: ${s} operators`),l&&(i._postrun=[],i.error(l)),i._postrun.length){const c=i._postrun.sort((f,d)=>d.priority-f.priority);i._postrun=[];for(let f=0;fi.runAsync(null,()=>{c.forEach(f=>{try{f(i)}catch(d){i.error(d)}})})),i}async function $8(e,t,n){for(;this._running;)await this._running;const i=()=>this._running=null;return(this._running=this.evaluate(e,t,n)).then(i,i),this._running}function k8(e,t,n){return this._pulse?JM(this):(this.evaluate(e,t,n),this)}function A8(e,t,n){if(this._pulse||t)this._postrun.push({priority:n||0,callback:e});else try{e(this)}catch(i){this.error(i)}}function JM(e){return e.error("Dataflow already running. Use runAsync() to chain invocations."),e}function C8(e,t){const n=e.stampr.pulse),t):this._input[e.id]||M8(this._pulse,n&&n.pulse)}function M8(e,t){return t&&t.stamp===e.stamp?t:(e=e.fork(),t&&t!==Eh&&(e.source=t.source),e)}const Nv={skip:!1,force:!1};function T8(e,t){const n=t||Nv;return this._pulse?this._enqueue(e):this._touched.add(e),n.skip&&e.skip(!0),this}function N8(e,t,n){const i=n||Nv;return(e.set(t)||i.force)&&this.touch(e,i),this}function R8(e,t,n){this.touch(e,n||Nv);const i=new Do(this,this._clock+(this._pulse?0:1)),r=e.pulse&&e.pulse.source||[];return i.target=e,this._input[e.id]=t.pulse(i,r),this}function O8(e){let t=[];return{clear:()=>t=[],size:()=>t.length,peek:()=>t[0],push:n=>(t.push(n),QM(t,0,t.length-1,e)),pop:()=>{const n=t.pop();let i;return t.length?(i=t[0],t[0]=n,D8(t,0,e)):i=n,i}}}function QM(e,t,n,i){let r,o;const s=e[n];for(;n>t;){if(o=n-1>>1,r=e[o],i(s,r)<0){e[n]=r,n=o;continue}break}return e[n]=s}function D8(e,t,n){const i=t,r=e.length,o=e[t];let s=(t<<1)+1,a;for(;s=0&&(s=a),e[t]=e[s],t=s,s=(t<<1)+1;return e[t]=o,QM(e,i,t,n)}function nu(){this.logger(Yg()),this.logLevel(sv),this._clock=0,this._rank=0,this._locale=kv();try{this._loader=np()}catch{}this._touched=ip(uf),this._input={},this._pulse=null,this._heap=O8((e,t)=>e.qrank-t.qrank),this._postrun=[]}function Ml(e){return function(){return this._log[e].apply(this,arguments)}}nu.prototype={stamp(){return this._clock},loader(e){return arguments.length?(this._loader=e,this):this._loader},locale(e){return arguments.length?(this._locale=e,this):this._locale},logger(e){return arguments.length?(this._log=e,this):this._log},error:Ml("error"),warn:Ml("warn"),info:Ml("info"),debug:Ml("debug"),logLevel:Ml("level"),cleanThreshold:1e4,add:a8,connect:u8,rank:w8,rerank:E8,pulse:R8,touch:T8,update:N8,changeset:va,ingest:d8,parse:f8,preload:g8,request:h8,events:c8,on:y8,evaluate:S8,run:k8,runAsync:$8,runAfter:A8,_enqueue:C8,_getPulse:F8};function R(e,t){ze.call(this,e,null,t)}Y(R,ze,{run(e){if(e.stampthis.pulse=n):t!==e.StopPropagation&&(this.pulse=t),t},evaluate(e){const t=this.marshall(e.stamp),n=this.transform(t,e);return t.clear(),n},transform(){}});const bu={};function ZM(e){const t=eT(e);return t&&t.Definition||null}function eT(e){return e=e&&e.toLowerCase(),Z(bu,e)?bu[e]:null}function*tT(e,t){if(t==null)for(let n of e)n!=null&&n!==""&&(n=+n)>=n&&(yield n);else{let n=-1;for(let i of e)i=t(i,++n,e),i!=null&&i!==""&&(i=+i)>=i&&(yield i)}}function Rv(e,t,n){const i=Float64Array.from(tT(e,n));return i.sort(Ur),t.map(r=>QF(i,r))}function Ov(e,t){return Rv(e,[.25,.5,.75],t)}function Dv(e,t){const n=e.length,i=HI(e,t),r=Ov(e,t),o=(r[2]-r[0])/1.34;return 1.06*(Math.min(i,o)||i||Math.abs(r[0])||1)*Math.pow(n,-.2)}function nT(e){const t=e.maxbins||20,n=e.base||10,i=Math.log(n),r=e.divide||[5,2];let o=e.extent[0],s=e.extent[1],a,u,l,c,f,d;const h=e.span||s-o||Math.abs(o)||1;if(e.step)a=e.step;else if(e.steps){for(c=h/t,f=0,d=e.steps.length;ft;)a*=n;for(f=0,d=r.length;f=l&&h/c<=t&&(a=c)}c=Math.log(a);const g=c>=0?0:~~(-c/i)+1,p=Math.pow(n,-g-1);return(e.nice||e.nice===void 0)&&(c=Math.floor(o/a+p)*a,o=od);const r=e.length,o=new Float64Array(r);let s=0,a=1,u=i(e[0]),l=u,c=u+t,f;for(;a=c){for(l=(u+l)/2;s>1);sr;)e[s--]=e[i]}i=r,r=o}return e}function I8(e){return function(){return e=(1103515245*e+12345)%2147483647,e/2147483647}}function z8(e,t){t==null&&(t=e,e=0);let n,i,r;const o={min(s){return arguments.length?(n=s||0,r=i-n,o):n},max(s){return arguments.length?(i=s||0,r=i-n,o):i},sample(){return n+Math.floor(r*ii())},pdf(s){return s===Math.floor(s)&&s>=n&&s=i?1:(a-n+1)/r},icdf(s){return s>=0&&s<=1?n-1+Math.floor(s*r):NaN}};return o.min(e).max(t)}const oT=Math.sqrt(2*Math.PI),B8=Math.SQRT2;let Tl=NaN;function up(e,t){e=e||0,t=t??1;let n=0,i=0,r,o;if(Tl===Tl)n=Tl,Tl=NaN;else{do n=ii()*2-1,i=ii()*2-1,r=n*n+i*i;while(r===0||r>1);o=Math.sqrt(-2*Math.log(r)/r),n*=o,Tl=i*o}return e+n*t}function Lv(e,t,n){n=n??1;const i=(e-(t||0))/n;return Math.exp(-.5*i*i)/(n*oT)}function lp(e,t,n){t=t||0,n=n??1;const i=(e-t)/n,r=Math.abs(i);let o;if(r>37)o=0;else{const s=Math.exp(-r*r/2);let a;r<7.07106781186547?(a=.0352624965998911*r+.700383064443688,a=a*r+6.37396220353165,a=a*r+33.912866078383,a=a*r+112.079291497871,a=a*r+221.213596169931,a=a*r+220.206867912376,o=s*a,a=.0883883476483184*r+1.75566716318264,a=a*r+16.064177579207,a=a*r+86.7807322029461,a=a*r+296.564248779674,a=a*r+637.333633378831,a=a*r+793.826512519948,a=a*r+440.413735824752,o=o/a):(a=r+.65,a=r+4/a,a=r+3/a,a=r+2/a,a=r+1/a,o=s/a/2.506628274631)}return i>0?1-o:o}function cp(e,t,n){return e<0||e>1?NaN:(t||0)+(n??1)*B8*U8(2*e-1)}function U8(e){let t=-Math.log((1-e)*(1+e)),n;return t<6.25?(t-=3.125,n=-364441206401782e-35,n=-16850591381820166e-35+n*t,n=128584807152564e-32+n*t,n=11157877678025181e-33+n*t,n=-1333171662854621e-31+n*t,n=20972767875968562e-33+n*t,n=6637638134358324e-30+n*t,n=-4054566272975207e-29+n*t,n=-8151934197605472e-29+n*t,n=26335093153082323e-28+n*t,n=-12975133253453532e-27+n*t,n=-5415412054294628e-26+n*t,n=10512122733215323e-25+n*t,n=-4112633980346984e-24+n*t,n=-29070369957882005e-24+n*t,n=42347877827932404e-23+n*t,n=-13654692000834679e-22+n*t,n=-13882523362786469e-21+n*t,n=.00018673420803405714+n*t,n=-.000740702534166267+n*t,n=-.006033670871430149+n*t,n=.24015818242558962+n*t,n=1.6536545626831027+n*t):t<16?(t=Math.sqrt(t)-3.25,n=22137376921775787e-25,n=9075656193888539e-23+n*t,n=-27517406297064545e-23+n*t,n=18239629214389228e-24+n*t,n=15027403968909828e-22+n*t,n=-4013867526981546e-21+n*t,n=29234449089955446e-22+n*t,n=12475304481671779e-21+n*t,n=-47318229009055734e-21+n*t,n=6828485145957318e-20+n*t,n=24031110387097894e-21+n*t,n=-.0003550375203628475+n*t,n=.0009532893797373805+n*t,n=-.0016882755560235047+n*t,n=.002491442096107851+n*t,n=-.003751208507569241+n*t,n=.005370914553590064+n*t,n=1.0052589676941592+n*t,n=3.0838856104922208+n*t):Number.isFinite(t)?(t=Math.sqrt(t)-5,n=-27109920616438573e-27,n=-2555641816996525e-25+n*t,n=15076572693500548e-25+n*t,n=-3789465440126737e-24+n*t,n=761570120807834e-23+n*t,n=-1496002662714924e-23+n*t,n=2914795345090108e-23+n*t,n=-6771199775845234e-23+n*t,n=22900482228026655e-23+n*t,n=-99298272942317e-20+n*t,n=4526062597223154e-21+n*t,n=-1968177810553167e-20+n*t,n=7599527703001776e-20+n*t,n=-.00021503011930044477+n*t,n=-.00013871931833623122+n*t,n=1.0103004648645344+n*t,n=4.849906401408584+n*t):n=1/0,n*e}function Pv(e,t){let n,i;const r={mean(o){return arguments.length?(n=o||0,r):n},stdev(o){return arguments.length?(i=o??1,r):i},sample:()=>up(n,i),pdf:o=>Lv(o,n,i),cdf:o=>lp(o,n,i),icdf:o=>cp(o,n,i)};return r.mean(e).stdev(t)}function Iv(e,t){const n=Pv();let i=0;const r={data(o){return arguments.length?(e=o,i=o?o.length:0,r.bandwidth(t)):e},bandwidth(o){return arguments.length?(t=o,!t&&e&&(t=Dv(e)),r):t},sample(){return e[~~(ii()*i)]+t*n.sample()},pdf(o){let s=0,a=0;for(;azv(n,i),pdf:o=>Bv(o,n,i),cdf:o=>Uv(o,n,i),icdf:o=>jv(o,n,i)};return r.mean(e).stdev(t)}function aT(e,t){let n=0,i;function r(s){const a=[];let u=0,l;for(l=0;l=t&&e<=n?1/(n-t):0}function Hv(e,t,n){return n==null&&(n=t??1,t=0),en?1:(e-t)/(n-t)}function Gv(e,t,n){return n==null&&(n=t??1,t=0),e>=0&&e<=1?t+e*(n-t):NaN}function uT(e,t){let n,i;const r={min(o){return arguments.length?(n=o||0,r):n},max(o){return arguments.length?(i=o??1,r):i},sample:()=>qv(n,i),pdf:o=>Wv(o,n,i),cdf:o=>Hv(o,n,i),icdf:o=>Gv(o,n,i)};return t==null&&(t=e??1,e=0),r.min(e).max(t)}function Yv(e,t,n){let i=0,r=0;for(const o of e){const s=n(o);t(o)==null||s==null||isNaN(s)||(i+=(s-i)/++r)}return{coef:[i],predict:()=>i,rSquared:0}}function cf(e,t,n,i){const r=i-e*e,o=Math.abs(r)<1e-24?0:(n-e*t)/r;return[t-o*e,o]}function fp(e,t,n,i){e=e.filter(h=>{let g=t(h),p=n(h);return g!=null&&(g=+g)>=g&&p!=null&&(p=+p)>=p}),i&&e.sort((h,g)=>t(h)-t(g));const r=e.length,o=new Float64Array(r),s=new Float64Array(r);let a=0,u=0,l=0,c,f,d;for(d of e)o[a]=c=+t(d),s[a]=f=+n(d),++a,u+=(c-u)/a,l+=(f-l)/a;for(a=0;a=o&&s!=null&&(s=+s)>=s&&i(o,s,++r)}function sl(e,t,n,i,r){let o=0,s=0;return ff(e,t,n,(a,u)=>{const l=u-r(a),c=u-i;o+=l*l,s+=c*c}),1-o/s}function Vv(e,t,n){let i=0,r=0,o=0,s=0,a=0;ff(e,t,n,(c,f)=>{++a,i+=(c-i)/a,r+=(f-r)/a,o+=(c*f-o)/a,s+=(c*c-s)/a});const u=cf(i,r,o,s),l=c=>u[0]+u[1]*c;return{coef:u,predict:l,rSquared:sl(e,t,n,r,l)}}function lT(e,t,n){let i=0,r=0,o=0,s=0,a=0;ff(e,t,n,(c,f)=>{++a,c=Math.log(c),i+=(c-i)/a,r+=(f-r)/a,o+=(c*f-o)/a,s+=(c*c-s)/a});const u=cf(i,r,o,s),l=c=>u[0]+u[1]*Math.log(c);return{coef:u,predict:l,rSquared:sl(e,t,n,r,l)}}function cT(e,t,n){const[i,r,o,s]=fp(e,t,n);let a=0,u=0,l=0,c=0,f=0,d,h,g;ff(e,t,n,(b,v)=>{d=i[f++],h=Math.log(v),g=d*v,a+=(v*h-a)/f,u+=(g-u)/f,l+=(g*h-l)/f,c+=(d*g-c)/f});const[p,m]=cf(u/s,a/s,l/s,c/s),y=b=>Math.exp(p+m*(b-o));return{coef:[Math.exp(p-m*o),m],predict:y,rSquared:sl(e,t,n,s,y)}}function fT(e,t,n){let i=0,r=0,o=0,s=0,a=0,u=0;ff(e,t,n,(f,d)=>{const h=Math.log(f),g=Math.log(d);++u,i+=(h-i)/u,r+=(g-r)/u,o+=(h*g-o)/u,s+=(h*h-s)/u,a+=(d-a)/u});const l=cf(i,r,o,s),c=f=>l[0]*Math.pow(f,l[1]);return l[0]=Math.exp(l[0]),{coef:l,predict:c,rSquared:sl(e,t,n,a,c)}}function Xv(e,t,n){const[i,r,o,s]=fp(e,t,n),a=i.length;let u=0,l=0,c=0,f=0,d=0,h,g,p,m;for(h=0;h(w=w-o,v*w*w+x*w+E+s);return{coef:[E-x*o+v*o*o+s,x-2*v*o,v],predict:_,rSquared:sl(e,t,n,s,_)}}function dT(e,t,n,i){if(i===0)return Yv(e,t,n);if(i===1)return Vv(e,t,n);if(i===2)return Xv(e,t,n);const[r,o,s,a]=fp(e,t,n),u=r.length,l=[],c=[],f=i+1;let d,h,g,p,m;for(d=0;d{v-=s;let x=a+y[0]+y[1]*v+y[2]*v*v;for(d=3;d=0;--o)for(a=t[o],u=1,r[o]+=a,s=1;s<=o;++s)u*=(o+1-s)/s,r[o-s]+=a*Math.pow(n,s)*u;return r[0]+=i,r}function q8(e){const t=e.length-1,n=[];let i,r,o,s,a;for(i=0;iMath.abs(e[i][s])&&(s=r);for(o=i;o=i;o--)e[o][r]-=e[o][i]*e[i][r]/e[i][i]}for(r=t-1;r>=0;--r){for(a=0,o=r+1;or[v]-y?b:v;let E=0,_=0,w=0,S=0,$=0;const A=1/Math.abs(r[x]-y||1);for(let N=b;N<=v;++N){const C=r[N],k=o[N],M=W8(Math.abs(y-C)*A)*d[N],D=C*M;E+=M,_+=D,w+=k*M,S+=k*D,$+=C*D}const[F,T]=cf(_/E,w/E,S/E,$/E);c[m]=F+T*y,f[m]=Math.abs(o[m]-c[m]),H8(r,m+1,g)}if(h===hS)break;const p=ZF(f);if(Math.abs(p)=1?gS:(b=1-y*y)*b}return G8(r,c,s,a)}function W8(e){return(e=1-e*e*e)*e*e}function H8(e,t,n){const i=e[t];let r=n[0],o=n[1]+1;if(!(o>=e.length))for(;t>r&&e[o]-i<=i-e[r];)n[0]=++r,n[1]=o,++o}function G8(e,t,n,i){const r=e.length,o=[];let s=0,a=0,u=[],l;for(;s[p,e(p)],o=t[0],s=t[1],a=s-o,u=a/i,l=[r(o)],c=[];if(n===i){for(let p=1;p0;)c.push(r(o+p/n*a))}let f=l[0],d=c[c.length-1];const h=1/a,g=V8(f[1],c);for(;d;){const p=r((f[0]+d[0])/2);p[0]-f[0]>=u&&X8(f,p,d,h,g)>Y8?c.push(p):(f=d,l.push(d),c.pop()),d=c[c.length-1]}return l}function V8(e,t){let n=e,i=e;const r=t.length;for(let o=0;oi&&(i=s)}return 1/(i-n)}function X8(e,t,n,i,r){const o=Math.atan2(r*(n[1]-e[1]),i*(n[0]-e[0])),s=Math.atan2(r*(t[1]-e[1]),i*(t[0]-e[0]));return Math.abs(o-s)}function K8(e){return t=>{const n=e.length;let i=1,r=String(e[0](t));for(;i{},J8={init:c0,add:c0,rem:c0,idx:0},Oc={values:{init:e=>e.cell.store=!0,value:e=>e.cell.data.values(),idx:-1},count:{value:e=>e.cell.num},__count__:{value:e=>e.missing+e.valid},missing:{value:e=>e.missing},valid:{value:e=>e.valid},sum:{init:e=>e.sum=0,value:e=>e.valid?e.sum:void 0,add:(e,t)=>e.sum+=+t,rem:(e,t)=>e.sum-=t},product:{init:e=>e.product=1,value:e=>e.valid?e.product:void 0,add:(e,t)=>e.product*=t,rem:(e,t)=>e.product/=t},mean:{init:e=>e.mean=0,value:e=>e.valid?e.mean:void 0,add:(e,t)=>(e.mean_d=t-e.mean,e.mean+=e.mean_d/e.valid),rem:(e,t)=>(e.mean_d=t-e.mean,e.mean-=e.valid?e.mean_d/e.valid:e.mean)},average:{value:e=>e.valid?e.mean:void 0,req:["mean"],idx:1},variance:{init:e=>e.dev=0,value:e=>e.valid>1?e.dev/(e.valid-1):void 0,add:(e,t)=>e.dev+=e.mean_d*(t-e.mean),rem:(e,t)=>e.dev-=e.mean_d*(t-e.mean),req:["mean"],idx:1},variancep:{value:e=>e.valid>1?e.dev/e.valid:void 0,req:["variance"],idx:2},stdev:{value:e=>e.valid>1?Math.sqrt(e.dev/(e.valid-1)):void 0,req:["variance"],idx:2},stdevp:{value:e=>e.valid>1?Math.sqrt(e.dev/e.valid):void 0,req:["variance"],idx:2},stderr:{value:e=>e.valid>1?Math.sqrt(e.dev/(e.valid*(e.valid-1))):void 0,req:["variance"],idx:2},distinct:{value:e=>e.cell.data.distinct(e.get),req:["values"],idx:3},ci0:{value:e=>e.cell.data.ci0(e.get),req:["values"],idx:3},ci1:{value:e=>e.cell.data.ci1(e.get),req:["values"],idx:3},median:{value:e=>e.cell.data.q2(e.get),req:["values"],idx:3},q1:{value:e=>e.cell.data.q1(e.get),req:["values"],idx:3},q3:{value:e=>e.cell.data.q3(e.get),req:["values"],idx:3},min:{init:e=>e.min=void 0,value:e=>e.min=Number.isNaN(e.min)?e.cell.data.min(e.get):e.min,add:(e,t)=>{(t{t<=e.min&&(e.min=NaN)},req:["values"],idx:4},max:{init:e=>e.max=void 0,value:e=>e.max=Number.isNaN(e.max)?e.cell.data.max(e.get):e.max,add:(e,t)=>{(t>e.max||e.max===void 0)&&(e.max=t)},rem:(e,t)=>{t>=e.max&&(e.max=NaN)},req:["values"],idx:4},argmin:{init:e=>e.argmin=void 0,value:e=>e.argmin||e.cell.data.argmin(e.get),add:(e,t,n)=>{t{t<=e.min&&(e.argmin=void 0)},req:["min","values"],idx:3},argmax:{init:e=>e.argmax=void 0,value:e=>e.argmax||e.cell.data.argmax(e.get),add:(e,t,n)=>{t>e.max&&(e.argmax=n)},rem:(e,t)=>{t>=e.max&&(e.argmax=void 0)},req:["max","values"],idx:3},exponential:{init:(e,t)=>{e.exp=0,e.exp_r=t},value:e=>e.valid?e.exp*(1-e.exp_r)/(1-e.exp_r**e.valid):void 0,add:(e,t)=>e.exp=e.exp_r*e.exp+t,rem:(e,t)=>e.exp=(e.exp-t/e.exp_r**(e.valid-1))/e.exp_r},exponentialb:{value:e=>e.valid?e.exp*(1-e.exp_r):void 0,req:["exponential"],idx:1}},df=Object.keys(Oc).filter(e=>e!=="__count__");function Q8(e,t){return(n,i)=>pe({name:e,aggregate_param:i,out:n||e},J8,t)}[...df,"__count__"].forEach(e=>{Oc[e]=Q8(e,Oc[e])});function pT(e,t,n){return Oc[e](n,t)}function mT(e,t){return e.idx-t.idx}function Z8(e){const t={};e.forEach(i=>t[i.name]=i);const n=i=>{i.req&&i.req.forEach(r=>{t[r]||n(t[r]=Oc[r]())})};return e.forEach(n),Object.values(t).sort(mT)}function e9(){this.valid=0,this.missing=0,this._ops.forEach(e=>e.aggregate_param==null?e.init(this):e.init(this,e.aggregate_param))}function t9(e,t){if(e==null||e===""){++this.missing;return}e===e&&(++this.valid,this._ops.forEach(n=>n.add(this,e,t)))}function n9(e,t){if(e==null||e===""){--this.missing;return}e===e&&(--this.valid,this._ops.forEach(n=>n.rem(this,e,t)))}function i9(e){return this._out.forEach(t=>e[t.out]=t.value(this)),e}function yT(e,t){const n=t||vn,i=Z8(e),r=e.slice().sort(mT);function o(s){this._ops=i,this._out=r,this.cell=s,this.init()}return o.prototype.init=e9,o.prototype.add=t9,o.prototype.rem=n9,o.prototype.set=i9,o.prototype.get=n,o.fields=e.map(s=>s.out),o}function Kv(e){this._key=e?ei(e):re,this.reset()}const Rt=Kv.prototype;Rt.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null};Rt.add=function(e){this._add.push(e)};Rt.rem=function(e){this._rem.push(e)};Rt.values=function(){if(this._get=null,this._rem.length===0)return this._add;const e=this._add,t=this._rem,n=this._key,i=e.length,r=t.length,o=Array(i-r),s={};let a,u,l;for(a=0;a=0;)o=e(t[i])+"",Z(n,o)||(n[o]=1,++r);return r};Rt.extent=function(e){if(this._get!==e||!this._ext){const t=this.values(),n=DF(t,e);this._ext=[t[n[0]],t[n[1]]],this._get=e}return this._ext};Rt.argmin=function(e){return this.extent(e)[0]||{}};Rt.argmax=function(e){return this.extent(e)[1]||{}};Rt.min=function(e){const t=this.extent(e)[0];return t!=null?e(t):void 0};Rt.max=function(e){const t=this.extent(e)[1];return t!=null?e(t):void 0};Rt.quartile=function(e){return(this._get!==e||!this._q)&&(this._q=Ov(this.values(),e),this._get=e),this._q};Rt.q1=function(e){return this.quartile(e)[0]};Rt.q2=function(e){return this.quartile(e)[1]};Rt.q3=function(e){return this.quartile(e)[2]};Rt.ci=function(e){return(this._get!==e||!this._ci)&&(this._ci=iT(this.values(),1e3,.05,e),this._get=e),this._ci};Rt.ci0=function(e){return this.ci(e)[0]};Rt.ci1=function(e){return this.ci(e)[1]};function Uo(e){R.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}Uo.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:df},{name:"aggregate_params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};Y(Uo,R,{transform(e,t){const n=this,i=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=e.modified();return n.stamp=i.stamp,n.value&&(r||t.modified(n._inputs,!0))?(n._prev=n.value,n.value=r?n.init(e):Object.create(null),t.visit(t.SOURCE,o=>n.add(o))):(n.value=n.value||n.init(e),t.visit(t.REM,o=>n.rem(o)),t.visit(t.ADD,o=>n.add(o))),i.modifies(n._outputs),n._drop=e.drop!==!1,e.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),t.clean()&&n._drop&&i.clean(!0).runAfter(()=>this.clean()),n.changes(i)},cross(){const e=this,t=e.value,n=e._dnames,i=n.map(()=>({})),r=n.length;function o(a){let u,l,c,f;for(u in a)for(c=a[u].tuple,l=0;l{const v=Ze(b);return r(b),n.push(v),v}),this.cellkey=e.key?e.key:iy(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];const o=e.fields||[null],s=e.ops||["count"],a=e.aggregate_params||[null],u=e.as||[],l=o.length,c={};let f,d,h,g,p,m,y;for(l!==s.length&&O("Unmatched number of fields and aggregate ops."),y=0;yyT(b,b.field)),Object.create(null)},cellkey:iy(),cell(e,t){let n=this.value[e];return n?n.num===0&&this._drop&&n.stamp{const f=i(c);c[a]=f,c[u]=f==null?null:r+o*(1+(f-r)/o)}:c=>c[a]=i(c)),t.modifies(n?s:a)},_bins(e){if(this.value&&!e.modified())return this.value;const t=e.field,n=nT(e),i=n.step;let r=n.start,o=r+Math.ceil((n.stop-r)/i)*i,s,a;(s=e.anchor)!=null&&(a=s-(r+i*Math.floor((s-r)/i)),r+=a,o+=a);const u=function(l){let c=nn(t(l));return c==null?null:co?1/0:(c=Math.max(r,Math.min(c,o-i)),r+i*Math.floor(r9+(c-r)/i))};return u.start=r,u.stop=n.stop,u.step=i,this.value=kn(u,qt(t),e.name||"bin_"+Ze(t))}});function bT(e,t,n){const i=e;let r=t||[],o=n||[],s={},a=0;return{add:u=>o.push(u),remove:u=>s[i(u)]=++a,size:()=>r.length,data:(u,l)=>(a&&(r=r.filter(c=>!s[i(c)]),s={},a=0),l&&u&&r.sort(u),o.length&&(r=u?BF(u,r,o.sort(u)):r.concat(o),o=[]),r)}}function Qv(e){R.call(this,[],e)}Qv.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]};Y(Qv,R,{transform(e,t){const n=t.fork(t.ALL),i=bT(re,this.value,n.materialize(n.ADD).add),r=e.sort,o=t.changed()||r&&(e.modified("sort")||t.modified(r.fields));return n.visit(n.REM,i.remove),this.modified(o),this.value=n.source=i.data(ba(r),o),t.source&&t.source.root&&(this.value.root=t.source.root),n}});function vT(e){ze.call(this,null,o9,e)}Y(vT,ze);function o9(e){return this.value&&!e.modified()?this.value:fv(e.fields,e.orders)}function Zv(e){R.call(this,null,e)}Zv.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]};function s9(e,t,n){switch(t){case"upper":e=e.toUpperCase();break;case"lower":e=e.toLowerCase();break}return e.match(n)}Y(Zv,R,{transform(e,t){const n=f=>d=>{for(var h=s9(a(d),e.case,o)||[],g,p=0,m=h.length;pr[f]=1+(r[f]||0)),c=n(f=>r[f]-=1);return i?t.visit(t.SOURCE,l):(t.visit(t.ADD,l),t.visit(t.REM,c)),this._finish(t,u)},_parameterCheck(e,t){let n=!1;return(e.modified("stopwords")||!this._stop)&&(this._stop=new RegExp("^"+(e.stopwords||"")+"$","i"),n=!0),(e.modified("pattern")||!this._match)&&(this._match=new RegExp(e.pattern||"[\\w']+","g"),n=!0),(e.modified("field")||t.modified(e.field.fields))&&(n=!0),n&&(this._counts={}),n},_finish(e,t){const n=this._counts,i=this._tuples||(this._tuples={}),r=t[0],o=t[1],s=e.fork(e.NO_SOURCE|e.NO_FIELDS);let a,u,l;for(a in n)u=i[a],l=n[a]||0,!u&&l?(i[a]=u=Fe({}),u[r]=a,u[o]=l,s.add.push(u)):l===0?(u&&s.rem.push(u),n[a]=null,i[a]=null):u[o]!==l&&(u[o]=l,s.mod.push(u));return s.modifies(t)}});function ex(e){R.call(this,null,e)}ex.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]};Y(ex,R,{transform(e,t){const n=t.fork(t.NO_SOURCE),i=e.as||["a","b"],r=i[0],o=i[1],s=!this.value||t.changed(t.ADD_REM)||e.modified("as")||e.modified("filter");let a=this.value;return s?(a&&(n.rem=a),a=t.materialize(t.SOURCE).source,n.add=this.value=a9(a,r,o,e.filter||ti)):n.mod=a,n.source=this.value,n.modifies(i)}});function a9(e,t,n,i){for(var r=[],o={},s=e.length,a=0,u,l;axT(o,t))):typeof i[r]===mS&&i[r](e[r]);return i}function tx(e){R.call(this,null,e)}const wT=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],c9={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:wT},{name:"weights",type:"number",array:!0}]};tx.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:wT.concat(c9)},{name:"as",type:"string",array:!0,default:["value","density"]}]};Y(tx,R,{transform(e,t){const n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){const i=xT(e.distribution,f9(t)),r=e.steps||e.minsteps||25,o=e.steps||e.maxsteps||200;let s=e.method||"pdf";s!=="pdf"&&s!=="cdf"&&O("Invalid density method: "+s),!e.extent&&!i.data&&O("Missing density extent parameter."),s=i[s];const a=e.as||["value","density"],u=e.extent||ir(i.data()),l=dp(s,u,r,o).map(c=>{const f={};return f[a[0]]=c[0],f[a[1]]=c[1],Fe(f)});this.value&&(n.rem=this.value),this.value=n.add=n.source=l}return n}});function f9(e){return()=>e.materialize(e.SOURCE).source}function ET(e,t){return e?e.map((n,i)=>t[i]||Ze(n)):null}function nx(e,t,n){const i=[],r=f=>f(u);let o,s,a,u,l,c;if(t==null)i.push(e.map(n));else for(o={},s=0,a=e.length;slf(ir(e,t))/30;Y(ix,R,{transform(e,t){if(this.value&&!(e.modified()||t.changed()))return t;const n=t.materialize(t.SOURCE).source,i=nx(t.source,e.groupby,vn),r=e.smooth||!1,o=e.field,s=e.step||d9(n,o),a=ba((g,p)=>o(g)-o(p)),u=e.as||_T,l=i.length;let c=1/0,f=-1/0,d=0,h;for(;df&&(f=p),g[++h][u]=p}return this.value={start:c,stop:f,step:s},t.reflow(!0).modifies(u)}});function ST(e){ze.call(this,null,h9,e),this.modified(!0)}Y(ST,ze);function h9(e){const t=e.expr;return this.value&&!e.modified("expr")?this.value:kn(n=>t(n,e),qt(t),Ze(t))}function rx(e){R.call(this,[void 0,void 0],e)}rx.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]};Y(rx,R,{transform(e,t){const n=this.value,i=e.field,r=t.changed()||t.modified(i.fields)||e.modified("field");let o=n[0],s=n[1];if((r||o==null)&&(o=1/0,s=-1/0),t.visit(r?t.SOURCE:t.ADD,a=>{const u=nn(i(a));u!=null&&(us&&(s=u))}),!Number.isFinite(o)||!Number.isFinite(s)){let a=Ze(i);a&&(a=` for field "${a}"`),t.dataflow.warn(`Infinite extent${a}: [${o}, ${s}]`),o=s=void 0}this.value=[o,s]}});function ox(e,t){ze.call(this,e),this.parent=t,this.count=0}Y(ox,ze,{connect(e){return this.detachSubflow=e.detachSubflow,this.targets().add(e),e.source=this},add(e){this.count+=1,this.value.add.push(e)},rem(e){this.count-=1,this.value.rem.push(e)},mod(e){this.value.mod.push(e)},init(e){this.value.init(e,e.NO_SOURCE)},evaluate(){return this.value}});function hp(e){R.call(this,{},e),this._keys=el();const t=this._targets=[];t.active=0,t.forEach=n=>{for(let i=0,r=t.active;ii&&i.count>0);this.initTargets(n)}},initTargets(e){const t=this._targets,n=t.length,i=e?e.length:0;let r=0;for(;rthis.subflow(u,r,t);return this._group=e.group||{},this.initTargets(),t.visit(t.REM,u=>{const l=re(u),c=o.get(l);c!==void 0&&(o.delete(l),a(c).rem(u))}),t.visit(t.ADD,u=>{const l=i(u);o.set(re(u),l),a(l).add(u)}),s||t.modified(i.fields)?t.visit(t.MOD,u=>{const l=re(u),c=o.get(l),f=i(u);c===f?a(f).mod(u):(o.set(l,f),a(c).rem(u),a(f).add(u))}):t.changed(t.MOD)&&t.visit(t.MOD,u=>{a(o.get(re(u))).mod(u)}),s&&t.visit(t.REFLOW,u=>{const l=re(u),c=o.get(l),f=i(u);c!==f&&(o.set(l,f),a(c).rem(u),a(f).add(u))}),t.clean()?n.runAfter(()=>{this.clean(),o.clean()}):o.empty>n.cleanThreshold&&n.runAfter(o.clean),t}});function $T(e){ze.call(this,null,g9,e)}Y($T,ze);function g9(e){return this.value&&!e.modified()?this.value:P(e.name)?Q(e.name).map(t=>ei(t)):ei(e.name,e.as)}function sx(e){R.call(this,el(),e)}sx.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]};Y(sx,R,{transform(e,t){const n=t.dataflow,i=this.value,r=t.fork(),o=r.add,s=r.rem,a=r.mod,u=e.expr;let l=!0;t.visit(t.REM,f=>{const d=re(f);i.has(d)?i.delete(d):s.push(f)}),t.visit(t.ADD,f=>{u(f,e)?o.push(f):i.set(re(f),1)});function c(f){const d=re(f),h=u(f,e),g=i.get(d);h&&g?(i.delete(d),o.push(f)):!h&&!g?(i.set(d,1),s.push(f)):l&&h&&!g&&a.push(f)}return t.visit(t.MOD,c),e.modified()&&(l=!1,t.visit(t.REFLOW,c)),i.empty>n.cleanThreshold&&n.runAfter(i.clean),r}});function ax(e){R.call(this,[],e)}ax.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"index",type:"string"},{name:"as",type:"string",array:!0}]};Y(ax,R,{transform(e,t){const n=t.fork(t.NO_SOURCE),i=e.fields,r=ET(i,e.as||[]),o=e.index||null,s=r.length;return n.rem=this.value,t.visit(t.SOURCE,a=>{const u=i.map(g=>g(a)),l=u.reduce((g,p)=>Math.max(g,p.length),0);let c=0,f,d,h;for(;c{for(let c=0,f;cs[i]=n(s,e))}});function kT(e){R.call(this,[],e)}Y(kT,R,{transform(e,t){const n=t.fork(t.ALL),i=e.generator;let r=this.value,o=e.size-r.length,s,a,u;if(o>0){for(s=[];--o>=0;)s.push(u=Fe(i(e))),r.push(u);n.add=n.add.length?n.materialize(n.ADD).add.concat(s):s}else a=r.slice(0,-o),n.rem=n.rem.length?n.materialize(n.REM).rem.concat(a):a,r=r.slice(-o);return n.source=this.value=r,n}});const rd={value:"value",median:ZF,mean:JI,min:G1,max:Ls},p9=[];function cx(e){R.call(this,[],e)}cx.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]};function m9(e){var t=e.method||rd.value,n;if(rd[t]==null)O("Unrecognized imputation method: "+t);else return t===rd.value?(n=e.value!==void 0?e.value:0,()=>n):rd[t]}function y9(e){const t=e.field;return n=>n?t(n):NaN}Y(cx,R,{transform(e,t){var n=t.fork(t.ALL),i=m9(e),r=y9(e),o=Ze(e.field),s=Ze(e.key),a=(e.groupby||[]).map(Ze),u=b9(t.source,e.groupby,e.key,e.keyvals),l=[],c=this.value,f=u.domain.length,d,h,g,p,m,y,b,v,x,E;for(m=0,v=u.length;my(m),o=[],s=i?i.slice():[],a={},u={},l,c,f,d,h,g,p,m;for(s.forEach((y,b)=>a[y]=b+1),d=0,p=e.length;dn.add(o))):(r=n.value=n.value||this.init(e),t.visit(t.REM,o=>n.rem(o)),t.visit(t.ADD,o=>n.add(o))),n.changes(),t.visit(t.SOURCE,o=>{pe(o,r[n.cellkey(o)].tuple)}),t.reflow(i).modifies(this._outputs)},changes(){const e=this._adds,t=this._mods;let n,i;for(n=0,i=this._alen;n{const g=Iv(h,s)[a],p=e.counts?h.length:1,m=c||ir(h);dp(g,m,f,d).forEach(y=>{const b={};for(let v=0;v(this._pending=Q(r.data),o=>o.touch(this)))}:n.request(e.url,e.format).then(i=>f0(this,t,Q(i.data)))}});function x9(e){return e.modified("async")&&!(e.modified("values")||e.modified("url")||e.modified("format"))}function f0(e,t,n){n.forEach(Fe);const i=t.fork(t.NO_FIELDS&t.NO_SOURCE);return i.rem=e.value,e.value=i.source=i.add=n,e._pending=null,i.rem.length&&i.clean(!0),i}function hx(e){R.call(this,{},e)}hx.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]};Y(hx,R,{transform(e,t){const n=e.fields,i=e.index,r=e.values,o=e.default==null?null:e.default,s=e.modified(),a=n.length;let u=s?t.SOURCE:t.ADD,l=t,c=e.as,f,d,h;return r?(d=r.length,a>1&&!c&&O('Multi-field lookup requires explicit "as" parameter.'),c&&c.length!==a*d&&O('The "as" parameter has too few output field names.'),c=c||r.map(Ze),f=function(g){for(var p=0,m=0,y,b;pt.modified(g.fields)),u|=h?t.MOD:0),t.visit(u,f),l.modifies(c)}});function FT(e){ze.call(this,null,w9,e)}Y(FT,ze);function w9(e){if(this.value&&!e.modified())return this.value;const t=e.extents,n=t.length;let i=1/0,r=-1/0,o,s;for(o=0;or&&(r=s[1]);return[i,r]}function MT(e){ze.call(this,null,E9,e)}Y(MT,ze);function E9(e){return this.value&&!e.modified()?this.value:e.values.reduce((t,n)=>t.concat(n),[])}function TT(e){R.call(this,null,e)}Y(TT,R,{transform(e,t){return this.modified(e.modified()),this.value=e,t.fork(t.NO_SOURCE|t.NO_FIELDS)}});function gx(e){Uo.call(this,e)}gx.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:df,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};Y(gx,Uo,{_transform:Uo.prototype.transform,transform(e,t){return this._transform(_9(e,t),t)}});function _9(e,t){const n=e.field,i=e.value,r=(e.op==="count"?"__count__":e.op)||"sum",o=qt(n).concat(qt(i)),s=$9(n,e.limit||0,t);return t.changed()&&e.set("__pivot__",null,null,!0),{key:e.key,groupby:e.groupby,ops:s.map(()=>r),fields:s.map(a=>S9(a,n,i,o)),as:s.map(a=>a+""),modified:e.modified.bind(e)}}function S9(e,t,n,i){return kn(r=>t(r)===e?n(r):NaN,i,e+"")}function $9(e,t,n){const i={},r=[];return n.visit(n.SOURCE,o=>{const s=e(o);i[s]||(i[s]=1,r.push(s))}),r.sort(Zu),t?r.slice(0,t):r}function NT(e){hp.call(this,e)}Y(NT,hp,{transform(e,t){const n=e.subflow,i=e.field,r=o=>this.subflow(re(o),n,t,o);return(e.modified("field")||i&&t.modified(qt(i)))&&O("PreFacet does not support field modification."),this.initTargets(),i?(t.visit(t.MOD,o=>{const s=r(o);i(o).forEach(a=>s.mod(a))}),t.visit(t.ADD,o=>{const s=r(o);i(o).forEach(a=>s.add(Fe(a)))}),t.visit(t.REM,o=>{const s=r(o);i(o).forEach(a=>s.rem(a))})):(t.visit(t.MOD,o=>r(o).mod(o)),t.visit(t.ADD,o=>r(o).add(o)),t.visit(t.REM,o=>r(o).rem(o))),t.clean()&&t.runAfter(()=>this.clean()),t}});function px(e){R.call(this,null,e)}px.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]};Y(px,R,{transform(e,t){const n=t.fork(t.NO_SOURCE),i=e.fields,r=ET(e.fields,e.as||[]),o=i?(a,u)=>k9(a,u,i,r):op;let s;return this.value?s=this.value:(t=t.addAll(),s=this.value={}),t.visit(t.REM,a=>{const u=re(a);n.rem.push(s[u]),s[u]=null}),t.visit(t.ADD,a=>{const u=o(a,Fe({}));s[re(a)]=u,n.add.push(u)}),t.visit(t.MOD,a=>{n.mod.push(o(a,s[re(a)]))}),n}});function k9(e,t,n,i){for(let r=0,o=n.length;r{const d=Rv(f,l);for(let h=0;h{const o=re(r);n.rem.push(i[o]),i[o]=null}),t.visit(t.ADD,r=>{const o=Mv(r);i[re(r)]=o,n.add.push(o)}),t.visit(t.MOD,r=>{const o=i[re(r)];for(const s in r)o[s]=r[s],n.modifies(s);n.mod.push(o)})),n}});function yx(e){R.call(this,[],e),this.count=0}yx.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]};Y(yx,R,{transform(e,t){const n=t.fork(t.NO_SOURCE),i=e.modified("size"),r=e.size,o=this.value.reduce((c,f)=>(c[re(f)]=1,c),{});let s=this.value,a=this.count,u=0;function l(c){let f,d;s.length=u&&(f=s[d],o[re(f)]&&n.rem.push(f),s[d]=c)),++a}if(t.rem.length&&(t.visit(t.REM,c=>{const f=re(c);o[f]&&(o[f]=-1,n.rem.push(c)),--a}),s=s.filter(c=>o[re(c)]!==-1)),(t.rem.length||i)&&s.length{o[re(c)]||l(c)}),u=-1),i&&s.length>r){const c=s.length-r;for(let f=0;f{o[re(c)]&&n.mod.push(c)}),t.add.length&&t.visit(t.ADD,l),(t.add.length||u<0)&&(n.add=s.filter(c=>!o[re(c)])),this.count=a,this.value=n.source=s,n}});function bx(e){R.call(this,null,e)}bx.Definition={type:"Sequence",metadata:{generates:!0,changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]};Y(bx,R,{transform(e,t){if(this.value&&!e.modified())return;const n=t.materialize().fork(t.MOD),i=e.as||"data";return n.rem=this.value?t.rem.concat(this.value):t.rem,this.value=Nn(e.start,e.stop,e.step||1).map(r=>{const o={};return o[i]=r,Fe(o)}),n.add=t.add.concat(this.value),n}});function DT(e){R.call(this,null,e),this.modified(!0)}Y(DT,R,{transform(e,t){return this.value=t.source,t.changed()?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation}});function vx(e){R.call(this,null,e)}const LT=["unit0","unit1"];vx.Definition={type:"TimeUnit",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"interval",type:"boolean",default:!0},{name:"units",type:"enum",values:wv,array:!0},{name:"step",type:"number",default:1},{name:"maxbins",type:"number",default:40},{name:"extent",type:"date",array:!0},{name:"timezone",type:"enum",default:"local",values:["local","utc"]},{name:"as",type:"string",array:!0,length:2,default:LT}]};Y(vx,R,{transform(e,t){const n=e.field,i=e.interval!==!1,r=e.timezone==="utc",o=this._floor(e,t),s=(r?ol:rl)(o.unit).offset,a=e.as||LT,u=a[0],l=a[1],c=o.step;let f=o.start||1/0,d=o.stop||-1/0,h=t.ADD;return(e.modified()||t.changed(t.REM)||t.modified(qt(n)))&&(t=t.reflow(!0),h=t.SOURCE,f=1/0,d=-1/0),t.visit(h,g=>{const p=n(g);let m,y;p==null?(g[u]=null,i&&(g[l]=null)):(g[u]=m=y=o(p),i&&(g[l]=y=s(m,c)),md&&(d=y))}),o.start=f,o.stop=d,t.modifies(i?a:u)},_floor(e,t){const n=e.timezone==="utc",{units:i,step:r}=e.units?{units:e.units,step:e.step||1}:kM({extent:e.extent||ir(t.materialize(t.SOURCE).source,e.field),maxbins:e.maxbins}),o=Ev(i),s=this.value||{},a=(n?yM:mM)(o,r);return a.unit=_e(o),a.units=o,a.step=r,a.start=s.start,a.stop=s.stop,this.value=a}});function PT(e){R.call(this,el(),e)}Y(PT,R,{transform(e,t){const n=t.dataflow,i=e.field,r=this.value,o=a=>r.set(i(a),a);let s=!0;return e.modified("field")||t.modified(i.fields)?(r.clear(),t.visit(t.SOURCE,o)):t.changed()?(t.visit(t.REM,a=>r.delete(i(a))),t.visit(t.ADD,o)):s=!1,this.modified(s),r.empty>n.cleanThreshold&&n.runAfter(r.clean),t.fork()}});function IT(e){R.call(this,null,e)}Y(IT,R,{transform(e,t){(!this.value||e.modified("field")||e.modified("sort")||t.changed()||e.sort&&t.modified(e.sort.fields))&&(this.value=(e.sort?t.source.slice().sort(ba(e.sort)):t.source).map(e.field))}});function C9(e,t,n,i){const r=Dc[e](t,n);return{init:r.init||_o,update:function(o,s){s[i]=r.next(o)}}}const Dc={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:t=>{const n=t.index,i=t.data;return n&&t.compare(i[n-1],i[n])?e=n+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:t=>{const n=t.index,i=t.data;return n&&t.compare(i[n-1],i[n])?++e:e}}},percent_rank:function(){const e=Dc.rank(),t=e.next;return{init:e.init,next:n=>(t(n)-1)/(n.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:t=>{const n=t.data,i=t.compare;let r=t.index;if(e0||O("ntile num must be greater than zero.");const n=Dc.cume_dist(),i=n.next;return{init:n.init,next:r=>Math.ceil(t*i(r))}},lag:function(e,t){return t=+t||1,{next:n=>{const i=n.index-t;return i>=0?e(n.data[i]):null}}},lead:function(e,t){return t=+t||1,{next:n=>{const i=n.index+t,r=n.data;return ie(t.data[t.i0])}},last_value:function(e){return{next:t=>e(t.data[t.i1-1])}},nth_value:function(e,t){return t=+t,t>0||O("nth_value nth must be greater than zero."),{next:n=>{const i=n.i0+(t-1);return it=null,next:n=>{const i=e(n.data[n.index]);return i!=null?t=i:t}}},next_value:function(e){let t,n;return{init:()=>(t=null,n=-1),next:i=>{const r=i.data;return i.index<=n?t:(n=F9(e,r,i.index))<0?(n=r.length,t=null):t=e(r[n])}}}};function F9(e,t,n){for(let i=t.length;nu[p]=1)}h(e.sort),t.forEach((g,p)=>{const m=n[p],y=i[p],b=r[p]||null,v=Ze(m),x=gT(g,v,o[p]);if(h(m),s.push(x),Z(Dc,g))a.push(C9(g,m,y,x));else{if(m==null&&g!=="count"&&O("Null aggregate field specified."),g==="count"){c.push(x);return}d=!1;let E=l[v];E||(E=l[v]=[],E.field=m,f.push(E)),E.push(pT(g,b,x))}}),(c.length||f.length)&&(this.cell=T9(f,c,d)),this.inputs=Object.keys(u)}const BT=zT.prototype;BT.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()};BT.update=function(e,t){const n=this.cell,i=this.windows,r=e.data,o=i&&i.length;let s;if(n){for(s=e.p0;syT(u,u.field));const i={num:0,agg:null,store:!1,count:t};if(!n)for(var r=e.length,o=i.agg=Array(r),s=0;sthis.group(r(a));let s=this.state;(!s||n)&&(s=this.state=new zT(e)),n||t.modified(s.inputs)?(this.value={},t.visit(t.SOURCE,a=>o(a).add(a))):(t.visit(t.REM,a=>o(a).remove(a)),t.visit(t.ADD,a=>o(a).add(a)));for(let a=0,u=this._mlen;a0&&!r(o[n],o[n-1])&&(e.i0=t.left(o,o[n])),i1?0:e<-1?vu:Math.acos(e)}function bS(e){return e>=1?_h:e<=-1?-_h:Math.asin(e)}const ry=Math.PI,oy=2*ry,Ss=1e-6,I9=oy-Ss;function jT(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw new Error(`invalid digits: ${e}`);if(t>15)return jT;const n=10**t;return function(i){this._+=i[0];for(let r=1,o=i.length;rSs)if(!(Math.abs(f*u-l*c)>Ss)||!o)this._append`L${this._x1=t},${this._y1=n}`;else{let h=i-s,g=r-a,p=u*u+l*l,m=h*h+g*g,y=Math.sqrt(p),b=Math.sqrt(d),v=o*Math.tan((ry-Math.acos((p+d-m)/(2*y*b)))/2),x=v/b,E=v/y;Math.abs(x-1)>Ss&&this._append`L${t+x*c},${n+x*f}`,this._append`A${o},${o},0,0,${+(f*h>c*g)},${this._x1=t+E*u},${this._y1=n+E*l}`}}arc(t,n,i,r,o,s){if(t=+t,n=+n,i=+i,s=!!s,i<0)throw new Error(`negative radius: ${i}`);let a=i*Math.cos(r),u=i*Math.sin(r),l=t+a,c=n+u,f=1^s,d=s?r-o:o-r;this._x1===null?this._append`M${l},${c}`:(Math.abs(this._x1-l)>Ss||Math.abs(this._y1-c)>Ss)&&this._append`L${l},${c}`,i&&(d<0&&(d=d%oy+oy),d>I9?this._append`A${i},${i},0,1,${f},${t-a},${n-u}A${i},${i},0,1,${f},${this._x1=l},${this._y1=c}`:d>Ss&&this._append`A${i},${i},0,${+(d>=ry)},${f},${this._x1=t+i*Math.cos(o)},${this._y1=n+i*Math.sin(o)}`)}rect(t,n,i,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${i=+i}v${+r}h${-i}Z`}toString(){return this._}};function gp(){return new wx}gp.prototype=wx.prototype;function pp(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{const i=Math.floor(n);if(!(i>=0))throw new RangeError(`invalid digits: ${n}`);t=i}return e},()=>new wx(t)}function B9(e){return e.innerRadius}function U9(e){return e.outerRadius}function j9(e){return e.startAngle}function q9(e){return e.endAngle}function W9(e){return e&&e.padAngle}function H9(e,t,n,i,r,o,s,a){var u=n-e,l=i-t,c=s-r,f=a-o,d=f*u-c*l;if(!(d*dC*C+k*k&&(S=A,$=F),{cx:S,cy:$,x01:-c,y01:-f,x11:S*(r/E-1),y11:$*(r/E-1)}}function G9(){var e=B9,t=U9,n=Me(0),i=null,r=j9,o=q9,s=W9,a=null,u=pp(l);function l(){var c,f,d=+e.apply(this,arguments),h=+t.apply(this,arguments),g=r.apply(this,arguments)-_h,p=o.apply(this,arguments)-_h,m=yS(p-g),y=p>g;if(a||(a=c=u()),hIt))a.moveTo(0,0);else if(m>UT-It)a.moveTo(h*hs(g),h*Bi(g)),a.arc(0,0,h,g,p,!y),d>It&&(a.moveTo(d*hs(p),d*Bi(p)),a.arc(0,0,d,p,g,y));else{var b=g,v=p,x=g,E=p,_=m,w=m,S=s.apply(this,arguments)/2,$=S>It&&(i?+i.apply(this,arguments):Ns(d*d+h*h)),A=d0(yS(h-d)/2,+n.apply(this,arguments)),F=A,T=A,N,C;if($>It){var k=bS($/d*Bi(S)),M=bS($/h*Bi(S));(_-=k*2)>It?(k*=y?1:-1,x+=k,E-=k):(_=0,x=E=(g+p)/2),(w-=M*2)>It?(M*=y?1:-1,b+=M,v-=M):(w=0,b=v=(g+p)/2)}var D=h*hs(b),B=h*Bi(b),z=d*hs(E),X=d*Bi(E);if(A>It){var le=h*hs(v),se=h*Bi(v),he=d*hs(x),Ie=d*Bi(x),ge;if(mIt?T>It?(N=od(he,Ie,D,B,h,T,y),C=od(le,se,z,X,h,T,y),a.moveTo(N.cx+N.x01,N.cy+N.y01),TIt)||!(_>It)?a.lineTo(z,X):F>It?(N=od(z,X,le,se,d,-F,y),C=od(D,B,he,Ie,d,-F,y),a.lineTo(N.cx+N.x01,N.cy+N.y01),F=h;--g)a.point(v[g],x[g]);a.lineEnd(),a.areaEnd()}y&&(v[d]=+e(m,d,f),x[d]=+t(m,d,f),a.point(i?+i(m,d,f):v[d],n?+n(m,d,f):x[d]))}if(b)return a=null,b+""||null}function c(){return YT().defined(r).curve(s).context(o)}return l.x=function(f){return arguments.length?(e=typeof f=="function"?f:Me(+f),i=null,l):e},l.x0=function(f){return arguments.length?(e=typeof f=="function"?f:Me(+f),l):e},l.x1=function(f){return arguments.length?(i=f==null?null:typeof f=="function"?f:Me(+f),l):i},l.y=function(f){return arguments.length?(t=typeof f=="function"?f:Me(+f),n=null,l):t},l.y0=function(f){return arguments.length?(t=typeof f=="function"?f:Me(+f),l):t},l.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Me(+f),l):n},l.lineX0=l.lineY0=function(){return c().x(e).y(t)},l.lineY1=function(){return c().x(e).y(n)},l.lineX1=function(){return c().x(i).y(t)},l.defined=function(f){return arguments.length?(r=typeof f=="function"?f:Me(!!f),l):r},l.curve=function(f){return arguments.length?(s=f,o!=null&&(a=s(o)),l):s},l.context=function(f){return arguments.length?(f==null?o=a=null:a=s(o=f),l):o},l}const Y9={draw(e,t){const n=Ns(t/vu);e.moveTo(n,0),e.arc(0,0,n,0,UT)}};function V9(e,t){let n=null,i=pp(r);e=typeof e=="function"?e:Me(e||Y9),t=typeof t=="function"?t:Me(t===void 0?64:+t);function r(){let o;if(n||(n=o=i()),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),o)return n=null,o+""||null}return r.type=function(o){return arguments.length?(e=typeof o=="function"?o:Me(o),r):e},r.size=function(o){return arguments.length?(t=typeof o=="function"?o:Me(+o),r):t},r.context=function(o){return arguments.length?(n=o??null,r):n},r}function jo(){}function Sh(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function mp(e){this._context=e}mp.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Sh(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Sh(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function X9(e){return new mp(e)}function XT(e){this._context=e}XT.prototype={areaStart:jo,areaEnd:jo,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:Sh(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function K9(e){return new XT(e)}function KT(e){this._context=e}KT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,i=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,i):this._context.moveTo(n,i);break;case 3:this._point=4;default:Sh(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function J9(e){return new KT(e)}function JT(e,t){this._basis=new mp(e),this._beta=t}JT.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var e=this._x,t=this._y,n=e.length-1;if(n>0)for(var i=e[0],r=t[0],o=e[n]-i,s=t[n]-r,a=-1,u;++a<=n;)u=a/n,this._basis.point(this._beta*e[a]+(1-this._beta)*(i+u*o),this._beta*t[a]+(1-this._beta)*(r+u*s));this._x=this._y=null,this._basis.lineEnd()},point:function(e,t){this._x.push(+e),this._y.push(+t)}};const Q9=function e(t){function n(i){return t===1?new mp(i):new JT(i,t)}return n.beta=function(i){return e(+i)},n}(.85);function $h(e,t,n){e._context.bezierCurveTo(e._x1+e._k*(e._x2-e._x0),e._y1+e._k*(e._y2-e._y0),e._x2+e._k*(e._x1-t),e._y2+e._k*(e._y1-n),e._x2,e._y2)}function _x(e,t){this._context=e,this._k=(1-t)/6}_x.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:$h(this,this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2,this._x1=e,this._y1=t;break;case 2:this._point=3;default:$h(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const Z9=function e(t){function n(i){return new _x(i,t)}return n.tension=function(i){return e(+i)},n}(0);function Sx(e,t){this._context=e,this._k=(1-t)/6}Sx.prototype={areaStart:jo,areaEnd:jo,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:$h(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const e7=function e(t){function n(i){return new Sx(i,t)}return n.tension=function(i){return e(+i)},n}(0);function $x(e,t){this._context=e,this._k=(1-t)/6}$x.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:$h(this,e,t);break}this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const t7=function e(t){function n(i){return new $x(i,t)}return n.tension=function(i){return e(+i)},n}(0);function kx(e,t,n){var i=e._x1,r=e._y1,o=e._x2,s=e._y2;if(e._l01_a>It){var a=2*e._l01_2a+3*e._l01_a*e._l12_a+e._l12_2a,u=3*e._l01_a*(e._l01_a+e._l12_a);i=(i*a-e._x0*e._l12_2a+e._x2*e._l01_2a)/u,r=(r*a-e._y0*e._l12_2a+e._y2*e._l01_2a)/u}if(e._l23_a>It){var l=2*e._l23_2a+3*e._l23_a*e._l12_a+e._l12_2a,c=3*e._l23_a*(e._l23_a+e._l12_a);o=(o*l+e._x1*e._l23_2a-t*e._l12_2a)/c,s=(s*l+e._y1*e._l23_2a-n*e._l12_2a)/c}e._context.bezierCurveTo(i,r,o,s,e._x2,e._y2)}function QT(e,t){this._context=e,this._alpha=t}QT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3;default:kx(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const n7=function e(t){function n(i){return t?new QT(i,t):new _x(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function ZT(e,t){this._context=e,this._alpha=t}ZT.prototype={areaStart:jo,areaEnd:jo,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x3,this._y3),this._context.closePath();break}case 2:{this._context.lineTo(this._x3,this._y3),this._context.closePath();break}case 3:{this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5);break}}},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=e,this._y3=t;break;case 1:this._point=2,this._context.moveTo(this._x4=e,this._y4=t);break;case 2:this._point=3,this._x5=e,this._y5=t;break;default:kx(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const i7=function e(t){function n(i){return t?new ZT(i,t):new Sx(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function eN(e,t){this._context=e,this._alpha=t}eN.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){if(e=+e,t=+t,this._point){var n=this._x2-e,i=this._y2-t;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(n*n+i*i,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:kx(this,e,t);break}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=e,this._y0=this._y1,this._y1=this._y2,this._y2=t}};const r7=function e(t){function n(i){return t?new eN(i,t):new $x(i,0)}return n.alpha=function(i){return e(+i)},n}(.5);function tN(e){this._context=e}tN.prototype={areaStart:jo,areaEnd:jo,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function o7(e){return new tN(e)}function vS(e){return e<0?-1:1}function xS(e,t,n){var i=e._x1-e._x0,r=t-e._x1,o=(e._y1-e._y0)/(i||r<0&&-0),s=(n-e._y1)/(r||i<0&&-0),a=(o*r+s*i)/(i+r);return(vS(o)+vS(s))*Math.min(Math.abs(o),Math.abs(s),.5*Math.abs(a))||0}function wS(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function h0(e,t,n){var i=e._x0,r=e._y0,o=e._x1,s=e._y1,a=(o-i)/3;e._context.bezierCurveTo(i+a,r+a*t,o-a,s-a*n,o,s)}function kh(e){this._context=e}kh.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:h0(this,this._t0,wS(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,h0(this,wS(this,n=xS(this,e,t)),n);break;default:h0(this,this._t0,n=xS(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function nN(e){this._context=new iN(e)}(nN.prototype=Object.create(kh.prototype)).point=function(e,t){kh.prototype.point.call(this,t,e)};function iN(e){this._context=e}iN.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,i,r,o){this._context.bezierCurveTo(t,e,i,n,o,r)}};function s7(e){return new kh(e)}function a7(e){return new nN(e)}function rN(e){this._context=e}rN.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var i=ES(e),r=ES(t),o=0,s=1;s=0;--t)r[t]=(s[t]-r[t+1])/o[t];for(o[n-1]=(e[n]+r[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}}this._x=e,this._y=t}};function l7(e){return new yp(e,.5)}function c7(e){return new yp(e,0)}function f7(e){return new yp(e,1)}function Lo(e,t){if(typeof document<"u"&&document.createElement){const n=document.createElement("canvas");if(n&&n.getContext)return n.width=e,n.height=t,n}return null}const d7=()=>typeof Image<"u"?Image:null;function hr(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function Zo(e,t){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof t=="function"?this.interpolator(t):this.range(t);break}}return this}const sy=Symbol("implicit");function Ax(){var e=new z_,t=[],n=[],i=sy;function r(o){let s=e.get(o);if(s===void 0){if(i!==sy)return i;e.set(o,s=t.push(o)-1)}return n[s%n.length]}return r.domain=function(o){if(!arguments.length)return t.slice();t=[],e=new z_;for(const s of o)e.has(s)||e.set(s,t.push(s)-1);return r},r.range=function(o){return arguments.length?(n=Array.from(o),r):n.slice()},r.unknown=function(o){return arguments.length?(i=o,r):i},r.copy=function(){return Ax(t,n).unknown(i)},hr.apply(r,arguments),r}function al(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function hf(e,t){var n=Object.create(e.prototype);for(var i in t)n[i]=t[i];return n}function es(){}var Ys=.7,xu=1/Ys,iu="\\s*([+-]?\\d+)\\s*",Lc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ji="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",h7=/^#([0-9a-f]{3,8})$/,g7=new RegExp(`^rgb\\(${iu},${iu},${iu}\\)$`),p7=new RegExp(`^rgb\\(${Ji},${Ji},${Ji}\\)$`),m7=new RegExp(`^rgba\\(${iu},${iu},${iu},${Lc}\\)$`),y7=new RegExp(`^rgba\\(${Ji},${Ji},${Ji},${Lc}\\)$`),b7=new RegExp(`^hsl\\(${Lc},${Ji},${Ji}\\)$`),v7=new RegExp(`^hsla\\(${Lc},${Ji},${Ji},${Lc}\\)$`),_S={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};al(es,Pc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:SS,formatHex:SS,formatHex8:x7,formatHsl:w7,formatRgb:$S,toString:$S});function SS(){return this.rgb().formatHex()}function x7(){return this.rgb().formatHex8()}function w7(){return oN(this).formatHsl()}function $S(){return this.rgb().formatRgb()}function Pc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=h7.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?kS(t):n===3?new yt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?sd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?sd(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=g7.exec(e))?new yt(t[1],t[2],t[3],1):(t=p7.exec(e))?new yt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=m7.exec(e))?sd(t[1],t[2],t[3],t[4]):(t=y7.exec(e))?sd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=b7.exec(e))?FS(t[1],t[2]/100,t[3]/100,1):(t=v7.exec(e))?FS(t[1],t[2]/100,t[3]/100,t[4]):_S.hasOwnProperty(e)?kS(_S[e]):e==="transparent"?new yt(NaN,NaN,NaN,0):null}function kS(e){return new yt(e>>16&255,e>>8&255,e&255,1)}function sd(e,t,n,i){return i<=0&&(e=t=n=NaN),new yt(e,t,n,i)}function Cx(e){return e instanceof es||(e=Pc(e)),e?(e=e.rgb(),new yt(e.r,e.g,e.b,e.opacity)):new yt}function qo(e,t,n,i){return arguments.length===1?Cx(e):new yt(e,t,n,i??1)}function yt(e,t,n,i){this.r=+e,this.g=+t,this.b=+n,this.opacity=+i}al(yt,qo,hf(es,{brighter(e){return e=e==null?xu:Math.pow(xu,e),new yt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ys:Math.pow(Ys,e),new yt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yt(Ps(this.r),Ps(this.g),Ps(this.b),Ah(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:AS,formatHex:AS,formatHex8:E7,formatRgb:CS,toString:CS}));function AS(){return`#${Rs(this.r)}${Rs(this.g)}${Rs(this.b)}`}function E7(){return`#${Rs(this.r)}${Rs(this.g)}${Rs(this.b)}${Rs((isNaN(this.opacity)?1:this.opacity)*255)}`}function CS(){const e=Ah(this.opacity);return`${e===1?"rgb(":"rgba("}${Ps(this.r)}, ${Ps(this.g)}, ${Ps(this.b)}${e===1?")":`, ${e})`}`}function Ah(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ps(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Rs(e){return e=Ps(e),(e<16?"0":"")+e.toString(16)}function FS(e,t,n,i){return i<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new yi(e,t,n,i)}function oN(e){if(e instanceof yi)return new yi(e.h,e.s,e.l,e.opacity);if(e instanceof es||(e=Pc(e)),!e)return new yi;if(e instanceof yi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,i=e.b/255,r=Math.min(t,n,i),o=Math.max(t,n,i),s=NaN,a=o-r,u=(o+r)/2;return a?(t===o?s=(n-i)/a+(n0&&u<1?0:s,new yi(s,a,u,e.opacity)}function Ch(e,t,n,i){return arguments.length===1?oN(e):new yi(e,t,n,i??1)}function yi(e,t,n,i){this.h=+e,this.s=+t,this.l=+n,this.opacity=+i}al(yi,Ch,hf(es,{brighter(e){return e=e==null?xu:Math.pow(xu,e),new yi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ys:Math.pow(Ys,e),new yi(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*t,r=2*n-i;return new yt(g0(e>=240?e-240:e+120,r,i),g0(e,r,i),g0(e<120?e+240:e-120,r,i),this.opacity)},clamp(){return new yi(MS(this.h),ad(this.s),ad(this.l),Ah(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ah(this.opacity);return`${e===1?"hsl(":"hsla("}${MS(this.h)}, ${ad(this.s)*100}%, ${ad(this.l)*100}%${e===1?")":`, ${e})`}`}}));function MS(e){return e=(e||0)%360,e<0?e+360:e}function ad(e){return Math.max(0,Math.min(1,e||0))}function g0(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const sN=Math.PI/180,aN=180/Math.PI,Fh=18,uN=.96422,lN=1,cN=.82521,fN=4/29,ru=6/29,dN=3*ru*ru,_7=ru*ru*ru;function hN(e){if(e instanceof Qi)return new Qi(e.l,e.a,e.b,e.opacity);if(e instanceof Ir)return gN(e);e instanceof yt||(e=Cx(e));var t=b0(e.r),n=b0(e.g),i=b0(e.b),r=p0((.2225045*t+.7168786*n+.0606169*i)/lN),o,s;return t===n&&n===i?o=s=r:(o=p0((.4360747*t+.3850649*n+.1430804*i)/uN),s=p0((.0139322*t+.0971045*n+.7141733*i)/cN)),new Qi(116*r-16,500*(o-r),200*(r-s),e.opacity)}function Mh(e,t,n,i){return arguments.length===1?hN(e):new Qi(e,t,n,i??1)}function Qi(e,t,n,i){this.l=+e,this.a=+t,this.b=+n,this.opacity=+i}al(Qi,Mh,hf(es,{brighter(e){return new Qi(this.l+Fh*(e??1),this.a,this.b,this.opacity)},darker(e){return new Qi(this.l-Fh*(e??1),this.a,this.b,this.opacity)},rgb(){var e=(this.l+16)/116,t=isNaN(this.a)?e:e+this.a/500,n=isNaN(this.b)?e:e-this.b/200;return t=uN*m0(t),e=lN*m0(e),n=cN*m0(n),new yt(y0(3.1338561*t-1.6168667*e-.4906146*n),y0(-.9787684*t+1.9161415*e+.033454*n),y0(.0719453*t-.2289914*e+1.4052427*n),this.opacity)}}));function p0(e){return e>_7?Math.pow(e,1/3):e/dN+fN}function m0(e){return e>ru?e*e*e:dN*(e-fN)}function y0(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function b0(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function S7(e){if(e instanceof Ir)return new Ir(e.h,e.c,e.l,e.opacity);if(e instanceof Qi||(e=hN(e)),e.a===0&&e.b===0)return new Ir(NaN,0=1?(n=1,t-1):Math.floor(n*t),r=e[i],o=e[i+1],s=i>0?e[i-1]:2*r-o,a=i()=>e;function vN(e,t){return function(n){return e+n*t}}function k7(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(i){return Math.pow(e+i*t,n)}}function xp(e,t){var n=t-e;return n?vN(e,n>180||n<-180?n-360*Math.round(n/360):n):vp(isNaN(e)?t:e)}function A7(e){return(e=+e)==1?bt:function(t,n){return n-t?k7(t,n,e):vp(isNaN(t)?n:t)}}function bt(e,t){var n=t-e;return n?vN(e,n):vp(isNaN(e)?t:e)}const uy=function e(t){var n=A7(t);function i(r,o){var s=n((r=qo(r)).r,(o=qo(o)).r),a=n(r.g,o.g),u=n(r.b,o.b),l=bt(r.opacity,o.opacity);return function(c){return r.r=s(c),r.g=a(c),r.b=u(c),r.opacity=l(c),r+""}}return i.gamma=e,i}(1);function xN(e){return function(t){var n=t.length,i=new Array(n),r=new Array(n),o=new Array(n),s,a;for(s=0;sn&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(i=i[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,u.push({i:s,x:pi(i,r)})),n=v0.lastIndex;return n180?c+=360:c-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,i)-2,x:pi(l,c)})):c&&f.push(r(f)+"rotate("+c+i)}function a(l,c,f,d){l!==c?d.push({i:f.push(r(f)+"skewX(",null,i)-2,x:pi(l,c)}):c&&f.push(r(f)+"skewX("+c+i)}function u(l,c,f,d,h,g){if(l!==f||c!==d){var p=h.push(r(h)+"scale(",null,",",null,")");g.push({i:p-4,x:pi(l,f)},{i:p-2,x:pi(c,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(l,c){var f=[],d=[];return l=e(l),c=e(c),o(l.translateX,l.translateY,c.translateX,c.translateY,f,d),s(l.rotate,c.rotate,f,d),a(l.skewX,c.skewX,f,d),u(l.scaleX,l.scaleY,c.scaleX,c.scaleY,f,d),l=c=null,function(h){for(var g=-1,p=d.length,m;++gt&&(n=e,e=t,t=n),function(i){return Math.max(e,Math.min(t,i))}}function eB(e,t,n){var i=e[0],r=e[1],o=t[0],s=t[1];return r2?tB:eB,u=l=null,f}function f(d){return d==null||isNaN(d=+d)?o:(u||(u=a(e.map(i),t,n)))(i(s(d)))}return f.invert=function(d){return s(r((l||(l=a(t,e.map(i),pi)))(d)))},f.domain=function(d){return arguments.length?(e=Array.from(d,fy),c()):e.slice()},f.range=function(d){return arguments.length?(t=Array.from(d),c()):t.slice()},f.rangeRound=function(d){return t=Array.from(d),n=gf,c()},f.clamp=function(d){return arguments.length?(s=d?!0:yn,c()):s!==yn},f.interpolate=function(d){return arguments.length?(n=d,c()):n},f.unknown=function(d){return arguments.length?(o=d,f):o},function(d,h){return i=d,r=h,c()}}function TN(){return wp()(yn,yn)}function NN(e,t,n,i){var r=Bo(e,t,n),o;switch(i=Gs(i??",f"),i.type){case"s":{var s=Math.max(Math.abs(e),Math.abs(t));return i.precision==null&&!isNaN(o=rM(r,s))&&(i.precision=o),vv(i,s)}case"":case"e":case"g":case"p":case"r":{i.precision==null&&!isNaN(o=oM(r,Math.max(Math.abs(e),Math.abs(t))))&&(i.precision=o-(i.type==="e"));break}case"f":case"%":{i.precision==null&&!isNaN(o=iM(r))&&(i.precision=o-(i.type==="%")*2);break}}return Kg(i)}function xa(e){var t=e.domain;return e.ticks=function(n){var i=t();return W1(i[0],i[i.length-1],n??10)},e.tickFormat=function(n,i){var r=t();return NN(r[0],r[r.length-1],n??10,i)},e.nice=function(n){n==null&&(n=10);var i=t(),r=0,o=i.length-1,s=i[r],a=i[o],u,l,c=10;for(a0;){if(l=H1(s,a,n),l===u)return i[r]=s,i[o]=a,t(i);if(l>0)s=Math.floor(s/l)*l,a=Math.ceil(a/l)*l;else if(l<0)s=Math.ceil(s*l)/l,a=Math.floor(a*l)/l;else break;u=l}return e},e}function RN(){var e=TN();return e.copy=function(){return pf(e,RN())},hr.apply(e,arguments),xa(e)}function ON(e){var t;function n(i){return i==null||isNaN(i=+i)?t:i}return n.invert=n,n.domain=n.range=function(i){return arguments.length?(e=Array.from(i,fy),n):e.slice()},n.unknown=function(i){return arguments.length?(t=i,n):t},n.copy=function(){return ON(e).unknown(t)},e=arguments.length?Array.from(e,fy):[0,1],xa(n)}function DN(e,t){e=e.slice();var n=0,i=e.length-1,r=e[n],o=e[i],s;return oMath.pow(e,t)}function sB(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function zS(e){return(t,n)=>-e(-t,n)}function Rx(e){const t=e(PS,IS),n=t.domain;let i=10,r,o;function s(){return r=sB(i),o=oB(i),n()[0]<0?(r=zS(r),o=zS(o),e(nB,iB)):e(PS,IS),t}return t.base=function(a){return arguments.length?(i=+a,s()):i},t.domain=function(a){return arguments.length?(n(a),s()):n()},t.ticks=a=>{const u=n();let l=u[0],c=u[u.length-1];const f=c0){for(;d<=h;++d)for(g=1;gc)break;y.push(p)}}else for(;d<=h;++d)for(g=i-1;g>=1;--g)if(p=d>0?g/o(-d):g*o(d),!(pc)break;y.push(p)}y.length*2{if(a==null&&(a=10),u==null&&(u=i===10?"s":","),typeof u!="function"&&(!(i%1)&&(u=Gs(u)).precision==null&&(u.trim=!0),u=Kg(u)),a===1/0)return u;const l=Math.max(1,i*a/t.ticks().length);return c=>{let f=c/o(Math.round(r(c)));return f*in(DN(n(),{floor:a=>o(Math.floor(r(a))),ceil:a=>o(Math.ceil(r(a)))})),t}function LN(){const e=Rx(wp()).domain([1,10]);return e.copy=()=>pf(e,LN()).base(e.base()),hr.apply(e,arguments),e}function BS(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function US(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function Ox(e){var t=1,n=e(BS(t),US(t));return n.constant=function(i){return arguments.length?e(BS(t=+i),US(t)):t},xa(n)}function PN(){var e=Ox(wp());return e.copy=function(){return pf(e,PN()).constant(e.constant())},hr.apply(e,arguments)}function jS(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function aB(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function uB(e){return e<0?-e*e:e*e}function Dx(e){var t=e(yn,yn),n=1;function i(){return n===1?e(yn,yn):n===.5?e(aB,uB):e(jS(n),jS(1/n))}return t.exponent=function(r){return arguments.length?(n=+r,i()):n},xa(t)}function Lx(){var e=Dx(wp());return e.copy=function(){return pf(e,Lx()).exponent(e.exponent())},hr.apply(e,arguments),e}function lB(){return Lx.apply(null,arguments).exponent(.5)}function IN(){var e=[],t=[],n=[],i;function r(){var s=0,a=Math.max(1,t.length);for(n=new Array(a-1);++s0?n[a-1]:e[0],a=n?[i[n-1],t]:[i[l-1],i[l]]},s.unknown=function(u){return arguments.length&&(o=u),s},s.thresholds=function(){return i.slice()},s.copy=function(){return zN().domain([e,t]).range(r).unknown(o)},hr.apply(xa(s),arguments)}function BN(){var e=[.5],t=[0,1],n,i=1;function r(o){return o!=null&&o<=o?t[zo(e,o,0,i)]:n}return r.domain=function(o){return arguments.length?(e=Array.from(o),i=Math.min(e.length,t.length-1),r):e.slice()},r.range=function(o){return arguments.length?(t=Array.from(o),i=Math.min(e.length,t.length-1),r):t.slice()},r.invertExtent=function(o){var s=t.indexOf(o);return[e[s-1],e[s]]},r.unknown=function(o){return arguments.length?(n=o,r):n},r.copy=function(){return BN().domain(e).range(t).unknown(n)},hr.apply(r,arguments)}function cB(e){return new Date(e)}function fB(e){return e instanceof Date?+e:+new Date(+e)}function Px(e,t,n,i,r,o,s,a,u,l){var c=TN(),f=c.invert,d=c.domain,h=l(".%L"),g=l(":%S"),p=l("%I:%M"),m=l("%I %p"),y=l("%a %d"),b=l("%b %d"),v=l("%B"),x=l("%Y");function E(_){return(u(_)<_?h:a(_)<_?g:s(_)<_?p:o(_)<_?m:i(_)<_?r(_)<_?y:b:n(_)<_?v:x)(_)}return c.invert=function(_){return new Date(f(_))},c.domain=function(_){return arguments.length?d(Array.from(_,fB)):d().map(cB)},c.ticks=function(_){var w=d();return e(w[0],w[w.length-1],_??10)},c.tickFormat=function(_,w){return w==null?E:l(w)},c.nice=function(_){var w=d();return(!_||typeof _.range!="function")&&(_=t(w[0],w[w.length-1],_??10)),_?d(DN(w,_)):c},c.copy=function(){return pf(c,Px(e,t,n,i,r,o,s,a,u,l))},c}function dB(){return hr.apply(Px(v4,x4,rr,Tc,nl,jr,Zg,Jg,Pr,Sv).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function hB(){return hr.apply(Px(y4,b4,or,Nc,il,Oo,ep,Qg,Pr,$v).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Ep(){var e=0,t=1,n,i,r,o,s=yn,a=!1,u;function l(f){return f==null||isNaN(f=+f)?u:s(r===0?.5:(f=(o(f)-n)*r,a?Math.max(0,Math.min(1,f)):f))}l.domain=function(f){return arguments.length?([e,t]=f,n=o(e=+e),i=o(t=+t),r=n===i?0:1/(i-n),l):[e,t]},l.clamp=function(f){return arguments.length?(a=!!f,l):a},l.interpolator=function(f){return arguments.length?(s=f,l):s};function c(f){return function(d){var h,g;return arguments.length?([h,g]=d,s=f(h,g),l):[s(0),s(1)]}}return l.range=c(ts),l.rangeRound=c(gf),l.unknown=function(f){return arguments.length?(u=f,l):u},function(f){return o=f,n=f(e),i=f(t),r=n===i?0:1/(i-n),l}}function ns(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function Ix(){var e=xa(Ep()(yn));return e.copy=function(){return ns(e,Ix())},Zo.apply(e,arguments)}function UN(){var e=Rx(Ep()).domain([1,10]);return e.copy=function(){return ns(e,UN()).base(e.base())},Zo.apply(e,arguments)}function jN(){var e=Ox(Ep());return e.copy=function(){return ns(e,jN()).constant(e.constant())},Zo.apply(e,arguments)}function zx(){var e=Dx(Ep());return e.copy=function(){return ns(e,zx()).exponent(e.exponent())},Zo.apply(e,arguments)}function gB(){return zx.apply(null,arguments).exponent(.5)}function _p(){var e=0,t=.5,n=1,i=1,r,o,s,a,u,l=yn,c,f=!1,d;function h(p){return isNaN(p=+p)?d:(p=.5+((p=+c(p))-o)*(i*p0?i:1:0}const kB="identity",wu="linear",Kr="log",mf="pow",yf="sqrt",Sp="symlog",Vs="time",Xs="utc",Zi="sequential",ul="diverging",Eu="quantile",$p="quantize",kp="threshold",jx="ordinal",hy="point",GN="band",qx="bin-ordinal",gt="continuous",bf="discrete",vf="discretizing",ai="interpolating",Wx="temporal";function AB(e){return function(t){let n=t[0],i=t[1],r;return i=i&&n[u]<=r&&(o<0&&(o=u),s=u);if(!(o<0))return i=e.invertExtent(n[o]),r=e.invertExtent(n[s]),[i[0]===void 0?i[1]:i[0],r[1]===void 0?r[0]:r[1]]}}function Hx(){const e=Ax().unknown(void 0),t=e.domain,n=e.range;let i=[0,1],r,o,s=!1,a=0,u=0,l=.5;delete e.unknown;function c(){const f=t().length,d=i[1]p+r*y);return n(d?m.reverse():m)}return e.domain=function(f){return arguments.length?(t(f),c()):t()},e.range=function(f){return arguments.length?(i=[+f[0],+f[1]],c()):i.slice()},e.rangeRound=function(f){return i=[+f[0],+f[1]],s=!0,c()},e.bandwidth=function(){return o},e.step=function(){return r},e.round=function(f){return arguments.length?(s=!!f,c()):s},e.padding=function(f){return arguments.length?(u=Math.max(0,Math.min(1,f)),a=u,c()):a},e.paddingInner=function(f){return arguments.length?(a=Math.max(0,Math.min(1,f)),c()):a},e.paddingOuter=function(f){return arguments.length?(u=Math.max(0,Math.min(1,f)),c()):u},e.align=function(f){return arguments.length?(l=Math.max(0,Math.min(1,f)),c()):l},e.invertRange=function(f){if(f[0]==null||f[1]==null)return;const d=i[1]i[1-d])))return y=Math.max(0,zo(h,p)-1),b=p===m?y:zo(h,m)-1,p-h[y]>o+1e-10&&++y,d&&(v=y,y=g-b,b=g-v),y>b?void 0:t().slice(y,b+1)},e.invert=function(f){const d=e.invertRange([f,f]);return d&&d[0]},e.copy=function(){return Hx().domain(t()).range(i).round(s).paddingInner(a).paddingOuter(u).align(l)},c()}function YN(e){const t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return YN(t())},e}function FB(){return YN(Hx().paddingInner(1))}var MB=Array.prototype.map;function TB(e){return MB.call(e,nn)}const NB=Array.prototype.slice;function VN(){let e=[],t=[];function n(i){return i==null||i!==i?void 0:t[(zo(e,i)-1)%t.length]}return n.domain=function(i){return arguments.length?(e=TB(i),n):e.slice()},n.range=function(i){return arguments.length?(t=NB.call(i),n):t.slice()},n.tickFormat=function(i,r){return NN(e[0],_e(e),i??10,r)},n.copy=function(){return VN().domain(n.domain()).range(n.range())},n}const Nh=new Map,XN=Symbol("vega_scale");function KN(e){return e[XN]=!0,e}function qS(e){return e&&e[XN]===!0}function RB(e,t,n){const i=function(){const o=t();return o.invertRange||(o.invertRange=o.invert?AB(o):o.invertExtent?CB(o):void 0),o.type=e,KN(o)};return i.metadata=$i(Q(n)),i}function Ce(e,t,n){return arguments.length>1?(Nh.set(e,RB(e,t,n)),this):JN(e)?Nh.get(e):void 0}Ce(kB,ON);Ce(wu,RN,gt);Ce(Kr,LN,[gt,Kr]);Ce(mf,Lx,gt);Ce(yf,lB,gt);Ce(Sp,PN,gt);Ce(Vs,dB,[gt,Wx]);Ce(Xs,hB,[gt,Wx]);Ce(Zi,Ix,[gt,ai]);Ce(`${Zi}-${wu}`,Ix,[gt,ai]);Ce(`${Zi}-${Kr}`,UN,[gt,ai,Kr]);Ce(`${Zi}-${mf}`,zx,[gt,ai]);Ce(`${Zi}-${yf}`,gB,[gt,ai]);Ce(`${Zi}-${Sp}`,jN,[gt,ai]);Ce(`${ul}-${wu}`,qN,[gt,ai]);Ce(`${ul}-${Kr}`,WN,[gt,ai,Kr]);Ce(`${ul}-${mf}`,Bx,[gt,ai]);Ce(`${ul}-${yf}`,pB,[gt,ai]);Ce(`${ul}-${Sp}`,HN,[gt,ai]);Ce(Eu,IN,[vf,Eu]);Ce($p,zN,vf);Ce(kp,BN,vf);Ce(qx,VN,[bf,vf]);Ce(jx,Ax,bf);Ce(GN,Hx,bf);Ce(hy,FB,bf);function JN(e){return Nh.has(e)}function wa(e,t){const n=Nh.get(e);return n&&n.metadata[t]}function Gx(e){return wa(e,gt)}function _u(e){return wa(e,bf)}function gy(e){return wa(e,vf)}function QN(e){return wa(e,Kr)}function OB(e){return wa(e,Wx)}function ZN(e){return wa(e,ai)}function e3(e){return wa(e,Eu)}const DB=["clamp","base","constant","exponent"];function t3(e,t){const n=t[0],i=_e(t)-n;return function(r){return e(n+r*i)}}function Ap(e,t,n){return Nx(Yx(t||"rgb",n),e)}function n3(e,t){const n=new Array(t),i=t+1;for(let r=0;re[a]?s[a](e[a]()):0),s)}function Yx(e,t){const n=J7[LB(e)];return t!=null&&n&&n.gamma?n.gamma(t):n}function LB(e){return"interpolate"+e.toLowerCase().split("-").map(t=>t[0].toUpperCase()+t.slice(1)).join("")}const PB={blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",cividis:"00205100235800265d002961012b65042e670831690d346b11366c16396d1c3c6e213f6e26426e2c456e31476e374a6e3c4d6e42506e47536d4c566d51586e555b6e5a5e6e5e616e62646f66676f6a6a706e6d717270717573727976737c79747f7c75827f758682768985778c8877908b78938e789691789a94789e9778a19b78a59e77a9a177aea575b2a874b6ab73bbaf71c0b26fc5b66dc9b96acebd68d3c065d8c462ddc85fe2cb5ce7cf58ebd355f0d652f3da4ff7de4cfae249fce647",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",turbo:"23171b32204a3e2a71453493493eae4b49c54a53d7485ee44569ee4074f53c7ff8378af93295f72e9ff42ba9ef28b3e926bce125c5d925cdcf27d5c629dcbc2de3b232e9a738ee9d3ff39347f68950f9805afc7765fd6e70fe667cfd5e88fc5795fb51a1f84badf545b9f140c5ec3cd0e637dae034e4d931ecd12ef4c92bfac029ffb626ffad24ffa223ff9821ff8d1fff821dff771cfd6c1af76118f05616e84b14df4111d5380fcb2f0dc0260ab61f07ac1805a313029b0f00950c00910b00",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},IB={accent:yB,category10:mB,category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",dark2:bB,observable10:vB,paired:xB,pastel1:wB,pastel2:EB,set1:_B,set2:SB,set3:$B,tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5"};function r3(e){if(P(e))return e;const t=e.length/6|0,n=new Array(t);for(let i=0;iAp(r3(e)));function Vx(e,t){return e=e&&e.toLowerCase(),arguments.length>1?(WS[e]=t,this):WS[e]}const Wd="symbol",zB="discrete",BB="gradient",UB=e=>P(e)?e.map(t=>String(t)):String(e),jB=(e,t)=>e[1]-t[1],qB=(e,t)=>t[1]-e[1];function Xx(e,t,n){let i;return ke(t)&&(e.bins&&(t=Math.max(t,e.bins.length)),n!=null&&(t=Math.min(t,Math.floor(lf(e.domain())/n||1)+1))),K(t)&&(i=t.step,t=t.interval),J(t)&&(t=e.type===Vs?rl(t):e.type==Xs?ol(t):O("Only time and utc scales accept interval strings."),i&&(t=t.every(i))),t}function s3(e,t,n){let i=e.range(),r=i[0],o=_e(i),s=jB;if(r>o&&(i=o,o=r,r=i,s=qB),r=Math.floor(r),o=Math.ceil(o),t=t.map(a=>[a,e(a)]).filter(a=>r<=a[1]&&a[1]<=o).sort(s).map(a=>a[0]),n>0&&t.length>1){const a=[t[0],_e(t)];for(;t.length>n&&t.length>=3;)t=t.filter((u,l)=>!(l%2));t.length<3&&(t=a)}return t}function Kx(e,t){return e.bins?s3(e,e.bins,t):e.ticks?e.ticks(t):e.domain()}function a3(e,t,n,i,r,o){const s=t.type;let a=UB;if(s===Vs||r===Vs)a=e.timeFormat(i);else if(s===Xs||r===Xs)a=e.utcFormat(i);else if(QN(s)){const u=e.formatFloat(i);if(o||t.bins)a=u;else{const l=u3(t,n,!1);a=c=>l(c)?u(c):""}}else if(t.tickFormat){const u=t.domain();a=e.formatSpan(u[0],u[u.length-1],n,i)}else i&&(a=e.format(i));return a}function u3(e,t,n){const i=Kx(e,t),r=e.base(),o=Math.log(r),s=Math.max(1,r*t/i.length),a=u=>{let l=u/Math.pow(r,Math.round(Math.log(u)/o));return l*r1?i[1]-i[0]:i[0],s;for(s=1;spy[e.type]||e.bins;function f3(e,t,n,i,r,o,s){const a=l3[t.type]&&o!==Vs&&o!==Xs?WB(e,t,r):a3(e,t,n,r,o,s);return i===Wd&&YB(t)?VB(a):i===zB?XB(a):KB(a)}const VB=e=>(t,n,i)=>{const r=HS(i[n+1],HS(i.max,1/0)),o=GS(t,e),s=GS(r,e);return o&&s?o+" – "+s:s?"< "+s:"≥ "+o},HS=(e,t)=>e??t,XB=e=>(t,n)=>n?e(t):null,KB=e=>t=>e(t),GS=(e,t)=>Number.isFinite(e)?t(e):null;function JB(e){const t=e.domain(),n=t.length-1;let i=+t[0],r=+_e(t),o=r-i;if(e.type===kp){const s=n?o/n:.1;i-=s,r+=s,o=r-i}return s=>(s-i)/o}function QB(e,t,n,i){const r=i||t.type;return J(n)&&OB(r)&&(n=n.replace(/%a/g,"%A").replace(/%b/g,"%B")),!n&&r===Vs?e.timeFormat("%A, %d %B %Y, %X"):!n&&r===Xs?e.utcFormat("%A, %d %B %Y, %X UTC"):f3(e,t,5,null,n,i,!0)}function d3(e,t,n){n=n||{};const i=Math.max(3,n.maxlen||7),r=QB(e,t,n.format,n.formatType);if(gy(t.type)){const o=c3(t).slice(1).map(r),s=o.length;return`${s} boundar${s===1?"y":"ies"}: ${o.join(", ")}`}else if(_u(t.type)){const o=t.domain(),s=o.length,a=s>i?o.slice(0,i-2).map(r).join(", ")+", ending with "+o.slice(-1).map(r):o.map(r).join(", ");return`${s} value${s===1?"":"s"}: ${a}`}else{const o=t.domain();return`values from ${r(o[0])} to ${r(_e(o))}`}}let h3=0;function ZB(){h3=0}const Rh="p_";function Jx(e){return e&&e.gradient}function g3(e,t,n){const i=e.gradient;let r=e.id,o=i==="radial"?Rh:"";return r||(r=e.id="gradient_"+h3++,i==="radial"?(e.x1=Ui(e.x1,.5),e.y1=Ui(e.y1,.5),e.r1=Ui(e.r1,0),e.x2=Ui(e.x2,.5),e.y2=Ui(e.y2,.5),e.r2=Ui(e.r2,.5),o=Rh):(e.x1=Ui(e.x1,0),e.y1=Ui(e.y1,0),e.x2=Ui(e.x2,1),e.y2=Ui(e.y2,0))),t[r]=e,"url("+(n||"")+"#"+o+r+")"}function Ui(e,t){return e??t}function p3(e,t){var n=[],i;return i={gradient:"linear",x1:e?e[0]:0,y1:e?e[1]:0,x2:t?t[0]:1,y2:t?t[1]:0,stops:n,stop:function(r,o){return n.push({offset:r,color:o}),i}}}const YS={basis:{curve:X9},"basis-closed":{curve:K9},"basis-open":{curve:J9},bundle:{curve:Q9,tension:"beta",value:.85},cardinal:{curve:Z9,tension:"tension",value:0},"cardinal-open":{curve:t7,tension:"tension",value:0},"cardinal-closed":{curve:e7,tension:"tension",value:0},"catmull-rom":{curve:n7,tension:"alpha",value:.5},"catmull-rom-closed":{curve:i7,tension:"alpha",value:.5},"catmull-rom-open":{curve:r7,tension:"alpha",value:.5},linear:{curve:Ex},"linear-closed":{curve:o7},monotone:{horizontal:a7,vertical:s7},natural:{curve:u7},step:{curve:l7},"step-after":{curve:f7},"step-before":{curve:c7}};function Qx(e,t,n){var i=Z(YS,e)&&YS[e],r=null;return i&&(r=i.curve||i[t||"vertical"],i.tension&&n!=null&&(r=r[i.tension](n))),r}const eU={m:2,l:2,h:1,v:1,z:0,c:6,s:4,q:4,t:2,a:7},tU=/[mlhvzcsqta]([^mlhvzcsqta]+|$)/gi,nU=/^[+-]?(([0-9]*\.[0-9]+)|([0-9]+\.)|([0-9]+))([eE][+-]?[0-9]+)?/,iU=/^((\s+,?\s*)|(,\s*))/,rU=/^[01]/;function Su(e){const t=[];return(e.match(tU)||[]).forEach(i=>{let r=i[0];const o=r.toLowerCase(),s=eU[o],a=oU(o,s,i.slice(1).trim()),u=a.length;if(u1&&(p=Math.sqrt(p),n*=p,i*=p);const m=d/n,y=f/n,b=-f/i,v=d/i,x=m*a+y*u,E=b*a+v*u,_=m*e+y*t,w=b*e+v*t;let $=1/((_-x)*(_-x)+(w-E)*(w-E))-.25;$<0&&($=0);let A=Math.sqrt($);o==r&&(A=-A);const F=.5*(x+_)-A*(w-E),T=.5*(E+w)+A*(_-x),N=Math.atan2(E-T,x-F);let k=Math.atan2(w-T,_-F)-N;k<0&&o===1?k+=Yi:k>0&&o===0&&(k-=Yi);const M=Math.ceil(Math.abs(k/(Cs+.001))),D=[];for(let B=0;B+e}function ld(e,t,n){return Math.max(t,Math.min(e,n))}function b3(){var e=fU,t=dU,n=hU,i=gU,r=kr(0),o=r,s=r,a=r,u=null;function l(c,f,d){var h,g=f??+e.call(this,c),p=d??+t.call(this,c),m=+n.call(this,c),y=+i.call(this,c),b=Math.min(m,y)/2,v=ld(+r.call(this,c),0,b),x=ld(+o.call(this,c),0,b),E=ld(+s.call(this,c),0,b),_=ld(+a.call(this,c),0,b);if(u||(u=h=gp()),v<=0&&x<=0&&E<=0&&_<=0)u.rect(g,p,m,y);else{var w=g+m,S=p+y;u.moveTo(g+v,p),u.lineTo(w-x,p),u.bezierCurveTo(w-go*x,p,w,p+go*x,w,p+x),u.lineTo(w,S-_),u.bezierCurveTo(w,S-go*_,w-go*_,S,w-_,S),u.lineTo(g+E,S),u.bezierCurveTo(g+go*E,S,g,S-go*E,g,S-E),u.lineTo(g,p+v),u.bezierCurveTo(g,p+go*v,g+go*v,p,g+v,p),u.closePath()}if(h)return u=null,h+""||null}return l.x=function(c){return arguments.length?(e=kr(c),l):e},l.y=function(c){return arguments.length?(t=kr(c),l):t},l.width=function(c){return arguments.length?(n=kr(c),l):n},l.height=function(c){return arguments.length?(i=kr(c),l):i},l.cornerRadius=function(c,f,d,h){return arguments.length?(r=kr(c),o=f!=null?kr(f):r,a=d!=null?kr(d):r,s=h!=null?kr(h):o,l):r},l.context=function(c){return arguments.length?(u=c??null,l):u},l}function v3(){var e,t,n,i,r=null,o,s,a,u;function l(f,d,h){const g=h/2;if(o){var p=a-d,m=f-s;if(p||m){var y=Math.hypot(p,m),b=(p/=y)*u,v=(m/=y)*u,x=Math.atan2(m,p);r.moveTo(s-b,a-v),r.lineTo(f-p*g,d-m*g),r.arc(f,d,g,x-Math.PI,x),r.lineTo(s+b,a+v),r.arc(s,a,u,x,x+Math.PI)}else r.arc(f,d,g,0,Yi);r.closePath()}else o=1;s=f,a=d,u=g}function c(f){var d,h=f.length,g,p=!1,m;for(r==null&&(r=m=gp()),d=0;d<=h;++d)!(de.x||0,Ef=e=>e.y||0,pU=e=>e.width||0,mU=e=>e.height||0,yU=e=>(e.x||0)+(e.width||0),bU=e=>(e.y||0)+(e.height||0),vU=e=>e.startAngle||0,xU=e=>e.endAngle||0,wU=e=>e.padAngle||0,EU=e=>e.innerRadius||0,_U=e=>e.outerRadius||0,SU=e=>e.cornerRadius||0,$U=e=>xf(e.cornerRadiusTopLeft,e.cornerRadius)||0,kU=e=>xf(e.cornerRadiusTopRight,e.cornerRadius)||0,AU=e=>xf(e.cornerRadiusBottomRight,e.cornerRadius)||0,CU=e=>xf(e.cornerRadiusBottomLeft,e.cornerRadius)||0,FU=e=>xf(e.size,64),MU=e=>e.size||1,Cp=e=>e.defined!==!1,TU=e=>y3(e.shape||"circle"),NU=G9().startAngle(vU).endAngle(xU).padAngle(wU).innerRadius(EU).outerRadius(_U).cornerRadius(SU),RU=VT().x(wf).y1(Ef).y0(bU).defined(Cp),OU=VT().y(Ef).x1(wf).x0(yU).defined(Cp),DU=YT().x(wf).y(Ef).defined(Cp),LU=b3().x(wf).y(Ef).width(pU).height(mU).cornerRadius($U,kU,AU,CU),PU=V9().type(TU).size(FU),IU=v3().x(wf).y(Ef).defined(Cp).size(MU);function Zx(e){return e.cornerRadius||e.cornerRadiusTopLeft||e.cornerRadiusTopRight||e.cornerRadiusBottomRight||e.cornerRadiusBottomLeft}function zU(e,t){return NU.context(e)(t)}function BU(e,t){const n=t[0],i=n.interpolate||"linear";return(n.orient==="horizontal"?OU:RU).curve(Qx(i,n.orient,n.tension)).context(e)(t)}function UU(e,t){const n=t[0],i=n.interpolate||"linear";return DU.curve(Qx(i,n.orient,n.tension)).context(e)(t)}function ll(e,t,n,i){return LU.context(e)(t,n,i)}function jU(e,t){return(t.mark.shape||t.shape).context(e)(t)}function qU(e,t){return PU.context(e)(t)}function WU(e,t){return IU.context(e)(t)}var x3=1;function HU(){x3=1}function e2(e,t,n){var i=t.clip,r=e._defs,o=t.clip_id||(t.clip_id="clip"+x3++),s=r.clipping[o]||(r.clipping[o]={id:o});return de(i)?s.path=i(null):Zx(n)?s.path=ll(null,n,0,0):(s.width=n.width||0,s.height=n.height||0),"url(#"+o+")"}function st(e){this.clear(),e&&this.union(e)}st.prototype={clone(){return new st(this)},clear(){return this.x1=+Number.MAX_VALUE,this.y1=+Number.MAX_VALUE,this.x2=-Number.MAX_VALUE,this.y2=-Number.MAX_VALUE,this},empty(){return this.x1===+Number.MAX_VALUE&&this.y1===+Number.MAX_VALUE&&this.x2===-Number.MAX_VALUE&&this.y2===-Number.MAX_VALUE},equals(e){return this.x1===e.x1&&this.y1===e.y1&&this.x2===e.x2&&this.y2===e.y2},set(e,t,n,i){return nthis.x2&&(this.x2=e),t>this.y2&&(this.y2=t),this},expand(e){return this.x1-=e,this.y1-=e,this.x2+=e,this.y2+=e,this},round(){return this.x1=Math.floor(this.x1),this.y1=Math.floor(this.y1),this.x2=Math.ceil(this.x2),this.y2=Math.ceil(this.y2),this},scale(e){return this.x1*=e,this.y1*=e,this.x2*=e,this.y2*=e,this},translate(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this},rotate(e,t,n){const i=this.rotatedPoints(e,t,n);return this.clear().add(i[0],i[1]).add(i[2],i[3]).add(i[4],i[5]).add(i[6],i[7])},rotatedPoints(e,t,n){var{x1:i,y1:r,x2:o,y2:s}=this,a=Math.cos(e),u=Math.sin(e),l=t-t*a+n*u,c=n-t*u-n*a;return[a*i-u*r+l,u*i+a*r+c,a*i-u*s+l,u*i+a*s+c,a*o-u*r+l,u*o+a*r+c,a*o-u*s+l,u*o+a*s+c]},union(e){return e.x1this.x2&&(this.x2=e.x2),e.y2>this.y2&&(this.y2=e.y2),this},intersect(e){return e.x1>this.x1&&(this.x1=e.x1),e.y1>this.y1&&(this.y1=e.y1),e.x2=e.x2&&this.y1<=e.y1&&this.y2>=e.y2},alignsWith(e){return e&&(this.x1==e.x1||this.x2==e.x2||this.y1==e.y1||this.y2==e.y2)},intersects(e){return e&&!(this.x2e.x2||this.y2e.y2)},contains(e,t){return!(ethis.x2||tthis.y2)},width(){return this.x2-this.x1},height(){return this.y2-this.y1}};function Fp(e){this.mark=e,this.bounds=this.bounds||new st}function Mp(e){Fp.call(this,e),this.items=this.items||[]}Y(Mp,Fp);class w3{constructor(t){this._pending=0,this._loader=t||np()}pending(){return this._pending}sanitizeURL(t){const n=this;return JS(n),n._loader.sanitize(t,{context:"href"}).then(i=>(Nl(n),i)).catch(()=>(Nl(n),null))}loadImage(t){const n=this,i=d7();return JS(n),n._loader.sanitize(t,{context:"image"}).then(r=>{const o=r.href;if(!o||!i)throw{url:o};const s=new i,a=Z(r,"crossOrigin")?r.crossOrigin:"anonymous";return a!=null&&(s.crossOrigin=a),s.onload=()=>Nl(n),s.onerror=()=>Nl(n),s.src=o,s}).catch(r=>(Nl(n),{complete:!1,width:0,height:0,src:r&&r.url||""}))}ready(){const t=this;return new Promise(n=>{function i(r){t.pending()?setTimeout(()=>{i(!0)},10):n(r)}i(!1)})}}function JS(e){e._pending+=1}function Nl(e){e._pending-=1}function io(e,t,n){if(t.stroke&&t.opacity!==0&&t.strokeOpacity!==0){const i=t.strokeWidth!=null?+t.strokeWidth:1;e.expand(i+(n?GU(t,i):0))}return e}function GU(e,t){return e.strokeJoin&&e.strokeJoin!=="miter"?0:t}const YU=Yi-1e-8;let Tp,Hd,Gd,Os,my,Yd,yy,by;const So=(e,t)=>Tp.add(e,t),Vd=(e,t)=>So(Hd=e,Gd=t),QS=e=>So(e,Tp.y1),ZS=e=>So(Tp.x1,e),Fs=(e,t)=>my*e+yy*t,Ms=(e,t)=>Yd*e+by*t,_0=(e,t)=>So(Fs(e,t),Ms(e,t)),S0=(e,t)=>Vd(Fs(e,t),Ms(e,t));function _f(e,t){return Tp=e,t?(Os=t*Wo,my=by=Math.cos(Os),Yd=Math.sin(Os),yy=-Yd):(my=by=1,Os=Yd=yy=0),VU}const VU={beginPath(){},closePath(){},moveTo:S0,lineTo:S0,rect(e,t,n,i){Os?(_0(e+n,t),_0(e+n,t+i),_0(e,t+i),S0(e,t)):(So(e+n,t+i),Vd(e,t))},quadraticCurveTo(e,t,n,i){const r=Fs(e,t),o=Ms(e,t),s=Fs(n,i),a=Ms(n,i);e$(Hd,r,s,QS),e$(Gd,o,a,ZS),Vd(s,a)},bezierCurveTo(e,t,n,i,r,o){const s=Fs(e,t),a=Ms(e,t),u=Fs(n,i),l=Ms(n,i),c=Fs(r,o),f=Ms(r,o);t$(Hd,s,u,c,QS),t$(Gd,a,l,f,ZS),Vd(c,f)},arc(e,t,n,i,r,o){if(i+=Os,r+=Os,Hd=n*Math.cos(r)+e,Gd=n*Math.sin(r)+t,Math.abs(r-i)>YU)So(e-n,t-n),So(e+n,t+n);else{const s=l=>So(n*Math.cos(l)+e,n*Math.sin(l)+t);let a,u;if(s(i),s(r),r!==i)if(i=i%Yi,i<0&&(i+=Yi),r=r%Yi,r<0&&(r+=Yi),rr;++u,a-=Cs)s(a);else for(a=i-i%Cs+Cs,u=0;u<4&&asU?(c=s*s+a*o,c>=0&&(c=Math.sqrt(c),u=(-s+c)/o,l=(-s-c)/o)):u=.5*a/s,0d)return!1;p>f&&(f=p)}else if(h>0){if(p0?(e.globalAlpha=n,e.fillStyle=S3(e,t,t.fill),!0):!1}var KU=[];function ku(e,t,n){var i=(i=t.strokeWidth)!=null?i:1;return i<=0?!1:(n*=t.strokeOpacity==null?1:t.strokeOpacity,n>0?(e.globalAlpha=n,e.strokeStyle=S3(e,t,t.stroke),e.lineWidth=i,e.lineCap=t.strokeCap||"butt",e.lineJoin=t.strokeJoin||"miter",e.miterLimit=t.strokeMiterLimit||10,e.setLineDash&&(e.setLineDash(t.strokeDash||KU),e.lineDashOffset=t.strokeDashOffset||0),!0):!1)}function JU(e,t){return e.zindex-t.zindex||e.index-t.index}function i2(e){if(!e.zdirty)return e.zitems;var t=e.items,n=[],i,r,o;for(r=0,o=t.length;r=0;)if(i=t(n[r]))return i;if(n===o){for(n=e.items,r=n.length;--r>=0;)if(!n[r].zindex&&(i=t(n[r])))return i}return null}function r2(e){return function(t,n,i){Ai(n,r=>{(!i||i.intersects(r.bounds))&&$3(e,t,r,r)})}}function QU(e){return function(t,n,i){n.items.length&&(!i||i.intersects(n.bounds))&&$3(e,t,n.items[0],n.items)}}function $3(e,t,n,i){var r=n.opacity==null?1:n.opacity;r!==0&&(e(t,i)||($u(t,n),n.fill&&Oh(t,n,r)&&t.fill(),n.stroke&&ku(t,n,r)&&t.stroke()))}function Np(e){return e=e||ti,function(t,n,i,r,o,s){return i*=t.pixelRatio,r*=t.pixelRatio,Dh(n,a=>{const u=a.bounds;if(!(u&&!u.contains(o,s)||!u)&&e(t,a,i,r,o,s))return a})}}function Sf(e,t){return function(n,i,r,o){var s=Array.isArray(i)?i[0]:i,a=t??s.fill,u=s.stroke&&n.isPointInStroke,l,c;return u&&(l=s.strokeWidth,c=s.strokeCap,n.lineWidth=l??1,n.lineCap=c??"butt"),e(n,i)?!1:a&&n.isPointInPath(r,o)||u&&n.isPointInStroke(r,o)}}function o2(e){return Np(Sf(e))}function zs(e,t){return"translate("+e+","+t+")"}function s2(e){return"rotate("+e+")"}function ZU(e,t){return"scale("+e+","+t+")"}function k3(e){return zs(e.x||0,e.y||0)}function ej(e){return zs(e.x||0,e.y||0)+(e.angle?" "+s2(e.angle):"")}function tj(e){return zs(e.x||0,e.y||0)+(e.angle?" "+s2(e.angle):"")+(e.scaleX||e.scaleY?" "+ZU(e.scaleX||1,e.scaleY||1):"")}function a2(e,t,n){function i(s,a){s("transform",ej(a)),s("d",t(null,a))}function r(s,a){return t(_f(s,a.angle),a),io(s,a).translate(a.x||0,a.y||0)}function o(s,a){var u=a.x||0,l=a.y||0,c=a.angle||0;s.translate(u,l),c&&s.rotate(c*=Wo),s.beginPath(),t(s,a),c&&s.rotate(-c),s.translate(-u,-l)}return{type:e,tag:"path",nested:!1,attr:i,bound:r,draw:r2(o),pick:o2(o),isect:n||t2(o)}}var nj=a2("arc",zU);function ij(e,t){for(var n=e[0].orient==="horizontal"?t[1]:t[0],i=e[0].orient==="horizontal"?"y":"x",r=e.length,o=1/0,s,a;--r>=0;)e[r].defined!==!1&&(a=Math.abs(e[r][i]-n),a=0;)if(e[i].defined!==!1&&(r=e[i].x-t[0],o=e[i].y-t[1],s=r*r+o*o,s=0;)if(e[n].defined!==!1&&(i=e[n].x-t[0],r=e[n].y-t[1],o=i*i+r*r,i=e[n].size||1,o.5&&t<1.5?.5-Math.abs(t-1):0}function uj(e,t){e("transform",k3(t))}function F3(e,t){const n=C3(t);e("d",ll(null,t,n,n))}function lj(e,t){e("class","background"),e("aria-hidden",!0),F3(e,t)}function cj(e,t){e("class","foreground"),e("aria-hidden",!0),t.strokeForeground?F3(e,t):e("d","")}function fj(e,t,n){const i=t.clip?e2(n,t,t):null;e("clip-path",i)}function dj(e,t){if(!t.clip&&t.items){const n=t.items,i=n.length;for(let r=0;r{const o=r.x||0,s=r.y||0,a=r.strokeForeground,u=r.opacity==null?1:r.opacity;(r.stroke||r.fill)&&u&&(Bc(e,r,o,s),$u(e,r),r.fill&&Oh(e,r,u)&&e.fill(),r.stroke&&!a&&ku(e,r,u)&&e.stroke()),e.save(),e.translate(o,s),r.clip&&A3(e,r),n&&n.translate(-o,-s),Ai(r,l=>{(l.marktype==="group"||i==null||i.includes(l.marktype))&&this.draw(e,l,n,i)}),n&&n.translate(o,s),e.restore(),a&&r.stroke&&u&&(Bc(e,r,o,s),$u(e,r),ku(e,r,u)&&e.stroke())})}function yj(e,t,n,i,r,o){if(t.bounds&&!t.bounds.contains(r,o)||!t.items)return null;const s=n*e.pixelRatio,a=i*e.pixelRatio;return Dh(t,u=>{let l,c,f;const d=u.bounds;if(d&&!d.contains(r,o))return;c=u.x||0,f=u.y||0;const h=c+(u.width||0),g=f+(u.height||0),p=u.clip;if(p&&(rh||og))return;if(e.save(),e.translate(c,f),c=r-c,f=o-f,p&&Zx(u)&&!pj(e,u,s,a))return e.restore(),null;const m=u.strokeForeground,y=t.interactive!==!1;return y&&m&&u.stroke&&gj(e,u,s,a)?(e.restore(),u):(l=Dh(u,b=>bj(b,c,f)?this.pick(b,n,i,c,f):null),!l&&y&&(u.fill||!m&&u.stroke)&&hj(e,u,s,a)&&(l=u),e.restore(),l||null)})}function bj(e,t,n){return(e.interactive!==!1||e.marktype==="group")&&e.bounds&&e.bounds.contains(t,n)}var vj={type:"group",tag:"g",nested:!1,attr:uj,bound:dj,draw:mj,pick:yj,isect:E3,content:fj,background:lj,foreground:cj},Uc={xmlns:"http://www.w3.org/2000/svg","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1"};function l2(e,t){var n=e.image;return(!n||e.url&&e.url!==n.url)&&(n={complete:!1,width:0,height:0},t.loadImage(e.url).then(i=>{e.image=i,e.image.url=e.url})),n}function c2(e,t){return e.width!=null?e.width:!t||!t.width?0:e.aspect!==!1&&e.height?e.height*t.width/t.height:t.width}function f2(e,t){return e.height!=null?e.height:!t||!t.height?0:e.aspect!==!1&&e.width?e.width*t.height/t.width:t.height}function Rp(e,t){return e==="center"?t/2:e==="right"?t:0}function Op(e,t){return e==="middle"?t/2:e==="bottom"?t:0}function xj(e,t,n){const i=l2(t,n),r=c2(t,i),o=f2(t,i),s=(t.x||0)-Rp(t.align,r),a=(t.y||0)-Op(t.baseline,o),u=!i.src&&i.toDataURL?i.toDataURL():i.src||"";e("href",u,Uc["xmlns:xlink"],"xlink:href"),e("transform",zs(s,a)),e("width",r),e("height",o),e("preserveAspectRatio",t.aspect===!1?"none":"xMidYMid")}function wj(e,t){const n=t.image,i=c2(t,n),r=f2(t,n),o=(t.x||0)-Rp(t.align,i),s=(t.y||0)-Op(t.baseline,r);return e.set(o,s,o+i,s+r)}function Ej(e,t,n){Ai(t,i=>{if(n&&!n.intersects(i.bounds))return;const r=l2(i,this);let o=c2(i,r),s=f2(i,r);if(o===0||s===0)return;let a=(i.x||0)-Rp(i.align,o),u=(i.y||0)-Op(i.baseline,s),l,c,f,d;i.aspect!==!1&&(c=r.width/r.height,f=i.width/i.height,c===c&&f===f&&c!==f&&(f{if(!(n&&!n.intersects(i.bounds))){var r=i.opacity==null?1:i.opacity;r&&M3(e,i,r)&&($u(e,i),e.stroke())}})}function Oj(e,t,n,i){return e.isPointInStroke?M3(e,t,1)&&e.isPointInStroke(n,i):!1}var Dj={type:"rule",tag:"line",nested:!1,attr:Tj,bound:Nj,draw:Rj,pick:Np(Oj),isect:_3},Lj=a2("shape",jU),Pj=a2("symbol",qU,n2);const o$=zF();var Ln={height:pr,measureWidth:d2,estimateWidth:Lh,width:Lh,canvas:T3};T3(!0);function T3(e){Ln.width=e&&Po?d2:Lh}function Lh(e,t){return N3(Go(e,t),pr(e))}function N3(e,t){return~~(.8*e.length*t)}function d2(e,t){return pr(e)<=0||!(t=Go(e,t))?0:R3(t,Dp(e))}function R3(e,t){const n=`(${t}) ${e}`;let i=o$.get(n);return i===void 0&&(Po.font=t,i=Po.measureText(e).width,o$.set(n,i)),i}function pr(e){return e.fontSize!=null?+e.fontSize||0:11}function Ho(e){return e.lineHeight!=null?e.lineHeight:pr(e)+2}function Ij(e){return P(e)?e.length>1?e:e[0]:e}function $f(e){return Ij(e.lineBreak&&e.text&&!P(e.text)?e.text.split(e.lineBreak):e.text)}function h2(e){const t=$f(e);return(P(t)?t.length-1:0)*Ho(e)}function Go(e,t){const n=t==null?"":(t+"").trim();return e.limit>0&&n.length?Bj(e,n):n}function zj(e){if(Ln.width===d2){const t=Dp(e);return n=>R3(n,t)}else if(Ln.width===Lh){const t=pr(e);return n=>N3(n,t)}else return t=>Ln.width(e,t)}function Bj(e,t){var n=+e.limit,i=zj(e);if(i(t)>>1,i(t.slice(u))>n?s=u+1:a=u;return r+t.slice(s)}else{for(;s>>1),i(t.slice(0,u))Math.max(d,Ln.width(t,h)),0)):f=Ln.width(t,c),r==="center"?u-=f/2:r==="right"&&(u-=f),e.set(u+=s,l+=a,u+f,l+i),t.angle&&!n)e.rotate(t.angle*Wo,s,a);else if(n===2)return e.rotatedPoints(t.angle*Wo,s,a);return e}function qj(e,t,n){Ai(t,i=>{var r=i.opacity==null?1:i.opacity,o,s,a,u,l,c,f;if(!(n&&!n.intersects(i.bounds)||r===0||i.fontSize<=0||i.text==null||i.text.length===0)){if(e.font=Dp(i),e.textAlign=i.align||"left",o=Lp(i),s=o.x1,a=o.y1,i.angle&&(e.save(),e.translate(s,a),e.rotate(i.angle*Wo),s=a=0),s+=i.dx||0,a+=(i.dy||0)+g2(i),c=$f(i),$u(e,i),P(c))for(l=Ho(i),u=0;ut;)e.removeChild(n[--i]);return e}function z3(e){return"mark-"+e.marktype+(e.role?" role-"+e.role:"")+(e.name?" "+e.name:"")}function Pp(e,t){const n=t.getBoundingClientRect();return[e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0)]}function Xj(e,t,n,i){var r=e&&e.mark,o,s;if(r&&(o=jn[r.marktype]).tip){for(s=Pp(t,n),s[0]-=i[0],s[1]-=i[1];e=e.mark.group;)s[0]-=e.x||0,s[1]-=e.y||0;e=o.tip(r.items,s)}return e}let y2=class{constructor(t,n){this._active=null,this._handlers={},this._loader=t||np(),this._tooltip=n||Kj}initialize(t,n,i){return this._el=t,this._obj=i||null,this.origin(n)}element(){return this._el}canvas(){return this._el&&this._el.firstChild}origin(t){return arguments.length?(this._origin=t||[0,0],this):this._origin.slice()}scene(t){return arguments.length?(this._scene=t,this):this._scene}on(){}off(){}_handlerIndex(t,n,i){for(let r=t?t.length:0;--r>=0;)if(t[r].type===n&&(!i||t[r].handler===i))return r;return-1}handlers(t){const n=this._handlers,i=[];if(t)i.push(...n[this.eventName(t)]);else for(const r in n)i.push(...n[r]);return i}eventName(t){const n=t.indexOf(".");return n<0?t:t.slice(0,n)}handleHref(t,n,i){this._loader.sanitize(i,{context:"href"}).then(r=>{const o=new MouseEvent(t.type,t),s=$o(null,"a");for(const a in r)s.setAttribute(a,r[a]);s.dispatchEvent(o)}).catch(()=>{})}handleTooltip(t,n,i){if(n&&n.tooltip!=null){n=Xj(n,t,this.canvas(),this._origin);const r=i&&n&&n.tooltip||null;this._tooltip.call(this._obj,this,t,n,r)}}getItemBoundingClientRect(t){const n=this.canvas();if(!n)return;const i=n.getBoundingClientRect(),r=this._origin,o=t.bounds,s=o.width(),a=o.height();let u=o.x1+r[0]+i.left,l=o.y1+r[1]+i.top;for(;t.mark&&(t=t.mark.group);)u+=t.x||0,l+=t.y||0;return{x:u,y:l,width:s,height:a,left:u,top:l,right:u+s,bottom:l+a}}};function Kj(e,t,n,i){e.element().setAttribute("title",i||"")}class Af{constructor(t){this._el=null,this._bgcolor=null,this._loader=new w3(t)}initialize(t,n,i,r,o){return this._el=t,this.resize(n,i,r,o)}element(){return this._el}canvas(){return this._el&&this._el.firstChild}background(t){return arguments.length===0?this._bgcolor:(this._bgcolor=t,this)}resize(t,n,i,r){return this._width=t,this._height=n,this._origin=i||[0,0],this._scale=r||1,this}dirty(){}render(t,n){const i=this;return i._call=function(){i._render(t,n)},i._call(),i._call=null,i}_render(){}renderAsync(t,n){const i=this.render(t,n);return this._ready?this._ready.then(()=>i):Promise.resolve(i)}_load(t,n){var i=this,r=i._loader[t](n);if(!i._ready){const o=i._call;i._ready=i._loader.ready().then(s=>{s&&o(),i._ready=null})}return r}sanitizeURL(t){return this._load("sanitizeURL",t)}loadImage(t){return this._load("loadImage",t)}}const Jj="keydown",Qj="keypress",Zj="keyup",B3="dragenter",Kd="dragleave",U3="dragover",wy="pointerdown",eq="pointerup",Ph="pointermove",Jd="pointerout",j3="pointerover",Ey="mousedown",tq="mouseup",q3="mousemove",Ih="mouseout",W3="mouseover",zh="click",nq="dblclick",iq="wheel",H3="mousewheel",Bh="touchstart",Uh="touchmove",jh="touchend",rq=[Jj,Qj,Zj,B3,Kd,U3,wy,eq,Ph,Jd,j3,Ey,tq,q3,Ih,W3,zh,nq,iq,H3,Bh,Uh,jh],_y=Ph,bc=Ih,Sy=zh;class Cf extends y2{constructor(t,n){super(t,n),this._down=null,this._touch=null,this._first=!0,this._events={},this.events=rq,this.pointermove=l$([Ph,q3],[j3,W3],[Jd,Ih]),this.dragover=l$([U3],[B3],[Kd]),this.pointerout=c$([Jd,Ih]),this.dragleave=c$([Kd])}initialize(t,n,i){return this._canvas=t&&m2(t,"canvas"),[zh,Ey,wy,Ph,Jd,Kd].forEach(r=>u$(this,r)),super.initialize(t,n,i)}canvas(){return this._canvas}context(){return this._canvas.getContext("2d")}DOMMouseScroll(t){this.fire(H3,t)}pointerdown(t){this._down=this._active,this.fire(wy,t)}mousedown(t){this._down=this._active,this.fire(Ey,t)}click(t){this._down===this._active&&(this.fire(zh,t),this._down=null)}touchstart(t){this._touch=this.pickEvent(t.changedTouches[0]),this._first&&(this._active=this._touch,this._first=!1),this.fire(Bh,t,!0)}touchmove(t){this.fire(Uh,t,!0)}touchend(t){this.fire(jh,t,!0),this._touch=null}fire(t,n,i){const r=i?this._touch:this._active,o=this._handlers[t];if(n.vegaType=t,t===Sy&&r&&r.href?this.handleHref(n,r,r.href):(t===_y||t===bc)&&this.handleTooltip(n,r,t!==bc),o)for(let s=0,a=o.length;s=0&&r.splice(o,1),this}pickEvent(t){const n=Pp(t,this._canvas),i=this._origin;return this.pick(this._scene,n[0],n[1],n[0]-i[0],n[1]-i[1])}pick(t,n,i,r,o){const s=this.context();return jn[t.marktype].pick.call(this,s,t,n,i,r,o)}}const oq=e=>e===Bh||e===Uh||e===jh?[Bh,Uh,jh]:[e];function u$(e,t){oq(t).forEach(n=>sq(e,n))}function sq(e,t){const n=e.canvas();n&&!e._events[t]&&(e._events[t]=1,n.addEventListener(t,e[t]?i=>e[t](i):i=>e.fire(t,i)))}function nc(e,t,n){t.forEach(i=>e.fire(i,n))}function l$(e,t,n){return function(i){const r=this._active,o=this.pickEvent(i);o===r?nc(this,e,i):((!r||!r.exit)&&nc(this,n,i),this._active=o,nc(this,t,i),nc(this,e,i))}}function c$(e){return function(t){nc(this,e,t),this._active=null}}function aq(){return typeof window<"u"&&window.devicePixelRatio||1}function uq(e,t,n,i,r,o){const s=typeof HTMLElement<"u"&&e instanceof HTMLElement&&e.parentNode!=null,a=e.getContext("2d"),u=s?aq():r;e.width=t*u,e.height=n*u;for(const l in o)a[l]=o[l];return s&&u!==1&&(e.style.width=t+"px",e.style.height=n+"px"),a.pixelRatio=u,a.setTransform(u,0,0,u,u*i[0],u*i[1]),e}class qh extends Af{constructor(t){super(t),this._options={},this._redraw=!1,this._dirty=new st,this._tempb=new st}initialize(t,n,i,r,o,s){return this._options=s||{},this._canvas=this._options.externalContext?null:Lo(1,1,this._options.type),t&&this._canvas&&(Gn(t,0).appendChild(this._canvas),this._canvas.setAttribute("class","marks")),super.initialize(t,n,i,r,o)}resize(t,n,i,r){if(super.resize(t,n,i,r),this._canvas)uq(this._canvas,this._width,this._height,this._origin,this._scale,this._options.context);else{const o=this._options.externalContext;o||O("CanvasRenderer is missing a valid canvas or context"),o.scale(this._scale,this._scale),o.translate(this._origin[0],this._origin[1])}return this._redraw=!0,this}canvas(){return this._canvas}context(){return this._options.externalContext||(this._canvas?this._canvas.getContext("2d"):null)}dirty(t){const n=this._tempb.clear().union(t.bounds);let i=t.mark.group;for(;i;)n.translate(i.x||0,i.y||0),i=i.mark.group;this._dirty.union(n)}_render(t,n){const i=this.context(),r=this._origin,o=this._width,s=this._height,a=this._dirty,u=lq(r,o,s);i.save();const l=this._redraw||a.empty()?(this._redraw=!1,u.expand(1)):cq(i,u.intersect(a),r);return this.clear(-r[0],-r[1],o,s),this.draw(i,t,l,n),i.restore(),a.clear(),this}draw(t,n,i,r){if(n.marktype!=="group"&&r!=null&&!r.includes(n.marktype))return;const o=jn[n.marktype];n.clip&&aj(t,n),o.draw.call(this,t,n,i,r),n.clip&&t.restore()}clear(t,n,i,r){const o=this._options,s=this.context();o.type!=="pdf"&&!o.externalContext&&s.clearRect(t,n,i,r),this._bgcolor!=null&&(s.fillStyle=this._bgcolor,s.fillRect(t,n,i,r))}}const lq=(e,t,n)=>new st().set(0,0,t,n).translate(-e[0],-e[1]);function cq(e,t,n){return t.expand(1).round(),e.pixelRatio%1&&t.scale(e.pixelRatio).round().scale(1/e.pixelRatio),t.translate(-(n[0]%1),-(n[1]%1)),e.beginPath(),e.rect(t.x1,t.y1,t.width(),t.height()),e.clip(),t}class G3 extends y2{constructor(t,n){super(t,n);const i=this;i._hrefHandler=$0(i,(r,o)=>{o&&o.href&&i.handleHref(r,o,o.href)}),i._tooltipHandler=$0(i,(r,o)=>{i.handleTooltip(r,o,r.type!==bc)})}initialize(t,n,i){let r=this._svg;return r&&(r.removeEventListener(Sy,this._hrefHandler),r.removeEventListener(_y,this._tooltipHandler),r.removeEventListener(bc,this._tooltipHandler)),this._svg=r=t&&m2(t,"svg"),r&&(r.addEventListener(Sy,this._hrefHandler),r.addEventListener(_y,this._tooltipHandler),r.addEventListener(bc,this._tooltipHandler)),super.initialize(t,n,i)}canvas(){return this._svg}on(t,n){const i=this.eventName(t),r=this._handlers;if(this._handlerIndex(r[i],t,n)<0){const s={type:t,handler:n,listener:$0(this,n)};(r[i]||(r[i]=[])).push(s),this._svg&&this._svg.addEventListener(i,s.listener)}return this}off(t,n){const i=this.eventName(t),r=this._handlers[i],o=this._handlerIndex(r,t,n);return o>=0&&(this._svg&&this._svg.removeEventListener(i,r[o].listener),r.splice(o,1)),this}}const $0=(e,t)=>n=>{let i=n.target.__data__;i=Array.isArray(i)?i[0]:i,n.vegaType=n.type,t.call(e._obj,n,i)},Y3="aria-hidden",b2="aria-label",v2="role",x2="aria-roledescription",V3="graphics-object",w2="graphics-symbol",X3=(e,t,n)=>({[v2]:e,[x2]:t,[b2]:n||void 0}),fq=$i(["axis-domain","axis-grid","axis-label","axis-tick","axis-title","legend-band","legend-entry","legend-gradient","legend-label","legend-title","legend-symbol","title"]),f$={axis:{desc:"axis",caption:gq},legend:{desc:"legend",caption:pq},"title-text":{desc:"title",caption:e=>`Title text '${h$(e)}'`},"title-subtitle":{desc:"subtitle",caption:e=>`Subtitle text '${h$(e)}'`}},d$={ariaRole:v2,ariaRoleDescription:x2,description:b2};function K3(e,t){const n=t.aria===!1;if(e(Y3,n||void 0),n||t.description==null)for(const i in d$)e(d$[i],void 0);else{const i=t.mark.marktype;e(b2,t.description),e(v2,t.ariaRole||(i==="group"?V3:w2)),e(x2,t.ariaRoleDescription||`${i} mark`)}}function J3(e){return e.aria===!1?{[Y3]:!0}:fq[e.role]?null:f$[e.role]?hq(e,f$[e.role]):dq(e)}function dq(e){const t=e.marktype,n=t==="group"||t==="text"||e.items.some(i=>i.description!=null&&i.aria!==!1);return X3(n?V3:w2,`${t} mark container`,e.description)}function hq(e,t){try{const n=e.items[0],i=t.caption||(()=>"");return X3(t.role||w2,t.desc,n.description||i(n))}catch{return null}}function h$(e){return Q(e.text).join(" ")}function gq(e){const t=e.datum,n=e.orient,i=t.title?Q3(e):null,r=e.context,o=r.scales[t.scale].value,s=r.dataflow.locale(),a=o.type;return`${n==="left"||n==="right"?"Y":"X"}-axis`+(i?` titled '${i}'`:"")+` for a ${_u(a)?"discrete":a} scale with ${d3(s,o,e)}`}function pq(e){const t=e.datum,n=t.title?Q3(e):null,i=`${t.type||""} legend`.trim(),r=t.scales,o=Object.keys(r),s=e.context,a=s.scales[r[o[0]]].value,u=s.dataflow.locale();return yq(i)+(n?` titled '${n}'`:"")+` for ${mq(o)} with ${d3(u,a,e)}`}function Q3(e){try{return Q(_e(e.items).items[0].text).join(" ")}catch{return null}}function mq(e){return e=e.map(t=>t+(t==="fill"||t==="stroke"?" color":"")),e.length<2?e[0]:e.slice(0,-1).join(", ")+" and "+_e(e)}function yq(e){return e.length?e[0].toUpperCase()+e.slice(1):e}const Z3=e=>(e+"").replace(/&/g,"&").replace(//g,">"),bq=e=>Z3(e).replace(/"/g,""").replace(/\t/g," ").replace(/\n/g," ").replace(/\r/g," ");function E2(){let e="",t="",n="";const i=[],r=()=>t=n="",o=u=>{t&&(e+=`${t}>${n}`,r()),i.push(u)},s=(u,l)=>(l!=null&&(t+=` ${u}="${bq(l)}"`),a),a={open(u,...l){o(u),t="<"+u;for(const c of l)for(const f in c)s(f,c[f]);return a},close(){const u=i.pop();return t?e+=t+(n?`>${n}`:"/>"):e+=``,r(),a},attr:s,text:u=>(n+=Z3(u),a),toString:()=>e};return a}const eR=e=>tR(E2(),e)+"";function tR(e,t){if(e.open(t.tagName),t.hasAttributes()){const n=t.attributes,i=n.length;for(let r=0;r{c.dirty=n})),!r.zdirty){if(i.exit){s.nested&&r.items.length?(l=r.items[0],l._svg&&this._update(s,l._svg,l)):i._svg&&(l=i._svg.parentNode,l&&l.removeChild(i._svg)),i._svg=null;continue}i=s.nested?r.items[0]:i,i._update!==n&&(!i._svg||!i._svg.ownerSVGElement?(this._dirtyAll=!1,p$(i,n)):this._update(s,i._svg,i),i._update=n)}return!this._dirtyAll}mark(t,n,i,r){if(!this.isDirty(n))return n._svg;const o=this._svg,s=n.marktype,a=jn[s],u=n.interactive===!1?"none":null,l=a.tag==="g",c=m$(n,t,i,"g",o);if(s!=="group"&&r!=null&&!r.includes(s))return Gn(c,0),n._svg;c.setAttribute("class",z3(n));const f=J3(n);for(const p in f)Kt(c,p,f[p]);l||Kt(c,"pointer-events",u),Kt(c,"clip-path",n.clip?e2(this,n,n.group):null);let d=null,h=0;const g=p=>{const m=this.isDirty(p),y=m$(p,c,d,a.tag,o);m&&(this._update(a,y,p),l&&wq(this,y,p,r)),d=y,++h};return a.nested?n.items.length&&g(n.items[0]):Ai(n,g),Gn(c,h),c}_update(t,n,i){zr=n,Bt=n.__values__,K3(vc,i),t.attr(vc,i,this);const r=_q[t.type];r&&r.call(this,t,n,i),zr&&this.style(zr,i)}style(t,n){if(n!=null){for(const i in Wh){let r=i==="font"?kf(n):n[i];if(r===Bt[i])continue;const o=Wh[i];r==null?t.removeAttribute(o):(Jx(r)&&(r=g3(r,this._defs.gradient,iR())),t.setAttribute(o,r+"")),Bt[i]=r}for(const i in Hh)Qd(t,Hh[i],n[i])}}defs(){const t=this._svg,n=this._defs;let i=n.el,r=0;for(const o in n.gradient)i||(n.el=i=ut(t,Rl+1,"defs",at)),r=vq(i,n.gradient[o],r);for(const o in n.clipping)i||(n.el=i=ut(t,Rl+1,"defs",at)),r=xq(i,n.clipping[o],r);i&&(r===0?(t.removeChild(i),n.el=null):Gn(i,r))}_clearDefs(){const t=this._defs;t.gradient={},t.clipping={}}}function p$(e,t){for(;e&&e.dirty!==t;e=e.mark.group)if(e.dirty=t,e.mark&&e.mark.dirty!==t)e.mark.dirty=t;else return}function vq(e,t,n){let i,r,o;if(t.gradient==="radial"){let s=ut(e,n++,"pattern",at);ko(s,{id:Rh+t.id,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),s=ut(s,0,"rect",at),ko(s,{width:1,height:1,fill:`url(${iR()}#${t.id})`}),e=ut(e,n++,"radialGradient",at),ko(e,{id:t.id,fx:t.x1,fy:t.y1,fr:t.r1,cx:t.x2,cy:t.y2,r:t.r2})}else e=ut(e,n++,"linearGradient",at),ko(e,{id:t.id,x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2});for(i=0,r=t.stops.length;i{r=e.mark(t,s,r,i),++o}),Gn(t,1+o)}function m$(e,t,n,i,r){let o=e._svg,s;if(!o&&(s=t.ownerDocument,o=$o(s,i,at),e._svg=o,e.mark&&(o.__data__=e,o.__values__={fill:"default"},i==="g"))){const a=$o(s,"path",at);o.appendChild(a),a.__data__=e;const u=$o(s,"g",at);o.appendChild(u),u.__data__=e;const l=$o(s,"path",at);o.appendChild(l),l.__data__=e,l.__values__={fill:"default"}}return(o.ownerSVGElement!==r||Eq(o,n))&&t.insertBefore(o,n?n.nextSibling:t.firstChild),o}function Eq(e,t){return e.parentNode&&e.parentNode.childNodes.length>1&&e.previousSibling!=t}let zr=null,Bt=null;const _q={group(e,t,n){const i=zr=t.childNodes[2];Bt=i.__values__,e.foreground(vc,n,this),Bt=t.__values__,zr=t.childNodes[1],e.content(vc,n,this);const r=zr=t.childNodes[0];e.background(vc,n,this);const o=n.mark.interactive===!1?"none":null;if(o!==Bt.events&&(Kt(i,"pointer-events",o),Kt(r,"pointer-events",o),Bt.events=o),n.strokeForeground&&n.stroke){const s=n.fill;Kt(i,"display",null),this.style(r,n),Kt(r,"stroke",null),s&&(n.fill=null),Bt=i.__values__,this.style(i,n),s&&(n.fill=s),zr=null}else Kt(i,"display","none")},image(e,t,n){n.smooth===!1?(Qd(t,"image-rendering","optimizeSpeed"),Qd(t,"image-rendering","pixelated")):Qd(t,"image-rendering",null)},text(e,t,n){const i=$f(n);let r,o,s,a;P(i)?(o=i.map(u=>Go(n,u)),r=o.join(` +`),r!==Bt.text&&(Gn(t,0),s=t.ownerDocument,a=Ho(n),o.forEach((u,l)=>{const c=$o(s,"tspan",at);c.__data__=n,c.textContent=u,l&&(c.setAttribute("x",0),c.setAttribute("dy",a)),t.appendChild(c)}),Bt.text=r)):(o=Go(n,i),o!==Bt.text&&(t.textContent=o,Bt.text=o)),Kt(t,"font-family",kf(n)),Kt(t,"font-size",pr(n)+"px"),Kt(t,"font-style",n.fontStyle),Kt(t,"font-variant",n.fontVariant),Kt(t,"font-weight",n.fontWeight)}};function vc(e,t,n){t!==Bt[e]&&(n?Sq(zr,e,t,n):Kt(zr,e,t),Bt[e]=t)}function Qd(e,t,n){n!==Bt[t]&&(n==null?e.style.removeProperty(t):e.style.setProperty(t,n+""),Bt[t]=n)}function ko(e,t){for(const n in t)Kt(e,n,t[n])}function Kt(e,t,n){n!=null?e.setAttribute(t,n):e.removeAttribute(t)}function Sq(e,t,n,i){n!=null?e.setAttributeNS(i,t,n):e.removeAttributeNS(i,t)}function iR(){let e;return typeof window>"u"?"":(e=window.location).hash?e.href.slice(0,-e.hash.length):e.href}class rR extends Af{constructor(t){super(t),this._text=null,this._defs={gradient:{},clipping:{}}}svg(){return this._text}_render(t){const n=E2();n.open("svg",pe({},Uc,{class:"marks",width:this._width*this._scale,height:this._height*this._scale,viewBox:`0 0 ${this._width} ${this._height}`}));const i=this._bgcolor;return i&&i!=="transparent"&&i!=="none"&&n.open("rect",{width:this._width,height:this._height,fill:i}).close(),n.open("g",nR,{transform:"translate("+this._origin+")"}),this.mark(n,t),n.close(),this.defs(n),this._text=n.close()+"",this}mark(t,n){const i=jn[n.marktype],r=i.tag,o=[K3,i.attr];t.open("g",{class:z3(n),"clip-path":n.clip?e2(this,n,n.group):null},J3(n),{"pointer-events":r!=="g"&&n.interactive===!1?"none":null});const s=a=>{const u=this.href(a);if(u&&t.open("a",u),t.open(r,this.attr(n,a,o,r!=="g"?r:null)),r==="text"){const l=$f(a);if(P(l)){const c={x:0,dy:Ho(a)};for(let f=0;fthis.mark(t,d)),t.close(),l&&f?(c&&(a.fill=null),a.stroke=f,t.open("path",this.attr(n,a,i.foreground,"bgrect")).close(),c&&(a.fill=c)):t.open("path",this.attr(n,a,i.foreground,"bgfore")).close()}t.close(),u&&t.close()};return i.nested?n.items&&n.items.length&&s(n.items[0]):Ai(n,s),t.close()}href(t){const n=t.href;let i;if(n){if(i=this._hrefs&&this._hrefs[n])return i;this.sanitizeURL(n).then(r=>{r["xlink:href"]=r.href,r.href=null,(this._hrefs||(this._hrefs={}))[n]=r})}return null}attr(t,n,i,r){const o={},s=(a,u,l,c)=>{o[c||a]=u};return Array.isArray(i)?i.forEach(a=>a(s,n,this)):i(s,n,this),r&&$q(o,n,t,r,this._defs),o}defs(t){const n=this._defs.gradient,i=this._defs.clipping;if(Object.keys(n).length+Object.keys(i).length!==0){t.open("defs");for(const o in n){const s=n[o],a=s.stops;s.gradient==="radial"?(t.open("pattern",{id:Rh+o,viewBox:"0,0,1,1",width:"100%",height:"100%",preserveAspectRatio:"xMidYMid slice"}),t.open("rect",{width:"1",height:"1",fill:"url(#"+o+")"}).close(),t.close(),t.open("radialGradient",{id:o,fx:s.x1,fy:s.y1,fr:s.r1,cx:s.x2,cy:s.y2,r:s.r2})):t.open("linearGradient",{id:o,x1:s.x1,x2:s.x2,y1:s.y1,y2:s.y2});for(let u=0;u!hi.svgMarkTypes.includes(o));this._svgRenderer.render(t,hi.svgMarkTypes),this._canvasRenderer.render(t,r)}resize(t,n,i,r){return super.resize(t,n,i,r),this._svgRenderer.resize(t,n,i,r),this._canvasRenderer.resize(t,n,i,r),this}background(t){return hi.svgOnTop?this._canvasRenderer.background(t):this._svgRenderer.background(t),this}}class oR extends Cf{constructor(t,n){super(t,n)}initialize(t,n,i){const r=ut(ut(t,0,"div"),hi.svgOnTop?0:1,"div");return super.initialize(r,n,i)}}const sR="canvas",aR="hybrid",uR="png",lR="svg",cR="none",Ao={Canvas:sR,PNG:uR,SVG:lR,Hybrid:aR,None:cR},Ks={};Ks[sR]=Ks[uR]={renderer:qh,headless:qh,handler:Cf};Ks[lR]={renderer:_2,headless:rR,handler:G3};Ks[aR]={renderer:$y,headless:$y,handler:oR};Ks[cR]={};function Ip(e,t){return e=String(e||"").toLowerCase(),arguments.length>1?(Ks[e]=t,this):Ks[e]}function fR(e,t,n){const i=[],r=new st().union(t),o=e.marktype;return o?dR(e,r,n,i):o==="group"?hR(e,r,n,i):O("Intersect scene must be mark node or group item.")}function dR(e,t,n,i){if(Aq(e,t,n)){const r=e.items,o=e.marktype,s=r.length;let a=0;if(o==="group")for(;a=0;o--)if(n[o]!=i[o])return!1;for(o=n.length-1;o>=0;o--)if(r=n[o],!S2(e[r],t[r],r))return!1;return typeof e==typeof t}function Mq(){HU(),ZB()}const Au="top",bi="left",vi="right",Yo="bottom",Tq="top-left",Nq="top-right",Rq="bottom-left",Oq="bottom-right",$2="start",ky="middle",Jt="end",Dq="x",Lq="y",zp="group",k2="axis",A2="title",Pq="frame",Iq="scope",C2="legend",yR="row-header",bR="row-footer",vR="row-title",xR="column-header",wR="column-footer",ER="column-title",zq="padding",Bq="symbol",_R="fit",SR="fit-x",$R="fit-y",Uq="pad",F2="none",cd="all",Ay="each",M2="flush",Co="column",Fo="row";function kR(e){R.call(this,null,e)}Y(kR,R,{transform(e,t){const n=t.dataflow,i=e.mark,r=i.marktype,o=jn[r],s=o.bound;let a=i.bounds,u;if(o.nested)i.items.length&&n.dirty(i.items[0]),a=fd(i,s),i.items.forEach(l=>{l.bounds.clear().union(a)});else if(r===zp||e.modified())switch(t.visit(t.MOD,l=>n.dirty(l)),a.clear(),i.items.forEach(l=>a.union(fd(l,s))),i.role){case k2:case C2:case A2:t.reflow()}else u=t.changed(t.REM),t.visit(t.ADD,l=>{a.union(fd(l,s))}),t.visit(t.MOD,l=>{u=u||a.alignsWith(l.bounds),n.dirty(l),a.union(fd(l,s))}),u&&(a.clear(),i.items.forEach(l=>a.union(l.bounds)));return pR(i),t.modifies("bounds")}});function fd(e,t,n){return t(e.bounds.clear(),e,n)}const y$=":vega_identifier:";function T2(e){R.call(this,0,e)}T2.Definition={type:"Identifier",metadata:{modifies:!0},params:[{name:"as",type:"string",required:!0}]};Y(T2,R,{transform(e,t){const n=jq(t.dataflow),i=e.as;let r=n.value;return t.visit(t.ADD,o=>o[i]=o[i]||++r),n.set(this.value=r),t}});function jq(e){return e._signals[y$]||(e._signals[y$]=e.add(0))}function AR(e){R.call(this,null,e)}Y(AR,R,{transform(e,t){let n=this.value;n||(n=t.dataflow.scenegraph().mark(e.markdef,qq(e),e.index),n.group.context=e.context,e.context.group||(e.context.group=n.group),n.source=this.source,n.clip=e.clip,n.interactive=e.interactive,this.value=n);const i=n.marktype===zp?Mp:Fp;return t.visit(t.ADD,r=>i.call(r,n)),(e.modified("clip")||e.modified("interactive"))&&(n.clip=e.clip,n.interactive=!!e.interactive,n.zdirty=!0,t.reflow()),n.items=t.source,t}});function qq(e){const t=e.groups,n=e.parent;return t&&t.size===1?t.get(Object.keys(t.object)[0]):t&&n?t.lookup(n):null}function CR(e){R.call(this,null,e)}const b$={parity:e=>e.filter((t,n)=>n%2?t.opacity=0:1),greedy:(e,t)=>{let n;return e.filter((i,r)=>!r||!FR(n.bounds,i.bounds,t)?(n=i,1):i.opacity=0)}},FR=(e,t,n)=>n>Math.max(t.x1-e.x2,e.x1-t.x2,t.y1-e.y2,e.y1-t.y2),v$=(e,t)=>{for(var n=1,i=e.length,r=e[0].bounds,o;n{const t=e.bounds;return t.width()>1&&t.height()>1},Hq=(e,t,n)=>{var i=e.range(),r=new st;return t===Au||t===Yo?r.set(i[0],-1/0,i[1],1/0):r.set(-1/0,i[0],1/0,i[1]),r.expand(n||1),o=>r.encloses(o.bounds)},x$=e=>(e.forEach(t=>t.opacity=1),e),w$=(e,t)=>e.reflow(t.modified()).modifies("opacity");Y(CR,R,{transform(e,t){const n=b$[e.method]||b$.parity,i=e.separation||0;let r=t.materialize(t.SOURCE).source,o,s;if(!r||!r.length)return;if(!e.method)return e.modified("method")&&(x$(r),t=w$(t,e)),t;if(r=r.filter(Wq),!r.length)return;if(e.sort&&(r=r.slice().sort(e.sort)),o=x$(r),t=w$(t,e),o.length>=3&&v$(o,i)){do o=n(o,i);while(o.length>=3&&v$(o,i));o.length<3&&!_e(r).opacity&&(o.length>1&&(_e(o).opacity=0),_e(r).opacity=1)}e.boundScale&&e.boundTolerance>=0&&(s=Hq(e.boundScale,e.boundOrient,+e.boundTolerance),r.forEach(u=>{s(u)||(u.opacity=0)}));const a=o[0].mark.bounds.clear();return r.forEach(u=>{u.opacity&&a.union(u.bounds)}),t}});function MR(e){R.call(this,null,e)}Y(MR,R,{transform(e,t){const n=t.dataflow;if(t.visit(t.ALL,i=>n.dirty(i)),t.fields&&t.fields.zindex){const i=t.source&&t.source[0];i&&(i.mark.zdirty=!0)}}});const zt=new st;function Ja(e,t,n){return e[t]===n?0:(e[t]=n,1)}function Gq(e){var t=e.items[0].orient;return t===bi||t===vi}function Yq(e){let t=+e.grid;return[e.ticks?t++:-1,e.labels?t++:-1,t+ +e.domain]}function Vq(e,t,n,i){var r=t.items[0],o=r.datum,s=r.translate!=null?r.translate:.5,a=r.orient,u=Yq(o),l=r.range,c=r.offset,f=r.position,d=r.minExtent,h=r.maxExtent,g=o.title&&r.items[u[2]].items[0],p=r.titlePadding,m=r.bounds,y=g&&h2(g),b=0,v=0,x,E;switch(zt.clear().union(m),m.clear(),(x=u[0])>-1&&m.union(r.items[x].bounds),(x=u[1])>-1&&m.union(r.items[x].bounds),a){case Au:b=f||0,v=-c,E=Math.max(d,Math.min(h,-m.y1)),m.add(0,-E).add(l,0),g&&dd(e,g,E,p,y,0,-1,m);break;case bi:b=-c,v=f||0,E=Math.max(d,Math.min(h,-m.x1)),m.add(-E,0).add(0,l),g&&dd(e,g,E,p,y,1,-1,m);break;case vi:b=n+c,v=f||0,E=Math.max(d,Math.min(h,m.x2)),m.add(0,0).add(E,l),g&&dd(e,g,E,p,y,1,1,m);break;case Yo:b=f||0,v=i+c,E=Math.max(d,Math.min(h,m.y2)),m.add(0,0).add(l,E),g&&dd(e,g,E,p,0,0,1,m);break;default:b=r.x,v=r.y}return io(m.translate(b,v),r),Ja(r,"x",b+s)|Ja(r,"y",v+s)&&(r.bounds=zt,e.dirty(r),r.bounds=m,e.dirty(r)),r.mark.bounds.clear().union(m)}function dd(e,t,n,i,r,o,s,a){const u=t.bounds;if(t.auto){const l=s*(n+r+i);let c=0,f=0;e.dirty(t),o?c=(t.x||0)-(t.x=l):f=(t.y||0)-(t.y=l),t.mark.bounds.clear().union(u.translate(-c,-f)),e.dirty(t)}a.union(u)}const E$=(e,t)=>Math.floor(Math.min(e,t)),_$=(e,t)=>Math.ceil(Math.max(e,t));function Xq(e){var t=e.items,n=t.length,i=0,r,o;const s={marks:[],rowheaders:[],rowfooters:[],colheaders:[],colfooters:[],rowtitle:null,coltitle:null};for(;i1)for(w=0;w0&&(v[w]+=C/2);if(a&&He(n.center,Fo)&&c!==1)for(w=0;w0&&(x[w]+=k/2);for(w=0;wr&&(e.warn("Grid headers exceed limit: "+r),t=t.slice(0,r)),p+=o,b=0,x=t.length;b=0&&(w=n[v])==null;v-=d);a?(S=h==null?w.x:Math.round(w.bounds.x1+h*w.bounds.width()),$=p):(S=p,$=h==null?w.y:Math.round(w.bounds.y1+h*w.bounds.height())),E.union(_.bounds.translate(S-(_.x||0),$-(_.y||0))),_.x=S,_.y=$,e.dirty(_),m=s(m,E[l])}return m}function $$(e,t,n,i,r,o){if(t){e.dirty(t);var s=n,a=n;i?s=Math.round(r.x1+o*r.width()):a=Math.round(r.y1+o*r.height()),t.bounds.translate(s-(t.x||0),a-(t.y||0)),t.mark.bounds.clear().union(t.bounds),t.x=s,t.y=a,e.dirty(t)}}function tW(e,t){const n=e[t]||{};return(i,r)=>n[i]!=null?n[i]:e[i]!=null?e[i]:r}function nW(e,t){let n=-1/0;return e.forEach(i=>{i.offset!=null&&(n=Math.max(n,i.offset))}),n>-1/0?n:t}function iW(e,t,n,i,r,o,s){const a=tW(n,t),u=nW(e,a("offset",0)),l=a("anchor",$2),c=l===Jt?1:l===ky?.5:0,f={align:Ay,bounds:a("bounds",M2),columns:a("direction")==="vertical"?1:e.length,padding:a("margin",8),center:a("center"),nodirty:!0};switch(t){case bi:f.anchor={x:Math.floor(i.x1)-u,column:Jt,y:c*(s||i.height()+2*i.y1),row:l};break;case vi:f.anchor={x:Math.ceil(i.x2)+u,y:c*(s||i.height()+2*i.y1),row:l};break;case Au:f.anchor={y:Math.floor(r.y1)-u,row:Jt,x:c*(o||r.width()+2*r.x1),column:l};break;case Yo:f.anchor={y:Math.ceil(r.y2)+u,x:c*(o||r.width()+2*r.x1),column:l};break;case Tq:f.anchor={x:u,y:u};break;case Nq:f.anchor={x:o-u,y:u,column:Jt};break;case Rq:f.anchor={x:u,y:s-u,row:Jt};break;case Oq:f.anchor={x:o-u,y:s-u,column:Jt,row:Jt};break}return f}function rW(e,t){var n=t.items[0],i=n.datum,r=n.orient,o=n.bounds,s=n.x,a=n.y,u,l;return n._bounds?n._bounds.clear().union(o):n._bounds=o.clone(),o.clear(),sW(e,n,n.items[0].items[0]),o=oW(n,o),u=2*n.padding,l=2*n.padding,o.empty()||(u=Math.ceil(o.width()+u),l=Math.ceil(o.height()+l)),i.type===Bq&&aW(n.items[0].items[0].items[0].items),r!==F2&&(n.x=s=0,n.y=a=0),n.width=u,n.height=l,io(o.set(s,a,s+u,a+l),n),n.mark.bounds.clear().union(o),n}function oW(e,t){return e.items.forEach(n=>t.union(n.bounds)),t.x1=e.padding,t.y1=e.padding,t}function sW(e,t,n){var i=t.padding,r=i-n.x,o=i-n.y;if(!t.datum.title)(r||o)&&Ol(e,n,r,o);else{var s=t.items[1].items[0],a=s.anchor,u=t.titlePadding||0,l=i-s.x,c=i-s.y;switch(s.orient){case bi:r+=Math.ceil(s.bounds.width())+u;break;case vi:case Yo:break;default:o+=s.bounds.height()+u}switch((r||o)&&Ol(e,n,r,o),s.orient){case bi:c+=Pa(t,n,s,a,1,1);break;case vi:l+=Pa(t,n,s,Jt,0,0)+u,c+=Pa(t,n,s,a,1,1);break;case Yo:l+=Pa(t,n,s,a,0,0),c+=Pa(t,n,s,Jt,-1,0,1)+u;break;default:l+=Pa(t,n,s,a,0,0)}(l||c)&&Ol(e,s,l,c),(l=Math.round(s.bounds.x1-i))<0&&(Ol(e,n,-l,0),Ol(e,s,-l,0))}}function Pa(e,t,n,i,r,o,s){const a=e.datum.type!=="symbol",u=n.datum.vgrad,l=a&&(o||!u)&&!s?t.items[0]:t,c=l.bounds[r?"y2":"x2"]-e.padding,f=u&&o?c:0,d=u&&o?0:c,h=r<=0?0:h2(n);return Math.round(i===$2?f:i===Jt?d-h:.5*(c-h))}function Ol(e,t,n,i){t.x+=n,t.y+=i,t.bounds.translate(n,i),t.mark.bounds.translate(n,i),e.dirty(t)}function aW(e){const t=e.reduce((n,i)=>(n[i.column]=Math.max(i.bounds.x2-i.x,n[i.column]||0),n),{});e.forEach(n=>{n.width=t[n.column],n.height=n.bounds.y2-n.y})}function uW(e,t,n,i,r){var o=t.items[0],s=o.frame,a=o.orient,u=o.anchor,l=o.offset,c=o.padding,f=o.items[0].items[0],d=o.items[1]&&o.items[1].items[0],h=a===bi||a===vi?i:n,g=0,p=0,m=0,y=0,b=0,v;if(s!==zp?a===bi?(g=r.y2,h=r.y1):a===vi?(g=r.y1,h=r.y2):(g=r.x1,h=r.x2):a===bi&&(g=i,h=0),v=u===$2?g:u===Jt?h:(g+h)/2,d&&d.text){switch(a){case Au:case Yo:b=f.bounds.height()+c;break;case bi:y=f.bounds.width()+c;break;case vi:y=-f.bounds.width()-c;break}zt.clear().union(d.bounds),zt.translate(y-(d.x||0),b-(d.y||0)),Ja(d,"x",y)|Ja(d,"y",b)&&(e.dirty(d),d.bounds.clear().union(zt),d.mark.bounds.clear().union(zt),e.dirty(d)),zt.clear().union(d.bounds)}else zt.clear();switch(zt.union(f.bounds),a){case Au:p=v,m=r.y1-zt.height()-l;break;case bi:p=r.x1-zt.width()-l,m=v;break;case vi:p=r.x2+zt.width()+l,m=v;break;case Yo:p=v,m=r.y2+l;break;default:p=o.x,m=o.y}return Ja(o,"x",p)|Ja(o,"y",m)&&(zt.translate(p,m),e.dirty(o),o.bounds.clear().union(zt),t.bounds.clear().union(zt),e.dirty(o)),o.bounds}function NR(e){R.call(this,null,e)}Y(NR,R,{transform(e,t){const n=t.dataflow;return e.mark.items.forEach(i=>{e.layout&&Qq(n,i,e.layout),cW(n,i,e)}),lW(e.mark.group)?t.reflow():t}});function lW(e){return e&&e.mark.role!=="legend-entry"}function cW(e,t,n){var i=t.items,r=Math.max(0,t.width||0),o=Math.max(0,t.height||0),s=new st().set(0,0,r,o),a=s.clone(),u=s.clone(),l=[],c,f,d,h,g,p;for(g=0,p=i.length;g{d=y.orient||vi,d!==F2&&(m[d]||(m[d]=[])).push(y)});for(const y in m){const b=m[y];TR(e,b,iW(b,y,n.legends,a,u,r,o))}l.forEach(y=>{const b=y.bounds;if(b.equals(y._bounds)||(y.bounds=y._bounds,e.dirty(y),y.bounds=b,e.dirty(y)),n.autosize&&(n.autosize.type===_R||n.autosize.type===SR||n.autosize.type===$R))switch(y.orient){case bi:case vi:s.add(b.x1,0).add(b.x2,0);break;case Au:case Yo:s.add(0,b.y1).add(0,b.y2)}else s.union(b)})}s.union(a).union(u),c&&s.union(uW(e,c,r,o,s)),t.clip&&s.set(0,0,t.width||0,t.height||0),fW(e,t,s,n)}function fW(e,t,n,i){const r=i.autosize||{},o=r.type;if(e._autosize<1||!o)return;let s=e._width,a=e._height,u=Math.max(0,t.width||0),l=Math.max(0,Math.ceil(-n.x1)),c=Math.max(0,t.height||0),f=Math.max(0,Math.ceil(-n.y1));const d=Math.max(0,Math.ceil(n.x2-u)),h=Math.max(0,Math.ceil(n.y2-c));if(r.contains===zq){const g=e.padding();s-=g.left+g.right,a-=g.top+g.bottom}o===F2?(l=0,f=0,u=s,c=a):o===_R?(u=Math.max(0,s-l-d),c=Math.max(0,a-f-h)):o===SR?(u=Math.max(0,s-l-d),a=c+f+h):o===$R?(s=u+l+d,c=Math.max(0,a-f-h)):o===Uq&&(s=u+l+d,a=c+f+h),e._resizeView(s,a,u,c,[l,f],r.resize)}const dW=Object.freeze(Object.defineProperty({__proto__:null,bound:kR,identifier:T2,mark:AR,overlap:CR,render:MR,viewlayout:NR},Symbol.toStringTag,{value:"Module"}));function RR(e){R.call(this,null,e)}Y(RR,R,{transform(e,t){if(this.value&&!e.modified())return t.StopPropagation;var n=t.dataflow.locale(),i=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=this.value,o=e.scale,s=e.count==null?e.values?e.values.length:10:e.count,a=Xx(o,s,e.minstep),u=e.format||a3(n,o,a,e.formatSpecifier,e.formatType,!!e.values),l=e.values?s3(o,e.values,a):Kx(o,a);return r&&(i.rem=r),r=l.map((c,f)=>Fe({index:f/(l.length-1||1),value:c,label:u(c)})),e.extra&&r.length&&r.push(Fe({index:-1,extra:{value:r[0].value},label:""})),i.source=r,i.add=r,this.value=r,i}});function OR(e){R.call(this,null,e)}function hW(){return Fe({})}function gW(e){const t=el().test(n=>n.exit);return t.lookup=n=>t.get(e(n)),t}Y(OR,R,{transform(e,t){var n=t.dataflow,i=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=e.item||hW,o=e.key||re,s=this.value;return P(i.encode)&&(i.encode=null),s&&(e.modified("key")||t.modified(o))&&O("DataJoin does not support modified key function or fields."),s||(t=t.addAll(),this.value=s=gW(o)),t.visit(t.ADD,a=>{const u=o(a);let l=s.get(u);l?l.exit?(s.empty--,i.add.push(l)):i.mod.push(l):(l=r(a),s.set(u,l),i.add.push(l)),l.datum=a,l.exit=!1}),t.visit(t.MOD,a=>{const u=o(a),l=s.get(u);l&&(l.datum=a,i.mod.push(l))}),t.visit(t.REM,a=>{const u=o(a),l=s.get(u);a===l.datum&&!l.exit&&(i.rem.push(l),l.exit=!0,++s.empty)}),t.changed(t.ADD_MOD)&&i.modifies("datum"),(t.clean()||e.clean&&s.empty>n.cleanThreshold)&&n.runAfter(s.clean),i}});function DR(e){R.call(this,null,e)}Y(DR,R,{transform(e,t){var n=t.fork(t.ADD_REM),i=e.mod||!1,r=e.encoders,o=t.encode;if(P(o))if(n.changed()||o.every(f=>r[f]))o=o[0],n.encode=null;else return t.StopPropagation;var s=o==="enter",a=r.update||po,u=r.enter||po,l=r.exit||po,c=(o&&!s?r[o]:a)||po;if(t.changed(t.ADD)&&(t.visit(t.ADD,f=>{u(f,e),a(f,e)}),n.modifies(u.output),n.modifies(a.output),c!==po&&c!==a&&(t.visit(t.ADD,f=>{c(f,e)}),n.modifies(c.output))),t.changed(t.REM)&&l!==po&&(t.visit(t.REM,f=>{l(f,e)}),n.modifies(l.output)),s||c!==po){const f=t.MOD|(e.modified()?t.REFLOW:0);s?(t.visit(f,d=>{const h=u(d,e)||i;(c(d,e)||h)&&n.mod.push(d)}),n.mod.length&&n.modifies(u.output)):t.visit(f,d=>{(c(d,e)||i)&&n.mod.push(d)}),n.mod.length&&n.modifies(c.output)}return n.changed()?n:t.StopPropagation}});function LR(e){R.call(this,[],e)}Y(LR,R,{transform(e,t){if(this.value!=null&&!e.modified())return t.StopPropagation;var n=t.dataflow.locale(),i=t.fork(t.NO_SOURCE|t.NO_FIELDS),r=this.value,o=e.type||Wd,s=e.scale,a=+e.limit,u=Xx(s,e.count==null?5:e.count,e.minstep),l=!!e.values||o===Wd,c=e.format||f3(n,s,u,o,e.formatSpecifier,e.formatType,l),f=e.values||c3(s,u),d,h,g,p,m;return r&&(i.rem=r),o===Wd?(a&&f.length>a?(t.dataflow.warn("Symbol legend count exceeds limit, filtering items."),r=f.slice(0,a-1),m=!0):r=f,de(g=e.size)?(!e.values&&s(r[0])===0&&(r=r.slice(1)),p=r.reduce((y,b)=>Math.max(y,g(b,e)),0)):g=Yt(p=g||8),r=r.map((y,b)=>Fe({index:b,label:c(y,b,r),value:y,offset:p,size:g(y,e)})),m&&(m=f[r.length],r.push(Fe({index:r.length,label:`…${f.length-r.length} entries`,value:m,offset:p,size:g(m,e)})))):o===BB?(d=s.domain(),h=i3(s,d[0],_e(d)),f.length<3&&!e.values&&d[0]!==_e(d)&&(f=[d[0],_e(d)]),r=f.map((y,b)=>Fe({index:b,label:c(y,b,f),value:y,perc:h(y)}))):(g=f.length-1,h=JB(s),r=f.map((y,b)=>Fe({index:b,label:c(y,b,f),value:y,perc:b?h(y):0,perc2:b===g?1:h(f[b+1])}))),i.source=r,i.add=r,this.value=r,i}});const pW=e=>e.source.x,mW=e=>e.source.y,yW=e=>e.target.x,bW=e=>e.target.y;function N2(e){R.call(this,{},e)}N2.Definition={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]};Y(N2,R,{transform(e,t){var n=e.sourceX||pW,i=e.sourceY||mW,r=e.targetX||yW,o=e.targetY||bW,s=e.as||"path",a=e.orient||"vertical",u=e.shape||"line",l=k$.get(u+"-"+a)||k$.get(u);return l||O("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),t.visit(t.SOURCE,c=>{c[s]=l(n(c),i(c),r(c),o(c))}),t.reflow(e.modified()).modifies(s)}});const PR=(e,t,n,i)=>"M"+e+","+t+"L"+n+","+i,vW=(e,t,n,i)=>PR(t*Math.cos(e),t*Math.sin(e),i*Math.cos(n),i*Math.sin(n)),IR=(e,t,n,i)=>{var r=n-e,o=i-t,s=Math.hypot(r,o)/2,a=180*Math.atan2(o,r)/Math.PI;return"M"+e+","+t+"A"+s+","+s+" "+a+" 0 1 "+n+","+i},xW=(e,t,n,i)=>IR(t*Math.cos(e),t*Math.sin(e),i*Math.cos(n),i*Math.sin(n)),zR=(e,t,n,i)=>{const r=n-e,o=i-t,s=.2*(r+o),a=.2*(o-r);return"M"+e+","+t+"C"+(e+s)+","+(t+a)+" "+(n+a)+","+(i-s)+" "+n+","+i},wW=(e,t,n,i)=>zR(t*Math.cos(e),t*Math.sin(e),i*Math.cos(n),i*Math.sin(n)),EW=(e,t,n,i)=>"M"+e+","+t+"V"+i+"H"+n,_W=(e,t,n,i)=>"M"+e+","+t+"H"+n+"V"+i,SW=(e,t,n,i)=>{const r=Math.cos(e),o=Math.sin(e),s=Math.cos(n),a=Math.sin(n),u=Math.abs(n-e)>Math.PI?n<=e:n>e;return"M"+t*r+","+t*o+"A"+t+","+t+" 0 0,"+(u?1:0)+" "+t*s+","+t*a+"L"+i*s+","+i*a},$W=(e,t,n,i)=>{const r=(e+n)/2;return"M"+e+","+t+"C"+r+","+t+" "+r+","+i+" "+n+","+i},kW=(e,t,n,i)=>{const r=(t+i)/2;return"M"+e+","+t+"C"+e+","+r+" "+n+","+r+" "+n+","+i},AW=(e,t,n,i)=>{const r=Math.cos(e),o=Math.sin(e),s=Math.cos(n),a=Math.sin(n),u=(t+i)/2;return"M"+t*r+","+t*o+"C"+u*r+","+u*o+" "+u*s+","+u*a+" "+i*s+","+i*a},k$=el({line:PR,"line-radial":vW,arc:IR,"arc-radial":xW,curve:zR,"curve-radial":wW,"orthogonal-horizontal":EW,"orthogonal-vertical":_W,"orthogonal-radial":SW,"diagonal-horizontal":$W,"diagonal-vertical":kW,"diagonal-radial":AW});function R2(e){R.call(this,null,e)}R2.Definition={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]};Y(R2,R,{transform(e,t){var n=e.as||["startAngle","endAngle"],i=n[0],r=n[1],o=e.field||Ku,s=e.startAngle||0,a=e.endAngle!=null?e.endAngle:2*Math.PI,u=t.source,l=u.map(o),c=l.length,f=s,d=(a-s)/tM(l),h=Nn(c),g,p,m;for(e.sort&&h.sort((y,b)=>l[y]-l[b]),g=0;g-1)return i;var r=t.domain,o=e.type,s=t.zero||t.zero===void 0&&FW(e),a,u;if(!r)return 0;if((s||t.domainMin!=null||t.domainMax!=null||t.domainMid!=null)&&(a=(r=r.slice()).length-1||1,s&&(r[0]>0&&(r[0]=0),r[a]<0&&(r[a]=0)),t.domainMin!=null&&(r[0]=t.domainMin),t.domainMax!=null&&(r[a]=t.domainMax),t.domainMid!=null)){u=t.domainMid;const l=u>r[a]?a+1:ur+(o<0?-1:o>0?1:0),0));i!==t.length&&n.warn("Log scale domain includes zero: "+G(t))}return t}function LW(e,t,n){let i=t.bins;if(i&&!P(i)){const r=e.domain(),o=r[0],s=_e(r),a=i.step;let u=i.start==null?o:i.start,l=i.stop==null?s:i.stop;a||O("Scale bins parameter missing step property."),us&&(l=a*Math.floor(s/a)),i=Nn(u,l+a/2,a)}return i?e.bins=i:e.bins&&delete e.bins,e.type===qx&&(i?!t.domain&&!t.domainRaw&&(e.domain(i),n=i.length):e.bins=e.domain()),n}function PW(e,t,n){var i=e.type,r=t.round||!1,o=t.range;if(t.rangeStep!=null)o=IW(i,t,n);else if(t.scheme&&(o=zW(i,t,n),de(o))){if(e.interpolator)return e.interpolator(o);O(`Scale type ${i} does not support interpolating color schemes.`)}if(o&&ZN(i))return e.interpolator(Ap(Cy(o,t.reverse),t.interpolate,t.interpolateGamma));o&&t.interpolate&&e.interpolate?e.interpolate(Yx(t.interpolate,t.interpolateGamma)):de(e.round)?e.round(r):de(e.rangeRound)&&e.interpolate(r?gf:ts),o&&e.range(Cy(o,t.reverse))}function IW(e,t,n){e!==GN&&e!==hy&&O("Only band and point scales support rangeStep.");var i=(t.paddingOuter!=null?t.paddingOuter:t.padding)||0,r=e===hy?1:(t.paddingInner!=null?t.paddingInner:t.padding)||0;return[0,t.rangeStep*Ux(n,r,i)]}function zW(e,t,n){var i=t.schemeExtent,r,o;return P(t.scheme)?o=Ap(t.scheme,t.interpolate,t.interpolateGamma):(r=t.scheme.toLowerCase(),o=Vx(r),o||O(`Unrecognized scheme name: ${t.scheme}`)),n=e===kp?n+1:e===qx?n-1:e===Eu||e===$p?+t.schemeCount||CW:n,ZN(e)?A$(o,i,t.reverse):de(o)?n3(A$(o,i),n):e===jx?o:o.slice(0,n)}function A$(e,t,n){return de(e)&&(t||n)?t3(e,Cy(t||[0,1],n)):e}function Cy(e,t){return t?e.slice().reverse():e}function qR(e){R.call(this,null,e)}Y(qR,R,{transform(e,t){const n=e.modified("sort")||t.changed(t.ADD)||t.modified(e.sort.fields)||t.modified("datum");return n&&t.source.sort(ba(e.sort)),this.modified(n),t}});const C$="zero",WR="center",HR="normalize",GR=["y0","y1"];function O2(e){R.call(this,null,e)}O2.Definition={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:C$,values:[C$,WR,HR]},{name:"as",type:"string",array:!0,length:2,default:GR}]};Y(O2,R,{transform(e,t){var n=e.as||GR,i=n[0],r=n[1],o=ba(e.sort),s=e.field||Ku,a=e.offset===WR?BW:e.offset===HR?UW:jW,u,l,c,f;for(u=qW(t.source,e.groupby,o,s),l=0,c=u.length,f=u.max;lp(c),s,a,u,l,c,f,d,h,g;if(t==null)r.push(e.slice());else for(s={},a=0,u=e.length;ag&&(g=h),n&&d.sort(n)}return r.max=g,r}const WW=Object.freeze(Object.defineProperty({__proto__:null,axisticks:RR,datajoin:OR,encode:DR,legendentries:LR,linkpath:N2,pie:R2,scale:UR,sortitems:qR,stack:O2},Symbol.toStringTag,{value:"Module"}));var ae=1e-6,Gh=1e-12,xe=Math.PI,Qe=xe/2,Yh=xe/4,un=xe*2,tt=180/xe,be=xe/180,Ee=Math.abs,cl=Math.atan,ri=Math.atan2,ue=Math.cos,gd=Math.ceil,YR=Math.exp,Fy=Math.hypot,Vh=Math.log,A0=Math.pow,oe=Math.sin,Xn=Math.sign||function(e){return e>0?1:e<0?-1:0},ln=Math.sqrt,D2=Math.tan;function VR(e){return e>1?0:e<-1?xe:Math.acos(e)}function En(e){return e>1?Qe:e<-1?-Qe:Math.asin(e)}function Ft(){}function Xh(e,t){e&&M$.hasOwnProperty(e.type)&&M$[e.type](e,t)}var F$={Feature:function(e,t){Xh(e.geometry,t)},FeatureCollection:function(e,t){for(var n=e.features,i=-1,r=n.length;++i=0?1:-1,r=i*n,o=ue(t),s=oe(t),a=Ry*s,u=Ny*o+a*ue(r),l=a*i*oe(r);Kh.add(ri(l,u)),Ty=e,Ny=o,Ry=s}function VW(e){return Jh=new sn,Rr(e,ar),Jh*2}function Qh(e){return[ri(e[1],e[0]),En(e[2])]}function Js(e){var t=e[0],n=e[1],i=ue(n);return[i*ue(t),i*oe(t),oe(n)]}function pd(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Cu(e,t){return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]}function C0(e,t){e[0]+=t[0],e[1]+=t[1],e[2]+=t[2]}function md(e,t){return[e[0]*t,e[1]*t,e[2]*t]}function Zh(e){var t=ln(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);e[0]/=t,e[1]/=t,e[2]/=t}var Ve,pn,Ke,Mn,$s,QR,ZR,ou,xc,xo,Jr,Tr={point:Oy,lineStart:N$,lineEnd:R$,polygonStart:function(){Tr.point=tO,Tr.lineStart=XW,Tr.lineEnd=KW,xc=new sn,ar.polygonStart()},polygonEnd:function(){ar.polygonEnd(),Tr.point=Oy,Tr.lineStart=N$,Tr.lineEnd=R$,Kh<0?(Ve=-(Ke=180),pn=-(Mn=90)):xc>ae?Mn=90:xc<-ae&&(pn=-90),Jr[0]=Ve,Jr[1]=Ke},sphere:function(){Ve=-(Ke=180),pn=-(Mn=90)}};function Oy(e,t){xo.push(Jr=[Ve=e,Ke=e]),tMn&&(Mn=t)}function eO(e,t){var n=Js([e*be,t*be]);if(ou){var i=Cu(ou,n),r=[i[1],-i[0],0],o=Cu(r,i);Zh(o),o=Qh(o);var s=e-$s,a=s>0?1:-1,u=o[0]*tt*a,l,c=Ee(s)>180;c^(a*$sMn&&(Mn=l)):(u=(u+360)%360-180,c^(a*$sMn&&(Mn=t))),c?e<$s?Fn(Ve,e)>Fn(Ve,Ke)&&(Ke=e):Fn(e,Ke)>Fn(Ve,Ke)&&(Ve=e):Ke>=Ve?(eKe&&(Ke=e)):e>$s?Fn(Ve,e)>Fn(Ve,Ke)&&(Ke=e):Fn(e,Ke)>Fn(Ve,Ke)&&(Ve=e)}else xo.push(Jr=[Ve=e,Ke=e]);tMn&&(Mn=t),ou=n,$s=e}function N$(){Tr.point=eO}function R$(){Jr[0]=Ve,Jr[1]=Ke,Tr.point=Oy,ou=null}function tO(e,t){if(ou){var n=e-$s;xc.add(Ee(n)>180?n+(n>0?360:-360):n)}else QR=e,ZR=t;ar.point(e,t),eO(e,t)}function XW(){ar.lineStart()}function KW(){tO(QR,ZR),ar.lineEnd(),Ee(xc)>ae&&(Ve=-(Ke=180)),Jr[0]=Ve,Jr[1]=Ke,ou=null}function Fn(e,t){return(t-=e)<0?t+360:t}function JW(e,t){return e[0]-t[0]}function O$(e,t){return e[0]<=e[1]?e[0]<=t&&t<=e[1]:tFn(i[0],i[1])&&(i[1]=r[1]),Fn(r[0],i[1])>Fn(i[0],i[1])&&(i[0]=r[0])):o.push(i=r);for(s=-1/0,n=o.length-1,t=0,i=o[n];t<=n;i=r,++t)r=o[t],(a=Fn(i[1],r[0]))>s&&(s=a,Ve=r[0],Ke=i[1])}return xo=Jr=null,Ve===1/0||pn===1/0?[[NaN,NaN],[NaN,NaN]]:[[Ve,pn],[Ke,Mn]]}var ic,eg,tg,ng,ig,rg,og,sg,Dy,Ly,Py,nO,iO,Qt,Zt,en,xi={sphere:Ft,point:L2,lineStart:D$,lineEnd:L$,polygonStart:function(){xi.lineStart=tH,xi.lineEnd=nH},polygonEnd:function(){xi.lineStart=D$,xi.lineEnd=L$}};function L2(e,t){e*=be,t*=be;var n=ue(t);Ff(n*ue(e),n*oe(e),oe(t))}function Ff(e,t,n){++ic,tg+=(e-tg)/ic,ng+=(t-ng)/ic,ig+=(n-ig)/ic}function D$(){xi.point=ZW}function ZW(e,t){e*=be,t*=be;var n=ue(t);Qt=n*ue(e),Zt=n*oe(e),en=oe(t),xi.point=eH,Ff(Qt,Zt,en)}function eH(e,t){e*=be,t*=be;var n=ue(t),i=n*ue(e),r=n*oe(e),o=oe(t),s=ri(ln((s=Zt*o-en*r)*s+(s=en*i-Qt*o)*s+(s=Qt*r-Zt*i)*s),Qt*i+Zt*r+en*o);eg+=s,rg+=s*(Qt+(Qt=i)),og+=s*(Zt+(Zt=r)),sg+=s*(en+(en=o)),Ff(Qt,Zt,en)}function L$(){xi.point=L2}function tH(){xi.point=iH}function nH(){rO(nO,iO),xi.point=L2}function iH(e,t){nO=e,iO=t,e*=be,t*=be,xi.point=rO;var n=ue(t);Qt=n*ue(e),Zt=n*oe(e),en=oe(t),Ff(Qt,Zt,en)}function rO(e,t){e*=be,t*=be;var n=ue(t),i=n*ue(e),r=n*oe(e),o=oe(t),s=Zt*o-en*r,a=en*i-Qt*o,u=Qt*r-Zt*i,l=Fy(s,a,u),c=En(l),f=l&&-c/l;Dy.add(f*s),Ly.add(f*a),Py.add(f*u),eg+=c,rg+=c*(Qt+(Qt=i)),og+=c*(Zt+(Zt=r)),sg+=c*(en+(en=o)),Ff(Qt,Zt,en)}function rH(e){ic=eg=tg=ng=ig=rg=og=sg=0,Dy=new sn,Ly=new sn,Py=new sn,Rr(e,xi);var t=+Dy,n=+Ly,i=+Py,r=Fy(t,n,i);return rxe&&(e-=Math.round(e/un)*un),[e,t]}zy.invert=zy;function oO(e,t,n){return(e%=un)?t||n?Iy(I$(e),z$(t,n)):I$(e):t||n?z$(t,n):zy}function P$(e){return function(t,n){return t+=e,Ee(t)>xe&&(t-=Math.round(t/un)*un),[t,n]}}function I$(e){var t=P$(e);return t.invert=P$(-e),t}function z$(e,t){var n=ue(e),i=oe(e),r=ue(t),o=oe(t);function s(a,u){var l=ue(u),c=ue(a)*l,f=oe(a)*l,d=oe(u),h=d*n+c*i;return[ri(f*r-h*o,c*n-d*i),En(h*r+f*o)]}return s.invert=function(a,u){var l=ue(u),c=ue(a)*l,f=oe(a)*l,d=oe(u),h=d*r-f*o;return[ri(f*r+d*o,c*n+h*i),En(h*n-c*i)]},s}function oH(e){e=oO(e[0]*be,e[1]*be,e.length>2?e[2]*be:0);function t(n){return n=e(n[0]*be,n[1]*be),n[0]*=tt,n[1]*=tt,n}return t.invert=function(n){return n=e.invert(n[0]*be,n[1]*be),n[0]*=tt,n[1]*=tt,n},t}function sH(e,t,n,i,r,o){if(n){var s=ue(t),a=oe(t),u=i*n;r==null?(r=t+i*un,o=t-u/2):(r=B$(s,r),o=B$(s,o),(i>0?ro)&&(r+=i*un));for(var l,c=r;i>0?c>o:c1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Zd(e,t){return Ee(e[0]-t[0])=0;--a)r.point((f=c[a])[0],f[1]);else i(d.x,d.p.x,-1,r);d=d.p}d=d.o,c=d.z,h=!h}while(!d.v);r.lineEnd()}}}function U$(e){if(t=e.length){for(var t,n=0,i=e[0],r;++n=0?1:-1,A=$*S,F=A>xe,T=m*_;if(u.add(ri(T*$*oe(A),y*w+T*ue(A))),s+=F?S+$*un:S,F^g>=n^x>=n){var N=Cu(Js(h),Js(v));Zh(N);var C=Cu(o,N);Zh(C);var k=(F^S>=0?-1:1)*En(C[2]);(i>k||i===k&&(N[0]||N[1]))&&(a+=F^S>=0?1:-1)}}return(s<-ae||s0){for(u||(r.polygonStart(),u=!0),r.lineStart(),_=0;_1&&x&2&&E.push(E.pop().concat(E.shift())),c.push(E.filter(uH))}}return d}}function uH(e){return e.length>1}function lH(e,t){return((e=e.x)[0]<0?e[1]-Qe-ae:Qe-e[1])-((t=t.x)[0]<0?t[1]-Qe-ae:Qe-t[1])}const j$=uO(function(){return!0},cH,dH,[-xe,-Qe]);function cH(e){var t=NaN,n=NaN,i=NaN,r;return{lineStart:function(){e.lineStart(),r=1},point:function(o,s){var a=o>0?xe:-xe,u=Ee(o-t);Ee(u-xe)0?Qe:-Qe),e.point(i,n),e.lineEnd(),e.lineStart(),e.point(a,n),e.point(o,n),r=0):i!==a&&u>=xe&&(Ee(t-i)ae?cl((oe(t)*(o=ue(i))*oe(n)-oe(i)*(r=ue(t))*oe(e))/(r*o*s)):(t+i)/2}function dH(e,t,n,i){var r;if(e==null)r=n*Qe,i.point(-xe,r),i.point(0,r),i.point(xe,r),i.point(xe,0),i.point(xe,-r),i.point(0,-r),i.point(-xe,-r),i.point(-xe,0),i.point(-xe,r);else if(Ee(e[0]-t[0])>ae){var o=e[0]0,r=Ee(t)>ae;function o(c,f,d,h){sH(h,e,n,d,c,f)}function s(c,f){return ue(c)*ue(f)>t}function a(c){var f,d,h,g,p;return{lineStart:function(){g=h=!1,p=1},point:function(m,y){var b=[m,y],v,x=s(m,y),E=i?x?0:l(m,y):x?l(m+(m<0?xe:-xe),y):0;if(!f&&(g=h=x)&&c.lineStart(),x!==h&&(v=u(f,b),(!v||Zd(f,v)||Zd(b,v))&&(b[2]=1)),x!==h)p=0,x?(c.lineStart(),v=u(b,f),c.point(v[0],v[1])):(v=u(f,b),c.point(v[0],v[1],2),c.lineEnd()),f=v;else if(r&&f&&i^x){var _;!(E&d)&&(_=u(b,f,!0))&&(p=0,i?(c.lineStart(),c.point(_[0][0],_[0][1]),c.point(_[1][0],_[1][1]),c.lineEnd()):(c.point(_[1][0],_[1][1]),c.lineEnd(),c.lineStart(),c.point(_[0][0],_[0][1],3)))}x&&(!f||!Zd(f,b))&&c.point(b[0],b[1]),f=b,h=x,d=E},lineEnd:function(){h&&c.lineEnd(),f=null},clean:function(){return p|(g&&h)<<1}}}function u(c,f,d){var h=Js(c),g=Js(f),p=[1,0,0],m=Cu(h,g),y=pd(m,m),b=m[0],v=y-b*b;if(!v)return!d&&c;var x=t*y/v,E=-t*b/v,_=Cu(p,m),w=md(p,x),S=md(m,E);C0(w,S);var $=_,A=pd(w,$),F=pd($,$),T=A*A-F*(pd(w,w)-1);if(!(T<0)){var N=ln(T),C=md($,(-A-N)/F);if(C0(C,w),C=Qh(C),!d)return C;var k=c[0],M=f[0],D=c[1],B=f[1],z;M0^C[1]<(Ee(C[0]-k)xe^(k<=C[0]&&C[0]<=M)){var he=md($,(-A+N)/F);return C0(he,w),[C,Qh(he)]}}}function l(c,f){var d=i?e:xe-e,h=0;return c<-d?h|=1:c>d&&(h|=2),f<-d?h|=4:f>d&&(h|=8),h}return uO(s,a,o,i?[0,-e]:[-xe,e-xe])}function gH(e,t,n,i,r,o){var s=e[0],a=e[1],u=t[0],l=t[1],c=0,f=1,d=u-s,h=l-a,g;if(g=n-s,!(!d&&g>0)){if(g/=d,d<0){if(g0){if(g>f)return;g>c&&(c=g)}if(g=r-s,!(!d&&g<0)){if(g/=d,d<0){if(g>f)return;g>c&&(c=g)}else if(d>0){if(g0)){if(g/=h,h<0){if(g0){if(g>f)return;g>c&&(c=g)}if(g=o-a,!(!h&&g<0)){if(g/=h,h<0){if(g>f)return;g>c&&(c=g)}else if(h>0){if(g0&&(e[0]=s+c*d,e[1]=a+c*h),f<1&&(t[0]=s+f*d,t[1]=a+f*h),!0}}}}}var rc=1e9,bd=-rc;function lO(e,t,n,i){function r(l,c){return e<=l&&l<=n&&t<=c&&c<=i}function o(l,c,f,d){var h=0,g=0;if(l==null||(h=s(l,f))!==(g=s(c,f))||u(l,c)<0^f>0)do d.point(h===0||h===3?e:n,h>1?i:t);while((h=(h+f+4)%4)!==g);else d.point(c[0],c[1])}function s(l,c){return Ee(l[0]-e)0?0:3:Ee(l[0]-n)0?2:1:Ee(l[1]-t)0?1:0:c>0?3:2}function a(l,c){return u(l.x,c.x)}function u(l,c){var f=s(l,1),d=s(c,1);return f!==d?f-d:f===0?c[1]-l[1]:f===1?l[0]-c[0]:f===2?l[1]-c[1]:c[0]-l[0]}return function(l){var c=l,f=sO(),d,h,g,p,m,y,b,v,x,E,_,w={point:S,lineStart:T,lineEnd:N,polygonStart:A,polygonEnd:F};function S(k,M){r(k,M)&&c.point(k,M)}function $(){for(var k=0,M=0,D=h.length;Mi&&(Ie-se)*(i-he)>(ge-he)*(e-se)&&++k:ge<=i&&(Ie-se)*(i-he)<(ge-he)*(e-se)&&--k;return k}function A(){c=f,d=[],h=[],_=!0}function F(){var k=$(),M=_&&k,D=(d=eM(d)).length;(M||D)&&(l.polygonStart(),M&&(l.lineStart(),o(null,null,1,l),l.lineEnd()),D&&aO(d,a,k,o,l),l.polygonEnd()),c=l,d=h=g=null}function T(){w.point=C,h&&h.push(g=[]),E=!0,x=!1,b=v=NaN}function N(){d&&(C(p,m),y&&x&&f.rejoin(),d.push(f.result())),w.point=S,x&&c.lineEnd()}function C(k,M){var D=r(k,M);if(h&&g.push([k,M]),E)p=k,m=M,y=D,E=!1,D&&(c.lineStart(),c.point(k,M));else if(D&&x)c.point(k,M);else{var B=[b=Math.max(bd,Math.min(rc,b)),v=Math.max(bd,Math.min(rc,v))],z=[k=Math.max(bd,Math.min(rc,k)),M=Math.max(bd,Math.min(rc,M))];gH(B,z,e,t,n,i)?(x||(c.lineStart(),c.point(B[0],B[1])),c.point(z[0],z[1]),D||c.lineEnd(),_=!1):D&&(c.lineStart(),c.point(k,M),_=!1)}b=k,v=M,x=D}return w}}function q$(e,t,n){var i=Nn(e,t-ae,n).concat(t);return function(r){return i.map(function(o){return[r,o]})}}function W$(e,t,n){var i=Nn(e,t-ae,n).concat(t);return function(r){return i.map(function(o){return[o,r]})}}function pH(){var e,t,n,i,r,o,s,a,u=10,l=u,c=90,f=360,d,h,g,p,m=2.5;function y(){return{type:"MultiLineString",coordinates:b()}}function b(){return Nn(gd(i/c)*c,n,c).map(g).concat(Nn(gd(a/f)*f,s,f).map(p)).concat(Nn(gd(t/u)*u,e,u).filter(function(v){return Ee(v%c)>ae}).map(d)).concat(Nn(gd(o/l)*l,r,l).filter(function(v){return Ee(v%f)>ae}).map(h))}return y.lines=function(){return b().map(function(v){return{type:"LineString",coordinates:v}})},y.outline=function(){return{type:"Polygon",coordinates:[g(i).concat(p(s).slice(1),g(n).reverse().slice(1),p(a).reverse().slice(1))]}},y.extent=function(v){return arguments.length?y.extentMajor(v).extentMinor(v):y.extentMinor()},y.extentMajor=function(v){return arguments.length?(i=+v[0][0],n=+v[1][0],a=+v[0][1],s=+v[1][1],i>n&&(v=i,i=n,n=v),a>s&&(v=a,a=s,s=v),y.precision(m)):[[i,a],[n,s]]},y.extentMinor=function(v){return arguments.length?(t=+v[0][0],e=+v[1][0],o=+v[0][1],r=+v[1][1],t>e&&(v=t,t=e,e=v),o>r&&(v=o,o=r,r=v),y.precision(m)):[[t,o],[e,r]]},y.step=function(v){return arguments.length?y.stepMajor(v).stepMinor(v):y.stepMinor()},y.stepMajor=function(v){return arguments.length?(c=+v[0],f=+v[1],y):[c,f]},y.stepMinor=function(v){return arguments.length?(u=+v[0],l=+v[1],y):[u,l]},y.precision=function(v){return arguments.length?(m=+v,d=q$(o,r,90),h=W$(t,e,m),g=q$(a,s,90),p=W$(i,n,m),y):m},y.extentMajor([[-180,-90+ae],[180,90-ae]]).extentMinor([[-180,-80-ae],[180,80+ae]])}const jc=e=>e;var M0=new sn,By=new sn,cO,fO,Uy,jy,Or={point:Ft,lineStart:Ft,lineEnd:Ft,polygonStart:function(){Or.lineStart=mH,Or.lineEnd=bH},polygonEnd:function(){Or.lineStart=Or.lineEnd=Or.point=Ft,M0.add(Ee(By)),By=new sn},result:function(){var e=M0/2;return M0=new sn,e}};function mH(){Or.point=yH}function yH(e,t){Or.point=dO,cO=Uy=e,fO=jy=t}function dO(e,t){By.add(jy*e-Uy*t),Uy=e,jy=t}function bH(){dO(cO,fO)}var Fu=1/0,ag=Fu,qc=-Fu,ug=qc,lg={point:vH,lineStart:Ft,lineEnd:Ft,polygonStart:Ft,polygonEnd:Ft,result:function(){var e=[[Fu,ag],[qc,ug]];return qc=ug=-(ag=Fu=1/0),e}};function vH(e,t){eqc&&(qc=e),tug&&(ug=t)}var qy=0,Wy=0,oc=0,cg=0,fg=0,Qa=0,Hy=0,Gy=0,sc=0,hO,gO,Vi,Xi,Yn={point:Qs,lineStart:H$,lineEnd:G$,polygonStart:function(){Yn.lineStart=EH,Yn.lineEnd=_H},polygonEnd:function(){Yn.point=Qs,Yn.lineStart=H$,Yn.lineEnd=G$},result:function(){var e=sc?[Hy/sc,Gy/sc]:Qa?[cg/Qa,fg/Qa]:oc?[qy/oc,Wy/oc]:[NaN,NaN];return qy=Wy=oc=cg=fg=Qa=Hy=Gy=sc=0,e}};function Qs(e,t){qy+=e,Wy+=t,++oc}function H$(){Yn.point=xH}function xH(e,t){Yn.point=wH,Qs(Vi=e,Xi=t)}function wH(e,t){var n=e-Vi,i=t-Xi,r=ln(n*n+i*i);cg+=r*(Vi+e)/2,fg+=r*(Xi+t)/2,Qa+=r,Qs(Vi=e,Xi=t)}function G$(){Yn.point=Qs}function EH(){Yn.point=SH}function _H(){pO(hO,gO)}function SH(e,t){Yn.point=pO,Qs(hO=Vi=e,gO=Xi=t)}function pO(e,t){var n=e-Vi,i=t-Xi,r=ln(n*n+i*i);cg+=r*(Vi+e)/2,fg+=r*(Xi+t)/2,Qa+=r,r=Xi*e-Vi*t,Hy+=r*(Vi+e),Gy+=r*(Xi+t),sc+=r*3,Qs(Vi=e,Xi=t)}function mO(e){this._context=e}mO.prototype={_radius:4.5,pointRadius:function(e){return this._radius=e,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(e,t){switch(this._point){case 0:{this._context.moveTo(e,t),this._point=1;break}case 1:{this._context.lineTo(e,t);break}default:{this._context.moveTo(e+this._radius,t),this._context.arc(e,t,this._radius,0,un);break}}},result:Ft};var Yy=new sn,T0,yO,bO,ac,uc,Wc={point:Ft,lineStart:function(){Wc.point=$H},lineEnd:function(){T0&&vO(yO,bO),Wc.point=Ft},polygonStart:function(){T0=!0},polygonEnd:function(){T0=null},result:function(){var e=+Yy;return Yy=new sn,e}};function $H(e,t){Wc.point=vO,yO=ac=e,bO=uc=t}function vO(e,t){ac-=e,uc-=t,Yy.add(ln(ac*ac+uc*uc)),ac=e,uc=t}let Y$,dg,V$,X$;class K${constructor(t){this._append=t==null?xO:kH(t),this._radius=4.5,this._=""}pointRadius(t){return this._radius=+t,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(t,n){switch(this._point){case 0:{this._append`M${t},${n}`,this._point=1;break}case 1:{this._append`L${t},${n}`;break}default:{if(this._append`M${t},${n}`,this._radius!==V$||this._append!==dg){const i=this._radius,r=this._;this._="",this._append`m0,${i}a${i},${i} 0 1,1 0,${-2*i}a${i},${i} 0 1,1 0,${2*i}z`,V$=i,dg=this._append,X$=this._,this._=r}this._+=X$;break}}}result(){const t=this._;return this._="",t.length?t:null}}function xO(e){let t=1;this._+=e[0];for(const n=e.length;t=0))throw new RangeError(`invalid digits: ${e}`);if(t>15)return xO;if(t!==Y$){const n=10**t;Y$=t,dg=function(r){let o=1;this._+=r[0];for(const s=r.length;o=0))throw new RangeError(`invalid digits: ${a}`);n=u}return t===null&&(o=new K$(n)),s},s.projection(e).digits(n).context(t)}function Bp(e){return function(t){var n=new Vy;for(var i in e)n[i]=e[i];return n.stream=t,n}}function Vy(){}Vy.prototype={constructor:Vy,point:function(e,t){this.stream.point(e,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function P2(e,t,n){var i=e.clipExtent&&e.clipExtent();return e.scale(150).translate([0,0]),i!=null&&e.clipExtent(null),Rr(n,e.stream(lg)),t(lg.result()),i!=null&&e.clipExtent(i),e}function Up(e,t,n){return P2(e,function(i){var r=t[1][0]-t[0][0],o=t[1][1]-t[0][1],s=Math.min(r/(i[1][0]-i[0][0]),o/(i[1][1]-i[0][1])),a=+t[0][0]+(r-s*(i[1][0]+i[0][0]))/2,u=+t[0][1]+(o-s*(i[1][1]+i[0][1]))/2;e.scale(150*s).translate([a,u])},n)}function I2(e,t,n){return Up(e,[[0,0],t],n)}function z2(e,t,n){return P2(e,function(i){var r=+t,o=r/(i[1][0]-i[0][0]),s=(r-o*(i[1][0]+i[0][0]))/2,a=-o*i[0][1];e.scale(150*o).translate([s,a])},n)}function B2(e,t,n){return P2(e,function(i){var r=+t,o=r/(i[1][1]-i[0][1]),s=-o*i[0][0],a=(r-o*(i[1][1]+i[0][1]))/2;e.scale(150*o).translate([s,a])},n)}var J$=16,AH=ue(30*be);function Q$(e,t){return+t?FH(e,t):CH(e)}function CH(e){return Bp({point:function(t,n){t=e(t,n),this.stream.point(t[0],t[1])}})}function FH(e,t){function n(i,r,o,s,a,u,l,c,f,d,h,g,p,m){var y=l-i,b=c-r,v=y*y+b*b;if(v>4*t&&p--){var x=s+d,E=a+h,_=u+g,w=ln(x*x+E*E+_*_),S=En(_/=w),$=Ee(Ee(_)-1)t||Ee((y*N+b*C)/v-.5)>.3||s*d+a*h+u*g2?k[2]%360*be:0,N()):[a*tt,u*tt,l*tt]},F.angle=function(k){return arguments.length?(f=k%360*be,N()):f*tt},F.reflectX=function(k){return arguments.length?(d=k?-1:1,N()):d<0},F.reflectY=function(k){return arguments.length?(h=k?-1:1,N()):h<0},F.precision=function(k){return arguments.length?(_=Q$(w,E=k*k),C()):ln(E)},F.fitExtent=function(k,M){return Up(F,k,M)},F.fitSize=function(k,M){return I2(F,k,M)},F.fitWidth=function(k,M){return z2(F,k,M)},F.fitHeight=function(k,M){return B2(F,k,M)};function N(){var k=Z$(n,0,0,d,h,f).apply(null,t(o,s)),M=Z$(n,i-k[0],r-k[1],d,h,f);return c=oO(a,u,l),w=Iy(t,M),S=Iy(c,w),_=Q$(w,E),C()}function C(){return $=A=null,F}return function(){return t=e.apply(this,arguments),F.invert=t.invert&&T,N()}}function U2(e){var t=0,n=xe/3,i=EO(e),r=i(t,n);return r.parallels=function(o){return arguments.length?i(t=o[0]*be,n=o[1]*be):[t*tt,n*tt]},r}function RH(e){var t=ue(e);function n(i,r){return[i*t,oe(r)/t]}return n.invert=function(i,r){return[i/t,En(r*t)]},n}function OH(e,t){var n=oe(e),i=(n+oe(t))/2;if(Ee(i)=.12&&m<.234&&p>=-.425&&p<-.214?r:m>=.166&&m<.234&&p>=-.214&&p<-.115?s:n).invert(d)},c.stream=function(d){return e&&t===d?e:e=DH([n.stream(t=d),r.stream(d),s.stream(d)])},c.precision=function(d){return arguments.length?(n.precision(d),r.precision(d),s.precision(d),f()):n.precision()},c.scale=function(d){return arguments.length?(n.scale(d),r.scale(d*.35),s.scale(d),c.translate(n.translate())):n.scale()},c.translate=function(d){if(!arguments.length)return n.translate();var h=n.scale(),g=+d[0],p=+d[1];return i=n.translate(d).clipExtent([[g-.455*h,p-.238*h],[g+.455*h,p+.238*h]]).stream(l),o=r.translate([g-.307*h,p+.201*h]).clipExtent([[g-.425*h+ae,p+.12*h+ae],[g-.214*h-ae,p+.234*h-ae]]).stream(l),a=s.translate([g-.205*h,p+.212*h]).clipExtent([[g-.214*h+ae,p+.166*h+ae],[g-.115*h-ae,p+.234*h-ae]]).stream(l),f()},c.fitExtent=function(d,h){return Up(c,d,h)},c.fitSize=function(d,h){return I2(c,d,h)},c.fitWidth=function(d,h){return z2(c,d,h)},c.fitHeight=function(d,h){return B2(c,d,h)};function f(){return e=t=null,c}return c.scale(1070)}function SO(e){return function(t,n){var i=ue(t),r=ue(n),o=e(i*r);return o===1/0?[2,0]:[o*r*oe(t),o*oe(n)]}}function Mf(e){return function(t,n){var i=ln(t*t+n*n),r=e(i),o=oe(r),s=ue(r);return[ri(t*o,i*s),En(i&&n*o/i)]}}var $O=SO(function(e){return ln(2/(1+e))});$O.invert=Mf(function(e){return 2*En(e/2)});function PH(){return mr($O).scale(124.75).clipAngle(180-.001)}var kO=SO(function(e){return(e=VR(e))&&e/oe(e)});kO.invert=Mf(function(e){return e});function IH(){return mr(kO).scale(79.4188).clipAngle(180-.001)}function jp(e,t){return[e,Vh(D2((Qe+t)/2))]}jp.invert=function(e,t){return[e,2*cl(YR(t))-Qe]};function zH(){return AO(jp).scale(961/un)}function AO(e){var t=mr(e),n=t.center,i=t.scale,r=t.translate,o=t.clipExtent,s=null,a,u,l;t.scale=function(f){return arguments.length?(i(f),c()):i()},t.translate=function(f){return arguments.length?(r(f),c()):r()},t.center=function(f){return arguments.length?(n(f),c()):n()},t.clipExtent=function(f){return arguments.length?(f==null?s=a=u=l=null:(s=+f[0][0],a=+f[0][1],u=+f[1][0],l=+f[1][1]),c()):s==null?null:[[s,a],[u,l]]};function c(){var f=xe*i(),d=t(oH(t.rotate()).invert([0,0]));return o(s==null?[[d[0]-f,d[1]-f],[d[0]+f,d[1]+f]]:e===jp?[[Math.max(d[0]-f,s),a],[Math.min(d[0]+f,u),l]]:[[s,Math.max(d[1]-f,a)],[u,Math.min(d[1]+f,l)]])}return c()}function vd(e){return D2((Qe+e)/2)}function BH(e,t){var n=ue(e),i=e===t?oe(e):Vh(n/ue(t))/Vh(vd(t)/vd(e)),r=n*A0(vd(e),i)/i;if(!i)return jp;function o(s,a){r>0?a<-Qe+ae&&(a=-Qe+ae):a>Qe-ae&&(a=Qe-ae);var u=r/A0(vd(a),i);return[u*oe(i*s),r-u*ue(i*s)]}return o.invert=function(s,a){var u=r-a,l=Xn(i)*ln(s*s+u*u),c=ri(s,Ee(u))*Xn(u);return u*i<0&&(c-=xe*Xn(s)*Xn(u)),[c/i,2*cl(A0(r/l,1/i))-Qe]},o}function UH(){return U2(BH).scale(109.5).parallels([30,30])}function gg(e,t){return[e,t]}gg.invert=gg;function jH(){return mr(gg).scale(152.63)}function qH(e,t){var n=ue(e),i=e===t?oe(e):(n-ue(t))/(t-e),r=n/i+e;if(Ee(i)ae&&--i>0);return[e/(.8707+(o=n*n)*(-.131979+o*(-.013791+o*o*o*(.003971-.001529*o)))),n]};function XH(){return mr(MO).scale(175.295)}function TO(e,t){return[ue(t)*oe(e),oe(t)]}TO.invert=Mf(En);function KH(){return mr(TO).scale(249.5).clipAngle(90+ae)}function NO(e,t){var n=ue(t),i=1+ue(e)*n;return[n*oe(e)/i,oe(t)/i]}NO.invert=Mf(function(e){return 2*cl(e)});function JH(){return mr(NO).scale(250).clipAngle(142)}function RO(e,t){return[Vh(D2((Qe+t)/2)),-e]}RO.invert=function(e,t){return[-t,2*cl(YR(e))-Qe]};function QH(){var e=AO(RO),t=e.center,n=e.rotate;return e.center=function(i){return arguments.length?t([-i[1],i[0]]):(i=t(),[i[1],-i[0]])},e.rotate=function(i){return arguments.length?n([i[0],i[1],i.length>2?i[2]+90:90]):(i=n(),[i[0],i[1],i[2]-90])},n([0,0,90]).scale(159.155)}var ZH=Math.abs,Xy=Math.cos,mg=Math.sin,eG=1e-6,OO=Math.PI,Ky=OO/2,ek=tG(2);function tk(e){return e>1?Ky:e<-1?-Ky:Math.asin(e)}function tG(e){return e>0?Math.sqrt(e):0}function nG(e,t){var n=e*mg(t),i=30,r;do t-=r=(t+mg(t)-n)/(1+Xy(t));while(ZH(r)>eG&&--i>0);return t/2}function iG(e,t,n){function i(r,o){return[e*r*Xy(o=nG(n,o)),t*mg(o)]}return i.invert=function(r,o){return o=tk(o/t),[r/(e*Xy(o)),tk((2*o+mg(2*o))/n)]},i}var rG=iG(ek/Ky,ek,OO);function oG(){return mr(rG).scale(169.529)}const sG=wO(),Jy=["clipAngle","clipExtent","scale","translate","center","rotate","parallels","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];function aG(e,t){return function n(){const i=t();return i.type=e,i.path=wO().projection(i),i.copy=i.copy||function(){const r=n();return Jy.forEach(o=>{i[o]&&r[o](i[o]())}),r.path.pointRadius(i.path.pointRadius()),r},KN(i)}}function j2(e,t){if(!e||typeof e!="string")throw new Error("Projection type must be a name string.");return e=e.toLowerCase(),arguments.length>1?(yg[e]=aG(e,t),this):yg[e]||null}function DO(e){return e&&e.path||sG}const yg={albers:_O,albersusa:LH,azimuthalequalarea:PH,azimuthalequidistant:IH,conicconformal:UH,conicequalarea:hg,conicequidistant:WH,equalEarth:GH,equirectangular:jH,gnomonic:YH,identity:VH,mercator:zH,mollweide:oG,naturalEarth1:XH,orthographic:KH,stereographic:JH,transversemercator:QH};for(const e in yg)j2(e,yg[e]);function uG(){}const Ar=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function LO(){var e=1,t=1,n=a;function i(u,l){return l.map(c=>r(u,c))}function r(u,l){var c=[],f=[];return o(u,l,d=>{n(d,u,l),lG(d)>0?c.push([d]):f.push(d)}),f.forEach(d=>{for(var h=0,g=c.length,p;h=l,Ar[m<<1].forEach(v);++h=l,Ar[p|m<<1].forEach(v);for(Ar[m<<0].forEach(v);++g=l,y=u[g*e]>=l,Ar[m<<1|y<<2].forEach(v);++h=l,b=y,y=u[g*e+h+1]>=l,Ar[p|m<<1|y<<2|b<<3].forEach(v);Ar[m|y<<3].forEach(v)}for(h=-1,y=u[g*e]>=l,Ar[y<<2].forEach(v);++h=l,Ar[y<<2|b<<3].forEach(v);Ar[y<<3].forEach(v);function v(x){var E=[x[0][0]+h,x[0][1]+g],_=[x[1][0]+h,x[1][1]+g],w=s(E),S=s(_),$,A;($=d[w])?(A=f[S])?(delete d[$.end],delete f[A.start],$===A?($.ring.push(_),c($.ring)):f[$.start]=d[A.end]={start:$.start,end:A.end,ring:$.ring.concat(A.ring)}):(delete d[$.end],$.ring.push(_),d[$.end=S]=$):($=f[S])?(A=d[w])?(delete f[$.start],delete d[A.end],$===A?($.ring.push(_),c($.ring)):f[A.start]=d[$.end]={start:A.start,end:$.end,ring:A.ring.concat($.ring)}):(delete f[$.start],$.ring.unshift(E),f[$.start=w]=$):f[w]=d[S]={start:w,end:S,ring:[E,_]}}}function s(u){return u[0]*2+u[1]*(e+1)*4}function a(u,l,c){u.forEach(f=>{var d=f[0],h=f[1],g=d|0,p=h|0,m,y=l[p*e+g];d>0&&d0&&h=0&&c>=0||O("invalid size"),e=l,t=c,i},i.smooth=function(u){return arguments.length?(n=u?a:uG,i):n===a},i}function lG(e){for(var t=0,n=e.length,i=e[n-1][1]*e[0][0]-e[n-1][0]*e[0][1];++ti!=h>i&&n<(d-l)*(i-c)/(h-c)+l&&(r=-r)}return r}function dG(e,t,n){var i;return hG(e,t,n)&&gG(e[i=+(e[0]===t[0])],n[i],t[i])}function hG(e,t,n){return(t[0]-e[0])*(n[1]-e[1])===(n[0]-e[0])*(t[1]-e[1])}function gG(e,t,n){return e<=t&&t<=n||n<=t&&t<=e}function PO(e,t,n){return function(i){var r=ir(i),o=n?Math.min(r[0],0):r[0],s=r[1],a=s-o,u=t?Bo(o,s,e):a/(e+1);return Nn(o+u,s,u)}}function q2(e){R.call(this,null,e)}q2.Definition={type:"Isocontour",metadata:{generates:!0},params:[{name:"field",type:"field"},{name:"thresholds",type:"number",array:!0},{name:"levels",type:"number"},{name:"nice",type:"boolean",default:!1},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"zero",type:"boolean",default:!0},{name:"smooth",type:"boolean",default:!0},{name:"scale",type:"number",expr:!0},{name:"translate",type:"number",array:!0,expr:!0},{name:"as",type:"string",null:!0,default:"contour"}]};Y(q2,R,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=t.materialize(t.SOURCE).source,r=e.field||vn,o=LO().smooth(e.smooth!==!1),s=e.thresholds||pG(i,r,e),a=e.as===null?null:e.as||"contour",u=[];return i.forEach(l=>{const c=r(l),f=o.size([c.width,c.height])(c.values,P(s)?s:s(c.values));mG(f,c,l,e),f.forEach(d=>{u.push(op(l,Fe(a!=null?{[a]:d}:d)))})}),this.value&&(n.rem=this.value),this.value=n.source=n.add=u,n}});function pG(e,t,n){const i=PO(n.levels||10,n.nice,n.zero!==!1);return n.resolve!=="shared"?i:i(e.map(r=>Ls(t(r).values)))}function mG(e,t,n,i){let r=i.scale||t.scale,o=i.translate||t.translate;if(de(r)&&(r=r(n,i)),de(o)&&(o=o(n,i)),(r===1||r==null)&&!o)return;const s=(ke(r)?r:r[0])||1,a=(ke(r)?r:r[1])||1,u=o&&o[0]||0,l=o&&o[1]||0;e.forEach(IO(t,s,a,u,l))}function IO(e,t,n,i,r){const o=e.x1||0,s=e.y1||0,a=t*n<0;function u(f){f.forEach(l)}function l(f){a&&f.reverse(),f.forEach(c)}function c(f){f[0]=(f[0]-o)*t+i,f[1]=(f[1]-s)*n+r}return function(f){return f.coordinates.forEach(u),f}}function nk(e,t,n){const i=e>=0?e:Dv(t,n);return Math.round((Math.sqrt(4*i*i+1)-1)/2)}function N0(e){return de(e)?e:Yt(+e)}function zO(){var e=u=>u[0],t=u=>u[1],n=Ku,i=[-1,-1],r=960,o=500,s=2;function a(u,l){const c=nk(i[0],u,e)>>s,f=nk(i[1],u,t)>>s,d=c?c+2:0,h=f?f+2:0,g=2*d+(r>>s),p=2*h+(o>>s),m=new Float32Array(g*p),y=new Float32Array(g*p);let b=m;u.forEach(x=>{const E=d+(+e(x)>>s),_=h+(+t(x)>>s);E>=0&&E=0&&_0&&f>0?(Ia(g,p,m,y,c),za(g,p,y,m,f),Ia(g,p,m,y,c),za(g,p,y,m,f),Ia(g,p,m,y,c),za(g,p,y,m,f)):c>0?(Ia(g,p,m,y,c),Ia(g,p,y,m,c),Ia(g,p,m,y,c),b=y):f>0&&(za(g,p,m,y,f),za(g,p,y,m,f),za(g,p,m,y,f),b=y);const v=l?Math.pow(2,-2*s):1/tM(b);for(let x=0,E=g*p;x>s),y2:h+(o>>s)}}return a.x=function(u){return arguments.length?(e=N0(u),a):e},a.y=function(u){return arguments.length?(t=N0(u),a):t},a.weight=function(u){return arguments.length?(n=N0(u),a):n},a.size=function(u){if(!arguments.length)return[r,o];var l=+u[0],c=+u[1];return l>=0&&c>=0||O("invalid size"),r=l,o=c,a},a.cellSize=function(u){return arguments.length?((u=+u)>=1||O("invalid cell size"),s=Math.floor(Math.log(u)/Math.LN2),a):1<=r&&(a>=o&&(u-=n[a-o+s*e]),i[a-r+s*e]=u/Math.min(a+1,e-1+o-a,o))}function za(e,t,n,i,r){const o=(r<<1)+1;for(let s=0;s=r&&(a>=o&&(u-=n[s+(a-o)*e]),i[s+(a-r)*e]=u/Math.min(a+1,t-1+o-a,o))}function W2(e){R.call(this,null,e)}W2.Definition={type:"KDE2D",metadata:{generates:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"weight",type:"field"},{name:"groupby",type:"field",array:!0},{name:"cellSize",type:"number"},{name:"bandwidth",type:"number",array:!0,length:2},{name:"counts",type:"boolean",default:!1},{name:"as",type:"string",default:"grid"}]};const yG=["x","y","weight","size","cellSize","bandwidth"];function BO(e,t){return yG.forEach(n=>t[n]!=null?e[n](t[n]):0),e}Y(W2,R,{transform(e,t){if(this.value&&!t.changed()&&!e.modified())return t.StopPropagation;var n=t.fork(t.NO_SOURCE|t.NO_FIELDS),i=t.materialize(t.SOURCE).source,r=bG(i,e.groupby),o=(e.groupby||[]).map(Ze),s=BO(zO(),e),a=e.as||"grid",u=[];function l(c,f){for(let d=0;dFe(l({[a]:s(c,e.counts)},c.dims))),this.value&&(n.rem=this.value),this.value=n.source=n.add=u,n}});function bG(e,t){var n=[],i=c=>c(a),r,o,s,a,u,l;if(t==null)n.push(e);else for(r={},o=0,s=e.length;on.push(a(c))),o&&s&&(t.visit(u,c=>{var f=o(c),d=s(c);f!=null&&d!=null&&(f=+f)===f&&(d=+d)===d&&i.push([f,d])}),n=n.concat({type:Qy,geometry:{type:vG,coordinates:i}})),this.value={type:G2,features:n}}});function V2(e){R.call(this,null,e)}V2.Definition={type:"GeoPath",metadata:{modifies:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"path"}]};Y(V2,R,{transform(e,t){var n=t.fork(t.ALL),i=this.value,r=e.field||vn,o=e.as||"path",s=n.SOURCE;!i||e.modified()?(this.value=i=DO(e.projection),n.materialize().reflow()):s=r===vn||t.modified(r.fields)?n.ADD_MOD:n.ADD;const a=xG(i,e.pointRadius);return n.visit(s,u=>u[o]=i(r(u))),i.pointRadius(a),n.modifies(o)}});function xG(e,t){const n=e.pointRadius();return e.context(null),t!=null&&e.pointRadius(t),n}function X2(e){R.call(this,null,e)}X2.Definition={type:"GeoPoint",metadata:{modifies:!0},params:[{name:"projection",type:"projection",required:!0},{name:"fields",type:"field",array:!0,required:!0,length:2},{name:"as",type:"string",array:!0,length:2,default:["x","y"]}]};Y(X2,R,{transform(e,t){var n=e.projection,i=e.fields[0],r=e.fields[1],o=e.as||["x","y"],s=o[0],a=o[1],u;function l(c){const f=n([i(c),r(c)]);f?(c[s]=f[0],c[a]=f[1]):(c[s]=void 0,c[a]=void 0)}return e.modified()?t=t.materialize().reflow(!0).visit(t.SOURCE,l):(u=t.modified(i.fields)||t.modified(r.fields),t.visit(u?t.ADD_MOD:t.ADD,l)),t.modifies(o)}});function K2(e){R.call(this,null,e)}K2.Definition={type:"GeoShape",metadata:{modifies:!0,nomod:!0},params:[{name:"projection",type:"projection"},{name:"field",type:"field",default:"datum"},{name:"pointRadius",type:"number",expr:!0},{name:"as",type:"string",default:"shape"}]};Y(K2,R,{transform(e,t){var n=t.fork(t.ALL),i=this.value,r=e.as||"shape",o=n.ADD;return(!i||e.modified())&&(this.value=i=wG(DO(e.projection),e.field||ei("datum"),e.pointRadius),n.materialize().reflow(),o=n.SOURCE),n.visit(o,s=>s[r]=i),n.modifies(r)}});function wG(e,t,n){const i=n==null?r=>e(t(r)):r=>{var o=e.pointRadius(),s=e.pointRadius(n)(t(r));return e.pointRadius(o),s};return i.context=r=>(e.context(r),i),i}function J2(e){R.call(this,[],e),this.generator=pH()}J2.Definition={type:"Graticule",metadata:{changes:!0,generates:!0},params:[{name:"extent",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMajor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"extentMinor",type:"array",array:!0,length:2,content:{type:"number",array:!0,length:2}},{name:"step",type:"number",array:!0,length:2},{name:"stepMajor",type:"number",array:!0,length:2,default:[90,360]},{name:"stepMinor",type:"number",array:!0,length:2,default:[10,10]},{name:"precision",type:"number",default:2.5}]};Y(J2,R,{transform(e,t){var n=this.value,i=this.generator,r;if(!n.length||e.modified())for(const o in e)de(i[o])&&i[o](e[o]);return r=i(),n.length?t.mod.push(XM(n[0],r)):t.add.push(Fe(r)),n[0]=r,t}});function Q2(e){R.call(this,null,e)}Q2.Definition={type:"heatmap",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"color",type:"string",expr:!0},{name:"opacity",type:"number",expr:!0},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"as",type:"string",default:"image"}]};Y(Q2,R,{transform(e,t){if(!t.changed()&&!e.modified())return t.StopPropagation;var n=t.materialize(t.SOURCE).source,i=e.resolve==="shared",r=e.field||vn,o=_G(e.opacity,e),s=EG(e.color,e),a=e.as||"image",u={$x:0,$y:0,$value:0,$max:i?Ls(n.map(l=>Ls(r(l).values))):0};return n.forEach(l=>{const c=r(l),f=pe({},l,u);i||(f.$max=Ls(c.values||[])),l[a]=SG(c,f,s.dep?s:Yt(s(f)),o.dep?o:Yt(o(f)))}),t.reflow(!0).modifies(a)}});function EG(e,t){let n;return de(e)?(n=i=>qo(e(i,t)),n.dep=UO(e)):n=Yt(qo(e||"#888")),n}function _G(e,t){let n;return de(e)?(n=i=>e(i,t),n.dep=UO(e)):e?n=Yt(e):(n=i=>i.$value/i.$max||0,n.dep=!0),n}function UO(e){if(!de(e))return!1;const t=$i(qt(e));return t.$x||t.$y||t.$value||t.$max}function SG(e,t,n,i){const r=e.width,o=e.height,s=e.x1||0,a=e.y1||0,u=e.x2||r,l=e.y2||o,c=e.values,f=c?m=>c[m]:_o,d=Lo(u-s,l-a),h=d.getContext("2d"),g=h.getImageData(0,0,u-s,l-a),p=g.data;for(let m=a,y=0;m{e[i]!=null&&ik(n,i,e[i])})):Jy.forEach(i=>{e.modified(i)&&ik(n,i,e[i])}),e.pointRadius!=null&&n.path.pointRadius(e.pointRadius),e.fit&&$G(n,e),t.fork(t.NO_SOURCE|t.NO_FIELDS)}});function $G(e,t){const n=AG(t.fit);t.extent?e.fitExtent(t.extent,n):t.size&&e.fitSize(t.size,n)}function kG(e){const t=j2((e||"mercator").toLowerCase());return t||O("Unrecognized projection type: "+e),t()}function ik(e,t,n){de(e[t])&&e[t](n)}function AG(e){return e=Q(e),e.length===1?e[0]:{type:G2,features:e.reduce((t,n)=>t.concat(CG(n)),[])}}function CG(e){return e.type===G2?e.features:Q(e).filter(t=>t!=null).map(t=>t.type===Qy?t:{type:Qy,geometry:t})}const FG=Object.freeze(Object.defineProperty({__proto__:null,contour:H2,geojson:Y2,geopath:V2,geopoint:X2,geoshape:K2,graticule:J2,heatmap:Q2,isocontour:q2,kde2d:W2,projection:jO},Symbol.toStringTag,{value:"Module"}));function MG(e,t){var n,i=1;e==null&&(e=0),t==null&&(t=0);function r(){var o,s=n.length,a,u=0,l=0;for(o=0;o=(f=(a+l)/2))?a=f:l=f,(m=n>=(d=(u+c)/2))?u=d:c=d,r=o,!(o=o[y=m<<1|p]))return r[y]=s,e;if(h=+e._x.call(null,o.data),g=+e._y.call(null,o.data),t===h&&n===g)return s.next=o,r?r[y]=s:e._root=s,e;do r=r?r[y]=new Array(4):e._root=new Array(4),(p=t>=(f=(a+l)/2))?a=f:l=f,(m=n>=(d=(u+c)/2))?u=d:c=d;while((y=m<<1|p)===(b=(g>=d)<<1|h>=f));return r[b]=o,r[y]=s,e}function NG(e){var t,n,i=e.length,r,o,s=new Array(i),a=new Array(i),u=1/0,l=1/0,c=-1/0,f=-1/0;for(n=0;nc&&(c=r),of&&(f=o));if(u>c||l>f)return this;for(this.cover(u,l).cover(c,f),n=0;ne||e>=r||i>t||t>=o;)switch(l=(tc||(a=g.y0)>f||(u=g.x1)=y)<<1|e>=m)&&(g=d[d.length-1],d[d.length-1]=d[d.length-1-p],d[d.length-1-p]=g)}else{var b=e-+this._x.call(null,h.data),v=t-+this._y.call(null,h.data),x=b*b+v*v;if(x=(d=(s+u)/2))?s=d:u=d,(p=f>=(h=(a+l)/2))?a=h:l=h,t=n,!(n=n[m=p<<1|g]))return this;if(!n.length)break;(t[m+1&3]||t[m+2&3]||t[m+3&3])&&(i=t,y=m)}for(;n.data!==e;)if(r=n,!(n=n.next))return this;return(o=n.next)&&delete n.next,r?(o?r.next=o:delete r.next,this):t?(o?t[m]=o:delete t[m],(n=t[0]||t[1]||t[2]||t[3])&&n===(t[3]||t[2]||t[1]||t[0])&&!n.length&&(i?i[y]=n:this._root=n),this):(this._root=o,this)}function IG(e){for(var t=0,n=e.length;td.index){var F=h-S.x-S.vx,T=g-S.y-S.vy,N=F*F+T*T;Nh+A||_g+A||wl.r&&(l.r=l[c].r)}function u(){if(t){var l,c=t.length,f;for(n=new Array(c),l=0;l[t(E,_,s),E])),x;for(m=0,a=new Array(y);m{}};function WO(){for(var e=0,t=arguments.length,n={},i;e=0&&(i=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:i}})}eh.prototype=WO.prototype={constructor:eh,on:function(e,t){var n=this._,i=ZG(e+"",n),r,o=-1,s=i.length;if(arguments.length<2){for(;++o0)for(var n=new Array(r),i=0,r,o;i=0&&e._call.call(void 0,t),e=e._next;--Mu}function ak(){Zs=(vg=Hc.now())+qp,Mu=lc=0;try{nY()}finally{Mu=0,rY(),Zs=0}}function iY(){var e=Hc.now(),t=e-vg;t>HO&&(qp-=t,vg=e)}function rY(){for(var e,t=bg,n,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:bg=n);cc=e,Zy(i)}function Zy(e){if(!Mu){lc&&(lc=clearTimeout(lc));var t=e-Zs;t>24?(e<1/0&&(lc=setTimeout(ak,e-Hc.now()-qp)),Dl&&(Dl=clearInterval(Dl))):(Dl||(vg=Hc.now(),Dl=setInterval(iY,HO)),Mu=1,GO(ak))}}function oY(e,t,n){var i=new xg,r=t;return t==null?(i.restart(e,t,n),i):(i._restart=i.restart,i.restart=function(o,s,a){s=+s,a=a==null?tw():+a,i._restart(function u(l){l+=r,i._restart(u,r+=s,a),o(l)},s,a)},i.restart(e,t,n),i)}const sY=1664525,aY=1013904223,uk=4294967296;function uY(){let e=1;return()=>(e=(sY*e+aY)%uk)/uk}function lY(e){return e.x}function cY(e){return e.y}var fY=10,dY=Math.PI*(3-Math.sqrt(5));function hY(e){var t,n=1,i=.001,r=1-Math.pow(i,1/300),o=0,s=.6,a=new Map,u=YO(f),l=WO("tick","end"),c=uY();e==null&&(e=[]);function f(){d(),l.call("tick",t),n1?(m==null?a.delete(p):a.set(p,g(m)),t):a.get(p)},find:function(p,m,y){var b=0,v=e.length,x,E,_,w,S;for(y==null?y=1/0:y*=y,b=0;b1?(l.on(p,m),t):l.on(p)}}}function gY(){var e,t,n,i,r=rn(-30),o,s=1,a=1/0,u=.81;function l(h){var g,p=e.length,m=Z2(e,lY,cY).visitAfter(f);for(i=h,g=0;g=a)return;(h.data!==t||h.next)&&(y===0&&(y=Mo(n),x+=y*y),b===0&&(b=Mo(n),x+=b*b),x=0;)n.tick();else if(n.stopped()&&n.restart(),!i)return t.StopPropagation}return this.finish(e,t)},finish(e,t){const n=t.dataflow;for(let a=this._argops,u=0,l=a.length,c;ue.touch(t).run()}function vY(e,t){const n=hY(e),i=n.stop,r=n.restart;let o=!1;return n.stopped=()=>o,n.restart=()=>(o=!1,r()),n.stop=()=>(o=!0,i()),XO(n,t,!0).on("end",()=>o=!0)}function XO(e,t,n,i){var r=Q(t.forces),o,s,a,u;for(o=0,s=eb.length;ot(i,n):t)}const _Y=Object.freeze(Object.defineProperty({__proto__:null,force:nw},Symbol.toStringTag,{value:"Module"}));function SY(e,t){return e.parent===t.parent?1:2}function $Y(e){return e.reduce(kY,0)/e.length}function kY(e,t){return e+t.x}function AY(e){return 1+e.reduce(CY,0)}function CY(e,t){return Math.max(e,t.y)}function FY(e){for(var t;t=e.children;)e=t[0];return e}function MY(e){for(var t;t=e.children;)e=t[t.length-1];return e}function TY(){var e=SY,t=1,n=1,i=!1;function r(o){var s,a=0;o.eachAfter(function(d){var h=d.children;h?(d.x=$Y(h),d.y=AY(h)):(d.x=s?a+=e(d,s):0,d.y=0,s=d)});var u=FY(o),l=MY(o),c=u.x-e(u,l)/2,f=l.x+e(l,u)/2;return o.eachAfter(i?function(d){d.x=(d.x-o.x)*t,d.y=(o.y-d.y)*n}:function(d){d.x=(d.x-c)/(f-c)*t,d.y=(1-(o.y?d.y/o.y:1))*n})}return r.separation=function(o){return arguments.length?(e=o,r):e},r.size=function(o){return arguments.length?(i=!1,t=+o[0],n=+o[1],r):i?null:[t,n]},r.nodeSize=function(o){return arguments.length?(i=!0,t=+o[0],n=+o[1],r):i?[t,n]:null},r}function NY(e){var t=0,n=e.children,i=n&&n.length;if(!i)t=1;else for(;--i>=0;)t+=n[i].value;e.value=t}function RY(){return this.eachAfter(NY)}function OY(e,t){let n=-1;for(const i of this)e.call(t,i,++n,this);return this}function DY(e,t){for(var n=this,i=[n],r,o,s=-1;n=i.pop();)if(e.call(t,n,++s,this),r=n.children)for(o=r.length-1;o>=0;--o)i.push(r[o]);return this}function LY(e,t){for(var n=this,i=[n],r=[],o,s,a,u=-1;n=i.pop();)if(r.push(n),o=n.children)for(s=0,a=o.length;s=0;)n+=i[r].value;t.value=n})}function zY(e){return this.eachBefore(function(t){t.children&&t.children.sort(e)})}function BY(e){for(var t=this,n=UY(t,e),i=[t];t!==n;)t=t.parent,i.push(t);for(var r=i.length;e!==n;)i.splice(r,0,e),e=e.parent;return i}function UY(e,t){if(e===t)return e;var n=e.ancestors(),i=t.ancestors(),r=null;for(e=n.pop(),t=i.pop();e===t;)r=e,e=n.pop(),t=i.pop();return r}function jY(){for(var e=this,t=[e];e=e.parent;)t.push(e);return t}function qY(){return Array.from(this)}function WY(){var e=[];return this.eachBefore(function(t){t.children||e.push(t)}),e}function HY(){var e=this,t=[];return e.each(function(n){n!==e&&t.push({source:n.parent,target:n})}),t}function*GY(){var e=this,t,n=[e],i,r,o;do for(t=n.reverse(),n=[];e=t.pop();)if(yield e,i=e.children)for(r=0,o=i.length;r=0;--a)r.push(o=s[a]=new Tu(s[a])),o.parent=i,o.depth=i.depth+1;return n.eachBefore(KO)}function YY(){return iw(this).eachBefore(KY)}function VY(e){return e.children}function XY(e){return Array.isArray(e)?e[1]:null}function KY(e){e.data.value!==void 0&&(e.value=e.data.value),e.data=e.data.data}function KO(e){var t=0;do e.height=t;while((e=e.parent)&&e.height<++t)}function Tu(e){this.data=e,this.depth=this.height=0,this.parent=null}Tu.prototype=iw.prototype={constructor:Tu,count:RY,each:OY,eachAfter:LY,eachBefore:DY,find:PY,sum:IY,sort:zY,path:BY,ancestors:jY,descendants:qY,leaves:WY,links:HY,copy:YY,[Symbol.iterator]:GY};function th(e){return e==null?null:JO(e)}function JO(e){if(typeof e!="function")throw new Error;return e}function Ts(){return 0}function Ga(e){return function(){return e}}const JY=1664525,QY=1013904223,ck=4294967296;function ZY(){let e=1;return()=>(e=(JY*e+QY)%ck)/ck}function eV(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function tV(e,t){let n=e.length,i,r;for(;n;)r=t()*n--|0,i=e[n],e[n]=e[r],e[r]=i;return e}function nV(e,t){for(var n=0,i=(e=tV(Array.from(e),t)).length,r=[],o,s;n0&&n*n>i*i+r*r}function R0(e,t){for(var n=0;n1e-6?(F+Math.sqrt(F*F-4*A*T))/(2*A):T/F);return{x:i+_+w*N,y:r+S+$*N,r:N}}function fk(e,t,n){var i=e.x-t.x,r,o,s=e.y-t.y,a,u,l=i*i+s*s;l?(o=t.r+n.r,o*=o,u=e.r+n.r,u*=u,o>u?(r=(l+u-o)/(2*l),a=Math.sqrt(Math.max(0,u/l-r*r)),n.x=e.x-r*i-a*s,n.y=e.y-r*s+a*i):(r=(l+o-u)/(2*l),a=Math.sqrt(Math.max(0,o/l-r*r)),n.x=t.x+r*i-a*s,n.y=t.y+r*s+a*i)):(n.x=t.x+n.r,n.y=t.y)}function dk(e,t){var n=e.r+t.r-1e-6,i=t.x-e.x,r=t.y-e.y;return n>0&&n*n>i*i+r*r}function hk(e){var t=e._,n=e.next._,i=t.r+n.r,r=(t.x*n.r+n.x*t.r)/i,o=(t.y*n.r+n.y*t.r)/i;return r*r+o*o}function wd(e){this._=e,this.next=null,this.previous=null}function sV(e,t){if(!(o=(e=eV(e)).length))return 0;var n,i,r,o,s,a,u,l,c,f,d;if(n=e[0],n.x=0,n.y=0,!(o>1))return n.r;if(i=e[1],n.x=-i.r,i.x=n.r,i.y=0,!(o>2))return n.r+i.r;fk(i,n,r=e[2]),n=new wd(n),i=new wd(i),r=new wd(r),n.next=r.previous=i,i.next=n.previous=r,r.next=i.previous=n;e:for(u=3;uhV(n(x,E,r))),b=y.map(bk),v=new Set(y).add("");for(const x of b)v.has(x)||(v.add(x),y.push(x),b.push(bk(x)),o.push(D0));s=(x,E)=>y[E],a=(x,E)=>b[E]}for(c=0,u=o.length;c=0&&(h=o[y],h.data===D0);--y)h.data=null}if(f.parent=cV,f.eachBefore(function(y){y.depth=y.parent.depth+1,--u}).eachBefore(KO),f.parent=null,u>0)throw new Error("cycle");return f}return i.id=function(r){return arguments.length?(e=th(r),i):e},i.parentId=function(r){return arguments.length?(t=th(r),i):t},i.path=function(r){return arguments.length?(n=th(r),i):n},i}function hV(e){e=`${e}`;let t=e.length;return tb(e,t-1)&&!tb(e,t-2)&&(e=e.slice(0,-1)),e[0]==="/"?e:`/${e}`}function bk(e){let t=e.length;if(t<2)return"";for(;--t>1&&!tb(e,t););return e.slice(0,t)}function tb(e,t){if(e[t]==="/"){let n=0;for(;t>0&&e[--t]==="\\";)++n;if(!(n&1))return!0}return!1}function gV(e,t){return e.parent===t.parent?1:2}function L0(e){var t=e.children;return t?t[0]:e.t}function P0(e){var t=e.children;return t?t[t.length-1]:e.t}function pV(e,t,n){var i=n/(t.i-e.i);t.c-=i,t.s+=n,e.c+=i,t.z+=n,t.m+=n}function mV(e){for(var t=0,n=0,i=e.children,r=i.length,o;--r>=0;)o=i[r],o.z+=t,o.m+=t,t+=o.s+(n+=o.c)}function yV(e,t,n){return e.a.parent===t.parent?e.a:n}function nh(e,t){this._=e,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=t}nh.prototype=Object.create(Tu.prototype);function bV(e){for(var t=new nh(e,0),n,i=[t],r,o,s,a;n=i.pop();)if(o=n._.children)for(n.children=new Array(a=o.length),s=a-1;s>=0;--s)i.push(r=n.children[s]=new nh(o[s],s)),r.parent=n;return(t.parent=new nh(null,0)).children=[t],t}function vV(){var e=gV,t=1,n=1,i=null;function r(l){var c=bV(l);if(c.eachAfter(o),c.parent.m=-c.z,c.eachBefore(s),i)l.eachBefore(u);else{var f=l,d=l,h=l;l.eachBefore(function(b){b.xd.x&&(d=b),b.depth>h.depth&&(h=b)});var g=f===d?1:e(f,d)/2,p=g-f.x,m=t/(d.x+g+p),y=n/(h.depth||1);l.eachBefore(function(b){b.x=(b.x+p)*m,b.y=b.depth*y})}return l}function o(l){var c=l.children,f=l.parent.children,d=l.i?f[l.i-1]:null;if(c){mV(l);var h=(c[0].z+c[c.length-1].z)/2;d?(l.z=d.z+e(l._,d._),l.m=l.z-h):l.z=h}else d&&(l.z=d.z+e(l._,d._));l.parent.A=a(l,d,l.parent.A||f[0])}function s(l){l._.x=l.z+l.parent.m,l.m+=l.parent.m}function a(l,c,f){if(c){for(var d=l,h=l,g=c,p=d.parent.children[0],m=d.m,y=h.m,b=g.m,v=p.m,x;g=P0(g),d=L0(d),g&&d;)p=L0(p),h=P0(h),h.a=l,x=g.z+b-d.z-m+e(g._,d._),x>0&&(pV(yV(g,l,f),l,x),m+=x,y+=x),b+=g.m,m+=d.m,v+=p.m,y+=h.m;g&&!P0(h)&&(h.t=g,h.m+=b-y),d&&!L0(p)&&(p.t=d,p.m+=m-v,f=l)}return f}function u(l){l.x*=t,l.y=l.depth*n}return r.separation=function(l){return arguments.length?(e=l,r):e},r.size=function(l){return arguments.length?(i=!1,t=+l[0],n=+l[1],r):i?null:[t,n]},r.nodeSize=function(l){return arguments.length?(i=!0,t=+l[0],n=+l[1],r):i?[t,n]:null},r}function Wp(e,t,n,i,r){for(var o=e.children,s,a=-1,u=o.length,l=e.value&&(r-n)/e.value;++ab&&(b=l),_=m*m*E,v=Math.max(b/_,_/y),v>x){m-=l;break}x=v}s.push(u={value:m,dice:h1?i:1)},n}(tD);function xV(){var e=iD,t=!1,n=1,i=1,r=[0],o=Ts,s=Ts,a=Ts,u=Ts,l=Ts;function c(d){return d.x0=d.y0=0,d.x1=n,d.y1=i,d.eachBefore(f),r=[0],t&&d.eachBefore(eD),d}function f(d){var h=r[d.depth],g=d.x0+h,p=d.y0+h,m=d.x1-h,y=d.y1-h;m=d-1){var b=o[f];b.x0=g,b.y0=p,b.x1=m,b.y1=y;return}for(var v=l[f],x=h/2+v,E=f+1,_=d-1;E<_;){var w=E+_>>>1;l[w]y-p){var A=h?(g*$+m*S)/h:m;c(f,E,S,g,p,A,y),c(E,d,$,A,p,m,y)}else{var F=h?(p*$+y*S)/h:y;c(f,E,S,g,p,m,F),c(E,d,$,g,F,m,y)}}}function EV(e,t,n,i,r){(e.depth&1?Wp:Tf)(e,t,n,i,r)}const _V=function e(t){function n(i,r,o,s,a){if((u=i._squarify)&&u.ratio===t)for(var u,l,c,f,d=-1,h,g=u.length,p=i.value;++d1?i:1)},n}(tD);function nb(e,t,n){const i={};return e.each(r=>{const o=r.data;n(o)&&(i[t(o)]=r)}),e.lookup=i,e}function rw(e){R.call(this,null,e)}rw.Definition={type:"Nest",metadata:{treesource:!0,changes:!0},params:[{name:"keys",type:"field",array:!0},{name:"generate",type:"boolean"}]};const SV=e=>e.values;Y(rw,R,{transform(e,t){t.source||O("Nest transform requires an upstream data source.");var n=e.generate,i=e.modified(),r=t.clone(),o=this.value;return(!o||i||t.changed())&&(o&&o.each(s=>{s.children&&rp(s.data)&&r.rem.push(s.data)}),this.value=o=iw({values:Q(e.keys).reduce((s,a)=>(s.key(a),s),$V()).entries(r.source)},SV),n&&o.each(s=>{s.children&&(s=Fe(s.data),r.add.push(s),r.source.push(s))}),nb(o,re,re)),r.source.root=o,r}});function $V(){const e=[],t={entries:r=>i(n(r,0),0),key:r=>(e.push(r),t)};function n(r,o){if(o>=e.length)return r;const s=r.length,a=e[o++],u={},l={};let c=-1,f,d,h;for(;++ce.length)return r;const s=[];for(const a in r)s.push({key:a,values:i(r[a],o)});return s}return t}function ro(e){R.call(this,null,e)}const kV=(e,t)=>e.parent===t.parent?1:2;Y(ro,R,{transform(e,t){(!t.source||!t.source.root)&&O(this.constructor.name+" transform requires a backing tree data source.");const n=this.layout(e.method),i=this.fields,r=t.source.root,o=e.as||i;e.field?r.sum(e.field):r.count(),e.sort&&r.sort(ba(e.sort,s=>s.data)),AV(n,this.params,e),n.separation&&n.separation(e.separation!==!1?kV:Ku);try{this.value=n(r)}catch(s){O(s)}return r.each(s=>CV(s,i,o)),t.reflow(e.modified()).modifies(o).modifies("leaf")}});function AV(e,t,n){for(let i,r=0,o=t.length;ro[re(s)]=1),i.each(s=>{const a=s.data,u=s.parent&&s.parent.data;u&&o[re(a)]&&o[re(u)]&&r.add.push(Fe({source:u,target:a}))}),this.value=r.add):t.changed(t.MOD)&&(t.visit(t.MOD,s=>o[re(s)]=1),n.forEach(s=>{(o[re(s.source)]||o[re(s.target)])&&r.mod.push(s)})),r}});const xk={binary:wV,dice:Tf,slice:Wp,slicedice:EV,squarify:iD,resquarify:_V},sb=["x0","y0","x1","y1","depth","children"];function cw(e){ro.call(this,e)}cw.Definition={type:"Treemap",metadata:{tree:!0,modifies:!0},params:[{name:"field",type:"field"},{name:"sort",type:"compare"},{name:"method",type:"enum",default:"squarify",values:["squarify","resquarify","binary","dice","slice","slicedice"]},{name:"padding",type:"number",default:0},{name:"paddingInner",type:"number",default:0},{name:"paddingOuter",type:"number",default:0},{name:"paddingTop",type:"number",default:0},{name:"paddingRight",type:"number",default:0},{name:"paddingBottom",type:"number",default:0},{name:"paddingLeft",type:"number",default:0},{name:"ratio",type:"number",default:1.618033988749895},{name:"round",type:"boolean",default:!1},{name:"size",type:"number",array:!0,length:2},{name:"as",type:"string",array:!0,length:sb.length,default:sb}]};Y(cw,ro,{layout(){const e=xV();return e.ratio=t=>{const n=e.tile();n.ratio&&e.tile(n.ratio(t))},e.method=t=>{Z(xk,t)?e.tile(xk[t]):O("Unrecognized Treemap layout method: "+t)},e},params:["method","ratio","size","round","padding","paddingInner","paddingOuter","paddingTop","paddingRight","paddingBottom","paddingLeft"],fields:sb});const FV=Object.freeze(Object.defineProperty({__proto__:null,nest:rw,pack:ow,partition:sw,stratify:aw,tree:uw,treelinks:lw,treemap:cw},Symbol.toStringTag,{value:"Module"})),I0=4278190080;function MV(e,t){const n=e.bitmap();return(t||[]).forEach(i=>n.set(e(i.boundary[0]),e(i.boundary[3]))),[n,void 0]}function TV(e,t,n,i,r){const o=e.width,s=e.height,a=i||r,u=Lo(o,s).getContext("2d"),l=Lo(o,s).getContext("2d"),c=a&&Lo(o,s).getContext("2d");n.forEach(S=>ih(u,S,!1)),ih(l,t,!1),a&&ih(c,t,!0);const f=z0(u,o,s),d=z0(l,o,s),h=a&&z0(c,o,s),g=e.bitmap(),p=a&&e.bitmap();let m,y,b,v,x,E,_,w;for(y=0;y{r.items.forEach(o=>ih(e,o.items,n))}):jn[i].draw(e,{items:n?t.map(NV):t})}function NV(e){const t=op(e,{});return t.stroke&&t.strokeOpacity!==0||t.fill&&t.fillOpacity!==0?{...t,strokeOpacity:1,stroke:"#000",fillOpacity:0}:t}const Cr=5,Vt=31,Gc=32,wo=new Uint32Array(Gc+1),mi=new Uint32Array(Gc+1);mi[0]=0;wo[0]=~mi[0];for(let e=1;e<=Gc;++e)mi[e]=mi[e-1]<<1|1,wo[e]=~mi[e];function RV(e,t){const n=new Uint32Array(~~((e*t+Gc)/Gc));function i(o,s){n[o]|=s}function r(o,s){n[o]&=s}return{array:n,get:(o,s)=>{const a=s*e+o;return n[a>>>Cr]&1<<(a&Vt)},set:(o,s)=>{const a=s*e+o;i(a>>>Cr,1<<(a&Vt))},clear:(o,s)=>{const a=s*e+o;r(a>>>Cr,~(1<<(a&Vt)))},getRange:(o,s,a,u)=>{let l=u,c,f,d,h;for(;l>=s;--l)if(c=l*e+o,f=l*e+a,d=c>>>Cr,h=f>>>Cr,d===h){if(n[d]&wo[c&Vt]&mi[(f&Vt)+1])return!0}else{if(n[d]&wo[c&Vt]||n[h]&mi[(f&Vt)+1])return!0;for(let g=d+1;g{let l,c,f,d,h;for(;s<=u;++s)if(l=s*e+o,c=s*e+a,f=l>>>Cr,d=c>>>Cr,f===d)i(f,wo[l&Vt]&mi[(c&Vt)+1]);else for(i(f,wo[l&Vt]),i(d,mi[(c&Vt)+1]),h=f+1;h{let l,c,f,d,h;for(;s<=u;++s)if(l=s*e+o,c=s*e+a,f=l>>>Cr,d=c>>>Cr,f===d)r(f,mi[l&Vt]|wo[(c&Vt)+1]);else for(r(f,mi[l&Vt]),r(d,wo[(c&Vt)+1]),h=f+1;ho<0||s<0||u>=t||a>=e}}function OV(e,t,n){const i=Math.max(1,Math.sqrt(e*t/1e6)),r=~~((e+2*n+i)/i),o=~~((t+2*n+i)/i),s=a=>~~((a+n)/i);return s.invert=a=>a*i-n,s.bitmap=()=>RV(r,o),s.ratio=i,s.padding=n,s.width=e,s.height=t,s}function DV(e,t,n,i){const r=e.width,o=e.height;return function(s){const a=s.datum.datum.items[i].items,u=a.length,l=s.datum.fontSize,c=Ln.width(s.datum,s.datum.text);let f=0,d,h,g,p,m,y,b;for(let v=0;v=f&&(f=b,s.x=m,s.y=y);return m=c/2,y=l/2,d=s.x-m,h=s.x+m,g=s.y-y,p=s.y+y,s.align="center",d<0&&h<=r?s.align="left":0<=d&&rr||t-(s=i/2)<0||t+s>o}function To(e,t,n,i,r,o,s,a){const u=r*o/(i*2),l=e(t-u),c=e(t+u),f=e(n-(o=o/2)),d=e(n+o);return s.outOfBounds(l,f,c,d)||s.getRange(l,f,c,d)||a&&a.getRange(l,f,c,d)}function LV(e,t,n,i){const r=e.width,o=e.height,s=t[0],a=t[1];function u(l,c,f,d,h){const g=e.invert(l),p=e.invert(c);let m=f,y=o,b;if(!wg(g,p,d,h,r,o)&&!To(e,g,p,h,d,m,s,a)&&!To(e,g,p,h,d,h,s,null)){for(;y-m>=1;)b=(m+y)/2,To(e,g,p,h,d,b,s,a)?y=b:m=b;if(m>f)return[g,p,m,!0]}}return function(l){const c=l.datum.datum.items[i].items,f=c.length,d=l.datum.fontSize,h=Ln.width(l.datum,l.datum.text);let g=n?d:0,p=!1,m=!1,y=0,b,v,x,E,_,w,S,$,A,F,T,N,C,k,M,D,B;for(let z=0;zv&&(B=b,b=v,v=B),x>E&&(B=x,x=E,E=B),A=e(b),T=e(v),F=~~((A+T)/2),N=e(x),k=e(E),C=~~((N+k)/2),S=F;S>=A;--S)for($=C;$>=N;--$)D=u(S,$,g,h,d),D&&([l.x,l.y,g,p]=D);for(S=F;S<=T;++S)for($=C;$<=k;++$)D=u(S,$,g,h,d),D&&([l.x,l.y,g,p]=D);!p&&!n&&(M=Math.abs(v-b+E-x),_=(b+v)/2,w=(x+E)/2,M>=y&&!wg(_,w,h,d,r,o)&&!To(e,_,w,d,h,d,s,null)&&(y=M,l.x=_,l.y=w,m=!0))}return p||m?(_=h/2,w=d/2,s.setRange(e(l.x-_),e(l.y-w),e(l.x+_),e(l.y+w)),l.align="center",l.baseline="middle",!0):!1}}const PV=[-1,-1,1,1],IV=[-1,1,-1,1];function zV(e,t,n,i){const r=e.width,o=e.height,s=t[0],a=t[1],u=e.bitmap();return function(l){const c=l.datum.datum.items[i].items,f=c.length,d=l.datum.fontSize,h=Ln.width(l.datum,l.datum.text),g=[];let p=n?d:0,m=!1,y=!1,b=0,v,x,E,_,w,S,$,A,F,T,N,C;for(let k=0;k=1;)N=(F+T)/2,To(e,w,S,d,h,N,s,a)?T=N:F=N;F>p&&(l.x=w,l.y=S,p=F,m=!0)}}!m&&!n&&(C=Math.abs(x-v+_-E),w=(v+x)/2,S=(E+_)/2,C>=b&&!wg(w,S,h,d,r,o)&&!To(e,w,S,d,h,d,s,null)&&(b=C,l.x=w,l.y=S,y=!0))}return m||y?(w=h/2,S=d/2,s.setRange(e(l.x-w),e(l.y-S),e(l.x+w),e(l.y+S)),l.align="center",l.baseline="middle",!0):!1}}const BV=["right","center","left"],UV=["bottom","middle","top"];function jV(e,t,n,i){const r=e.width,o=e.height,s=t[0],a=t[1],u=i.length;return function(l){const c=l.boundary,f=l.datum.fontSize;if(c[2]<0||c[5]<0||c[0]>r||c[3]>o)return!1;let d=l.textWidth??0,h,g,p,m,y,b,v,x,E,_,w,S,$,A,F;for(let T=0;T>>2&3)-1,p=h===0&&g===0||i[T]<0,m=h&&g?Math.SQRT1_2:1,y=i[T]<0?-1:1,b=c[1+h]+i[T]*h*m,w=c[4+g]+y*f*g/2+i[T]*g*m,x=w-f/2,E=w+f/2,S=e(b),A=e(x),F=e(E),!d)if(wk(S,S,A,F,s,a,b,b,x,E,c,p))d=Ln.width(l.datum,l.datum.text);else continue;if(_=b+y*d*h/2,b=_-d/2,v=_+d/2,S=e(b),$=e(v),wk(S,$,A,F,s,a,b,v,x,E,c,p))return l.x=h?h*y<0?v:b:_,l.y=g?g*y<0?E:x:w,l.align=BV[h*y+1],l.baseline=UV[g*y+1],s.setRange(S,A,$,F),!0}return!1}}function wk(e,t,n,i,r,o,s,a,u,l,c,f){return!(r.outOfBounds(e,n,t,i)||(f&&o||r).getRange(e,n,t,i))}const B0=0,U0=4,j0=8,q0=0,W0=1,H0=2,qV={"top-left":B0+q0,top:B0+W0,"top-right":B0+H0,left:U0+q0,middle:U0+W0,right:U0+H0,"bottom-left":j0+q0,bottom:j0+W0,"bottom-right":j0+H0},WV={naive:DV,"reduced-search":LV,floodfill:zV};function HV(e,t,n,i,r,o,s,a,u,l,c){if(!e.length)return e;const f=Math.max(i.length,r.length),d=GV(i,f),h=YV(r,f),g=VV(e[0].datum),p=g==="group"&&e[0].datum.items[u].marktype,m=p==="area",y=XV(g,p,a,u),b=l===null||l===1/0,v=m&&c==="naive";let x=-1,E=-1;const _=e.map(A=>{const F=b?Ln.width(A,A.text):void 0;return x=Math.max(x,F),E=Math.max(E,A.fontSize),{datum:A,opacity:0,x:void 0,y:void 0,align:void 0,baseline:void 0,boundary:y(A),textWidth:F}});l=l===null||l===1/0?Math.max(x,E)+Math.max(...i):l;const w=OV(t[0],t[1],l);let S;if(!v){n&&_.sort((T,N)=>n(T.datum,N.datum));let A=!1;for(let T=0;TT.datum);S=o.length||F?TV(w,F||[],o,A,m):MV(w,s&&_)}const $=m?WV[c](w,S,s,u):jV(w,S,h,d);return _.forEach(A=>A.opacity=+$(A)),_}function GV(e,t){const n=new Float64Array(t),i=e.length;for(let r=0;r[o.x,o.x,o.x,o.y,o.y,o.y];return e?e==="line"||e==="area"?o=>r(o.datum):t==="line"?o=>{const s=o.datum.items[i].items;return r(s.length?s[n==="start"?0:s.length-1]:{x:NaN,y:NaN})}:o=>{const s=o.datum.bounds;return[s.x1,(s.x1+s.x2)/2,s.x2,s.y1,(s.y1+s.y2)/2,s.y2]}:r}const ab=["x","y","opacity","align","baseline"],rD=["top-left","left","bottom-left","top","bottom","top-right","right","bottom-right"];function fw(e){R.call(this,null,e)}fw.Definition={type:"Label",metadata:{modifies:!0},params:[{name:"size",type:"number",array:!0,length:2,required:!0},{name:"sort",type:"compare"},{name:"anchor",type:"string",array:!0,default:rD},{name:"offset",type:"number",array:!0,default:[1]},{name:"padding",type:"number",default:0,null:!0},{name:"lineAnchor",type:"string",values:["start","end"],default:"end"},{name:"markIndex",type:"number",default:0},{name:"avoidBaseMark",type:"boolean",default:!0},{name:"avoidMarks",type:"data",array:!0},{name:"method",type:"string",default:"naive"},{name:"as",type:"string",array:!0,length:ab.length,default:ab}]};Y(fw,R,{transform(e,t){function n(o){const s=e[o];return de(s)&&t.modified(s.fields)}const i=e.modified();if(!(i||t.changed(t.ADD_REM)||n("sort")))return;(!e.size||e.size.length!==2)&&O("Size parameter should be specified as a [width, height] array.");const r=e.as||ab;return HV(t.materialize(t.SOURCE).source||[],e.size,e.sort,Q(e.offset==null?1:e.offset),Q(e.anchor||rD),e.avoidMarks||[],e.avoidBaseMark!==!1,e.lineAnchor||"end",e.markIndex||0,e.padding===void 0?0:e.padding,e.method||"naive").forEach(o=>{const s=o.datum;s[r[0]]=o.x,s[r[1]]=o.y,s[r[2]]=o.opacity,s[r[3]]=o.align,s[r[4]]=o.baseline}),t.reflow(i).modifies(r)}});const KV=Object.freeze(Object.defineProperty({__proto__:null,label:fw},Symbol.toStringTag,{value:"Module"}));function oD(e,t){var n=[],i=function(c){return c(a)},r,o,s,a,u,l;if(t==null)n.push(e);else for(r={},o=0,s=e.length;o{hT(l,e.x,e.y,e.bandwidth||.3).forEach(c=>{const f={};for(let d=0;de==="poly"?t:e==="quad"?2:1;function hw(e){R.call(this,null,e)}hw.Definition={type:"Regression",metadata:{generates:!0},params:[{name:"x",type:"field",required:!0},{name:"y",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"string",default:"linear",values:Object.keys(ub)},{name:"order",type:"number",default:3},{name:"extent",type:"number",array:!0,length:2},{name:"params",type:"boolean",default:!1},{name:"as",type:"string",array:!0}]};Y(hw,R,{transform(e,t){const n=t.fork(t.NO_SOURCE|t.NO_FIELDS);if(!this.value||t.changed()||e.modified()){const i=t.materialize(t.SOURCE).source,r=oD(i,e.groupby),o=(e.groupby||[]).map(Ze),s=e.method||"linear",a=e.order==null?3:e.order,u=JV(s,a),l=e.as||[Ze(e.x),Ze(e.y)],c=ub[s],f=[];let d=e.extent;Z(ub,s)||O("Invalid regression method: "+s),d!=null&&s==="log"&&d[0]<=0&&(t.dataflow.warn("Ignoring extent with values <= 0 for log regression."),d=null),r.forEach(h=>{if(h.length<=u){t.dataflow.warn("Skipping regression with more parameters than data points.");return}const p=c(h,e.x,e.y,a);if(e.params){f.push(Fe({keys:h.dims,coef:p.coef,rSquared:p.rSquared}));return}const m=d||ir(h,e.x),y=b=>{const v={};for(let x=0;xy([b,p.predict(b)])):dp(p.predict,m,25,200).forEach(y)}),this.value&&(n.rem=this.value),this.value=n.add=n.source=f}return n}});const QV=Object.freeze(Object.defineProperty({__proto__:null,loess:dw,regression:hw},Symbol.toStringTag,{value:"Module"})),qr=11102230246251565e-32,Pt=134217729,ZV=(3+8*qr)*qr;function G0(e,t,n,i,r){let o,s,a,u,l=t[0],c=i[0],f=0,d=0;c>l==c>-l?(o=l,l=t[++f]):(o=c,c=i[++d]);let h=0;if(fl==c>-l?(s=l+o,a=o-(s-l),l=t[++f]):(s=c+o,a=o-(s-c),c=i[++d]),o=s,a!==0&&(r[h++]=a);fl==c>-l?(s=o+l,u=s-o,a=o-(s-u)+(l-u),l=t[++f]):(s=o+c,u=s-o,a=o-(s-u)+(c-u),c=i[++d]),o=s,a!==0&&(r[h++]=a);for(;f=C||-N>=C||(f=e-$,a=e-($+f)+(f-r),f=n-A,l=n-(A+f)+(f-r),f=t-F,u=t-(F+f)+(f-o),f=i-T,c=i-(T+f)+(f-o),a===0&&u===0&&l===0&&c===0)||(C=iX*s+ZV*Math.abs(N),N+=$*c+T*a-(F*l+A*u),N>=C||-N>=C))return N;x=a*T,d=Pt*a,h=d-(d-a),g=a-h,d=Pt*T,p=d-(d-T),m=T-p,E=g*m-(x-h*p-g*p-h*m),_=u*A,d=Pt*u,h=d-(d-u),g=u-h,d=Pt*A,p=d-(d-A),m=A-p,w=g*m-(_-h*p-g*p-h*m),y=E-w,f=E-y,Xt[0]=E-(y+f)+(f-w),b=x+y,f=b-x,v=x-(b-f)+(y-f),y=v-_,f=v-y,Xt[1]=v-(y+f)+(f-_),S=b+y,f=S-b,Xt[2]=b-(S-f)+(y-f),Xt[3]=S;const k=G0(4,Ba,4,Xt,Ek);x=$*c,d=Pt*$,h=d-(d-$),g=$-h,d=Pt*c,p=d-(d-c),m=c-p,E=g*m-(x-h*p-g*p-h*m),_=F*l,d=Pt*F,h=d-(d-F),g=F-h,d=Pt*l,p=d-(d-l),m=l-p,w=g*m-(_-h*p-g*p-h*m),y=E-w,f=E-y,Xt[0]=E-(y+f)+(f-w),b=x+y,f=b-x,v=x-(b-f)+(y-f),y=v-_,f=v-y,Xt[1]=v-(y+f)+(f-_),S=b+y,f=S-b,Xt[2]=b-(S-f)+(y-f),Xt[3]=S;const M=G0(k,Ek,4,Xt,_k);x=a*c,d=Pt*a,h=d-(d-a),g=a-h,d=Pt*c,p=d-(d-c),m=c-p,E=g*m-(x-h*p-g*p-h*m),_=u*l,d=Pt*u,h=d-(d-u),g=u-h,d=Pt*l,p=d-(d-l),m=l-p,w=g*m-(_-h*p-g*p-h*m),y=E-w,f=E-y,Xt[0]=E-(y+f)+(f-w),b=x+y,f=b-x,v=x-(b-f)+(y-f),y=v-_,f=v-y,Xt[1]=v-(y+f)+(f-_),S=b+y,f=S-b,Xt[2]=b-(S-f)+(y-f),Xt[3]=S;const D=G0(M,_k,4,Xt,Sk);return Sk[D-1]}function Ed(e,t,n,i,r,o){const s=(t-o)*(n-r),a=(e-r)*(i-o),u=s-a,l=Math.abs(s+a);return Math.abs(u)>=tX*l?u:-rX(e,t,n,i,r,o,l)}const $k=Math.pow(2,-52),_d=new Uint32Array(512);class Eg{static from(t,n=lX,i=cX){const r=t.length,o=new Float64Array(r*2);for(let s=0;s>1;if(n>0&&typeof t[0]!="number")throw new Error("Expected coords to contain numbers.");this.coords=t;const i=Math.max(2*n-5,0);this._triangles=new Uint32Array(i*3),this._halfedges=new Int32Array(i*3),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.trianglesLen=0,this._cx=0,this._cy=0,this._hullStart=0,this.hull=this._triangles,this.triangles=this._triangles,this.halfedges=this._halfedges,this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:i,_hullTri:r,_hullHash:o}=this,s=t.length>>1;let a=1/0,u=1/0,l=-1/0,c=-1/0;for(let $=0;$l&&(l=A),F>c&&(c=F),this._ids[$]=$}const f=(a+l)/2,d=(u+c)/2;let h=0,g=0,p=0;for(let $=0,A=1/0;$0&&(g=$,A=F)}let b=t[2*g],v=t[2*g+1],x=1/0;for(let $=0;$T&&($[A++]=N,T=C)}this.hull=$.subarray(0,A),this.triangles=new Uint32Array(0),this.halfedges=new Int32Array(0);return}if(Ed(m,y,b,v,E,_)<0){const $=g,A=b,F=v;g=p,b=E,v=_,p=$,E=A,_=F}const w=uX(m,y,b,v,E,_);this._cx=w.x,this._cy=w.y;for(let $=0;$0&&Math.abs(N-A)<=$k&&Math.abs(C-F)<=$k||(A=N,F=C,T===h||T===g||T===p))continue;let k=0;for(let X=0,le=this._hashKey(N,C);X=0;)if(M=D,M===k){M=-1;break}if(M===-1)continue;let B=this._addTriangle(M,T,i[M],-1,-1,r[M]);r[T]=this._legalize(B+2),r[M]=B,S++;let z=i[M];for(;D=i[z],Ed(N,C,t[2*z],t[2*z+1],t[2*D],t[2*D+1])<0;)B=this._addTriangle(z,T,D,r[T],-1,r[z]),r[T]=this._legalize(B+2),i[z]=z,S--,z=D;if(M===k)for(;D=n[M],Ed(N,C,t[2*D],t[2*D+1],t[2*M],t[2*M+1])<0;)B=this._addTriangle(D,T,M,-1,r[M],r[D]),this._legalize(B+2),r[D]=B,i[M]=M,S--,M=D;this._hullStart=n[T]=M,i[M]=n[z]=T,i[T]=z,o[this._hashKey(N,C)]=T,o[this._hashKey(t[2*M],t[2*M+1])]=M}this.hull=new Uint32Array(S);for(let $=0,A=this._hullStart;$0?3-n:1+n)/4}function Y0(e,t,n,i){const r=e-n,o=t-i;return r*r+o*o}function sX(e,t,n,i,r,o,s,a){const u=e-s,l=t-a,c=n-s,f=i-a,d=r-s,h=o-a,g=u*u+l*l,p=c*c+f*f,m=d*d+h*h;return u*(f*m-p*h)-l*(c*m-p*d)+g*(c*h-f*d)<0}function aX(e,t,n,i,r,o){const s=n-e,a=i-t,u=r-e,l=o-t,c=s*s+a*a,f=u*u+l*l,d=.5/(s*l-a*u),h=(l*c-a*f)*d,g=(s*f-u*c)*d;return h*h+g*g}function uX(e,t,n,i,r,o){const s=n-e,a=i-t,u=r-e,l=o-t,c=s*s+a*a,f=u*u+l*l,d=.5/(s*l-a*u),h=e+(l*c-a*f)*d,g=t+(s*f-u*c)*d;return{x:h,y:g}}function Za(e,t,n,i){if(i-n<=20)for(let r=n+1;r<=i;r++){const o=e[r],s=t[o];let a=r-1;for(;a>=n&&t[e[a]]>s;)e[a+1]=e[a--];e[a+1]=o}else{const r=n+i>>1;let o=n+1,s=i;Ll(e,r,o),t[e[n]]>t[e[i]]&&Ll(e,n,i),t[e[o]]>t[e[i]]&&Ll(e,o,i),t[e[n]]>t[e[o]]&&Ll(e,n,o);const a=e[o],u=t[a];for(;;){do o++;while(t[e[o]]u);if(s=s-n?(Za(e,t,o,i),Za(e,t,n,s-1)):(Za(e,t,n,s-1),Za(e,t,o,i))}}function Ll(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}function lX(e){return e[0]}function cX(e){return e[1]}const kk=1e-6;class Ds{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(t,n){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(t,n){this._+=`L${this._x1=+t},${this._y1=+n}`}arc(t,n,i){t=+t,n=+n,i=+i;const r=t+i,o=n;if(i<0)throw new Error("negative radius");this._x1===null?this._+=`M${r},${o}`:(Math.abs(this._x1-r)>kk||Math.abs(this._y1-o)>kk)&&(this._+="L"+r+","+o),i&&(this._+=`A${i},${i},0,1,1,${t-i},${n}A${i},${i},0,1,1,${this._x1=r},${this._y1=o}`)}rect(t,n,i,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${+i}v${+r}h${-i}Z`}value(){return this._||null}}class lb{constructor(){this._=[]}moveTo(t,n){this._.push([t,n])}closePath(){this._.push(this._[0].slice())}lineTo(t,n){this._.push([t,n])}value(){return this._.length?this._:null}}let fX=class{constructor(t,[n,i,r,o]=[0,0,960,500]){if(!((r=+r)>=(n=+n))||!((o=+o)>=(i=+i)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(t.points.length*2),this.vectors=new Float64Array(t.points.length*2),this.xmax=r,this.xmin=n,this.ymax=o,this.ymin=i,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:n,triangles:i},vectors:r}=this;let o,s;const a=this.circumcenters=this._circumcenters.subarray(0,i.length/3*2);for(let p=0,m=0,y=i.length,b,v;p1;)o-=2;for(let s=2;s0){if(n>=this.ymax)return null;(s=(this.ymax-n)/r)0){if(t>=this.xmax)return null;(s=(this.xmax-t)/i)this.xmax?2:0)|(nthis.ymax?8:0)}_simplify(t){if(t&&t.length>4){for(let n=0;n1e-10)return!1}return!0}function mX(e,t,n){return[e+Math.sin(e+t)*n,t+Math.cos(e-t)*n]}class gw{static from(t,n=hX,i=gX,r){return new gw("length"in t?yX(t,n,i,r):Float64Array.from(bX(t,n,i,r)))}constructor(t){this._delaunator=new Eg(t),this.inedges=new Int32Array(t.length/2),this._hullIndex=new Int32Array(t.length/2),this.points=this._delaunator.coords,this._init()}update(){return this._delaunator.update(),this._init(),this}_init(){const t=this._delaunator,n=this.points;if(t.hull&&t.hull.length>2&&pX(t)){this.collinear=Int32Array.from({length:n.length/2},(d,h)=>h).sort((d,h)=>n[2*d]-n[2*h]||n[2*d+1]-n[2*h+1]);const u=this.collinear[0],l=this.collinear[this.collinear.length-1],c=[n[2*u],n[2*u+1],n[2*l],n[2*l+1]],f=1e-8*Math.hypot(c[3]-c[1],c[2]-c[0]);for(let d=0,h=n.length/2;d0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],s[r[0]]=1,r.length===2&&(s[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(t){return new fX(this,t)}*neighbors(t){const{inedges:n,hull:i,_hullIndex:r,halfedges:o,triangles:s,collinear:a}=this;if(a){const f=a.indexOf(t);f>0&&(yield a[f-1]),f=0&&o!==i&&o!==r;)i=o;return o}_step(t,n,i){const{inedges:r,hull:o,_hullIndex:s,halfedges:a,triangles:u,points:l}=this;if(r[t]===-1||!l.length)return(t+1)%(l.length>>1);let c=t,f=Ua(n-l[t*2],2)+Ua(i-l[t*2+1],2);const d=r[t];let h=d;do{let g=u[h];const p=Ua(n-l[g*2],2)+Ua(i-l[g*2+1],2);if(p>5)*e[1]),m=null,y=l.length,b=-1,v=[],x=l.map(_=>({text:t(_),font:n(_),style:r(_),weight:o(_),rotate:s(_),size:~~(i(_)+1e-14),padding:a(_),xoff:0,yoff:0,x1:0,y1:0,x0:0,y0:0,hasText:!1,sprite:null,datum:_})).sort((_,w)=>w.size-_.size);++b>1,E.y=e[1]*(c()+.5)>>1,SX(g,E,x,b),E.hasText&&h(p,E,m)&&(v.push(E),m?kX(m,E):m=[{x:E.x+E.x0,y:E.y+E.y0},{x:E.x+E.x1,y:E.y+E.y1}],E.x-=e[0]>>1,E.y-=e[1]>>1)}return v};function d(g){g.width=g.height=1;var p=Math.sqrt(g.getContext("2d").getImageData(0,0,1,1).data.length>>2);g.width=(hc<<5)/p,g.height=rh/p;var m=g.getContext("2d");return m.fillStyle=m.strokeStyle="red",m.textAlign="center",{context:m,ratio:p}}function h(g,p,m){for(var y=p.x,b=p.y,v=Math.hypot(e[0],e[1]),x=u(e),E=c()<.5?1:-1,_=-E,w,S,$;(w=x(_+=E))&&(S=~~w[0],$=~~w[1],!(Math.min(Math.abs(S),Math.abs($))>=v));)if(p.x=y+S,p.y=b+$,!(p.x+p.x0<0||p.y+p.y0<0||p.x+p.x1>e[0]||p.y+p.y1>e[1])&&(!m||!$X(p,g,e[0]))&&(!m||AX(p,m))){for(var A=p.sprite,F=p.width>>5,T=e[0]>>5,N=p.x-(F<<4),C=N&127,k=32-C,M=p.y1-p.y0,D=(p.y+p.y0)*T+(N>>5),B,z=0;z>>C:0);D+=T}return p.sprite=null,!0}return!1}return f.words=function(g){return arguments.length?(l=g,f):l},f.size=function(g){return arguments.length?(e=[+g[0],+g[1]],f):e},f.font=function(g){return arguments.length?(n=gs(g),f):n},f.fontStyle=function(g){return arguments.length?(r=gs(g),f):r},f.fontWeight=function(g){return arguments.length?(o=gs(g),f):o},f.rotate=function(g){return arguments.length?(s=gs(g),f):s},f.text=function(g){return arguments.length?(t=gs(g),f):t},f.spiral=function(g){return arguments.length?(u=MX[g]||g,f):u},f.fontSize=function(g){return arguments.length?(i=gs(g),f):i},f.padding=function(g){return arguments.length?(a=gs(g),f):a},f.random=function(g){return arguments.length?(c=g,f):c},f}function SX(e,t,n,i){if(!t.sprite){var r=e.context,o=e.ratio;r.clearRect(0,0,(hc<<5)/o,rh/o);var s=0,a=0,u=0,l=n.length,c,f,d,h,g;for(--i;++i>5<<5,d=~~Math.max(Math.abs(b+v),Math.abs(b-v))}else c=c+31>>5<<5;if(d>u&&(u=d),s+c>=hc<<5&&(s=0,a+=u,u=0),a+d>=rh)break;r.translate((s+(c>>1))/o,(a+(d>>1))/o),t.rotate&&r.rotate(t.rotate*V0),r.fillText(t.text,0,0),t.padding&&(r.lineWidth=2*t.padding,r.strokeText(t.text,0,0)),r.restore(),t.width=c,t.height=d,t.xoff=s,t.yoff=a,t.x1=c>>1,t.y1=d>>1,t.x0=-t.x1,t.y0=-t.y1,t.hasText=!0,s+=c}for(var E=r.getImageData(0,0,(hc<<5)/o,rh/o).data,_=[];--i>=0;)if(t=n[i],!!t.hasText){for(c=t.width,f=c>>5,d=t.y1-t.y0,h=0;h>5),A=E[(a+g)*(hc<<5)+(s+h)<<2]?1<<31-h%32:0;_[$]|=A,w|=A}w?S=g:(t.y0++,d--,g--,a++)}t.y1=t.y0+S,t.sprite=_.slice(0,(t.y1-t.y0)*f)}}}function $X(e,t,n){n>>=5;for(var i=e.sprite,r=e.width>>5,o=e.x-(r<<4),s=o&127,a=32-s,u=e.y1-e.y0,l=(e.y+e.y0)*n+(o>>5),c,f=0;f>>s:0))&t[l+d])return!0;l+=n}return!1}function kX(e,t){var n=e[0],i=e[1];t.x+t.x0i.x&&(i.x=t.x+t.x1),t.y+t.y1>i.y&&(i.y=t.y+t.y1)}function AX(e,t){return e.x+e.x1>t[0].x&&e.x+e.x0t[0].y&&e.y+e.y0p(g(m))}r.forEach(g=>{g[s[0]]=NaN,g[s[1]]=NaN,g[s[3]]=0});const l=o.words(r).text(e.text).size(e.size||[500,500]).padding(e.padding||1).spiral(e.spiral||"archimedean").rotate(e.rotate||0).font(e.font||"sans-serif").fontStyle(e.fontStyle||"normal").fontWeight(e.fontWeight||"normal").fontSize(a).random(ii).layout(),c=o.size(),f=c[0]>>1,d=c[1]>>1,h=l.length;for(let g=0,p,m;gnew Uint8Array(e),OX=e=>new Uint16Array(e),$c=e=>new Uint32Array(e);function DX(){let e=8,t=[],n=$c(0),i=Sd(0,e),r=Sd(0,e);return{data:()=>t,seen:()=>n=LX(n,t.length),add(o){for(let s=0,a=t.length,u=o.length,l;st.length,curr:()=>i,prev:()=>r,reset:o=>r[o]=i[o],all:()=>e<257?255:e<65537?65535:4294967295,set(o,s){i[o]|=s},clear(o,s){i[o]&=~s},resize(o,s){const a=i.length;(o>a||s>e)&&(e=Math.max(s,e),i=Sd(o,e,i),r=Sd(o,e))}}}function LX(e,t,n){return e.length>=t?e:(n=n||new e.constructor(t),n.set(e),n)}function Sd(e,t,n){const i=(t<257?RX:t<65537?OX:$c)(e);return n&&i.set(n),i}function Ak(e,t,n){const i=1<0)for(m=0;me,size:()=>n}}function PX(e,t){return e.sort.call(t,(n,i)=>{const r=e[n],o=e[i];return ro?1:0}),GI(e,t)}function IX(e,t,n,i,r,o,s,a,u){let l=0,c=0,f;for(f=0;lt.modified(i.fields));return n?this.reinit(e,t):this.eval(e,t)}else return this.init(e,t)},init(e,t){const n=e.fields,i=e.query,r=this._indices={},o=this._dims=[],s=i.length;let a=0,u,l;for(;a{const o=r.remove(t,n);for(const s in i)i[s].reindex(o)})},update(e,t,n){const i=this._dims,r=e.query,o=t.stamp,s=i.length;let a=0,u,l;for(n.filters=0,l=0;lh)for(m=h,y=Math.min(f,g);mg)for(m=Math.max(f,g),y=d;mf)for(g=f,p=Math.min(l,d);gd)for(g=Math.max(l,d),p=c;ga[c]&n?null:s[c];return o.filter(o.MOD,l),r&r-1?(o.filter(o.ADD,c=>{const f=a[c]&n;return!f&&f^u[c]&n?s[c]:null}),o.filter(o.REM,c=>{const f=a[c]&n;return f&&!(f^(f^u[c]&n))?s[c]:null})):(o.filter(o.ADD,l),o.filter(o.REM,c=>(a[c]&n)===r?s[c]:null)),o.filter(o.SOURCE,c=>l(c._index))}});const zX=Object.freeze(Object.defineProperty({__proto__:null,crossfilter:yw,resolvefilter:bw},Symbol.toStringTag,{value:"Module"})),BX="RawCode",ea="Literal",UX="Property",jX="Identifier",qX="ArrayExpression",WX="BinaryExpression",uD="CallExpression",HX="ConditionalExpression",GX="LogicalExpression",YX="MemberExpression",VX="ObjectExpression",XX="UnaryExpression";function Ni(e){this.type=e}Ni.prototype.visit=function(e){let t,n,i;if(e(this))return 1;for(t=KX(this),n=0,i=t.length;n";yr[ta]="Identifier";yr[is]="Keyword";yr[Gp]="Null";yr[Ea]="Numeric";yr[gn]="Punctuator";yr[Of]="String";yr[JX]="RegularExpression";var QX="ArrayExpression",ZX="BinaryExpression",eK="CallExpression",tK="ConditionalExpression",lD="Identifier",nK="Literal",iK="LogicalExpression",rK="MemberExpression",oK="ObjectExpression",sK="Property",aK="UnaryExpression",vt="Unexpected token %0",uK="Unexpected number",lK="Unexpected string",cK="Unexpected identifier",fK="Unexpected reserved word",dK="Unexpected end of input",cb="Invalid regular expression",X0="Invalid regular expression: missing /",cD="Octal literals are not allowed in strict mode.",hK="Duplicate data property in object literal not allowed in strict mode",Mt="ILLEGAL",Yc="Disabled.",gK=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),pK=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function Yp(e,t){if(!e)throw new Error("ASSERT: "+t)}function Nr(e){return e>=48&&e<=57}function vw(e){return"0123456789abcdefABCDEF".includes(e)}function kc(e){return"01234567".includes(e)}function mK(e){return e===32||e===9||e===11||e===12||e===160||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].includes(e)}function Vc(e){return e===10||e===13||e===8232||e===8233}function Df(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e===92||e>=128&&gK.test(String.fromCharCode(e))}function _g(e){return e===36||e===95||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===92||e>=128&&pK.test(String.fromCharCode(e))}const yK={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function fD(){for(;L1114111||e!=="}")&&$e({},vt,Mt),t<=65535?String.fromCharCode(t):(n=(t-65536>>10)+55296,i=(t-65536&1023)+56320,String.fromCharCode(n,i))}function dD(){var e,t;for(e=te.charCodeAt(L++),t=String.fromCharCode(e),e===92&&(te.charCodeAt(L)!==117&&$e({},vt,Mt),++L,e=fb("u"),(!e||e==="\\"||!Df(e.charCodeAt(0)))&&$e({},vt,Mt),t=e);L>>=")return L+=4,{type:gn,value:s,start:e,end:L};if(o=s.substr(0,3),o===">>>"||o==="<<="||o===">>=")return L+=3,{type:gn,value:o,start:e,end:L};if(r=o.substr(0,2),i===r[1]&&"+-<>&|".includes(i)||r==="=>")return L+=2,{type:gn,value:r,start:e,end:L};if(r==="//"&&$e({},vt,Mt),"<>=!+-*%&|^/".includes(i))return++L,{type:gn,value:i,start:e,end:L};$e({},vt,Mt)}function wK(e){let t="";for(;L{if(parseInt(r,16)<=1114111)return"x";$e({},cb)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n)}catch{$e({},cb)}try{return new RegExp(e,t)}catch{return null}}function $K(){var e,t,n,i,r;for(e=te[L],Yp(e==="/","Regular expression literal must start with a slash"),t=te[L++],n=!1,i=!1;L=0&&$e({},cb,n),{value:n,literal:t}}function AK(){var e,t,n,i;return Oe=null,fD(),e=L,t=$K(),n=kK(),i=SK(t.value,n.value),{literal:t.literal+n.literal,value:i,regex:{pattern:t.value,flags:n.value},start:e,end:L}}function CK(e){return e.type===ta||e.type===is||e.type===Hp||e.type===Gp}function hD(){if(fD(),L>=Ht)return{type:Rf,start:L,end:L};const e=te.charCodeAt(L);return Df(e)?xK():e===40||e===41||e===59?K0():e===39||e===34?_K():e===46?Nr(te.charCodeAt(L+1))?Fk():K0():Nr(e)?Fk():K0()}function mn(){const e=Oe;return L=e.end,Oe=hD(),L=e.end,e}function gD(){const e=L;Oe=hD(),L=e}function FK(e){const t=new Ni(QX);return t.elements=e,t}function Mk(e,t,n){const i=new Ni(e==="||"||e==="&&"?iK:ZX);return i.operator=e,i.left=t,i.right=n,i}function MK(e,t){const n=new Ni(eK);return n.callee=e,n.arguments=t,n}function TK(e,t,n){const i=new Ni(tK);return i.test=e,i.consequent=t,i.alternate=n,i}function xw(e){const t=new Ni(lD);return t.name=e,t}function gc(e){const t=new Ni(nK);return t.value=e.value,t.raw=te.slice(e.start,e.end),e.regex&&(t.raw==="//"&&(t.raw="/(?:)/"),t.regex=e.regex),t}function Tk(e,t,n){const i=new Ni(rK);return i.computed=e==="[",i.object=t,i.property=n,i.computed||(n.member=!0),i}function NK(e){const t=new Ni(oK);return t.properties=e,t}function Nk(e,t,n){const i=new Ni(sK);return i.key=t,i.value=n,i.kind=e,i}function RK(e,t){const n=new Ni(aK);return n.operator=e,n.argument=t,n.prefix=!0,n}function $e(e,t){var n,i=Array.prototype.slice.call(arguments,2),r=t.replace(/%(\d)/g,(o,s)=>(Yp(s":case"<=":case">=":case"instanceof":case"in":t=7;break;case"<<":case">>":case">>>":t=8;break;case"+":case"-":t=9;break;case"*":case"/":case"%":t=11;break}return t}function HK(){var e,t,n,i,r,o,s,a,u,l;if(e=Oe,u=oh(),i=Oe,r=Dk(i),r===0)return u;for(i.prec=r,mn(),t=[e,Oe],s=oh(),o=[u,i,s];(r=Dk(Oe))>0;){for(;o.length>2&&r<=o[o.length-2].prec;)s=o.pop(),a=o.pop().value,u=o.pop(),t.pop(),n=Mk(a,u,s),o.push(n);i=mn(),i.prec=r,o.push(i),t.push(Oe),n=oh(),o.push(n)}for(l=o.length-1,n=o[l],t.pop();l>1;)t.pop(),n=Mk(o[l-1].value,o[l-2],n),l-=2;return n}function na(){var e,t,n;return e=HK(),je("?")&&(mn(),t=na(),Gt(":"),n=na(),e=TK(e,t,n)),e}function ww(){const e=na();if(je(","))throw new Error(Yc);return e}function Ew(e){te=e,L=0,Ht=te.length,Oe=null,gD();const t=ww();if(Oe.type!==Rf)throw new Error("Unexpect token after expression.");return t}var pD={NaN:"NaN",E:"Math.E",LN2:"Math.LN2",LN10:"Math.LN10",LOG2E:"Math.LOG2E",LOG10E:"Math.LOG10E",PI:"Math.PI",SQRT1_2:"Math.SQRT1_2",SQRT2:"Math.SQRT2",MIN_VALUE:"Number.MIN_VALUE",MAX_VALUE:"Number.MAX_VALUE"};function mD(e){function t(s,a,u,l){let c=e(a[0]);return u&&(c=u+"("+c+")",u.lastIndexOf("new ",0)===0&&(c="("+c+")")),c+"."+s+(l<0?"":l===0?"()":"("+a.slice(1).map(e).join(",")+")")}function n(s,a,u){return l=>t(s,l,a,u)}const i="new Date",r="String",o="RegExp";return{isNaN:"Number.isNaN",isFinite:"Number.isFinite",abs:"Math.abs",acos:"Math.acos",asin:"Math.asin",atan:"Math.atan",atan2:"Math.atan2",ceil:"Math.ceil",cos:"Math.cos",exp:"Math.exp",floor:"Math.floor",hypot:"Math.hypot",log:"Math.log",max:"Math.max",min:"Math.min",pow:"Math.pow",random:"Math.random",round:"Math.round",sin:"Math.sin",sqrt:"Math.sqrt",tan:"Math.tan",clamp:function(s){s.length<3&&O("Missing arguments to clamp function."),s.length>3&&O("Too many arguments to clamp function.");const a=s.map(e);return"Math.max("+a[1]+", Math.min("+a[2]+","+a[0]+"))"},now:"Date.now",utc:"Date.UTC",datetime:i,date:n("getDate",i,0),day:n("getDay",i,0),year:n("getFullYear",i,0),month:n("getMonth",i,0),hours:n("getHours",i,0),minutes:n("getMinutes",i,0),seconds:n("getSeconds",i,0),milliseconds:n("getMilliseconds",i,0),time:n("getTime",i,0),timezoneoffset:n("getTimezoneOffset",i,0),utcdate:n("getUTCDate",i,0),utcday:n("getUTCDay",i,0),utcyear:n("getUTCFullYear",i,0),utcmonth:n("getUTCMonth",i,0),utchours:n("getUTCHours",i,0),utcminutes:n("getUTCMinutes",i,0),utcseconds:n("getUTCSeconds",i,0),utcmilliseconds:n("getUTCMilliseconds",i,0),length:n("length",null,-1),parseFloat:"parseFloat",parseInt:"parseInt",upper:n("toUpperCase",r,0),lower:n("toLowerCase",r,0),substring:n("substring",r),split:n("split",r),trim:n("trim",r,0),btoa:"btoa",atob:"atob",regexp:o,test:n("test",o),if:function(s){s.length<3&&O("Missing arguments to if function."),s.length>3&&O("Too many arguments to if function.");const a=s.map(e);return"("+a[0]+"?"+a[1]+":"+a[2]+")"}}}function GK(e){const t=e&&e.length-1;return t&&(e[0]==='"'&&e[t]==='"'||e[0]==="'"&&e[t]==="'")?e.slice(1,-1):e}function yD(e){e=e||{};const t=e.allowed?$i(e.allowed):{},n=e.forbidden?$i(e.forbidden):{},i=e.constants||pD,r=(e.functions||mD)(f),o=e.globalvar,s=e.fieldvar,a=de(o)?o:g=>`${o}["${g}"]`;[...Object.getOwnPropertyNames(Object.prototype).filter(g=>typeof Object.prototype[g]=="function")];let u={},l={},c=0;function f(g){if(J(g))return g;const p=d[g.type];return p==null&&O("Unsupported type: "+g.type),p(g)}const d={Literal:g=>g.raw,Identifier:g=>{const p=g.name;return c>0?p:Z(n,p)?O("Illegal identifier: "+p):Z(i,p)?i[p]:Z(t,p)?p:(u[p]=1,a(p))},MemberExpression:g=>{const p=!g.computed,m=f(g.object);p&&(c+=1);const y=f(g.property);return m===s&&(l[GK(y)]=1),p&&(c-=1),m+(p?"."+y:"["+y+"]")},CallExpression:g=>{g.callee.type!=="Identifier"&&O("Illegal callee type: "+g.callee.type);const p=g.callee.name,m=g.arguments,y=Z(r,p)&&r[p];return y||O("Unrecognized function: "+p),de(y)?y(m):y+"("+m.map(f).join(",")+")"},ArrayExpression:g=>"["+g.elements.map(f).join(",")+"]",BinaryExpression:g=>"("+f(g.left)+" "+g.operator+" "+f(g.right)+")",UnaryExpression:g=>"("+g.operator+f(g.argument)+")",ConditionalExpression:g=>"("+f(g.test)+"?"+f(g.consequent)+":"+f(g.alternate)+")",LogicalExpression:g=>"("+f(g.left)+g.operator+f(g.right)+")",ObjectExpression:g=>{for(const p of g.properties){const m=p.key.name;ov.has(m)&&O("Illegal property: "+m)}return"{"+g.properties.map(f).join(",")+"}"},Property:g=>{c+=1;const p=f(g.key);return c-=1,p+":"+f(g.value)}};function h(g){const p={code:f(g),globals:Object.keys(u),fields:Object.keys(l)};return u={},l={},p}return h.functions=r,h.constants=i,h}const Lk=Symbol("vega_selection_getter");function bD(e){return(!e.getter||!e.getter[Lk])&&(e.getter=ei(e.field),e.getter[Lk]=!0),e.getter}const _w="intersect",Pk="union",YK="vlMulti",VK="vlPoint",Ik="or",XK="and",Gi="_vgsid_",Xc=ei(Gi),KK="E",JK="R",QK="R-E",ZK="R-LE",eJ="R-RE",tJ="E-LT",nJ="E-LTE",iJ="E-GT",rJ="E-GTE",oJ="E-VALID",sJ="E-ONE",Sg="index:unit";function zk(e,t){for(var n=t.fields,i=t.values,r=n.length,o=0,s,a;o=i[o])return!1}else if(a.type===nJ){if(s>i[o])return!1}else if(a.type===iJ){if(s<=i[o])return!1}else if(a.type===rJ){if(spe(t.fields?{values:t.fields.map(i=>bD(i)(n.datum))}:{[Gi]:Xc(n.datum)},t))}function dJ(e,t,n,i){for(var r=this.context.data[e],o=r?r.values.value:[],s={},a={},u={},l,c,f,d,h,g,p,m,y,b,v=o.length,x=0,E,_;x(w[c[$].field]=S,w),{})))}else h=Gi,g=Xc(l),p=s[h]||(s[h]={}),m=p[d]||(p[d]=[]),m.push(g),n&&(m=a[d]||(a[d]=[]),m.push({[Gi]:g}));if(t=t||Pk,s[Gi]?s[Gi]=Q0[`${Gi}_${t}`](...Object.values(s[Gi])):Object.keys(s).forEach(w=>{s[w]=Object.keys(s[w]).map(S=>s[w][S]).reduce((S,$)=>S===void 0?$:Q0[`${u[w]}_${t}`](S,$))}),o=Object.keys(a),n&&o.length){const w=i?VK:YK;s[w]=t===Pk?{[Ik]:o.reduce((S,$)=>(S.push(...a[$]),S),[])}:{[XK]:o.map(S=>({[Ik]:a[S]}))}}return s}var Q0={[`${Gi}_union`]:t4,[`${Gi}_intersect`]:ZI,E_union:function(e,t){if(!e.length)return t;for(var n=0,i=t.length;nt.includes(n)):t},R_union:function(e,t){var n=nn(t[0]),i=nn(t[1]);return n>i&&(n=t[1],i=t[0]),e.length?(e[0]>n&&(e[0]=n),e[1]i&&(n=t[1],i=t[0]),e.length?ii&&(e[1]=i),e):[n,i]}};const hJ=":",gJ="@";function Sw(e,t,n,i){t[0].type!==ea&&O("First argument to selection functions must be a string literal.");const r=t[0].value,o=t.length>=2&&_e(t).value,s="unit",a=gJ+s,u=hJ+r;o===_w&&!Z(i,a)&&(i[a]=n.getData(r).indataRef(n,s)),Z(i,u)||(i[u]=n.getData(r).tuplesRef())}function xD(e){const t=this.context.data[e];return t?t.values.value:[]}function pJ(e,t,n){const i=this.context.data[e]["index:"+t],r=i?i.value.get(n):void 0;return r&&r.count}function mJ(e,t){const n=this.context.dataflow,i=this.context.data[e],r=i.input;return n.pulse(r,n.changeset().remove(ti).insert(t)),1}function yJ(e,t,n){if(e){const i=this.context.dataflow,r=e.mark.source;i.pulse(r,i.changeset().encode(e,t))}return n!==void 0?n:e}const Lf=e=>function(t,n){const i=this.context.dataflow.locale();return t===null?"null":i[e](n)(t)},bJ=Lf("format"),wD=Lf("timeFormat"),vJ=Lf("utcFormat"),xJ=Lf("timeParse"),wJ=Lf("utcParse"),$d=new Date(2e3,0,1);function Xp(e,t,n){return!Number.isInteger(e)||!Number.isInteger(t)?"":($d.setYear(2e3),$d.setMonth(e),$d.setDate(t),wD.call(this,$d,n))}function EJ(e){return Xp.call(this,e,1,"%B")}function _J(e){return Xp.call(this,e,1,"%b")}function SJ(e){return Xp.call(this,0,2+e,"%A")}function $J(e){return Xp.call(this,0,2+e,"%a")}const kJ=":",AJ="@",db="%",ED="$";function $w(e,t,n,i){t[0].type!==ea&&O("First argument to data functions must be a string literal.");const r=t[0].value,o=kJ+r;if(!Z(o,i))try{i[o]=n.getData(r).tuplesRef()}catch{}}function CJ(e,t,n,i){t[0].type!==ea&&O("First argument to indata must be a string literal."),t[1].type!==ea&&O("Second argument to indata must be a string literal.");const r=t[0].value,o=t[1].value,s=AJ+o;Z(s,i)||(i[s]=n.getData(r).indataRef(n,o))}function an(e,t,n,i){if(t[0].type===ea)Bk(n,i,t[0].value);else for(e in n.scales)Bk(n,i,e)}function Bk(e,t,n){const i=db+n;if(!Z(t,i))try{t[i]=e.scaleRef(n)}catch{}}function br(e,t){if(J(e)){const n=t.scales[e];return n&&qS(n.value)?n.value:void 0}else if(de(e))return qS(e)?e:void 0}function FJ(e,t,n){t.__bandwidth=r=>r&&r.bandwidth?r.bandwidth():0,n._bandwidth=an,n._range=an,n._scale=an;const i=r=>"_["+(r.type===ea?G(db+r.value):G(db)+"+"+e(r))+"]";return{_bandwidth:r=>`this.__bandwidth(${i(r[0])})`,_range:r=>`${i(r[0])}.range()`,_scale:r=>`${i(r[0])}(${e(r[1])})`}}function kw(e,t){return function(n,i,r){if(n){const o=br(n,(r||this).context);return o&&o.path[e](i)}else return t(i)}}const MJ=kw("area",VW),TJ=kw("bounds",QW),NJ=kw("centroid",rH);function RJ(e,t){const n=br(e,(t||this).context);return n&&n.scale()}function OJ(e){const t=this.context.group;let n=!1;if(t)for(;e;){if(e===t){n=!0;break}e=e.mark.group}return n}function Aw(e,t,n){try{e[t].apply(e,["EXPRESSION"].concat([].slice.call(n)))}catch(i){e.warn(i)}return n[n.length-1]}function DJ(){return Aw(this.context.dataflow,"warn",arguments)}function LJ(){return Aw(this.context.dataflow,"info",arguments)}function PJ(){return Aw(this.context.dataflow,"debug",arguments)}function Z0(e){const t=e/255;return t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4)}function hb(e){const t=qo(e),n=Z0(t.r),i=Z0(t.g),r=Z0(t.b);return .2126*n+.7152*i+.0722*r}function IJ(e,t){const n=hb(e),i=hb(t),r=Math.max(n,i),o=Math.min(n,i);return(r+.05)/(o+.05)}function zJ(){const e=[].slice.call(arguments);return e.unshift({}),pe(...e)}function _D(e,t){return e===t||e!==e&&t!==t?!0:P(e)?P(t)&&e.length===t.length?BJ(e,t):!1:K(e)&&K(t)?SD(e,t):!1}function BJ(e,t){for(let n=0,i=e.length;nSD(e,t)}function UJ(e,t,n,i,r,o){const s=this.context.dataflow,a=this.context.data[e],u=a.input,l=s.stamp();let c=a.changes,f,d;if(s._trigger===!1||!(u.value.length||t||i))return 0;if((!c||c.stamp{a.modified=!0,s.pulse(u,c).run()},!0,1)),n&&(f=n===!0?ti:P(n)||rp(n)?n:Uk(n),c.remove(f)),t&&c.insert(t),i&&(f=Uk(i),u.value.some(f)?c.remove(f):c.insert(i)),r){if(de(r))throw Error("modify parameter must be a data tuple, not a function");for(d in o)c.modify(r,d,o[d])}return 1}function jJ(e){const t=e.touches,n=t[0].clientX-t[1].clientX,i=t[0].clientY-t[1].clientY;return Math.hypot(n,i)}function qJ(e){const t=e.touches;return Math.atan2(t[0].clientY-t[1].clientY,t[0].clientX-t[1].clientX)}const jk={};function WJ(e,t){const n=jk[t]||(jk[t]=ei(t));return P(e)?e.map(n):n(e)}function Kp(e){return P(e)||ArrayBuffer.isView(e)?e:null}function Cw(e){return Kp(e)||(J(e)?e:null)}function HJ(e,...t){return Kp(e).join(...t)}function GJ(e,...t){return Cw(e).indexOf(...t)}function YJ(e,...t){return Cw(e).lastIndexOf(...t)}function VJ(e,...t){return Cw(e).slice(...t)}function XJ(e,t,n){return de(n)&&O("Function argument passed to replace."),!J(t)&&!hv(t)&&O("Please pass a string or RegExp argument to replace."),String(e).replace(t,n)}function KJ(e){return Kp(e).slice().reverse()}function JJ(e){return Kp(e).slice().sort(Zu)}function QJ(e,t,n){return Ux(e||0,t||0,n||0)}function ZJ(e,t){const n=br(e,(t||this).context);return n&&n.bandwidth?n.bandwidth():0}function eQ(e,t){const n=br(e,(t||this).context);return n?n.copy():void 0}function tQ(e,t){const n=br(e,(t||this).context);return n?n.domain():[]}function nQ(e,t,n){const i=br(e,(n||this).context);return i?P(t)?(i.invertRange||i.invert)(t):(i.invert||i.invertExtent)(t):void 0}function iQ(e,t){const n=br(e,(t||this).context);return n&&n.range?n.range():[]}function rQ(e,t,n){const i=br(e,(n||this).context);return i?i(t):void 0}function oQ(e,t,n,i,r){e=br(e,(r||this).context);const o=p3(t,n);let s=e.domain(),a=s[0],u=_e(s),l=vn;return u-a?l=i3(e,a,u):e=(e.interpolator?Ce("sequential")().interpolator(e.interpolator()):Ce("linear")().interpolate(e.interpolate()).range(e.range())).domain([a=0,u=1]),e.ticks&&(s=e.ticks(+i||15),a!==s[0]&&s.unshift(a),u!==_e(s)&&s.push(u)),s.forEach(c=>o.stop(l(c),e(c))),o}function sQ(e,t,n){const i=br(e,(n||this).context);return function(r){return i?i.path.context(r)(t):""}}function aQ(e){let t=null;return function(n){return n?zc(n,t=t||Su(e)):e}}const $D=e=>e.data;function kD(e,t){const n=xD.call(t,e);return n.root&&n.root.lookup||{}}function uQ(e,t,n){const i=kD(e,this),r=i[t],o=i[n];return r&&o?r.path(o).map($D):void 0}function lQ(e,t){const n=kD(e,this)[t];return n?n.ancestors().map($D):void 0}const AD=()=>typeof window<"u"&&window||null;function cQ(){const e=AD();return e?e.screen:{}}function fQ(){const e=AD();return e?[e.innerWidth,e.innerHeight]:[void 0,void 0]}function dQ(){const e=this.context.dataflow,t=e.container&&e.container();return t?[t.clientWidth,t.clientHeight]:[void 0,void 0]}function CD(e,t,n){if(!e)return[];const[i,r]=e,o=new st().set(i[0],i[1],r[0],r[1]),s=n||this.context.dataflow.scenegraph().root;return fR(s,o,hQ(t))}function hQ(e){let t=null;if(e){const n=Q(e.marktype),i=Q(e.markname);t=r=>(!n.length||n.some(o=>r.marktype===o))&&(!i.length||i.some(o=>r.name===o))}return t}function gQ(e,t,n,i=5){e=Q(e);const r=e[e.length-1];return r===void 0||Math.hypot(r[0]-t,r[1]-n)>i?[...e,[t,n]]:e}function pQ(e){return Q(e).reduce((t,[n,i],r)=>t+=r==0?`M ${n},${i} `:r===e.length-1?" Z":`L ${n},${i} `,"")}function mQ(e,t,n){const{x:i,y:r,mark:o}=n,s=new st().set(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER,Number.MIN_SAFE_INTEGER);for(const[u,l]of t)us.x2&&(s.x2=u),ls.y2&&(s.y2=l);return s.translate(i,r),CD([[s.x1,s.y1],[s.x2,s.y2]],e,o).filter(u=>yQ(u.x,u.y,t))}function yQ(e,t,n){let i=0;for(let r=0,o=n.length-1;rt!=a>t&&e<(s-u)*(t-l)/(a-l)+u&&i++}return i&1}const Kc={random(){return ii()},cumulativeNormal:lp,cumulativeLogNormal:Uv,cumulativeUniform:Hv,densityNormal:Lv,densityLogNormal:Bv,densityUniform:Wv,quantileNormal:cp,quantileLogNormal:jv,quantileUniform:Gv,sampleNormal:up,sampleLogNormal:zv,sampleUniform:qv,isArray:P,isBoolean:pa,isDate:Ro,isDefined(e){return e!==void 0},isNumber:ke,isObject:K,isRegExp:hv,isString:J,isTuple:rp,isValid(e){return e!=null&&e===e},toBoolean:pv,toDate(e){return mv(e)},toNumber:nn,toString:yv,indexof:GJ,join:HJ,lastindexof:YJ,replace:XJ,reverse:KJ,sort:JJ,slice:VJ,flush:LF,lerp:IF,merge:zJ,pad:UF,peek:_e,pluck:WJ,span:lf,inrange:Xa,truncate:jF,rgb:qo,lab:Mh,hcl:Th,hsl:Ch,luminance:hb,contrast:IJ,sequence:Nn,format:bJ,utcFormat:vJ,utcParse:wJ,utcOffset:xM,utcSequence:_M,timeFormat:wD,timeParse:xJ,timeOffset:vM,timeSequence:EM,timeUnitSpecifier:uM,monthFormat:EJ,monthAbbrevFormat:_J,dayFormat:SJ,dayAbbrevFormat:$J,quarter:NF,utcquarter:RF,week:cM,utcweek:hM,dayofyear:lM,utcdayofyear:dM,warn:DJ,info:LJ,debug:PJ,extent(e){return ir(e)},inScope:OJ,intersect:CD,clampRange:OF,pinchDistance:jJ,pinchAngle:qJ,screen:cQ,containerSize:dQ,windowSize:fQ,bandspace:QJ,setdata:mJ,pathShape:aQ,panLinear:CF,panLog:FF,panPow:MF,panSymlog:TF,zoomLinear:uv,zoomLog:lv,zoomPow:gh,zoomSymlog:cv,encode:yJ,modify:UJ,lassoAppend:gQ,lassoPath:pQ,intersectLasso:mQ},bQ=["view","item","group","xy","x","y"],vQ="event.vega.",FD="this.",Fw={},MD={forbidden:["_"],allowed:["datum","event","item"],fieldvar:"datum",globalvar:e=>`_[${G(ED+e)}]`,functions:xQ,constants:pD,visitors:Fw},gb=yD(MD);function xQ(e){const t=mD(e);bQ.forEach(n=>t[n]=vQ+n);for(const n in Kc)t[n]=FD+n;return pe(t,FJ(e,Kc,Fw)),t}function rt(e,t,n){return arguments.length===1?Kc[e]:(Kc[e]=t,n&&(Fw[e]=n),gb&&(gb.functions[e]=FD+e),this)}rt("bandwidth",ZJ,an);rt("copy",eQ,an);rt("domain",tQ,an);rt("range",iQ,an);rt("invert",nQ,an);rt("scale",rQ,an);rt("gradient",oQ,an);rt("geoArea",MJ,an);rt("geoBounds",TJ,an);rt("geoCentroid",NJ,an);rt("geoShape",sQ,an);rt("geoScale",RJ,an);rt("indata",pJ,CJ);rt("data",xD,$w);rt("treePath",uQ,$w);rt("treeAncestors",lQ,$w);rt("vlSelectionTest",aJ,Sw);rt("vlSelectionIdTest",cJ,Sw);rt("vlSelectionResolve",dJ,Sw);rt("vlSelectionTuples",fJ);function ur(e,t){const n={};let i;try{e=J(e)?e:G(e)+"",i=Ew(e)}catch{O("Expression parse error: "+e)}i.visit(o=>{if(o.type!==uD)return;const s=o.callee.name,a=MD.visitors[s];a&&a(s,o.arguments,t,n)});const r=gb(i);return r.globals.forEach(o=>{const s=ED+o;!Z(n,s)&&t.getSignal(o)&&(n[s]=t.signalRef(o))}),{$expr:pe({code:r.code},t.options.ast?{ast:i}:null),$fields:r.fields,$params:n}}function wQ(e){const t=this,n=e.operators||[];return e.background&&(t.background=e.background),e.eventConfig&&(t.eventConfig=e.eventConfig),e.locale&&(t.locale=e.locale),n.forEach(i=>t.parseOperator(i)),n.forEach(i=>t.parseOperatorParameters(i)),(e.streams||[]).forEach(i=>t.parseStream(i)),(e.updates||[]).forEach(i=>t.parseUpdate(i)),t.resolve()}const EQ=$i(["rule"]),qk=$i(["group","image","rect"]);function _Q(e,t){let n="";return EQ[t]||(e.x2&&(e.x?(qk[t]&&(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;"),n+="o.width=o.x2-o.x;"):n+="o.x=o.x2-(o.width||0);"),e.xc&&(n+="o.x=o.xc-(o.width||0)/2;"),e.y2&&(e.y?(qk[t]&&(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;"),n+="o.height=o.y2-o.y;"):n+="o.y=o.y2-(o.height||0);"),e.yc&&(n+="o.y=o.yc-(o.height||0)/2;")),n}function Mw(e){return(e+"").toLowerCase()}function SQ(e){return Mw(e)==="operator"}function $Q(e){return Mw(e)==="collect"}function Pl(e,t,n){n.endsWith(";")||(n="return("+n+");");const i=Function(...t.concat(n));return e&&e.functions?i.bind(e.functions):i}function kQ(e,t,n,i){return`((u = ${e}) < (v = ${t}) || u == null) && v != null ? ${n} + : (u > v || v == null) && u != null ? ${i} + : ((v = v instanceof Date ? +v : v), (u = u instanceof Date ? +u : u)) !== u && v === v ? ${n} + : v !== v && u === u ? ${i} : `}var AQ={operator:(e,t)=>Pl(e,["_"],t.code),parameter:(e,t)=>Pl(e,["datum","_"],t.code),event:(e,t)=>Pl(e,["event"],t.code),handler:(e,t)=>{const n=`var datum=event.item&&event.item.datum;return ${t.code};`;return Pl(e,["_","event"],n)},encode:(e,t)=>{const{marktype:n,channels:i}=t;let r="var o=item,datum=o.datum,m=0,$;";for(const o in i){const s="o["+G(o)+"]";r+=`$=${i[o].code};if(${s}!==$)${s}=$,m=1;`}return r+=_Q(i,n),r+="return m;",Pl(e,["item","_"],r)},codegen:{get(e){const t=`[${e.map(G).join("][")}]`,n=Function("_",`return _${t};`);return n.path=t,n},comparator(e,t){let n;const i=(o,s)=>{const a=t[s];let u,l;return o.path?(u=`a${o.path}`,l=`b${o.path}`):((n=n||{})["f"+s]=o,u=`this.f${s}(a)`,l=`this.f${s}(b)`),kQ(u,l,-a,a)},r=Function("a","b","var u, v; return "+e.map(i).join("")+"0;");return n?r.bind(n):r}}};function CQ(e){const t=this;SQ(e.type)||!e.type?t.operator(e,e.update?t.operatorExpression(e.update):null):t.transform(e,e.type)}function FQ(e){const t=this;if(e.params){const n=t.get(e.id);n||O("Invalid operator id: "+e.id),t.dataflow.connect(n,n.parameters(t.parseParameters(e.params),e.react,e.initonly))}}function MQ(e,t){t=t||{};const n=this;for(const i in e){const r=e[i];t[i]=P(r)?r.map(o=>Wk(o,n,t)):Wk(r,n,t)}return t}function Wk(e,t,n){if(!e||!K(e))return e;for(let i=0,r=Hk.length,o;ir&&r.$tupleid?re:r);return t.fn[n]||(t.fn[n]=fv(i,e.$order,t.expr.codegen))}function LQ(e,t){const n=e.$encode,i={};for(const r in n){const o=n[r];i[r]=kn(t.encodeExpression(o.$expr),o.$fields),i[r].output=o.$output}return i}function PQ(e,t){return t}function IQ(e,t){const n=e.$subflow;return function(i,r,o){const s=t.fork().parse(n),a=s.get(n.operators[0].id),u=s.signals.parent;return u&&u.set(o),a.detachSubflow=()=>t.detach(s),a}}function zQ(){return re}function BQ(e){var t=this,n=e.filter!=null?t.eventExpression(e.filter):void 0,i=e.stream!=null?t.get(e.stream):void 0,r;e.source?i=t.events(e.source,e.type,n):e.merge&&(r=e.merge.map(o=>t.get(o)),i=r[0].merge.apply(r[0],r.slice(1))),e.between&&(r=e.between.map(o=>t.get(o)),i=i.between(r[0],r[1])),e.filter&&(i=i.filter(n)),e.throttle!=null&&(i=i.throttle(+e.throttle)),e.debounce!=null&&(i=i.debounce(+e.debounce)),i==null&&O("Invalid stream definition: "+JSON.stringify(e)),e.consume&&i.consume(!0),t.stream(e,i)}function UQ(e){var t=this,n=K(n=e.source)?n.$ref:n,i=t.get(n),r=null,o=e.update,s=void 0;i||O("Source not defined: "+e.source),r=e.target&&e.target.$expr?t.eventExpression(e.target.$expr):t.get(e.target),o&&o.$expr&&(o.$params&&(s=t.parseParameters(o.$params)),o=t.handlerExpression(o.$expr)),t.update(e,i,r,o,s)}const jQ={skip:!0};function qQ(e){var t=this,n={};if(e.signals){var i=n.signals={};Object.keys(t.signals).forEach(o=>{const s=t.signals[o];e.signals(o,s)&&(i[o]=s.value)})}if(e.data){var r=n.data={};Object.keys(t.data).forEach(o=>{const s=t.data[o];e.data(o,s)&&(r[o]=s.input.value)})}return t.subcontext&&e.recurse!==!1&&(n.subcontext=t.subcontext.map(o=>o.getState(e))),n}function WQ(e){var t=this,n=t.dataflow,i=e.data,r=e.signals;Object.keys(r||{}).forEach(o=>{n.update(t.signals[o],r[o],jQ)}),Object.keys(i||{}).forEach(o=>{n.pulse(t.data[o].input,n.changeset().remove(ti).insert(i[o]))}),(e.subcontext||[]).forEach((o,s)=>{const a=t.subcontext[s];a&&a.setState(o)})}function TD(e,t,n,i){return new ND(e,t,n,i)}function ND(e,t,n,i){this.dataflow=e,this.transforms=t,this.events=e.events.bind(e),this.expr=i||AQ,this.signals={},this.scales={},this.nodes={},this.data={},this.fn={},n&&(this.functions=Object.create(n),this.functions.context=this)}function Gk(e){this.dataflow=e.dataflow,this.transforms=e.transforms,this.events=e.events,this.expr=e.expr,this.signals=Object.create(e.signals),this.scales=Object.create(e.scales),this.nodes=Object.create(e.nodes),this.data=Object.create(e.data),this.fn=Object.create(e.fn),e.functions&&(this.functions=Object.create(e.functions),this.functions.context=this)}ND.prototype=Gk.prototype={fork(){const e=new Gk(this);return(this.subcontext||(this.subcontext=[])).push(e),e},detach(e){this.subcontext=this.subcontext.filter(n=>n!==e);const t=Object.keys(e.nodes);for(const n of t)e.nodes[n]._targets=null;for(const n of t)e.nodes[n].detach();e.nodes=null},get(e){return this.nodes[e]},set(e,t){return this.nodes[e]=t},add(e,t){const n=this,i=n.dataflow,r=e.value;if(n.set(e.id,t),$Q(e.type)&&r&&(r.$ingest?i.ingest(t,r.$ingest,r.$format):r.$request?i.preload(t,r.$request,r.$format):i.pulse(t,i.changeset().insert(r))),e.root&&(n.root=t),e.parent){let o=n.get(e.parent.$ref);o?(i.connect(o,[t]),t.targets().add(o)):(n.unresolved=n.unresolved||[]).push(()=>{o=n.get(e.parent.$ref),i.connect(o,[t]),t.targets().add(o)})}if(e.signal&&(n.signals[e.signal]=t),e.scale&&(n.scales[e.scale]=t),e.data)for(const o in e.data){const s=n.data[o]||(n.data[o]={});e.data[o].forEach(a=>s[a]=t)}},resolve(){return(this.unresolved||[]).forEach(e=>e()),delete this.unresolved,this},operator(e,t){this.add(e,this.dataflow.add(e.value,t))},transform(e,t){this.add(e,this.dataflow.add(this.transforms[Mw(t)]))},stream(e,t){this.set(e.id,t)},update(e,t,n,i,r){this.dataflow.on(t,n,i,r,e.options)},operatorExpression(e){return this.expr.operator(this,e)},parameterExpression(e){return this.expr.parameter(this,e)},eventExpression(e){return this.expr.event(this,e)},handlerExpression(e){return this.expr.handler(this,e)},encodeExpression(e){return this.expr.encode(this,e)},parse:wQ,parseOperator:CQ,parseOperatorParameters:FQ,parseParameters:MQ,parseStream:BQ,parseUpdate:UQ,getState:qQ,setState:WQ};function HQ(e){const t=e.container();t&&(t.setAttribute("role","graphics-document"),t.setAttribute("aria-roleDescription","visualization"),RD(t,e.description()))}function RD(e,t){e&&(t==null?e.removeAttribute("aria-label"):e.setAttribute("aria-label",t))}function GQ(e){e.add(null,t=>(e._background=t.bg,e._resize=1,t.bg),{bg:e._signals.background})}const e1="default";function YQ(e){const t=e._signals.cursor||(e._signals.cursor=e.add({user:e1,item:null}));e.on(e.events("view","pointermove"),t,(n,i)=>{const r=t.value,o=r?J(r)?r:r.user:e1,s=i.item&&i.item.cursor||null;return r&&o===r.user&&s==r.item?r:{user:o,item:s}}),e.add(null,function(n){let i=n.cursor,r=this.value;return J(i)||(r=i.item,i=i.user),pb(e,i&&i!==e1?i:r||i),r},{cursor:t})}function pb(e,t){const n=e.globalCursor()?typeof document<"u"&&document.body:e.container();if(n)return t==null?n.style.removeProperty("cursor"):n.style.cursor=t}function $g(e,t){var n=e._runtime.data;return Z(n,t)||O("Unrecognized data set: "+t),n[t]}function VQ(e,t){return arguments.length<2?$g(this,e).values.value:Jp.call(this,e,va().remove(ti).insert(t))}function Jp(e,t){KM(t)||O("Second argument to changes must be a changeset.");const n=$g(this,e);return n.modified=!0,this.pulse(n.input,t)}function XQ(e,t){return Jp.call(this,e,va().insert(t))}function KQ(e,t){return Jp.call(this,e,va().remove(t))}function OD(e){var t=e.padding();return Math.max(0,e._viewWidth+t.left+t.right)}function DD(e){var t=e.padding();return Math.max(0,e._viewHeight+t.top+t.bottom)}function Qp(e){var t=e.padding(),n=e._origin;return[t.left+n[0],t.top+n[1]]}function JQ(e){var t=Qp(e),n=OD(e),i=DD(e);e._renderer.background(e.background()),e._renderer.resize(n,i,t),e._handler.origin(t),e._resizeListeners.forEach(r=>{try{r(n,i)}catch(o){e.error(o)}})}function QQ(e,t,n){var i=e._renderer,r=i&&i.canvas(),o,s,a;return r&&(a=Qp(e),s=t.changedTouches?t.changedTouches[0]:t,o=Pp(s,r),o[0]-=a[0],o[1]-=a[1]),t.dataflow=e,t.item=n,t.vega=ZQ(e,n,o),t}function ZQ(e,t,n){const i=t?t.mark.marktype==="group"?t:t.mark.group:null;function r(s){var a=i,u;if(s){for(u=t;u;u=u.mark.group)if(u.mark.name===s){a=u;break}}return a&&a.mark&&a.mark.interactive?a:{}}function o(s){if(!s)return n;J(s)&&(s=r(s));const a=n.slice();for(;s;)a[0]-=s.x||0,a[1]-=s.y||0,s=s.mark&&s.mark.group;return a}return{view:Yt(e),item:Yt(t||{}),group:r,xy:o,x:s=>o(s)[0],y:s=>o(s)[1]}}const Yk="view",eZ="timer",tZ="window",nZ={trap:!1};function iZ(e){const t=pe({defaults:{}},e),n=(i,r)=>{r.forEach(o=>{P(i[o])&&(i[o]=$i(i[o]))})};return n(t.defaults,["prevent","allow"]),n(t,["view","window","selector"]),t}function LD(e,t,n,i){e._eventListeners.push({type:n,sources:Q(t),handler:i})}function rZ(e,t){var n=e._eventConfig.defaults,i=n.prevent,r=n.allow;return i===!1||r===!0?!1:i===!0||r===!1?!0:i?i[t]:r?!r[t]:e.preventDefault()}function kd(e,t,n){const i=e._eventConfig&&e._eventConfig[t];return i===!1||K(i)&&!i[n]?(e.warn(`Blocked ${t} ${n} event listener.`),!1):!0}function oZ(e,t,n){var i=this,r=new ap(n),o=function(l,c){i.runAsync(null,()=>{e===Yk&&rZ(i,t)&&l.preventDefault(),r.receive(QQ(i,l,c))})},s;if(e===eZ)kd(i,"timer",t)&&i.timer(o,t);else if(e===Yk)kd(i,"view",t)&&i.addEventListener(t,o,nZ);else if(e===tZ?kd(i,"window",t)&&typeof window<"u"&&(s=[window]):typeof document<"u"&&kd(i,"selector",t)&&(s=Array.from(document.querySelectorAll(e))),!s)i.warn("Can not resolve event source: "+e);else{for(var a=0,u=s.length;a=0;)t[r].stop();for(r=i.length;--r>=0;)for(s=i[r],o=s.sources.length;--o>=0;)s.sources[o].removeEventListener(s.type,s.handler);for(e&&e.call(this,this._handler,null,null,null),r=n.length;--r>=0;)u=n[r].type,a=n[r].handler,this._handler.off(u,a);return this}function Pn(e,t,n){const i=document.createElement(e);for(const r in t)i.setAttribute(r,t[r]);return n!=null&&(i.textContent=n),i}const uZ="vega-bind",lZ="vega-bind-name",cZ="vega-bind-radio";function fZ(e,t,n){if(!t)return;const i=n.param;let r=n.state;return r||(r=n.state={elements:null,active:!1,set:null,update:s=>{s!=e.signal(i.signal)&&e.runAsync(null,()=>{r.source=!0,e.signal(i.signal,s)})}},i.debounce&&(r.update=dv(i.debounce,r.update))),(i.input==null&&i.element?dZ:gZ)(r,t,i,e),r.active||(e.on(e._signals[i.signal],null,()=>{r.source?r.source=!1:r.set(e.signal(i.signal))}),r.active=!0),r}function dZ(e,t,n,i){const r=n.event||"input",o=()=>e.update(t.value);i.signal(n.signal,t.value),t.addEventListener(r,o),LD(i,t,r,o),e.set=s=>{t.value=s,t.dispatchEvent(hZ(r))}}function hZ(e){return typeof Event<"u"?new Event(e):{type:e}}function gZ(e,t,n,i){const r=i.signal(n.signal),o=Pn("div",{class:uZ}),s=n.input==="radio"?o:o.appendChild(Pn("label"));s.appendChild(Pn("span",{class:lZ},n.name||n.signal)),t.appendChild(o);let a=pZ;switch(n.input){case"checkbox":a=mZ;break;case"select":a=yZ;break;case"radio":a=bZ;break;case"range":a=vZ;break}a(e,s,n,r)}function pZ(e,t,n,i){const r=Pn("input");for(const o in n)o!=="signal"&&o!=="element"&&r.setAttribute(o==="input"?"type":o,n[o]);r.setAttribute("name",n.signal),r.value=i,t.appendChild(r),r.addEventListener("input",()=>e.update(r.value)),e.elements=[r],e.set=o=>r.value=o}function mZ(e,t,n,i){const r={type:"checkbox",name:n.signal};i&&(r.checked=!0);const o=Pn("input",r);t.appendChild(o),o.addEventListener("change",()=>e.update(o.checked)),e.elements=[o],e.set=s=>o.checked=!!s||null}function yZ(e,t,n,i){const r=Pn("select",{name:n.signal}),o=n.labels||[];n.options.forEach((s,a)=>{const u={value:s};kg(s,i)&&(u.selected=!0),r.appendChild(Pn("option",u,(o[a]||s)+""))}),t.appendChild(r),r.addEventListener("change",()=>{e.update(n.options[r.selectedIndex])}),e.elements=[r],e.set=s=>{for(let a=0,u=n.options.length;a{const u={type:"radio",name:n.signal,value:s};kg(s,i)&&(u.checked=!0);const l=Pn("input",u);l.addEventListener("change",()=>e.update(s));const c=Pn("label",{},(o[a]||s)+"");return c.prepend(l),r.appendChild(c),l}),e.set=s=>{const a=e.elements,u=a.length;for(let l=0;l{u.textContent=a.value,e.update(+a.value)};a.addEventListener("input",l),a.addEventListener("change",l),e.elements=[a],e.set=c=>{a.value=c,u.textContent=c}}function kg(e,t){return e===t||e+""==t+""}function PD(e,t,n,i,r,o){return t=t||new i(e.loader()),t.initialize(n,OD(e),DD(e),Qp(e),r,o).background(e.background())}function Tw(e,t){return t?function(){try{t.apply(this,arguments)}catch(n){e.error(n)}}:null}function xZ(e,t,n,i){const r=new i(e.loader(),Tw(e,e.tooltip())).scene(e.scenegraph().root).initialize(n,Qp(e),e);return t&&t.handlers().forEach(o=>{r.on(o.type,o.handler)}),r}function wZ(e,t){const n=this,i=n._renderType,r=n._eventConfig.bind,o=Ip(i);e=n._el=e?t1(n,e,!0):null,HQ(n),o||n.error("Unrecognized renderer type: "+i);const s=o.handler||Cf,a=e?o.renderer:o.headless;return n._renderer=a?PD(n,n._renderer,e,a):null,n._handler=xZ(n,n._handler,e,s),n._redraw=!0,e&&r!=="none"&&(t=t?n._elBind=t1(n,t,!0):e.appendChild(Pn("form",{class:"vega-bindings"})),n._bind.forEach(u=>{u.param.element&&r!=="container"&&(u.element=t1(n,u.param.element,!!u.param.input))}),n._bind.forEach(u=>{fZ(n,u.element||t,u)})),n}function t1(e,t,n){if(typeof t=="string")if(typeof document<"u"){if(t=document.querySelector(t),!t)return e.error("Signal bind element not found: "+t),null}else return e.error("DOM document instance not found."),null;if(t&&n)try{t.textContent=""}catch(i){t=null,e.error(i)}return t}const Il=e=>+e||0,EZ=e=>({top:e,bottom:e,left:e,right:e});function Jk(e){return K(e)?{top:Il(e.top),bottom:Il(e.bottom),left:Il(e.left),right:Il(e.right)}:EZ(Il(e))}async function Nw(e,t,n,i){const r=Ip(t),o=r&&r.headless;return o||O("Unrecognized renderer type: "+t),await e.runAsync(),PD(e,null,null,o,n,i).renderAsync(e._scenegraph.root)}async function _Z(e,t){e!==Ao.Canvas&&e!==Ao.SVG&&e!==Ao.PNG&&O("Unrecognized image type: "+e);const n=await Nw(this,e,t);return e===Ao.SVG?SZ(n.svg(),"image/svg+xml"):n.canvas().toDataURL("image/png")}function SZ(e,t){const n=new Blob([e],{type:t});return window.URL.createObjectURL(n)}async function $Z(e,t){return(await Nw(this,Ao.Canvas,e,t)).canvas()}async function kZ(e){return(await Nw(this,Ao.SVG,e)).svg()}function AZ(e,t,n){return TD(e,bu,Kc,n).parse(t)}function CZ(e){var t=this._runtime.scales;return Z(t,e)||O("Unrecognized scale or projection: "+e),t[e].value}var ID="width",zD="height",Rw="padding",Qk={skip:!0};function BD(e,t){var n=e.autosize(),i=e.padding();return t-(n&&n.contains===Rw?i.left+i.right:0)}function UD(e,t){var n=e.autosize(),i=e.padding();return t-(n&&n.contains===Rw?i.top+i.bottom:0)}function FZ(e){var t=e._signals,n=t[ID],i=t[zD],r=t[Rw];function o(){e._autosize=e._resize=1}e._resizeWidth=e.add(null,a=>{e._width=a.size,e._viewWidth=BD(e,a.size),o()},{size:n}),e._resizeHeight=e.add(null,a=>{e._height=a.size,e._viewHeight=UD(e,a.size),o()},{size:i});const s=e.add(null,o,{pad:r});e._resizeWidth.rank=n.rank+1,e._resizeHeight.rank=i.rank+1,s.rank=r.rank+1}function MZ(e,t,n,i,r,o){this.runAfter(s=>{let a=0;s._autosize=0,s.width()!==n&&(a=1,s.signal(ID,n,Qk),s._resizeWidth.skip(!0)),s.height()!==i&&(a=1,s.signal(zD,i,Qk),s._resizeHeight.skip(!0)),s._viewWidth!==e&&(s._resize=1,s._viewWidth=e),s._viewHeight!==t&&(s._resize=1,s._viewHeight=t),(s._origin[0]!==r[0]||s._origin[1]!==r[1])&&(s._resize=1,s._origin=r),a&&s.run("enter"),o&&s.runAfter(u=>u.resize())},!1,1)}function TZ(e){return this._runtime.getState(e||{data:NZ,signals:RZ,recurse:!0})}function NZ(e,t){return t.modified&&P(t.input.value)&&!e.startsWith("_:vega:_")}function RZ(e,t){return!(e==="parent"||t instanceof bu.proxy)}function OZ(e){return this.runAsync(null,t=>{t._trigger=!1,t._runtime.setState(e)},t=>{t._trigger=!0}),this}function DZ(e,t){function n(i){e({timestamp:Date.now(),elapsed:i})}this._timers.push(oY(n,t))}function LZ(e,t,n,i){const r=e.element();r&&r.setAttribute("title",PZ(i))}function PZ(e){return e==null?"":P(e)?jD(e):K(e)&&!Ro(e)?IZ(e):e+""}function IZ(e){return Object.keys(e).map(t=>{const n=e[t];return t+": "+(P(n)?jD(n):qD(n))}).join(` +`)}function jD(e){return"["+e.map(qD).join(", ")+"]"}function qD(e){return P(e)?"[…]":K(e)&&!Ro(e)?"{…}":e}function zZ(){if(this.renderer()==="canvas"&&this._renderer._canvas){let e=null;const t=()=>{e!=null&&e();const n=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);n.addEventListener("change",t),e=()=>{n.removeEventListener("change",t)},this._renderer._canvas.getContext("2d").pixelRatio=window.devicePixelRatio||1,this._redraw=!0,this._resize=1,this.resize().runAsync()};t()}}function WD(e,t){const n=this;if(t=t||{},nu.call(n),t.loader&&n.loader(t.loader),t.logger&&n.logger(t.logger),t.logLevel!=null&&n.logLevel(t.logLevel),t.locale||e.locale){const o=pe({},e.locale,t.locale);n.locale(BM(o.number,o.time))}n._el=null,n._elBind=null,n._renderType=t.renderer||Ao.Canvas,n._scenegraph=new I3;const i=n._scenegraph.root;n._renderer=null,n._tooltip=t.tooltip||LZ,n._redraw=!0,n._handler=new Cf().scene(i),n._globalCursor=!1,n._preventDefault=!1,n._timers=[],n._eventListeners=[],n._resizeListeners=[],n._eventConfig=iZ(e.eventConfig),n.globalCursor(n._eventConfig.globalCursor);const r=AZ(n,e,t.expr);n._runtime=r,n._signals=r.signals,n._bind=(e.bindings||[]).map(o=>({state:null,param:pe({},o)})),r.root&&r.root.set(i),i.source=r.data.root.input,n.pulse(r.data.root.input,n.changeset().insert(i.items)),n._width=n.width(),n._height=n.height(),n._viewWidth=BD(n,n._width),n._viewHeight=UD(n,n._height),n._origin=[0,0],n._resize=0,n._autosize=1,FZ(n),GQ(n),YQ(n),n.description(e.description),t.hover&&n.hover(),t.container&&n.initialize(t.container,t.bind),t.watchPixelRatio&&n._watchPixelRatio()}function Ad(e,t){return Z(e._signals,t)?e._signals[t]:O("Unrecognized signal name: "+G(t))}function HD(e,t){const n=(e._targets||[]).filter(i=>i._update&&i._update.handler===t);return n.length?n[0]:null}function Zk(e,t,n,i){let r=HD(n,i);return r||(r=Tw(e,()=>i(t,n.value)),r.handler=i,e.on(n,null,r)),e}function eA(e,t,n){const i=HD(t,n);return i&&t._targets.remove(i),e}Y(WD,nu,{async evaluate(e,t,n){if(await nu.prototype.evaluate.call(this,e,t),this._redraw||this._resize)try{this._renderer&&(this._resize&&(this._resize=0,JQ(this)),await this._renderer.renderAsync(this._scenegraph.root)),this._redraw=!1}catch(i){this.error(i)}return n&&jd(this,n),this},dirty(e){this._redraw=!0,this._renderer&&this._renderer.dirty(e)},description(e){if(arguments.length){const t=e!=null?e+"":null;return t!==this._desc&&RD(this._el,this._desc=t),this}return this._desc},container(){return this._el},scenegraph(){return this._scenegraph},origin(){return this._origin.slice()},signal(e,t,n){const i=Ad(this,e);return arguments.length===1?i.value:this.update(i,t,n)},width(e){return arguments.length?this.signal("width",e):this.signal("width")},height(e){return arguments.length?this.signal("height",e):this.signal("height")},padding(e){return arguments.length?this.signal("padding",Jk(e)):Jk(this.signal("padding"))},autosize(e){return arguments.length?this.signal("autosize",e):this.signal("autosize")},background(e){return arguments.length?this.signal("background",e):this.signal("background")},renderer(e){return arguments.length?(Ip(e)||O("Unrecognized renderer type: "+e),e!==this._renderType&&(this._renderType=e,this._resetRenderer()),this):this._renderType},tooltip(e){return arguments.length?(e!==this._tooltip&&(this._tooltip=e,this._resetRenderer()),this):this._tooltip},loader(e){return arguments.length?(e!==this._loader&&(nu.prototype.loader.call(this,e),this._resetRenderer()),this):this._loader},resize(){return this._autosize=1,this.touch(Ad(this,"autosize"))},_resetRenderer(){this._renderer&&(this._renderer=null,this.initialize(this._el,this._elBind))},_resizeView:MZ,addEventListener(e,t,n){let i=t;return n&&n.trap===!1||(i=Tw(this,t),i.raw=t),this._handler.on(e,i),this},removeEventListener(e,t){for(var n=this._handler.handlers(e),i=n.length,r,o;--i>=0;)if(o=n[i].type,r=n[i].handler,e===o&&(t===r||t===r.raw)){this._handler.off(o,r);break}return this},addResizeListener(e){const t=this._resizeListeners;return t.includes(e)||t.push(e),this},removeResizeListener(e){var t=this._resizeListeners,n=t.indexOf(e);return n>=0&&t.splice(n,1),this},addSignalListener(e,t){return Zk(this,e,Ad(this,e),t)},removeSignalListener(e,t){return eA(this,Ad(this,e),t)},addDataListener(e,t){return Zk(this,e,$g(this,e).values,t)},removeDataListener(e,t){return eA(this,$g(this,e).values,t)},globalCursor(e){if(arguments.length){if(this._globalCursor!==!!e){const t=pb(this,null);this._globalCursor=!!e,t&&pb(this,t)}return this}else return this._globalCursor},preventDefault(e){return arguments.length?(this._preventDefault=e,this):this._preventDefault},timer:DZ,events:oZ,finalize:aZ,hover:sZ,data:VQ,change:Jp,insert:XQ,remove:KQ,scale:CZ,initialize:wZ,toImageURL:_Z,toCanvas:$Z,toSVG:kZ,getState:TZ,setState:OZ,_watchPixelRatio:zZ});const BZ="view",Ag="[",Cg="]",GD="{",YD="}",UZ=":",VD=",",jZ="@",qZ=">",WZ=/[[\]{}]/,HZ={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};let XD,KD;function rs(e,t,n){return XD=t||BZ,KD=n||HZ,JD(e.trim()).map(mb)}function GZ(e){return KD[e]}function Ac(e,t,n,i,r){const o=e.length;let s=0,a;for(;t' after between selector: "+e;i=i.map(mb);const r=mb(e.slice(1).trim());return r.between?{between:i,stream:r}:(r.between=i,r)}function VZ(e){const t={source:XD},n=[];let i=[0,0],r=0,o=0,s=e.length,a=0,u,l;if(e[s-1]===YD){if(a=e.lastIndexOf(GD),a>=0){try{i=XZ(e.substring(a+1,s-1))}catch{throw"Invalid throttle specification: "+e}e=e.slice(0,a).trim(),s=e.length}else throw"Unmatched right brace: "+e;a=0}if(!s)throw e;if(e[0]===jZ&&(r=++a),u=Ac(e,a,UZ),u1?(t.type=n[1],r?t.markname=n[0].slice(1):GZ(n[0])?t.marktype=n[0]:t.source=n[0]):t.type=n[0],t.type.slice(-1)==="!"&&(t.consume=!0,t.type=t.type.slice(0,-1)),l!=null&&(t.filter=l),i[0]&&(t.throttle=i[0]),i[1]&&(t.debounce=i[1]),t}function XZ(e){const t=e.split(VD);if(!e.length||t.length>2)throw e;return t.map(n=>{const i=+n;if(i!==i)throw e;return i})}function KZ(e){return K(e)?e:{type:e||"pad"}}const zl=e=>+e||0,JZ=e=>({top:e,bottom:e,left:e,right:e});function QZ(e){return K(e)?e.signal?e:{top:zl(e.top),bottom:zl(e.bottom),left:zl(e.left),right:zl(e.right)}:JZ(zl(e))}const xt=e=>K(e)&&!P(e)?pe({},e):{value:e};function tA(e,t,n,i){return n!=null?(K(n)&&!P(n)||P(n)&&n.length&&K(n[0])?e.update[t]=n:e[i||"enter"][t]={value:n},1):0}function Nt(e,t,n){for(const i in t)tA(e,i,t[i]);for(const i in n)tA(e,i,n[i],"update")}function fl(e,t,n){for(const i in t)n&&Z(n,i)||(e[i]=pe(e[i]||{},t[i]));return e}function Ya(e,t){return t&&(t.enter&&t.enter[e]||t.update&&t.update[e])}const Ow="mark",Dw="frame",Lw="scope",ZZ="axis",eee="axis-domain",tee="axis-grid",nee="axis-label",iee="axis-tick",ree="axis-title",oee="legend",see="legend-band",aee="legend-entry",uee="legend-gradient",QD="legend-label",lee="legend-symbol",cee="legend-title",fee="title",dee="title-text",hee="title-subtitle";function gee(e,t,n,i,r){const o={},s={};let a,u,l,c;u="lineBreak",t==="text"&&r[u]!=null&&!Ya(u,e)&&n1(o,u,r[u]),(n=="legend"||String(n).startsWith("axis"))&&(n=null),c=n===Dw?r.group:n===Ow?pe({},r.mark,r[t]):null;for(u in c)l=Ya(u,e)||(u==="fill"||u==="stroke")&&(Ya("fill",e)||Ya("stroke",e)),l||n1(o,u,c[u]);Q(i).forEach(f=>{const d=r.style&&r.style[f];for(const h in d)Ya(h,e)||n1(o,h,d[h])}),e=pe({},e);for(u in o)c=o[u],c.signal?(a=a||{})[u]=c:s[u]=c;return e.enter=pe(s,e.enter),a&&(e.update=pe(a,e.update)),e}function n1(e,t,n){e[t]=n&&n.signal?{signal:n.signal}:{value:n}}const ZD=e=>J(e)?G(e):e.signal?`(${e.signal})`:e5(e);function Zp(e){if(e.gradient!=null)return mee(e);let t=e.signal?`(${e.signal})`:e.color?pee(e.color):e.field!=null?e5(e.field):e.value!==void 0?G(e.value):void 0;return e.scale!=null&&(t=yee(e,t)),t===void 0&&(t=null),e.exponent!=null&&(t=`pow(${t},${sh(e.exponent)})`),e.mult!=null&&(t+=`*${sh(e.mult)}`),e.offset!=null&&(t+=`+${sh(e.offset)}`),e.round&&(t=`round(${t})`),t}const Cd=(e,t,n,i)=>`(${e}(${[t,n,i].map(Zp).join(",")})+'')`;function pee(e){return e.c?Cd("hcl",e.h,e.c,e.l):e.h||e.s?Cd("hsl",e.h,e.s,e.l):e.l||e.a?Cd("lab",e.l,e.a,e.b):e.r||e.g||e.b?Cd("rgb",e.r,e.g,e.b):null}function mee(e){const t=[e.start,e.stop,e.count].map(n=>n==null?null:G(n));for(;t.length&&_e(t)==null;)t.pop();return t.unshift(ZD(e.gradient)),`gradient(${t.join(",")})`}function sh(e){return K(e)?"("+Zp(e)+")":e}function e5(e){return t5(K(e)?e:{datum:e})}function t5(e){let t,n,i;if(e.signal)t="datum",i=e.signal;else if(e.group||e.parent){for(n=Math.max(1,e.level||1),t="item";n-- >0;)t+=".mark.group";e.parent?(i=e.parent,t+=".datum"):i=e.group}else e.datum?(t="datum",i=e.datum):O("Invalid field reference: "+G(e));return e.signal||(i=J(i)?dr(i).map(G).join("]["):t5(i)),t+"["+i+"]"}function yee(e,t){const n=ZD(e.scale);return e.range!=null?t=`lerp(_range(${n}), ${+e.range})`:(t!==void 0&&(t=`_scale(${n}, ${t})`),e.band&&(t=(t?t+"+":"")+`_bandwidth(${n})`+(+e.band==1?"":"*"+sh(e.band)),e.extra&&(t=`(datum.extra ? _scale(${n}, datum.extra.value) : ${t})`)),t==null&&(t="0")),t}function bee(e){let t="";return e.forEach(n=>{const i=Zp(n);t+=n.test?`(${n.test})?${i}:`:i}),_e(t)===":"&&(t+="null"),t}function n5(e,t,n,i,r,o){const s={};o=o||{},o.encoders={$encode:s},e=gee(e,t,n,i,r.config);for(const a in e)s[a]=vee(e[a],t,o,r);return o}function vee(e,t,n,i){const r={},o={};for(const s in e)e[s]!=null&&(r[s]=wee(xee(e[s]),i,n,o));return{$expr:{marktype:t,channels:r},$fields:Object.keys(o),$output:Object.keys(e)}}function xee(e){return P(e)?bee(e):Zp(e)}function wee(e,t,n,i){const r=ur(e,t);return r.$fields.forEach(o=>i[o]=1),pe(n,r.$params),r.$expr}const Eee="outer",_ee=["value","update","init","react","bind"];function nA(e,t){O(e+' for "outer" push: '+G(t))}function i5(e,t){const n=e.name;if(e.push===Eee)t.signals[n]||nA("No prior signal definition",n),_ee.forEach(i=>{e[i]!==void 0&&nA("Invalid property ",i)});else{const i=t.addSignal(n,e.value);e.react===!1&&(i.react=!1),e.bind&&t.addBinding(n,e.bind)}}function yb(e,t,n,i){this.id=-1,this.type=e,this.value=t,this.params=n,i&&(this.parent=i)}function em(e,t,n,i){return new yb(e,t,n,i)}function Fg(e,t){return em("operator",e,t)}function ie(e){const t={$ref:e.id};return e.id<0&&(e.refs=e.refs||[]).push(t),t}function Jc(e,t){return t?{$field:e,$name:t}:{$field:e}}const bb=Jc("key");function iA(e,t){return{$compare:e,$order:t}}function See(e,t){const n={$key:e};return t&&(n.$flat=!0),n}const $ee="ascending",kee="descending";function Aee(e){return K(e)?(e.order===kee?"-":"+")+tm(e.op,e.field):""}function tm(e,t){return(e&&e.signal?"$"+e.signal:e||"")+(e&&t?"_":"")+(t&&t.signal?"$"+t.signal:t||"")}const Pw="scope",vb="view";function ft(e){return e&&e.signal}function Cee(e){return e&&e.expr}function ah(e){if(ft(e))return!0;if(K(e)){for(const t in e)if(ah(e[t]))return!0}return!1}function gi(e,t){return e??t}function Bs(e){return e&&e.signal||e}const rA="timer";function Qc(e,t){return(e.merge?Mee:e.stream?Tee:e.type?Nee:O("Invalid stream specification: "+G(e)))(e,t)}function Fee(e){return e===Pw?vb:e||vb}function Mee(e,t){const n=e.merge.map(r=>Qc(r,t)),i=Iw({merge:n},e,t);return t.addStream(i).id}function Tee(e,t){const n=Qc(e.stream,t),i=Iw({stream:n},e,t);return t.addStream(i).id}function Nee(e,t){let n;e.type===rA?(n=t.event(rA,e.throttle),e={between:e.between,filter:e.filter}):n=t.event(Fee(e.source),e.type);const i=Iw({stream:n},e,t);return Object.keys(i).length===1?n:t.addStream(i).id}function Iw(e,t,n){let i=t.between;return i&&(i.length!==2&&O('Stream "between" parameter must have 2 entries: '+G(t)),e.between=[Qc(i[0],n),Qc(i[1],n)]),i=t.filter?[].concat(t.filter):[],(t.marktype||t.markname||t.markrole)&&i.push(Ree(t.marktype,t.markname,t.markrole)),t.source===Pw&&i.push("inScope(event.item)"),i.length&&(e.filter=ur("("+i.join(")&&(")+")",n).$expr),(i=t.throttle)!=null&&(e.throttle=+i),(i=t.debounce)!=null&&(e.debounce=+i),t.consume&&(e.consume=!0),e}function Ree(e,t,n){const i="event.item";return i+(e&&e!=="*"?"&&"+i+".mark.marktype==='"+e+"'":"")+(n?"&&"+i+".mark.role==='"+n+"'":"")+(t?"&&"+i+".mark.name==='"+t+"'":"")}const Oee={code:"_.$value",ast:{type:"Identifier",value:"value"}};function Dee(e,t,n){const i=e.encode,r={target:n};let o=e.events,s=e.update,a=[];o||O("Signal update missing events specification."),J(o)&&(o=rs(o,t.isSubscope()?Pw:vb)),o=Q(o).filter(u=>u.signal||u.scale?(a.push(u),0):1),a.length>1&&(a=[Pee(a)]),o.length&&a.push(o.length>1?{merge:o}:o[0]),i!=null&&(s&&O("Signal encode and update are mutually exclusive."),s="encode(item(),"+G(i)+")"),r.update=J(s)?ur(s,t):s.expr!=null?ur(s.expr,t):s.value!=null?s.value:s.signal!=null?{$expr:Oee,$params:{$value:t.signalRef(s.signal)}}:O("Invalid signal update specification."),e.force&&(r.options={force:!0}),a.forEach(u=>t.addUpdate(pe(Lee(u,t),r)))}function Lee(e,t){return{source:e.signal?t.signalRef(e.signal):e.scale?t.scaleRef(e.scale):Qc(e,t)}}function Pee(e){return{signal:"["+e.map(t=>t.scale?'scale("'+t.scale+'")':t.signal)+"]"}}function Iee(e,t){const n=t.getSignal(e.name);let i=e.update;e.init&&(i?O("Signals can not include both init and update expressions."):(i=e.init,n.initonly=!0)),i&&(i=ur(i,t),n.update=i.$expr,n.params=i.$params),e.on&&e.on.forEach(r=>Dee(r,t,n.id))}const Pe=e=>(t,n,i)=>em(e,n,t||void 0,i),r5=Pe("aggregate"),zee=Pe("axisticks"),o5=Pe("bound"),Ri=Pe("collect"),oA=Pe("compare"),Bee=Pe("datajoin"),s5=Pe("encode"),Uee=Pe("expression"),jee=Pe("facet"),qee=Pe("field"),Wee=Pe("key"),Hee=Pe("legendentries"),Gee=Pe("load"),Yee=Pe("mark"),Vee=Pe("multiextent"),Xee=Pe("multivalues"),Kee=Pe("overlap"),Jee=Pe("params"),a5=Pe("prefacet"),Qee=Pe("projection"),Zee=Pe("proxy"),ete=Pe("relay"),u5=Pe("render"),tte=Pe("scale"),_a=Pe("sieve"),nte=Pe("sortitems"),l5=Pe("viewlayout"),ite=Pe("values");let rte=0;const c5={min:"min",max:"max",count:"sum"};function ote(e,t){const n=e.type||"linear";JN(n)||O("Unrecognized scale type: "+G(n)),t.addScale(e.name,{type:n,domain:void 0})}function ste(e,t){const n=t.getScale(e.name).params;let i;n.domain=f5(e.domain,e,t),e.range!=null&&(n.range=h5(e,t,n)),e.interpolate!=null&&mte(e.interpolate,n),e.nice!=null&&(n.nice=pte(e.nice,t)),e.bins!=null&&(n.bins=gte(e.bins,t));for(i in e)Z(n,i)||i==="name"||(n[i]=Kn(e[i],t))}function Kn(e,t){return K(e)?e.signal?t.signalRef(e.signal):O("Unsupported object: "+G(e)):e}function uh(e,t){return e.signal?t.signalRef(e.signal):e.map(n=>Kn(n,t))}function nm(e){O("Can not find data set: "+G(e))}function f5(e,t,n){if(!e){(t.domainMin!=null||t.domainMax!=null)&&O("No scale domain defined for domainMin/domainMax to override.");return}return e.signal?n.signalRef(e.signal):(P(e)?ate:e.fields?lte:ute)(e,t,n)}function ate(e,t,n){return e.map(i=>Kn(i,n))}function ute(e,t,n){const i=n.getData(e.data);return i||nm(e.data),_u(t.type)?i.valuesRef(n,e.field,d5(e.sort,!1)):e3(t.type)?i.domainRef(n,e.field):i.extentRef(n,e.field)}function lte(e,t,n){const i=e.data,r=e.fields.reduce((o,s)=>(s=J(s)?{data:i,field:s}:P(s)||s.signal?cte(s,n):s,o.push(s),o),[]);return(_u(t.type)?fte:e3(t.type)?dte:hte)(e,n,r)}function cte(e,t){const n="_:vega:_"+rte++,i=Ri({});if(P(e))i.value={$ingest:e};else if(e.signal){const r="setdata("+G(n)+","+e.signal+")";i.params.input=t.signalRef(r)}return t.addDataPipeline(n,[i,_a({})]),{data:n,field:"data"}}function fte(e,t,n){const i=d5(e.sort,!0);let r,o;const s=n.map(l=>{const c=t.getData(l.data);return c||nm(l.data),c.countsRef(t,l.field,i)}),a={groupby:bb,pulse:s};i&&(r=i.op||"count",o=i.field?tm(r,i.field):"count",a.ops=[c5[r]],a.fields=[t.fieldRef(o)],a.as=[o]),r=t.add(r5(a));const u=t.add(Ri({pulse:ie(r)}));return o=t.add(ite({field:bb,sort:t.sortRef(i),pulse:ie(u)})),ie(o)}function d5(e,t){return e&&(!e.field&&!e.op?K(e)?e.field="key":e={field:"key"}:!e.field&&e.op!=="count"?O("No field provided for sort aggregate op: "+e.op):t&&e.field&&e.op&&!c5[e.op]&&O("Multiple domain scales can not be sorted using "+e.op)),e}function dte(e,t,n){const i=n.map(r=>{const o=t.getData(r.data);return o||nm(r.data),o.domainRef(t,r.field)});return ie(t.add(Xee({values:i})))}function hte(e,t,n){const i=n.map(r=>{const o=t.getData(r.data);return o||nm(r.data),o.extentRef(t,r.field)});return ie(t.add(Vee({extents:i})))}function gte(e,t){return e.signal||P(e)?uh(e,t):t.objectProperty(e)}function pte(e,t){return e.signal?t.signalRef(e.signal):K(e)?{interval:Kn(e.interval),step:Kn(e.step)}:Kn(e)}function mte(e,t){t.interpolate=Kn(e.type||e),e.gamma!=null&&(t.interpolateGamma=Kn(e.gamma))}function h5(e,t,n){const i=t.config.range;let r=e.range;if(r.signal)return t.signalRef(r.signal);if(J(r)){if(i&&Z(i,r))return e=pe({},e,{range:i[r]}),h5(e,t,n);r==="width"?r=[0,{signal:"width"}]:r==="height"?r=_u(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:O("Unrecognized scale range value: "+G(r))}else if(r.scheme){n.scheme=P(r.scheme)?uh(r.scheme,t):Kn(r.scheme,t),r.extent&&(n.schemeExtent=uh(r.extent,t)),r.count&&(n.schemeCount=Kn(r.count,t));return}else if(r.step){n.rangeStep=Kn(r.step,t);return}else{if(_u(e.type)&&!P(r))return f5(r,e,t);P(r)||O("Unsupported range type: "+G(r))}return r.map(o=>(P(o)?uh:Kn)(o,t))}function yte(e,t){const n=t.config.projection||{},i={};for(const r in e)r!=="name"&&(i[r]=xb(e[r],r,t));for(const r in n)i[r]==null&&(i[r]=xb(n[r],r,t));t.addProjection(e.name,i)}function xb(e,t,n){return P(e)?e.map(i=>xb(i,t,n)):K(e)?e.signal?n.signalRef(e.signal):t==="fit"?e:O("Unsupported parameter object: "+G(e)):e}const Oi="top",dl="left",hl="right",Vo="bottom",g5="center",bte="vertical",vte="start",xte="middle",wte="end",wb="index",zw="label",Ete="offset",Nu="perc",_te="perc2",Qn="value",Pf="guide-label",Bw="guide-title",Ste="group-title",$te="group-subtitle",sA="symbol",lh="gradient",Eb="discrete",_b="size",kte="shape",Ate="fill",Cte="stroke",Fte="strokeWidth",Mte="strokeDash",Tte="opacity",Uw=[_b,kte,Ate,Cte,Fte,Mte,Tte],If={name:1,style:1,interactive:1},Se={value:0},Zn={value:1},im="group",p5="rect",jw="rule",Nte="symbol",Sa="text";function Zc(e){return e.type=im,e.interactive=e.interactive||!1,e}function An(e,t){const n=(i,r)=>gi(e[i],gi(t[i],r));return n.isVertical=i=>bte===gi(e.direction,t.direction||(i?t.symbolDirection:t.gradientDirection)),n.gradientLength=()=>gi(e.gradientLength,t.gradientLength||t.gradientWidth),n.gradientThickness=()=>gi(e.gradientThickness,t.gradientThickness||t.gradientHeight),n.entryColumns=()=>gi(e.columns,gi(t.columns,+n.isVertical(!0))),n}function m5(e,t){const n=t&&(t.update&&t.update[e]||t.enter&&t.enter[e]);return n&&n.signal?n:n?n.value:null}function Rte(e,t,n){const i=t.config.style[n];return i&&i[e]}function rm(e,t,n){return`item.anchor === '${vte}' ? ${e} : item.anchor === '${wte}' ? ${t} : ${n}`}const qw=rm(G(dl),G(hl),G(g5));function Ote(e){const t=e("tickBand");let n=e("tickOffset"),i,r;return t?t.signal?(i={signal:`(${t.signal}) === 'extent' ? 1 : 0.5`},r={signal:`(${t.signal}) === 'extent'`},K(n)||(n={signal:`(${t.signal}) === 'extent' ? 0 : ${n}`})):t==="extent"?(i=1,r=!0,n=0):(i=.5,r=!1):(i=e("bandPosition"),r=e("tickExtra")),{extra:r,band:i,offset:n}}function y5(e,t){return t?e?K(e)?Object.assign({},e,{offset:y5(e.offset,t)}):{value:e,offset:t}:t:e}function qn(e,t){return t?(e.name=t.name,e.style=t.style||e.style,e.interactive=!!t.interactive,e.encode=fl(e.encode,t,If)):e.interactive=!1,e}function Dte(e,t,n,i){const r=An(e,n),o=r.isVertical(),s=r.gradientThickness(),a=r.gradientLength();let u,l,c,f,d;o?(l=[0,1],c=[0,0],f=s,d=a):(l=[0,0],c=[1,0],f=a,d=s);const h={enter:u={opacity:Se,x:Se,y:Se,width:xt(f),height:xt(d)},update:pe({},u,{opacity:Zn,fill:{gradient:t,start:l,stop:c}}),exit:{opacity:Se}};return Nt(h,{stroke:r("gradientStrokeColor"),strokeWidth:r("gradientStrokeWidth")},{opacity:r("gradientOpacity")}),qn({type:p5,role:uee,encode:h},i)}function Lte(e,t,n,i,r){const o=An(e,n),s=o.isVertical(),a=o.gradientThickness(),u=o.gradientLength();let l,c,f,d,h="";s?(l="y",f="y2",c="x",d="width",h="1-"):(l="x",f="x2",c="y",d="height");const g={opacity:Se,fill:{scale:t,field:Qn}};g[l]={signal:h+"datum."+Nu,mult:u},g[c]=Se,g[f]={signal:h+"datum."+_te,mult:u},g[d]=xt(a);const p={enter:g,update:pe({},g,{opacity:Zn}),exit:{opacity:Se}};return Nt(p,{stroke:o("gradientStrokeColor"),strokeWidth:o("gradientStrokeWidth")},{opacity:o("gradientOpacity")}),qn({type:p5,role:see,key:Qn,from:r,encode:p},i)}const Pte=`datum.${Nu}<=0?"${dl}":datum.${Nu}>=1?"${hl}":"${g5}"`,Ite=`datum.${Nu}<=0?"${Vo}":datum.${Nu}>=1?"${Oi}":"${xte}"`;function aA(e,t,n,i){const r=An(e,t),o=r.isVertical(),s=xt(r.gradientThickness()),a=r.gradientLength();let u=r("labelOverlap"),l,c,f,d,h="";const g={enter:l={opacity:Se},update:c={opacity:Zn,text:{field:zw}},exit:{opacity:Se}};return Nt(g,{fill:r("labelColor"),fillOpacity:r("labelOpacity"),font:r("labelFont"),fontSize:r("labelFontSize"),fontStyle:r("labelFontStyle"),fontWeight:r("labelFontWeight"),limit:gi(e.labelLimit,t.gradientLabelLimit)}),o?(l.align={value:"left"},l.baseline=c.baseline={signal:Ite},f="y",d="x",h="1-"):(l.align=c.align={signal:Pte},l.baseline={value:"top"},f="x",d="y"),l[f]=c[f]={signal:h+"datum."+Nu,mult:a},l[d]=c[d]=s,s.offset=gi(e.labelOffset,t.gradientLabelOffset)||0,u=u?{separation:r("labelSeparation"),method:u,order:"datum."+wb}:void 0,qn({type:Sa,role:QD,style:Pf,key:Qn,from:i,encode:g,overlap:u},n)}function zte(e,t,n,i,r){const o=An(e,t),s=n.entries,a=!!(s&&s.interactive),u=s?s.name:void 0,l=o("clipHeight"),c=o("symbolOffset"),f={data:"value"},d=`(${r}) ? datum.${Ete} : datum.${_b}`,h=l?xt(l):{field:_b},g=`datum.${wb}`,p=`max(1, ${r})`;let m,y,b,v,x;h.mult=.5,m={enter:y={opacity:Se,x:{signal:d,mult:.5,offset:c},y:h},update:b={opacity:Zn,x:y.x,y:y.y},exit:{opacity:Se}};let E=null,_=null;e.fill||(E=t.symbolBaseFillColor,_=t.symbolBaseStrokeColor),Nt(m,{fill:o("symbolFillColor",E),shape:o("symbolType"),size:o("symbolSize"),stroke:o("symbolStrokeColor",_),strokeDash:o("symbolDash"),strokeDashOffset:o("symbolDashOffset"),strokeWidth:o("symbolStrokeWidth")},{opacity:o("symbolOpacity")}),Uw.forEach(A=>{e[A]&&(b[A]=y[A]={scale:e[A],field:Qn})});const w=qn({type:Nte,role:lee,key:Qn,from:f,clip:l?!0:void 0,encode:m},n.symbols),S=xt(c);S.offset=o("labelOffset"),m={enter:y={opacity:Se,x:{signal:d,offset:S},y:h},update:b={opacity:Zn,text:{field:zw},x:y.x,y:y.y},exit:{opacity:Se}},Nt(m,{align:o("labelAlign"),baseline:o("labelBaseline"),fill:o("labelColor"),fillOpacity:o("labelOpacity"),font:o("labelFont"),fontSize:o("labelFontSize"),fontStyle:o("labelFontStyle"),fontWeight:o("labelFontWeight"),limit:o("labelLimit")});const $=qn({type:Sa,role:QD,style:Pf,key:Qn,from:f,encode:m},n.labels);return m={enter:{noBound:{value:!l},width:Se,height:l?xt(l):Se,opacity:Se},exit:{opacity:Se},update:b={opacity:Zn,row:{signal:null},column:{signal:null}}},o.isVertical(!0)?(v=`ceil(item.mark.items.length / ${p})`,b.row.signal=`${g}%${v}`,b.column.signal=`floor(${g} / ${v})`,x={field:["row",g]}):(b.row.signal=`floor(${g} / ${p})`,b.column.signal=`${g} % ${p}`,x={field:g}),b.column.signal=`(${r})?${b.column.signal}:${g}`,i={facet:{data:i,name:"value",groupby:wb}},Zc({role:Lw,from:i,encode:fl(m,s,If),marks:[w,$],name:u,interactive:a,sort:x})}function Bte(e,t){const n=An(e,t);return{align:n("gridAlign"),columns:n.entryColumns(),center:{row:!0,column:!1},padding:{row:n("rowPadding"),column:n("columnPadding")}}}const Ww='item.orient === "left"',Hw='item.orient === "right"',om=`(${Ww} || ${Hw})`,Ute=`datum.vgrad && ${om}`,jte=rm('"top"','"bottom"','"middle"'),qte=rm('"right"','"left"','"center"'),Wte=`datum.vgrad && ${Hw} ? (${qte}) : (${om} && !(datum.vgrad && ${Ww})) ? "left" : ${qw}`,Hte=`item._anchor || (${om} ? "middle" : "start")`,Gte=`${Ute} ? (${Ww} ? -90 : 90) : 0`,Yte=`${om} ? (datum.vgrad ? (${Hw} ? "bottom" : "top") : ${jte}) : "top"`;function Vte(e,t,n,i){const r=An(e,t),o={enter:{opacity:Se},update:{opacity:Zn,x:{field:{group:"padding"}},y:{field:{group:"padding"}}},exit:{opacity:Se}};return Nt(o,{orient:r("titleOrient"),_anchor:r("titleAnchor"),anchor:{signal:Hte},angle:{signal:Gte},align:{signal:Wte},baseline:{signal:Yte},text:e.title,fill:r("titleColor"),fillOpacity:r("titleOpacity"),font:r("titleFont"),fontSize:r("titleFontSize"),fontStyle:r("titleFontStyle"),fontWeight:r("titleFontWeight"),limit:r("titleLimit"),lineHeight:r("titleLineHeight")},{align:r("titleAlign"),baseline:r("titleBaseline")}),qn({type:Sa,role:cee,style:Bw,from:i,encode:o},n)}function Xte(e,t){let n;return K(e)&&(e.signal?n=e.signal:e.path?n="pathShape("+uA(e.path)+")":e.sphere&&(n="geoShape("+uA(e.sphere)+', {type: "Sphere"})')),n?t.signalRef(n):!!e}function uA(e){return K(e)&&e.signal?e.signal:G(e)}function b5(e){const t=e.role||"";return t.startsWith("axis")||t.startsWith("legend")||t.startsWith("title")?t:e.type===im?Lw:t||Ow}function Kte(e){return{marktype:e.type,name:e.name||void 0,role:e.role||b5(e),zindex:+e.zindex||void 0,aria:e.aria,description:e.description}}function Jte(e,t){return e&&e.signal?t.signalRef(e.signal):e!==!1}function Gw(e,t){const n=ZM(e.type);n||O("Unrecognized transform type: "+G(e.type));const i=em(n.type.toLowerCase(),null,v5(n,e,t));return e.signal&&t.addSignal(e.signal,t.proxy(i)),i.metadata=n.metadata||{},i}function v5(e,t,n){const i={},r=e.params.length;for(let o=0;olA(e,o,n)):lA(e,r,n)}function lA(e,t,n){const i=e.type;if(ft(t))return fA(i)?O("Expression references can not be signals."):i1(i)?n.fieldRef(t):dA(i)?n.compareRef(t):n.signalRef(t.signal);{const r=e.expr||i1(i);return r&&tne(t)?n.exprRef(t.expr,t.as):r&&nne(t)?Jc(t.field,t.as):fA(i)?ur(t,n):ine(i)?ie(n.getData(t).values):i1(i)?Jc(t):dA(i)?n.compareRef(t):t}}function Zte(e,t,n){return J(t.from)||O('Lookup "from" parameter must be a string literal.'),n.getData(t.from).lookupRef(n,t.key)}function ene(e,t,n){const i=t[e.name];return e.array?(P(i)||O("Expected an array of sub-parameters. Instead: "+G(i)),i.map(r=>cA(e,r,n))):cA(e,i,n)}function cA(e,t,n){const i=e.params.length;let r;for(let s=0;se&&e.expr,nne=e=>e&&e.field,ine=e=>e==="data",fA=e=>e==="expr",i1=e=>e==="field",dA=e=>e==="compare";function rne(e,t,n){let i,r,o,s,a;return e?(i=e.facet)&&(t||O("Only group marks can be faceted."),i.field!=null?s=a=ch(i,n):(e.data?a=ie(n.getData(e.data).aggregate):(o=Gw(pe({type:"aggregate",groupby:Q(i.groupby)},i.aggregate),n),o.params.key=n.keyRef(i.groupby),o.params.pulse=ch(i,n),s=a=ie(n.add(o))),r=n.keyRef(i.groupby,!0))):s=ie(n.add(Ri(null,[{}]))),s||(s=ch(e,n)),{key:r,pulse:s,parent:a}}function ch(e,t){return e.$ref?e:e.data&&e.data.$ref?e.data:ie(t.getData(e.data).output)}function ia(e,t,n,i,r){this.scope=e,this.input=t,this.output=n,this.values=i,this.aggregate=r,this.index={}}ia.fromEntries=function(e,t){const n=t.length,i=t[n-1],r=t[n-2];let o=t[0],s=null,a=1;for(o&&o.type==="load"&&(o=t[1]),e.add(t[0]);af??"null").join(",")+"),0)",c=ur(l,t);u.update=c.$expr,u.params=c.$params}function sm(e,t){const n=b5(e),i=e.type===im,r=e.from&&e.from.facet,o=e.overlap;let s=e.layout||n===Lw||n===Dw,a,u,l,c,f,d,h;const g=n===Ow||s||r,p=rne(e.from,i,t);u=t.add(Bee({key:p.key||(e.key?Jc(e.key):void 0),pulse:p.pulse,clean:!i}));const m=ie(u);u=l=t.add(Ri({pulse:m})),u=t.add(Yee({markdef:Kte(e),interactive:Jte(e.interactive,t),clip:Xte(e.clip,t),context:{$context:!0},groups:t.lookup(),parent:t.signals.parent?t.signalRef("parent"):null,index:t.markpath(),pulse:ie(u)}));const y=ie(u);u=c=t.add(s5(n5(e.encode,e.type,n,e.style,t,{mod:!1,pulse:y}))),u.params.parent=t.encode(),e.transform&&e.transform.forEach(_=>{const w=Gw(_,t),S=w.metadata;(S.generates||S.changes)&&O("Mark transforms should not generate new data."),S.nomod||(c.params.mod=!0),w.params.pulse=ie(u),t.add(u=w)}),e.sort&&(u=t.add(nte({sort:t.compareRef(e.sort),pulse:ie(u)})));const b=ie(u);(r||s)&&(s=t.add(l5({layout:t.objectProperty(e.layout),legends:t.legends,mark:y,pulse:b})),d=ie(s));const v=t.add(o5({mark:y,pulse:d||b}));h=ie(v),i&&(g&&(a=t.operators,a.pop(),s&&a.pop()),t.pushState(b,d||h,m),r?one(e,t,p):g?sne(e,t,p):t.parse(e),t.popState(),g&&(s&&a.push(s),a.push(v))),o&&(h=ane(o,h,t));const x=t.add(u5({pulse:h})),E=t.add(_a({pulse:ie(x)},void 0,t.parent()));e.name!=null&&(f=e.name,t.addData(f,new ia(t,l,x,E)),e.on&&e.on.forEach(_=>{(_.insert||_.remove||_.toggle)&&O("Marks only support modify triggers."),w5(_,t,f)}))}function ane(e,t,n){const i=e.method,r=e.bound,o=e.separation,s={separation:ft(o)?n.signalRef(o.signal):o,method:ft(i)?n.signalRef(i.signal):i,pulse:t};if(e.order&&(s.sort=n.compareRef({field:e.order})),r){const a=r.tolerance;s.boundTolerance=ft(a)?n.signalRef(a.signal):+a,s.boundScale=n.scaleRef(r.scale),s.boundOrient=r.orient}return ie(n.add(Kee(s)))}function une(e,t){const n=t.config.legend,i=e.encode||{},r=An(e,n),o=i.legend||{},s=o.name||void 0,a=o.interactive,u=o.style,l={};let c=0,f,d,h;Uw.forEach(v=>e[v]?(l[v]=e[v],c=c||e[v]):0),c||O("Missing valid scale for legend.");const g=lne(e,t.scaleType(c)),p={title:e.title!=null,scales:l,type:g,vgrad:g!=="symbol"&&r.isVertical()},m=ie(t.add(Ri(null,[p]))),y={enter:{x:{value:0},y:{value:0}}},b=ie(t.add(Hee(d={type:g,scale:t.scaleRef(c),count:t.objectProperty(r("tickCount")),limit:t.property(r("symbolLimit")),values:t.objectProperty(e.values),minstep:t.property(e.tickMinStep),formatType:t.property(e.formatType),formatSpecifier:t.property(e.format)})));return g===lh?(h=[Dte(e,c,n,i.gradient),aA(e,n,i.labels,b)],d.count=d.count||t.signalRef(`max(2,2*floor((${Bs(r.gradientLength())})/100))`)):g===Eb?h=[Lte(e,c,n,i.gradient,b),aA(e,n,i.labels,b)]:(f=Bte(e,n),h=[zte(e,n,i,b,Bs(f.columns))],d.size=dne(e,t,h[0].marks)),h=[Zc({role:aee,from:m,encode:y,marks:h,layout:f,interactive:a})],p.title&&h.push(Vte(e,n,i.title,m)),sm(Zc({role:oee,from:m,encode:fl(fne(r,e,n),o,If),marks:h,aria:r("aria"),description:r("description"),zindex:r("zindex"),name:s,interactive:a,style:u}),t)}function lne(e,t){let n=e.type||sA;return!e.type&&cne(e)===1&&(e.fill||e.stroke)&&(n=Gx(t)?lh:gy(t)?Eb:sA),n!==lh?n:gy(t)?Eb:lh}function cne(e){return Uw.reduce((t,n)=>t+(e[n]?1:0),0)}function fne(e,t,n){const i={enter:{},update:{}};return Nt(i,{orient:e("orient"),offset:e("offset"),padding:e("padding"),titlePadding:e("titlePadding"),cornerRadius:e("cornerRadius"),fill:e("fillColor"),stroke:e("strokeColor"),strokeWidth:n.strokeWidth,strokeDash:n.strokeDash,x:e("legendX"),y:e("legendY"),format:t.format,formatType:t.formatType}),i}function dne(e,t,n){const i=Bs(gA("size",e,n)),r=Bs(gA("strokeWidth",e,n)),o=Bs(hne(n[1].encode,t,Pf));return ur(`max(ceil(sqrt(${i})+${r}),${o})`,t)}function gA(e,t,n){return t[e]?`scale("${t[e]}",datum)`:m5(e,n[0].encode)}function hne(e,t,n){return m5("fontSize",e)||Rte("fontSize",t,n)}const gne=`item.orient==="${dl}"?-90:item.orient==="${hl}"?90:0`;function pne(e,t){e=J(e)?{text:e}:e;const n=An(e,t.config.title),i=e.encode||{},r=i.group||{},o=r.name||void 0,s=r.interactive,a=r.style,u=[],l={},c=ie(t.add(Ri(null,[l])));return u.push(bne(e,n,mne(e),c)),e.subtitle&&u.push(vne(e,n,i.subtitle,c)),sm(Zc({role:fee,from:c,encode:yne(n,r),marks:u,aria:n("aria"),description:n("description"),zindex:n("zindex"),name:o,interactive:s,style:a}),t)}function mne(e){const t=e.encode;return t&&t.title||pe({name:e.name,interactive:e.interactive,style:e.style},t)}function yne(e,t){const n={enter:{},update:{}};return Nt(n,{orient:e("orient"),anchor:e("anchor"),align:{signal:qw},angle:{signal:gne},limit:e("limit"),frame:e("frame"),offset:e("offset")||0,padding:e("subtitlePadding")}),fl(n,t,If)}function bne(e,t,n,i){const r={value:0},o=e.text,s={enter:{opacity:r},update:{opacity:{value:1}},exit:{opacity:r}};return Nt(s,{text:o,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:t("dx"),dy:t("dy"),fill:t("color"),font:t("font"),fontSize:t("fontSize"),fontStyle:t("fontStyle"),fontWeight:t("fontWeight"),lineHeight:t("lineHeight")},{align:t("align"),angle:t("angle"),baseline:t("baseline")}),qn({type:Sa,role:dee,style:Ste,from:i,encode:s},n)}function vne(e,t,n,i){const r={value:0},o=e.subtitle,s={enter:{opacity:r},update:{opacity:{value:1}},exit:{opacity:r}};return Nt(s,{text:o,align:{signal:"item.mark.group.align"},angle:{signal:"item.mark.group.angle"},limit:{signal:"item.mark.group.limit"},baseline:"top",dx:t("dx"),dy:t("dy"),fill:t("subtitleColor"),font:t("subtitleFont"),fontSize:t("subtitleFontSize"),fontStyle:t("subtitleFontStyle"),fontWeight:t("subtitleFontWeight"),lineHeight:t("subtitleLineHeight")},{align:t("align"),angle:t("angle"),baseline:t("baseline")}),qn({type:Sa,role:hee,style:$te,from:i,encode:s},n)}function xne(e,t){const n=[];e.transform&&e.transform.forEach(i=>{n.push(Gw(i,t))}),e.on&&e.on.forEach(i=>{w5(i,t,e.name)}),t.addDataPipeline(e.name,wne(e,t,n))}function wne(e,t,n){const i=[];let r=null,o=!1,s=!1,a,u,l,c,f;for(e.values?ft(e.values)||ah(e.format)?(i.push(pA(t,e)),i.push(r=ps())):i.push(r=ps({$ingest:e.values,$format:e.format})):e.url?ah(e.url)||ah(e.format)?(i.push(pA(t,e)),i.push(r=ps())):i.push(r=ps({$request:e.url,$format:e.format})):e.source&&(r=a=Q(e.source).map(d=>ie(t.getData(d).output)),i.push(null)),u=0,l=n.length;ue===Vo||e===Oi,am=(e,t,n)=>ft(e)?$ne(e.signal,t,n):e===dl||e===Oi?t:n,wt=(e,t,n)=>ft(e)?_ne(e.signal,t,n):E5(e)?t:n,_i=(e,t,n)=>ft(e)?Sne(e.signal,t,n):E5(e)?n:t,_5=(e,t,n)=>ft(e)?kne(e.signal,t,n):e===Oi?{value:t}:{value:n},Ene=(e,t,n)=>ft(e)?Ane(e.signal,t,n):e===hl?{value:t}:{value:n},_ne=(e,t,n)=>S5(`${e} === '${Oi}' || ${e} === '${Vo}'`,t,n),Sne=(e,t,n)=>S5(`${e} !== '${Oi}' && ${e} !== '${Vo}'`,t,n),$ne=(e,t,n)=>Yw(`${e} === '${dl}' || ${e} === '${Oi}'`,t,n),kne=(e,t,n)=>Yw(`${e} === '${Oi}'`,t,n),Ane=(e,t,n)=>Yw(`${e} === '${hl}'`,t,n),S5=(e,t,n)=>(t=t!=null?xt(t):t,n=n!=null?xt(n):n,mA(t)&&mA(n)?(t=t?t.signal||G(t.value):null,n=n?n.signal||G(n.value):null,{signal:`${e} ? (${t}) : (${n})`}):[pe({test:e},t)].concat(n||[])),mA=e=>e==null||Object.keys(e).length===1,Yw=(e,t,n)=>({signal:`${e} ? (${eu(t)}) : (${eu(n)})`}),Cne=(e,t,n,i,r)=>({signal:(i!=null?`${e} === '${dl}' ? (${eu(i)}) : `:"")+(n!=null?`${e} === '${Vo}' ? (${eu(n)}) : `:"")+(r!=null?`${e} === '${hl}' ? (${eu(r)}) : `:"")+(t!=null?`${e} === '${Oi}' ? (${eu(t)}) : `:"")+"(null)"}),eu=e=>ft(e)?e.signal:e==null?null:G(e),Fne=(e,t)=>t===0?0:ft(e)?{signal:`(${e.signal}) * ${t}`}:{value:e*t},su=(e,t)=>{const n=e.signal;return n&&n.endsWith("(null)")?{signal:n.slice(0,-6)+t.signal}:e};function ja(e,t,n,i){let r;if(t&&Z(t,e))return t[e];if(Z(n,e))return n[e];if(e.startsWith("title")){switch(e){case"titleColor":r="fill";break;case"titleFont":case"titleFontSize":case"titleFontWeight":r=e[5].toLowerCase()+e.slice(6)}return i[Bw][r]}else if(e.startsWith("label")){switch(e){case"labelColor":r="fill";break;case"labelFont":case"labelFontSize":r=e[5].toLowerCase()+e.slice(6)}return i[Pf][r]}return null}function yA(e){const t={};for(const n of e)if(n)for(const i in n)t[i]=1;return Object.keys(t)}function Mne(e,t){var n=t.config,i=n.style,r=n.axis,o=t.scaleType(e.scale)==="band"&&n.axisBand,s=e.orient,a,u,l;if(ft(s)){const f=yA([n.axisX,n.axisY]),d=yA([n.axisTop,n.axisBottom,n.axisLeft,n.axisRight]);a={};for(l of f)a[l]=wt(s,ja(l,n.axisX,r,i),ja(l,n.axisY,r,i));u={};for(l of d)u[l]=Cne(s.signal,ja(l,n.axisTop,r,i),ja(l,n.axisBottom,r,i),ja(l,n.axisLeft,r,i),ja(l,n.axisRight,r,i))}else a=s===Oi||s===Vo?n.axisX:n.axisY,u=n["axis"+s[0].toUpperCase()+s.slice(1)];return a||u||o?pe({},r,a,u,o):r}function Tne(e,t,n,i){const r=An(e,t),o=e.orient;let s,a;const u={enter:s={opacity:Se},update:a={opacity:Zn},exit:{opacity:Se}};Nt(u,{stroke:r("domainColor"),strokeCap:r("domainCap"),strokeDash:r("domainDash"),strokeDashOffset:r("domainDashOffset"),strokeWidth:r("domainWidth"),strokeOpacity:r("domainOpacity")});const l=bA(e,0),c=bA(e,1);return s.x=a.x=wt(o,l,Se),s.x2=a.x2=wt(o,c),s.y=a.y=_i(o,l,Se),s.y2=a.y2=_i(o,c),qn({type:jw,role:eee,from:i,encode:u},n)}function bA(e,t){return{scale:e.scale,range:t}}function Nne(e,t,n,i,r){const o=An(e,t),s=e.orient,a=e.gridScale,u=am(s,1,-1),l=Rne(e.offset,u);let c,f,d;const h={enter:c={opacity:Se},update:d={opacity:Zn},exit:f={opacity:Se}};Nt(h,{stroke:o("gridColor"),strokeCap:o("gridCap"),strokeDash:o("gridDash"),strokeDashOffset:o("gridDashOffset"),strokeOpacity:o("gridOpacity"),strokeWidth:o("gridWidth")});const g={scale:e.scale,field:Qn,band:r.band,extra:r.extra,offset:r.offset,round:o("tickRound")},p=wt(s,{signal:"height"},{signal:"width"}),m=a?{scale:a,range:0,mult:u,offset:l}:{value:0,offset:l},y=a?{scale:a,range:1,mult:u,offset:l}:pe(p,{mult:u,offset:l});return c.x=d.x=wt(s,g,m),c.y=d.y=_i(s,g,m),c.x2=d.x2=_i(s,y),c.y2=d.y2=wt(s,y),f.x=wt(s,g),f.y=_i(s,g),qn({type:jw,role:tee,key:Qn,from:i,encode:h},n)}function Rne(e,t){if(t!==1)if(!K(e))e=ft(t)?{signal:`(${t.signal}) * (${e||0})`}:t*(e||0);else{let n=e=pe({},e);for(;n.mult!=null;)if(K(n.mult))n=n.mult=pe({},n.mult);else return n.mult=ft(t)?{signal:`(${n.mult}) * (${t.signal})`}:n.mult*t,e;n.mult=t}return e}function One(e,t,n,i,r,o){const s=An(e,t),a=e.orient,u=am(a,-1,1);let l,c,f;const d={enter:l={opacity:Se},update:f={opacity:Zn},exit:c={opacity:Se}};Nt(d,{stroke:s("tickColor"),strokeCap:s("tickCap"),strokeDash:s("tickDash"),strokeDashOffset:s("tickDashOffset"),strokeOpacity:s("tickOpacity"),strokeWidth:s("tickWidth")});const h=xt(r);h.mult=u;const g={scale:e.scale,field:Qn,band:o.band,extra:o.extra,offset:o.offset,round:s("tickRound")};return f.y=l.y=wt(a,Se,g),f.y2=l.y2=wt(a,h),c.x=wt(a,g),f.x=l.x=_i(a,Se,g),f.x2=l.x2=_i(a,h),c.y=_i(a,g),qn({type:jw,role:iee,key:Qn,from:i,encode:d},n)}function r1(e,t,n,i,r){return{signal:'flush(range("'+e+'"), scale("'+e+'", datum.value), '+t+","+n+","+i+","+r+")"}}function Dne(e,t,n,i,r,o){const s=An(e,t),a=e.orient,u=e.scale,l=am(a,-1,1),c=Bs(s("labelFlush")),f=Bs(s("labelFlushOffset")),d=s("labelAlign"),h=s("labelBaseline");let g=c===0||!!c,p;const m=xt(r);m.mult=l,m.offset=xt(s("labelPadding")||0),m.offset.mult=l;const y={scale:u,field:Qn,band:.5,offset:y5(o.offset,s("labelOffset"))},b=wt(a,g?r1(u,c,'"left"','"right"','"center"'):{value:"center"},Ene(a,"left","right")),v=wt(a,_5(a,"bottom","top"),g?r1(u,c,'"top"','"bottom"','"middle"'):{value:"middle"}),x=r1(u,c,`-(${f})`,f,0);g=g&&f;const E={opacity:Se,x:wt(a,y,m),y:_i(a,y,m)},_={enter:E,update:p={opacity:Zn,text:{field:zw},x:E.x,y:E.y,align:b,baseline:v},exit:{opacity:Se,x:E.x,y:E.y}};Nt(_,{dx:!d&&g?wt(a,x):null,dy:!h&&g?_i(a,x):null}),Nt(_,{angle:s("labelAngle"),fill:s("labelColor"),fillOpacity:s("labelOpacity"),font:s("labelFont"),fontSize:s("labelFontSize"),fontWeight:s("labelFontWeight"),fontStyle:s("labelFontStyle"),limit:s("labelLimit"),lineHeight:s("labelLineHeight")},{align:d,baseline:h});const w=s("labelBound");let S=s("labelOverlap");return S=S||w?{separation:s("labelSeparation"),method:S,order:"datum.index",bound:w?{scale:u,orient:a,tolerance:w}:null}:void 0,p.align!==b&&(p.align=su(p.align,b)),p.baseline!==v&&(p.baseline=su(p.baseline,v)),qn({type:Sa,role:nee,style:Pf,key:Qn,from:i,encode:_,overlap:S},n)}function Lne(e,t,n,i){const r=An(e,t),o=e.orient,s=am(o,-1,1);let a,u;const l={enter:a={opacity:Se,anchor:xt(r("titleAnchor",null)),align:{signal:qw}},update:u=pe({},a,{opacity:Zn,text:xt(e.title)}),exit:{opacity:Se}},c={signal:`lerp(range("${e.scale}"), ${rm(0,1,.5)})`};return u.x=wt(o,c),u.y=_i(o,c),a.angle=wt(o,Se,Fne(s,90)),a.baseline=wt(o,_5(o,Vo,Oi),{value:Vo}),u.angle=a.angle,u.baseline=a.baseline,Nt(l,{fill:r("titleColor"),fillOpacity:r("titleOpacity"),font:r("titleFont"),fontSize:r("titleFontSize"),fontStyle:r("titleFontStyle"),fontWeight:r("titleFontWeight"),limit:r("titleLimit"),lineHeight:r("titleLineHeight")},{align:r("titleAlign"),angle:r("titleAngle"),baseline:r("titleBaseline")}),Pne(r,o,l,n),l.update.align=su(l.update.align,a.align),l.update.angle=su(l.update.angle,a.angle),l.update.baseline=su(l.update.baseline,a.baseline),qn({type:Sa,role:ree,style:Bw,from:i,encode:l},n)}function Pne(e,t,n,i){const r=(a,u)=>a!=null?(n.update[u]=su(xt(a),n.update[u]),!1):!Ya(u,i),o=r(e("titleX"),"x"),s=r(e("titleY"),"y");n.enter.auto=s===o?xt(s):wt(t,xt(s),xt(o))}function Ine(e,t){const n=Mne(e,t),i=e.encode||{},r=i.axis||{},o=r.name||void 0,s=r.interactive,a=r.style,u=An(e,n),l=Ote(u),c={scale:e.scale,ticks:!!u("ticks"),labels:!!u("labels"),grid:!!u("grid"),domain:!!u("domain"),title:e.title!=null},f=ie(t.add(Ri({},[c]))),d=ie(t.add(zee({scale:t.scaleRef(e.scale),extra:t.property(l.extra),count:t.objectProperty(e.tickCount),values:t.objectProperty(e.values),minstep:t.property(e.tickMinStep),formatType:t.property(e.formatType),formatSpecifier:t.property(e.format)}))),h=[];let g;return c.grid&&h.push(Nne(e,n,i.grid,d,l)),c.ticks&&(g=u("tickSize"),h.push(One(e,n,i.ticks,d,g,l))),c.labels&&(g=c.ticks?g:0,h.push(Dne(e,n,i.labels,d,g,l))),c.domain&&h.push(Tne(e,n,i.domain,f)),c.title&&h.push(Lne(e,n,i.title,f)),sm(Zc({role:ZZ,from:f,encode:fl(zne(u,e),r,If),marks:h,aria:u("aria"),description:u("description"),zindex:u("zindex"),name:o,interactive:s,style:a}),t)}function zne(e,t){const n={enter:{},update:{}};return Nt(n,{orient:e("orient"),offset:e("offset")||0,position:gi(t.position,0),titlePadding:e("titlePadding"),minExtent:e("minExtent"),maxExtent:e("maxExtent"),range:{signal:`abs(span(range("${t.scale}")))`},translate:e("translate"),format:t.format,formatType:t.formatType}),n}function $5(e,t,n){const i=Q(e.signals),r=Q(e.scales);return n||i.forEach(o=>i5(o,t)),Q(e.projections).forEach(o=>yte(o,t)),r.forEach(o=>ote(o,t)),Q(e.data).forEach(o=>xne(o,t)),r.forEach(o=>ste(o,t)),(n||i).forEach(o=>Iee(o,t)),Q(e.axes).forEach(o=>Ine(o,t)),Q(e.marks).forEach(o=>sm(o,t)),Q(e.legends).forEach(o=>une(o,t)),e.title&&pne(e.title,t),t.parseLambdas(),t}const Bne=e=>fl({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e);function Une(e,t){const n=t.config,i=ie(t.root=t.add(Fg())),r=jne(e,n);r.forEach(l=>i5(l,t)),t.description=e.description||n.description,t.eventConfig=n.events,t.legends=t.objectProperty(n.legend&&n.legend.layout),t.locale=n.locale;const o=t.add(Ri()),s=t.add(s5(n5(Bne(e.encode),im,Dw,e.style,t,{pulse:ie(o)}))),a=t.add(l5({layout:t.objectProperty(e.layout),legends:t.legends,autosize:t.signalRef("autosize"),mark:i,pulse:ie(s)}));t.operators.pop(),t.pushState(ie(s),ie(a),null),$5(e,t,r),t.operators.push(a);let u=t.add(o5({mark:i,pulse:ie(a)}));return u=t.add(u5({pulse:ie(u)})),u=t.add(_a({pulse:ie(u)})),t.addData("root",new ia(t,o,o,u)),t}function Ul(e,t){return t&&t.signal?{name:e,update:t.signal}:{name:e,value:t}}function jne(e,t){const n=s=>gi(e[s],t[s]),i=[Ul("background",n("background")),Ul("autosize",KZ(n("autosize"))),Ul("padding",QZ(n("padding"))),Ul("width",n("width")||0),Ul("height",n("height")||0)],r=i.reduce((s,a)=>(s[a.name]=a,s),{}),o={};return Q(e.signals).forEach(s=>{Z(r,s.name)?s=pe(r[s.name],s):i.push(s),o[s.name]=s}),Q(t.signals).forEach(s=>{!Z(o,s.name)&&!Z(r,s.name)&&i.push(s)}),i}function k5(e,t){this.config=e||{},this.options=t||{},this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.eventConfig=null,this.locale=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._lookup=[],this._markpath=[]}function vA(e){this.config=e.config,this.options=e.options,this.legends=e.legends,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._lookup=e._lookup.slice(),this._markpath=e._markpath}k5.prototype=vA.prototype={parse(e){return $5(e,this)},fork(){return new vA(this)},isSubscope(){return this._subid>0},toRuntime(){return this.finish(),{description:this.description,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings,eventConfig:this.eventConfig,locale:this.locale}},id(){return(this._subid?this._subid+":":0)+this._id++},add(e){return this.operators.push(e),e.id=this.id(),e.refs&&(e.refs.forEach(t=>{t.$ref=e.id}),e.refs=null),e},proxy(e){const t=e instanceof yb?ie(e):e;return this.add(Zee({value:t}))},addStream(e){return this.streams.push(e),e.id=this.id(),e},addUpdate(e){return this.updates.push(e),e},finish(){let e,t;this.root&&(this.root.root=!0);for(e in this.signals)this.signals[e].signal=e;for(e in this.scales)this.scales[e].scale=e;function n(i,r,o){let s,a;i&&(s=i.data||(i.data={}),a=s[r]||(s[r]=[]),a.push(o))}for(e in this.data){t=this.data[e],n(t.input,e,"input"),n(t.output,e,"output"),n(t.values,e,"values");for(const i in t.index)n(t.index[i],e,"index:"+i)}return this},pushState(e,t,n){this._encode.push(ie(this.add(_a({pulse:e})))),this._parent.push(t),this._lookup.push(n?ie(this.proxy(n)):null),this._markpath.push(-1)},popState(){this._encode.pop(),this._parent.pop(),this._lookup.pop(),this._markpath.pop()},parent(){return _e(this._parent)},encode(){return _e(this._encode)},lookup(){return _e(this._lookup)},markpath(){const e=this._markpath;return++e[e.length-1]},fieldRef(e,t){if(J(e))return Jc(e,t);e.signal||O("Unsupported field reference: "+G(e));const n=e.signal;let i=this.field[n];if(!i){const r={name:this.signalRef(n)};t&&(r.as=t),this.field[n]=i=ie(this.add(qee(r)))}return i},compareRef(e){let t=!1;const n=o=>ft(o)?(t=!0,this.signalRef(o.signal)):Cee(o)?(t=!0,this.exprRef(o.expr)):o,i=Q(e.field).map(n),r=Q(e.order).map(n);return t?ie(this.add(oA({fields:i,orders:r}))):iA(i,r)},keyRef(e,t){let n=!1;const i=o=>ft(o)?(n=!0,ie(r[o.signal])):o,r=this.signals;return e=Q(e).map(i),n?ie(this.add(Wee({fields:e,flat:t}))):See(e,t)},sortRef(e){if(!e)return e;const t=tm(e.op,e.field),n=e.order||$ee;return n.signal?ie(this.add(oA({fields:t,orders:this.signalRef(n.signal)}))):iA(t,n)},event(e,t){const n=e+":"+t;if(!this.events[n]){const i=this.id();this.streams.push({id:i,source:e,type:t}),this.events[n]=i}return this.events[n]},hasOwnSignal(e){return Z(this.signals,e)},addSignal(e,t){this.hasOwnSignal(e)&&O("Duplicate signal name: "+G(e));const n=t instanceof yb?t:this.add(Fg(t));return this.signals[e]=n},getSignal(e){return this.signals[e]||O("Unrecognized signal name: "+G(e)),this.signals[e]},signalRef(e){return this.signals[e]?ie(this.signals[e]):(Z(this.lambdas,e)||(this.lambdas[e]=this.add(Fg(null))),ie(this.lambdas[e]))},parseLambdas(){const e=Object.keys(this.lambdas);for(let t=0,n=e.length;t0?",":"")+(K(r)?r.signal||Vw(r):G(r))}return n+"]"}function Wne(e){let t="{",n=0,i,r;for(i in e)r=e[i],t+=(++n>1?",":"")+G(i)+":"+(K(r)?r.signal||Vw(r):G(r));return t+"}"}function Hne(){const e="sans-serif",i="#4c78a8",r="#000",o="#888",s="#ddd";return{description:"Vega visualization",padding:0,autosize:"pad",background:null,events:{defaults:{allow:["wheel"]}},group:null,mark:null,arc:{fill:i},area:{fill:i},image:null,line:{stroke:i,strokeWidth:2},path:{stroke:i},rect:{fill:i},rule:{stroke:r},shape:{stroke:i},symbol:{fill:i,size:64},text:{fill:r,font:e,fontSize:11},trail:{fill:i,size:2},style:{"guide-label":{fill:r,font:e,fontSize:10},"guide-title":{fill:r,font:e,fontSize:11,fontWeight:"bold"},"group-title":{fill:r,font:e,fontSize:13,fontWeight:"bold"},"group-subtitle":{fill:r,font:e,fontSize:12},point:{size:30,strokeWidth:2,shape:"circle"},circle:{size:30,strokeWidth:2},square:{size:30,strokeWidth:2,shape:"square"},cell:{fill:"transparent",stroke:s},view:{fill:"transparent"}},title:{orient:"top",anchor:"middle",offset:4,subtitlePadding:3},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domain:!0,domainWidth:1,domainColor:o,grid:!1,gridWidth:1,gridColor:s,labels:!0,labelAngle:0,labelLimit:180,labelOffset:0,labelPadding:2,ticks:!0,tickColor:o,tickOffset:0,tickRound:!0,tickSize:5,tickWidth:1,titlePadding:4},axisBand:{tickOffset:-.5},projection:{type:"mercator"},legend:{orient:"right",padding:0,gridAlign:"each",columnPadding:10,rowPadding:2,symbolDirection:"vertical",gradientDirection:"vertical",gradientLength:200,gradientThickness:16,gradientStrokeColor:s,gradientStrokeWidth:0,gradientLabelOffset:2,labelAlign:"left",labelBaseline:"middle",labelLimit:160,labelOffset:4,labelOverlap:!0,symbolLimit:30,symbolType:"circle",symbolSize:100,symbolOffset:0,symbolStrokeWidth:1.5,symbolBaseFillColor:"transparent",symbolBaseStrokeColor:o,titleLimit:180,titleOrient:"top",titlePadding:5,layout:{offset:18,direction:"horizontal",left:{direction:"vertical"},right:{direction:"vertical"}}},range:{category:{scheme:"tableau10"},ordinal:{scheme:"blues"},heatmap:{scheme:"yellowgreenblue"},ramp:{scheme:"blues"},diverging:{scheme:"blueorange",extent:[1,0]},symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}function Gne(e,t,n){return K(e)||O("Input Vega specification must be an object."),t=Ju(Hne(),t,e.config),Une(e,new k5(t,n)).toRuntime()}var Yne="6.2.0";pe(bu,D9,dW,WW,FG,_Y,KV,FV,QV,EX,NX,zX);const Vne=Yne,Xne=Object.freeze(Object.defineProperty({__proto__:null,Bounds:st,CanvasHandler:Cf,CanvasRenderer:qh,DATE:wn,DAY:Ut,DAYOFYEAR:sr,Dataflow:nu,Debug:xF,DisallowedObjectProperties:ov,Error:sv,EventStream:ap,Gradient:p3,GroupItem:Mp,HOURS:Bn,Handler:y2,HybridHandler:oR,HybridRenderer:$y,Info:vF,Item:Fp,MILLISECONDS:ki,MINUTES:Un,MONTH:Wt,Marks:jn,MultiPulse:Tv,None:bF,Operator:ze,Parameters:sp,Pulse:Do,QUARTER:xn,RenderType:Ao,Renderer:Af,ResourceLoader:w3,SECONDS:ni,SVGHandler:G3,SVGRenderer:_2,SVGStringRenderer:rR,Scenegraph:I3,TIME_UNITS:wv,Transform:R,View:WD,WEEK:lt,Warn:av,YEAR:Tt,accessor:kn,accessorFields:qt,accessorName:Ze,array:Q,ascending:Zu,bandwidthNRD:Dv,bin:nT,bootstrapCI:iT,boundClip:pR,boundContext:_f,boundItem:xy,boundMark:O3,boundStroke:io,changeset:va,clampRange:OF,codegenExpression:yD,compare:fv,constant:Yt,cumulativeLogNormal:Uv,cumulativeNormal:lp,cumulativeUniform:Hv,dayofyear:lM,debounce:dv,defaultLocale:kv,definition:ZM,densityLogNormal:Bv,densityNormal:Lv,densityUniform:Wv,domChild:ut,domClear:Gn,domCreate:$o,domFind:m2,dotbin:rT,error:O,expressionFunction:rt,extend:pe,extent:ir,extentIndex:DF,falsy:po,fastmap:el,field:ei,flush:LF,font:Dp,fontFamily:kf,fontSize:pr,format:Ud,formatLocale:wh,formats:Fv,hasOwnProperty:Z,id:uf,identity:vn,inferType:jM,inferTypes:qM,ingest:Fe,inherits:Y,inrange:Xa,interpolate:Yx,interpolateColors:Ap,interpolateRange:t3,intersect:fR,intersectBoxLine:Ka,intersectPath:t2,intersectPoint:n2,intersectRule:_3,isArray:P,isBoolean:pa,isDate:Ro,isFunction:de,isIterable:PF,isNumber:ke,isObject:K,isRegExp:hv,isString:J,isTuple:rp,key:gv,lerp:IF,lineHeight:Ho,loader:np,locale:BM,logger:Yg,lruCache:zF,markup:E2,merge:BF,mergeConfig:Ju,multiLineOffset:h2,one:Ku,pad:UF,panLinear:CF,panLog:FF,panPow:MF,panSymlog:TF,parse:Gne,parseExpression:Ew,parseSelector:rs,path:gp,pathCurves:Qx,pathEqual:mR,pathParse:Su,pathRectangle:b3,pathRender:zc,pathSymbols:y3,pathTrail:v3,peek:_e,point:Pp,projection:j2,quantileLogNormal:jv,quantileNormal:cp,quantileUniform:Gv,quantiles:Rv,quantizeInterpolator:n3,quarter:NF,quartiles:Ov,get random(){return ii},randomInteger:z8,randomKDE:Iv,randomLCG:I8,randomLogNormal:sT,randomMixture:aT,randomNormal:Pv,randomUniform:uT,read:GM,regressionConstant:Yv,regressionExp:cT,regressionLinear:Vv,regressionLoess:hT,regressionLog:lT,regressionPoly:dT,regressionPow:fT,regressionQuad:Xv,renderModule:Ip,repeat:Vl,resetDefaultLocale:Lz,resetSVGDefIds:Mq,responseType:HM,runtimeContext:TD,sampleCurve:dp,sampleLogNormal:zv,sampleNormal:up,sampleUniform:qv,scale:Ce,sceneEqual:S2,sceneFromJSON:L3,scenePickVisit:Dh,sceneToJSON:D3,sceneVisit:Ai,sceneZOrder:i2,scheme:Vx,serializeXML:eR,setHybridRendererOptions:kq,setRandom:L8,span:lf,splitAccessPath:dr,stringValue:G,textMetrics:Ln,timeBin:kM,timeFloor:mM,timeFormatLocale:Rc,timeInterval:rl,timeOffset:vM,timeSequence:EM,timeUnitSpecifier:uM,timeUnits:Ev,toBoolean:pv,toDate:mv,toNumber:nn,toSet:$i,toString:yv,transform:eT,transforms:bu,truncate:jF,truthy:ti,tupleid:re,typeParsers:ny,utcFloor:yM,utcInterval:ol,utcOffset:xM,utcSequence:_M,utcdayofyear:dM,utcquarter:RF,utcweek:hM,version:Vne,visitArray:bo,week:cM,writeConfig:Qu,zero:_o,zoomLinear:uv,zoomLog:lv,zoomPow:gh,zoomSymlog:cv},Symbol.toStringTag,{value:"Module"}));function Kne(e,t,n){let i;t.x2&&(t.x?(n&&e.x>e.x2&&(i=e.x,e.x=e.x2,e.x2=i),e.width=e.x2-e.x):e.x=e.x2-(e.width||0)),t.xc&&(e.x=e.xc-(e.width||0)/2),t.y2&&(t.y?(n&&e.y>e.y2&&(i=e.y,e.y=e.y2,e.y2=i),e.height=e.y2-e.y):e.y=e.y2-(e.height||0)),t.yc&&(e.y=e.yc-(e.height||0)/2)}var Jne={NaN:NaN,E:Math.E,LN2:Math.LN2,LN10:Math.LN10,LOG2E:Math.LOG2E,LOG10E:Math.LOG10E,PI:Math.PI,SQRT1_2:Math.SQRT1_2,SQRT2:Math.SQRT2,MIN_VALUE:Number.MIN_VALUE,MAX_VALUE:Number.MAX_VALUE},Qne={"*":(e,t)=>e*t,"+":(e,t)=>e+t,"-":(e,t)=>e-t,"/":(e,t)=>e/t,"%":(e,t)=>e%t,">":(e,t)=>e>t,"<":(e,t)=>ee<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e==t,"!=":(e,t)=>e!=t,"===":(e,t)=>e===t,"!==":(e,t)=>e!==t,"&":(e,t)=>e&t,"|":(e,t)=>e|t,"^":(e,t)=>e^t,"<<":(e,t)=>e<>":(e,t)=>e>>t,">>>":(e,t)=>e>>>t},Zne={"+":e=>+e,"-":e=>-e,"~":e=>~e,"!":e=>!e};const eie=Array.prototype.slice,ms=(e,t,n)=>{const i=n?n(t[0]):t[0];return i[e].apply(i,eie.call(t,1))},tie=(e,t=0,n=1,i=0,r=0,o=0,s=0)=>J(e)?new Date(e):new Date(e,t,n,i,r,o,s);var nie={isNaN:Number.isNaN,isFinite:Number.isFinite,abs:Math.abs,acos:Math.acos,asin:Math.asin,atan:Math.atan,atan2:Math.atan2,ceil:Math.ceil,cos:Math.cos,exp:Math.exp,floor:Math.floor,log:Math.log,max:Math.max,min:Math.min,pow:Math.pow,random:Math.random,round:Math.round,sin:Math.sin,sqrt:Math.sqrt,tan:Math.tan,clamp:(e,t,n)=>Math.max(t,Math.min(n,e)),now:Date.now,utc:Date.UTC,datetime:tie,date:e=>new Date(e).getDate(),day:e=>new Date(e).getDay(),year:e=>new Date(e).getFullYear(),month:e=>new Date(e).getMonth(),hours:e=>new Date(e).getHours(),minutes:e=>new Date(e).getMinutes(),seconds:e=>new Date(e).getSeconds(),milliseconds:e=>new Date(e).getMilliseconds(),time:e=>new Date(e).getTime(),timezoneoffset:e=>new Date(e).getTimezoneOffset(),utcdate:e=>new Date(e).getUTCDate(),utcday:e=>new Date(e).getUTCDay(),utcyear:e=>new Date(e).getUTCFullYear(),utcmonth:e=>new Date(e).getUTCMonth(),utchours:e=>new Date(e).getUTCHours(),utcminutes:e=>new Date(e).getUTCMinutes(),utcseconds:e=>new Date(e).getUTCSeconds(),utcmilliseconds:e=>new Date(e).getUTCMilliseconds(),length:e=>e.length,join:function(){return ms("join",arguments)},indexof:function(){return ms("indexOf",arguments)},lastindexof:function(){return ms("lastIndexOf",arguments)},slice:function(){return ms("slice",arguments)},reverse:e=>e.slice().reverse(),sort:e=>e.slice().sort(Zu),parseFloat,parseInt,upper:e=>String(e).toUpperCase(),lower:e=>String(e).toLowerCase(),substring:function(){return ms("substring",arguments,String)},split:function(){return ms("split",arguments,String)},replace:function(){return ms("replace",arguments,String)},trim:e=>String(e).trim(),btoa:e=>btoa(e),atob:e=>atob(e),regexp:RegExp,test:(e,t)=>RegExp(e).test(t)};const iie=["view","item","group","xy","x","y"],Sb=new Set([Function,eval,setTimeout,setInterval]);typeof setImmediate=="function"&&Sb.add(setImmediate);const rie={Literal:(e,t)=>t.value,Identifier:(e,t)=>{const n=t.name;return e.memberDepth>0?n:n==="datum"?e.datum:n==="event"?e.event:n==="item"?e.item:Jne[n]||e.params["$"+n]},MemberExpression:(e,t)=>{const n=!t.computed,i=e(t.object);n&&(e.memberDepth+=1);const r=e(t.property);if(n&&(e.memberDepth-=1),Sb.has(i[r])){console.error(`Prevented interpretation of member "${r}" which could lead to insecure code execution`);return}return i[r]},CallExpression:(e,t)=>{const n=t.arguments;let i=t.callee.name;return i.startsWith("_")&&(i=i.slice(1)),i==="if"?e(n[0])?e(n[1]):e(n[2]):(e.fn[i]||nie[i]).apply(e.fn,n.map(e))},ArrayExpression:(e,t)=>t.elements.map(e),BinaryExpression:(e,t)=>Qne[t.operator](e(t.left),e(t.right)),UnaryExpression:(e,t)=>Zne[t.operator](e(t.argument)),ConditionalExpression:(e,t)=>e(t.test)?e(t.consequent):e(t.alternate),LogicalExpression:(e,t)=>t.operator==="&&"?e(t.left)&&e(t.right):e(t.left)||e(t.right),ObjectExpression:(e,t)=>t.properties.reduce((n,i)=>{e.memberDepth+=1;const r=e(i.key);e.memberDepth-=1;const o=e(i.value);return ov.has(r)?console.error(`Prevented interpretation of property "${r}" which could lead to insecure code execution`):Sb.has(o)?console.error(`Prevented interpretation of method "${r}" which could lead to insecure code execution`):n[r]=o,n},{})};function jl(e,t,n,i,r,o){const s=a=>rie[a.type](s,a);return s.memberDepth=0,s.fn=Object.create(t),s.params=n,s.datum=i,s.event=r,s.item=o,iie.forEach(a=>s.fn[a]=(...u)=>r.vega[a](...u)),s(e)}var oie={operator(e,t){const n=t.ast,i=e.functions;return r=>jl(n,i,r)},parameter(e,t){const n=t.ast,i=e.functions;return(r,o)=>jl(n,i,o,r)},event(e,t){const n=t.ast,i=e.functions;return r=>jl(n,i,void 0,void 0,r)},handler(e,t){const n=t.ast,i=e.functions;return(r,o)=>{const s=o.item&&o.item.datum;return jl(n,i,r,s,o)}},encode(e,t){const{marktype:n,channels:i}=t,r=e.functions,o=n==="group"||n==="image"||n==="rect";return(s,a)=>{const u=s.datum;let l=0,c;for(const f in i)c=jl(i[f].ast,r,a,u,void 0,s),s[f]!==c&&(s[f]=c,l=1);return n!=="rule"&&Kne(s,i,o),l}}},sie="6.4.3",aie={version:sie};function Xw(e){return q(e,"or")}function Kw(e){return q(e,"and")}function Jw(e){return q(e,"not")}function fh(e,t){if(Jw(e))fh(e.not,t);else if(Kw(e))for(const n of e.and)fh(n,t);else if(Xw(e))for(const n of e.or)fh(n,t);else t(e)}function au(e,t){return Jw(e)?{not:au(e.not,t)}:Kw(e)?{and:e.and.map(n=>au(n,t))}:Xw(e)?{or:e.or.map(n=>au(n,t))}:t(e)}const ce=structuredClone;function A5(e){throw new Error(e)}function Ru(e,t){const n={};for(const i of t)Z(e,i)&&(n[i]=e[i]);return n}function In(e,t){const n={...e};for(const i of t)delete n[i];return n}Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>De(e)).join(",")})`};function ye(e){if(ke(e))return e;const t=J(e)?e:De(e);if(t.length<250)return t;let n=0;for(let i=0;ia===0?s:`[${s}]`),o=r.map((s,a)=>r.slice(0,a+1).join(""));for(const s of o)t.add(s)}return t}function eE(e,t){return e===void 0||t===void 0?!0:Zw(kb(e),kb(t))}function Be(e){return U(e).length===0}const U=Object.keys,ot=Object.values,Xo=Object.entries;function Du(e){return e===!0||e===!1}function Mg(e){return J(e)||ke(e)||Du(e)}function Ye(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function Cc(e,t){return Jw(e)?`!(${Cc(e.not,t)})`:Kw(e)?`(${e.and.map(n=>Cc(n,t)).join(") && (")})`:Xw(e)?`(${e.or.map(n=>Cc(n,t)).join(") || (")})`:t(e)}function Tg(e,t){if(t.length===0)return!0;const n=t.shift();return n in e&&Tg(e[n],t)&&delete e[n],Be(e)}function zf(e){return e.charAt(0).toUpperCase()+e.substr(1)}function tE(e,t="datum"){const n=dr(e),i=[];for(let r=1;r<=n.length;r++){const o=`[${n.slice(0,r).map(G).join("][")}]`;i.push(`${t}${o}`)}return i.join(" && ")}function M5(e,t="datum"){return`${t}[${G(dr(e).join("."))}]`}function Re(e){return`datum['${e.replaceAll("'","\\'")}']`}function T5(e){return e.replaceAll("\\'","'").replaceAll("\\.",".")}function cie(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function oi(e){return`${dr(e).map(cie).join("\\.")}`}function ra(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function gl(e){return`${dr(e).join(".")}`}function Lu(e){return e?dr(e).length:0}function nt(...e){return e.find(t=>t!==void 0)}let N5=42;function R5(e){const t=++N5;return e?String(e)+t:t}function fie(){N5=42}function O5(e){return D5(e)?e:`__${e}`}function D5(e){return e.startsWith("__")}function ef(e){if(e!==void 0)return(e%360+360)%360}function um(e){return ke(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}const xA=Object.getPrototypeOf(structuredClone({}));function On(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor.name!==t.constructor.name)return!1;let n,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(i=n;i--!==0;)if(!On(e[i],t[i]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const o of e.entries())if(!t.has(o[0]))return!1;for(const o of e.entries())if(!On(o[1],t.get(o[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e.entries())if(!t.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(i=n;i--!==0;)if(e[i]!==t[i])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&e.valueOf!==xA.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&e.toString!==xA.toString)return e.toString()===t.toString();const r=Object.keys(e);if(n=r.length,n!==Object.keys(t).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[i]))return!1;for(i=n;i--!==0;){const o=r[i];if(!On(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function De(e){const t=[];return function n(i){if(i!=null&&i.toJSON&&typeof i.toJSON=="function"&&(i=i.toJSON()),i===void 0)return;if(typeof i=="number")return isFinite(i)?`${i}`:"null";if(typeof i!="object")return JSON.stringify(i);let r,o;if(Array.isArray(i)){for(o="[",r=0;rmm(e[t])?Ye(`_${t}_${Xo(e[t])}`):Ye(`_${t}_${e[t]}`)).join("")}`}function Ue(e){return e===!0||Aa(e)&&!e.binned}function $t(e){return e==="binned"||Aa(e)&&e.binned===!0}function Aa(e){return K(e)}function mm(e){return q(e,"param")}function wA(e){switch(e){case Wr:case Hr:case ao:case _n:case xr:case wr:case us:case uo:case ss:case as:case Sn:return 6;case ls:return 4;default:return 10}}function qf(e){return q(e,"expr")}function kt(e,{level:t}={level:0}){const n=U(e||{}),i={};for(const r of n)i[r]=t===0?Tn(e[r]):kt(e[r],{level:t-1});return i}function X5(e){const{anchor:t,frame:n,offset:i,orient:r,angle:o,limit:s,color:a,subtitleColor:u,subtitleFont:l,subtitleFontSize:c,subtitleFontStyle:f,subtitleFontWeight:d,subtitleLineHeight:h,subtitlePadding:g,...p}=e,m={...p,...a?{fill:a}:{}},y={...t?{anchor:t}:{},...n?{frame:n}:{},...i?{offset:i}:{},...r?{orient:r}:{},...o!==void 0?{angle:o}:{},...s!==void 0?{limit:s}:{}},b={...u?{subtitleColor:u}:{},...l?{subtitleFont:l}:{},...c?{subtitleFontSize:c}:{},...f?{subtitleFontStyle:f}:{},...d?{subtitleFontWeight:d}:{},...h?{subtitleLineHeight:h}:{},...g?{subtitlePadding:g}:{}},v=Ru(e,["align","baseline","dx","dy","limit"]);return{titleMarkConfig:m,subtitleMarkConfig:v,nonMarkTitleProperties:y,subtitle:b}}function Eo(e){return J(e)||P(e)&&J(e[0])}function ne(e){return q(e,"signal")}function Ca(e){return q(e,"step")}function K5(e){return P(e)?!1:q(e,"fields")&&!q(e,"data")}function Lie(e){return P(e)?!1:q(e,"fields")&&q(e,"data")}function Br(e){return P(e)?!1:q(e,"field")&&q(e,"data")}const Pie={aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1},Iie=U(Pie),zie={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},Ab=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"],Bie=" – ";function J5(e){const t=P(e.condition)?e.condition.map(EA):EA(e.condition);return{...Tn(e),condition:t}}function Tn(e){if(qf(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function EA(e){if(qf(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function qe(e){if(qf(e)){const{expr:t,...n}=e;return{signal:t,...n}}return ne(e)?e:e!==void 0?{value:e}:void 0}function Uie(e){return ne(e)?e.signal:G(e)}function _A(e){return ne(e)?e.signal:G(e.value)}function wi(e){return ne(e)?e.signal:e==null?null:G(e)}function jie(e,t,n){for(const i of n){const r=lr(i,t.markDef,t.config);r!==void 0&&(e[i]=qe(r))}return e}function Q5(e){return[].concat(e.type,e.style??[])}function Te(e,t,n,i={}){const{vgChannel:r,ignoreVgConfig:o}=i;return r&&q(t,r)?t[r]:t[e]!==void 0?t[e]:o&&(!r||r===e)?void 0:lr(e,t,n,i)}function lr(e,t,n,{vgChannel:i}={}){const r=Cb(e,t,n.style);return nt(i?r:void 0,r,i?n[t.type][i]:void 0,n[t.type][e],i?n.mark[i]:n.mark[e])}function Cb(e,t,n){return Z5(e,Q5(t),n)}function Z5(e,t,n){t=Q(t);let i;for(const r of t){const o=n[r];q(o,e)&&(i=o[e])}return i}function eL(e,t){return Q(e).reduce((n,i)=>(n.field.push(V(i,t)),n.order.push(i.sort??"ascending"),n),{field:[],order:[]})}function tL(e,t){const n=[...e];return t.forEach(i=>{for(const r of n)if(On(r,i))return;n.push(i)}),n}function nL(e,t){return On(e,t)||!t?e:e?[...Q(e),...Q(t)].join(", "):t}function iL(e,t){const n=e.value,i=t.value;if(n==null||i===null)return{explicit:e.explicit,value:null};if((Eo(n)||ne(n))&&(Eo(i)||ne(i)))return{explicit:e.explicit,value:nL(n,i)};if(Eo(n)||ne(n))return{explicit:e.explicit,value:n};if(Eo(i)||ne(i))return{explicit:e.explicit,value:i};if(!Eo(n)&&!ne(n)&&!Eo(i)&&!ne(i))return{explicit:e.explicit,value:tL(n,i)};throw new Error("It should never reach here")}function fE(e){return`Invalid specification ${De(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const qie='Autosize "fit" only works for single views and layered views.';function SA(e){return`${e=="width"?"Width":"Height"} "container" only works for single views and layered views.`}function $A(e){const t=e=="width"?"Width":"Height",n=e=="width"?"x":"y";return`${t} "container" only works well with autosize "fit" or "fit-${n}".`}function kA(e){return e?`Dropping "fit-${e}" because spec has discrete ${$n(e)}.`:'Dropping "fit" because spec has discrete size.'}function dE(e){return`Unknown field for ${e}. Cannot calculate view size.`}function AA(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function Wie(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function Hie(e){return`The "nearest" transform is not supported for ${e} marks.`}function rL(e){return`Selection not supported for ${e} yet.`}function Gie(e){return`Cannot find a selection named "${e}".`}const Yie="Scale bindings are currently only supported for scales with unbinned, continuous domains.",Vie="Sequntial scales are deprecated. The available quantitative scale type values are linear, log, pow, sqrt, symlog, time and utc",Xie="Legend bindings are only supported for selections over an individual field or encoding channel.";function Kie(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function Jie(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}const Qie="The same selection must be used to override scale domains in a layered view.",Zie='Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.';function ere(e){return`Unknown repeated value "${e}".`}function CA(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}const tre="Multiple timer selections in one unit spec are not supported. Ignoring all but the first.",hE="Animation involving facet, layer, or concat is currently unsupported.";function nre(e){return`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${G(e)}.`}function ire(e,t,n,i){return`${e.length?"Multiple ":"No "}matching ${G(t)} encoding found for selection ${G(n.param)}. Using "field": ${G(i)}.`}const rre="Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";function ore(e){return`Unrecognized parse "${e}".`}function FA(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}const sre="Attempt to add the same child twice.";function are(e){return`Ignoring an invalid transform: ${De(e)}.`}const ure='If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.';function MA(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function lre(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${De(t)} is overridden by a child projection ${De(n)}.`}const cre="Arc marks uses theta channel rather than angle, replacing angle with theta.";function fre(e){return`${e}Offset dropped because ${e} is continuous`}function dre(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${De(n)}}.`}function oL(e){return`Invalid field type "${e}".`}function hre(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}function gre(e){return`Invalid aggregation operator "${e}".`}function sL(e,t){const{fill:n,stroke:i}=t;return`Dropping color ${e} as the plot also has ${n&&i?"fill and stroke":n?"fill":"stroke"}.`}function pre(e){return`Position range does not support relative band size for ${e}.`}function Fb(e,t){return`Dropping ${De(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}const mre="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function ym(e,t,n){return`${e} dropped as it is incompatible with "${t}".`}function yre(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function bre(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function vre(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function xre(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`}function a1(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${t==="ordinal"?"order":"magnitude"}.`}function wre(e){return`The ${e} for range marks cannot be an expression`}function Ere(e,t){return`Line mark is for continuous lines and thus cannot be used with ${e&&t?"x2 and y2":e?"x2":"y2"}. We will use the rule mark (line segments) instead.`}function _re(e,t){return`Specified orient "${e}" overridden with "${t}".`}function Sre(e){return`Cannot use the scale property "${e}" with non-color channel.`}function $re(e){return`Cannot use the relative band size with ${e} scale.`}function kre(e){return`Using unaggregated domain with raw field has no effect (${De(e)}).`}function Are(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function Cre(e){return`Unaggregated domain is currently unsupported for log scale (${De(e)}).`}function Fre(e){return`Cannot apply size to non-oriented mark "${e}".`}function Mre(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`}function Tre(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`}function aL(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function uL(e){return`The step for "${e}" is dropped because the ${e==="width"?"x":"y"} is continuous.`}function Nre(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${De(n)} and ${De(i)}). Using ${De(n)}.`}function Rre(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${De(n)} and ${De(i)}). Using the union of the two domains.`}function Ore(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}function Dre(e){return`Dropping sort property ${De(e)} as unioned domains only support boolean or op "count", "min", and "max".`}const TA="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",Lre="Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect.",Pre="Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect.",Ire="Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.";function zre(e,t){return`Unioning discrete legend values from ${e} and ${t}.`}function Bre(e){return`Cannot stack "${e}" if there is already "${e}2".`}function Ure(e){return`Stack is applied to a non-linear scale (${e}).`}function jre(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function Ng(e,t){return`Invalid ${e}: ${De(t)}.`}function qre(e){return`Dropping day from datetime ${De(e)} as day cannot be combined with other units.`}function Wre(e,t){return`${t?"extent ":""}${t&&e?"and ":""}${e?"center ":""}${t&&e?"are ":"is "}not needed when data are aggregated.`}function Hre(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}function Gre(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}function NA(e){return`1D error band does not support ${e}.`}function lL(e){return`Channel ${e} is required for "binned" bin.`}function Yre(e){return`Channel ${e} should not be used with "binned" bin.`}function Vre(e){return`Domain for ${e} is required for threshold scale.`}const cL=Yg(av);let sa=cL;function Xre(e){return sa=e,sa}function Kre(){return sa=cL,sa}function gE(...e){sa.error(...e)}function W(...e){sa.warn(...e)}function Jre(...e){sa.debug(...e)}function Fa(e){if(e&&K(e)){for(const t of mE)if(q(e,t))return!0}return!1}const fL=["january","february","march","april","may","june","july","august","september","october","november","december"],Qre=fL.map(e=>e.substr(0,3)),dL=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Zre=dL.map(e=>e.substr(0,3));function eoe(e){if(um(e)&&(e=+e),ke(e))return e>4&&W(Ng("quarter",e)),e-1;throw new Error(Ng("quarter",e))}function toe(e){if(um(e)&&(e=+e),ke(e))return e-1;{const t=e.toLowerCase(),n=fL.indexOf(t);if(n!==-1)return n;const i=t.substr(0,3),r=Qre.indexOf(i);if(r!==-1)return r;throw new Error(Ng("month",e))}}function noe(e){if(um(e)&&(e=+e),ke(e))return e%7;{const t=e.toLowerCase(),n=dL.indexOf(t);if(n!==-1)return n;const i=t.substr(0,3),r=Zre.indexOf(i);if(r!==-1)return r;throw new Error(Ng("day",e))}}function pE(e,t){const n=[];if(t&&e.day!==void 0&&U(e).length>1&&(W(qre(e)),e=ce(e),delete e.day),e.year!==void 0?n.push(e.year):n.push(2012),e.month!==void 0){const i=t?toe(e.month):e.month;n.push(i)}else if(e.quarter!==void 0){const i=t?eoe(e.quarter):e.quarter;n.push(ke(i)?i*3:`${i}*3`)}else n.push(0);if(e.date!==void 0)n.push(e.date);else if(e.day!==void 0){const i=t?noe(e.day):e.day;n.push(ke(i)?i+1:`${i}+1`)}else n.push(1);for(const i of["hours","minutes","seconds","milliseconds"]){const r=e[i];n.push(typeof r>"u"?0:r)}return n}function aa(e){const n=pE(e,!0).join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function ioe(e){const n=pE(e,!1).join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function roe(e){const t=pE(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}const hL={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},mE=U(hL);function ooe(e){return Z(hL,e)}function Ma(e){return K(e)?e.binned:gL(e)}function gL(e){return e==null?void 0:e.startsWith("binned")}function yE(e){return e.startsWith("utc")}function soe(e){return e.substring(3)}const aoe={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function bm(e){return mE.filter(t=>mL(e,t))}function pL(e){const t=bm(e);return t[t.length-1]}function mL(e,t){const n=e.indexOf(t);return!(n<0||n>0&&t==="seconds"&&e.charAt(n-1)==="i"||e.length>n+3&&t==="day"&&e.charAt(n+3)==="o"||n>0&&t==="year"&&e.charAt(n-1)==="f")}function uoe(e,t,{end:n}={end:!1}){const i=tE(t),r=yE(e)?"utc":"";function o(u){return u==="quarter"?`(${r}quarter(${i})-1)`:`${r}${u}(${i})`}let s;const a={};for(const u of mE)mL(e,u)&&(a[u]=o(u),s=u);return n&&(a[s]+="+1"),ioe(a)}function yL(e){if(!e)return;const t=bm(e);return`timeUnitSpecifier(${De(t)}, ${De(aoe)})`}function loe(e,t,n){if(!e)return;const i=yL(e);return`${n||yE(e)?"utc":"time"}Format(${t}, ${i})`}function Et(e){if(!e)return;let t;return J(e)?gL(e)?t={unit:e.substring(6),binned:!0}:t={unit:e}:K(e)&&(t={...e,...e.unit?{unit:e.unit}:{}}),yE(t.unit)&&(t.utc=!0,t.unit=soe(t.unit)),t}function coe(e){const{utc:t,...n}=Et(e);return n.unit?(t?"utc":"")+U(n).map(i=>Ye(`${i==="unit"?"":`_${i}_`}${n[i]}`)).join(""):`${t?"utc":""}timeunit${U(n).map(i=>Ye(`_${i}_${n[i]}`)).join("")}`}function bL(e,t=n=>n){const n=Et(e),i=pL(n.unit);if(i&&i!=="day"){const r={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},{step:o,part:s}=vL(i,n.step),a={...r,[s]:+r[s]+o};return`${t(aa(a))} - ${t(aa(r))}`}}const foe={year:1,month:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1};function doe(e){return Z(foe,e)}function vL(e,t=1){if(doe(e))return{part:e,step:t};switch(e){case"day":case"dayofyear":return{part:"date",step:t};case"quarter":return{part:"month",step:t*3};case"week":return{part:"date",step:t*7}}}function hoe(e){return q(e,"param")}function bE(e){return!!(e!=null&&e.field)&&e.equal!==void 0}function vE(e){return!!(e!=null&&e.field)&&e.lt!==void 0}function xE(e){return!!(e!=null&&e.field)&&e.lte!==void 0}function wE(e){return!!(e!=null&&e.field)&&e.gt!==void 0}function EE(e){return!!(e!=null&&e.field)&&e.gte!==void 0}function _E(e){if(e!=null&&e.field){if(P(e.range)&&e.range.length===2)return!0;if(ne(e.range))return!0}return!1}function SE(e){return!!(e!=null&&e.field)&&(P(e.oneOf)||P(e.in))}function goe(e){return!!(e!=null&&e.field)&&e.valid!==void 0}function xL(e){return SE(e)||bE(e)||_E(e)||vE(e)||wE(e)||xE(e)||EE(e)}function ji(e,t){return Cm(e,{timeUnit:t,wrapTime:!0})}function poe(e,t){return e.map(n=>ji(n,t))}function wL(e,t=!0){const{field:n}=e,i=Et(e.timeUnit),{unit:r,binned:o}=i||{},s=V(e,{expr:"datum"}),a=r?`time(${o?s:uoe(r,n)})`:s;if(bE(e))return`${a}===${ji(e.equal,r)}`;if(vE(e)){const u=e.lt;return`${a}<${ji(u,r)}`}else if(wE(e)){const u=e.gt;return`${a}>${ji(u,r)}`}else if(xE(e)){const u=e.lte;return`${a}<=${ji(u,r)}`}else if(EE(e)){const u=e.gte;return`${a}>=${ji(u,r)}`}else{if(SE(e))return`indexof([${poe(e.oneOf,r).join(",")}], ${a}) !== -1`;if(goe(e))return vm(a,e.valid);if(_E(e)){const{range:u}=kt(e),l=ne(u)?{signal:`${u.signal}[0]`}:u[0],c=ne(u)?{signal:`${u.signal}[1]`}:u[1];if(l!==null&&c!==null&&t)return`inrange(${a}, [${ji(l,r)}, ${ji(c,r)}])`;const f=[];return l!==null&&f.push(`${a} >= ${ji(l,r)}`),c!==null&&f.push(`${a} <= ${ji(c,r)}`),f.length>0?f.join(" && "):"true"}}throw new Error(`Invalid field predicate: ${De(e)}`)}function vm(e,t=!0){return t?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function moe(e){return xL(e)&&e.timeUnit?{...e,timeUnit:Et(e.timeUnit)}:e}const Wf={quantitative:"quantitative",ordinal:"ordinal",temporal:"temporal",nominal:"nominal",geojson:"geojson"};function yoe(e){return e==="quantitative"||e==="temporal"}function $E(e){return e==="ordinal"||e==="nominal"}const ua=Wf.quantitative,kE=Wf.ordinal,Iu=Wf.temporal,AE=Wf.nominal,ml=Wf.geojson;function boe(e){if(e)switch(e=e.toLowerCase(),e){case"q":case ua:return"quantitative";case"t":case Iu:return"temporal";case"o":case kE:return"ordinal";case"n":case AE:return"nominal";case ml:return"geojson"}}const At={LINEAR:"linear",LOG:"log",POW:"pow",SQRT:"sqrt",TIME:"time",UTC:"utc",POINT:"point",BAND:"band"},Mb={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",identity:"numeric",sequential:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"};function voe(e,t){const n=Mb[e],i=Mb[t];return n===i||n==="ordinal-position"&&i==="time"||i==="ordinal-position"&&n==="time"}const xoe={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function RA(e){return xoe[e]}const EL=new Set(["linear","log","pow","sqrt","symlog"]),_L=new Set([...EL,"time","utc"]);function SL(e){return EL.has(e)}const $L=new Set(["quantile","quantize","threshold"]),woe=new Set([..._L,...$L,"sequential","identity"]),Eoe=new Set(["ordinal","bin-ordinal","point","band"]);function et(e){return Eoe.has(e)}function Ci(e){return woe.has(e)}function Ki(e){return _L.has(e)}function zu(e){return $L.has(e)}const _oe={pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,tickBandPaddingInner:.25,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:4,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0,framesPerSecond:2,animationDuration:5};function Soe(e){return!J(e)&&q(e,"name")}function kL(e){return q(e,"param")}function $oe(e){return q(e,"unionWith")}function koe(e){return K(e)&&"field"in e}const Aoe={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,domainRaw:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},{type:age,domain:uge,range:lge,rangeMax:cge,rangeMin:fge,scheme:dge,...Coe}=Aoe,Foe=U(Coe);function Tb(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(e);case"bins":return!["point","band","identity","ordinal"].includes(e);case"round":return Ki(e)||e==="band"||e==="point";case"padding":case"rangeMin":case"rangeMax":return Ki(e)||["point","band"].includes(e);case"paddingOuter":case"align":return["point","band"].includes(e);case"paddingInner":return e==="band";case"domainMax":case"domainMid":case"domainMin":case"domainRaw":case"clamp":return Ki(e);case"nice":return Ki(e)||e==="quantize"||e==="threshold";case"exponent":return e==="pow";case"base":return e==="log";case"constant":return e==="symlog";case"zero":return Ci(e)&&!we(["log","time","utc","threshold","quantile"],e)}}function AL(e,t){switch(t){case"interpolate":case"scheme":case"domainMid":return uu(e)?void 0:Sre(t);case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":case"domainRaw":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeMax":case"rangeMin":case"reverse":case"round":case"clamp":case"zero":return}}function Moe(e,t){return we([kE,AE],t)?e===void 0||et(e):t===Iu?we([At.TIME,At.UTC,void 0],e):t===ua?SL(e)||zu(e)||e===void 0:!0}function Toe(e,t,n=!1){if(!_r(e))return!1;switch(e){case We:case dt:case Qr:case pl:case ui:case Li:return Ki(t)||t==="band"?!0:t==="point"?!n:!1;case os:return we(["linear","band"],t);case ao:case us:case uo:case ss:case as:case $a:return Ki(t)||zu(t)||we(["band","point","ordinal"],t);case _n:case xr:case wr:return t!=="band";case ls:case Sn:return t==="ordinal"||zu(t)}}function Noe(e){return K(e)&&"value"in e}const dn={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"},CL=dn.arc,xm=dn.area,wm=dn.bar,Roe=dn.image,Em=dn.line,_m=dn.point,Ooe=dn.rect,Rg=dn.rule,FL=dn.text,CE=dn.tick,Doe=dn.trail,FE=dn.circle,ME=dn.square,ML=dn.geoshape;function fs(e){return["line","area","trail"].includes(e)}function tf(e){return["rect","bar","image","arc","tick"].includes(e)}const Loe=new Set(U(dn));function cr(e){return q(e,"type")}const Poe=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"],Ioe=["fill","fillOpacity"],zoe=[...Poe,...Ioe],Boe={color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1},OA=U(Boe),u1=["binSpacing","continuousBandSize","discreteBandSize","minBandSize"],Uoe={area:["line","point"],bar:u1,rect:u1,line:["point"],tick:["bandSize","thickness",...u1]},joe={color:"#4c78a8",invalid:"break-paths-show-path-domains",timeUnitBandSize:1},qoe={mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1},TL=U(qoe);function la(e){return q(e,"band")}const Woe={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},Hoe=5,TE={binSpacing:0,continuousBandSize:Hoe,minBandSize:.25,timeUnitBandPosition:.5},Goe={...TE,binSpacing:1},Yoe={...TE,thickness:1};function Voe(e){return cr(e)?e.type:e}function NL(e,{isPath:t}){return e===void 0||e==="break-paths-show-path-domains"?t?"break-paths-show-domains":"filter":e===null?"show":e}function NE({markDef:e,config:t,scaleChannel:n,scaleType:i,isCountAggregate:r}){var a,u;if(!i||!Ci(i)||r)return"always-valid";const o=NL(Te("invalid",e,t),{isPath:fs(e.type)});return((u=(a=t.scale)==null?void 0:a.invalid)==null?void 0:u[n])!==void 0?"show":o}function Xoe(e){return e==="break-paths-filter-domains"||e==="break-paths-show-domains"}function RL({scaleName:e,scale:t,mode:n}){const i=`domain('${e}')`;if(!t||!e)return;const r=`${i}[0]`,o=`peek(${i})`,s=t.domainHasZero();return s==="definitely"?{scale:e,value:0}:s==="maybe"?{signal:`scale('${e}', inrange(0, ${i}) ? 0 : ${n==="zeroOrMin"?r:o})`}:{signal:`scale('${e}', ${n==="zeroOrMin"?r:o})`}}function OL({scaleChannel:e,channelDef:t,scale:n,scaleName:i,markDef:r,config:o}){var c;const s=n==null?void 0:n.get("type"),a=Mi(t),u=pm(a==null?void 0:a.aggregate),l=NE({scaleChannel:e,markDef:r,config:o,scaleType:s,isCountAggregate:u});if(a&&l==="show"){const f=((c=o.scale.invalid)==null?void 0:c[e])??"zero-or-min";return{test:vm(V(a,{expr:"datum"}),!1),...Koe(f,n,i)}}}function Koe(e,t,n){if(Noe(e)){const{value:i}=e;return ne(i)?{signal:i.signal}:{value:i}}return RL({scale:t,scaleName:n,mode:"zeroOrMin"})}function RE(e){const{channel:t,channelDef:n,markDef:i,scale:r,scaleName:o,config:s}=e,a=ka(t),u=OE(e),l=OL({scaleChannel:a,channelDef:n,scale:r,scaleName:o,markDef:i,config:s});return l!==void 0?[l,u]:u}function Joe(e){const{datum:t}=e;return Fa(t)?aa(t):`${De(t)}`}function Us(e,t,n,i){const r={};if(t&&(r.scale=t),Sr(e)){const{datum:o}=e;Fa(o)?r.signal=aa(o):ne(o)?r.signal=o.signal:qf(o)?r.signal=o.expr:r.value=o}else r.field=V(e,n);if(i){const{offset:o,band:s}=i;o&&(r.offset=o),s&&(r.band=s)}return r}function Og({scaleName:e,fieldOrDatumDef:t,fieldOrDatumDef2:n,offset:i,startSuffix:r,endSuffix:o="end",bandPosition:s=.5}){const a=!ne(s)&&0{switch(t.fieldTitle){case"plain":return e.field;case"functional":return fse(e);default:return cse(e,t)}};let YL=GL;function VL(e){YL=e}function dse(){VL(GL)}function lu(e,t,{allowDisabling:n,includeDefault:i=!0}){var a;const r=(a=IE(e))==null?void 0:a.title;if(!j(e))return r??e.title;const o=e,s=i?zE(o,t):void 0;return n?nt(r,o.title,s):r??o.title??s}function IE(e){if(Uu(e)&&e.axis)return e.axis;if(WL(e)&&e.legend)return e.legend;if(LE(e)&&e.header)return e.header}function zE(e,t){return YL(e,t)}function ju(e){if(HL(e)){const{format:t,formatType:n}=e;return{format:t,formatType:n}}else{const t=IE(e)??{},{format:n,formatType:i}=t;return{format:n,formatType:i}}}function hse(e,t){var o;switch(t){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(PE(e)&&P(e.sort))return"ordinal";const{aggregate:n,bin:i,timeUnit:r}=e;if(r)return"temporal";if(i||n&&!cs(n)&&!Zr(n))return"quantitative";if(Ta(e)&&((o=e.scale)!=null&&o.type))switch(Mb[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}function Mi(e){if(j(e))return e;if(km(e))return e.condition}function ct(e){if(fe(e))return e;if(Vf(e))return e.condition}function XL(e,t,n,i={}){if(Mg(e)){const r=J(e)?"string":ke(e)?"number":"boolean";return W(dre(t,r,e)),{value:e}}return fe(e)?Pg(e,t,n,i):Vf(e)?{...e,condition:Pg(e.condition,t,n,i)}:e}function Pg(e,t,n,i){if(HL(e)){const{format:r,formatType:o,...s}=e;if(ca(o)&&!n.customFormatTypes)return W(MA(t)),Pg(s,t,n,i)}else{const r=Uu(e)?"axis":WL(e)?"legend":LE(e)?"header":null;if(r&&e[r]){const{format:o,formatType:s,...a}=e[r];if(ca(s)&&!n.customFormatTypes)return W(MA(t)),Pg({...e,[r]:a},t,n,i)}}return j(e)?BE(e,t,i):gse(e)}function gse(e){let t=e.type;if(t)return e;const{datum:n}=e;return t=ke(n)?"quantitative":J(n)?"nominal":Fa(n)?"temporal":void 0,{...e,type:t}}function BE(e,t,{compositeMark:n=!1}={}){const{aggregate:i,timeUnit:r,bin:o,field:s}=e,a={...e};if(!n&&i&&!cE(i)&&!cs(i)&&!Zr(i)&&(W(gre(i)),delete a.aggregate),r&&(a.timeUnit=Et(r)),s&&(a.field=`${s}`),Ue(o)&&(a.bin=Am(o,t)),$t(o)&&!it(t)&&W(Yre(t)),cn(a)){const{type:u}=a,l=boe(u);u!==l&&(a.type=l),u!=="quantitative"&&pm(i)&&(W(hre(u,i)),a.type="quantitative")}else if(!j5(t)){const u=hse(a,t);a.type=u}if(cn(a)){const{compatible:u,warning:l}=pse(a,t)||{};u===!1&&W(l)}if(PE(a)&&J(a.sort)){const{sort:u}=a;if(LA(u))return{...a,sort:{encoding:u}};const l=u.substring(1);if(u.charAt(0)==="-"&&LA(l))return{...a,sort:{encoding:l,order:"descending"}}}if(LE(a)){const{header:u}=a;if(u){const{orient:l,...c}=u;if(l)return{...a,header:{...c,labelOrient:u.labelOrient||l,titleOrient:u.titleOrient||l}}}}return a}function Am(e,t){return pa(e)?{maxbins:wA(t)}:e==="binned"?{binned:!0}:!e.maxbins&&!e.step?{...e,maxbins:wA(t)}:e}const qa={compatible:!0};function pse(e,t){const n=e.type;if(n==="geojson"&&t!=="shape")return{compatible:!1,warning:`Channel ${t} should not be used with a geojson data.`};switch(t){case Wr:case Hr:case lm:return Lg(e)?qa:{compatible:!1,warning:bre(t)};case We:case dt:case Qr:case pl:case _n:case xr:case wr:case Bf:case Uf:case cm:case oa:case fm:case dm:case $a:case ui:case Li:case hm:return qa;case Ii:case si:case Pi:case zi:return n!==ua?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:qa;case uo:case ss:case as:case us:case ao:case so:case oo:case Di:case vr:case os:return n==="nominal"&&!e.sort?{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`}:qa;case Sn:case ls:return!Lg(e)&&!use(e)?{compatible:!1,warning:vre(t)}:qa;case Pu:return e.type==="nominal"&&!("sort"in e)?{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}:qa}}function qu(e){const{formatType:t}=ju(e);return t==="time"||!t&&mse(e)}function mse(e){return e&&(e.type==="temporal"||j(e)&&!!e.timeUnit)}function Cm(e,{timeUnit:t,type:n,wrapTime:i,undefinedIfExprNotRequired:r}){var u;const o=t&&((u=Et(t))==null?void 0:u.unit);let s=o||n==="temporal",a;return qf(e)?a=e.expr:ne(e)?a=e.signal:Fa(e)?(s=!0,a=aa(e)):(J(e)||ke(e))&&s&&(a=`datetime(${De(e)})`,ooe(o)&&(ke(e)&&e<1e4||J(e)&&isNaN(Date.parse(e)))&&(a=aa({[o]:e}))),a?i&&s?`time(${a})`:a:r?void 0:De(e)}function KL(e,t){const{type:n}=e;return t.map(i=>{const r=j(e)&&!Ma(e.timeUnit)?e.timeUnit:void 0,o=Cm(i,{timeUnit:r,type:n,undefinedIfExprNotRequired:!0});return o!==void 0?{signal:o}:i})}function Xf(e,t){return Ue(e.bin)?_r(t)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const zA={labelAlign:{part:"labels",vgProp:"align"},labelBaseline:{part:"labels",vgProp:"baseline"},labelColor:{part:"labels",vgProp:"fill"},labelFont:{part:"labels",vgProp:"font"},labelFontSize:{part:"labels",vgProp:"fontSize"},labelFontStyle:{part:"labels",vgProp:"fontStyle"},labelFontWeight:{part:"labels",vgProp:"fontWeight"},labelOpacity:{part:"labels",vgProp:"opacity"},labelOffset:null,labelPadding:null,gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDashOffset"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDashOffset"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickSize:null,tickWidth:{part:"ticks",vgProp:"strokeWidth"}};function Kf(e){return e==null?void 0:e.condition}const JL=["domain","grid","labels","ticks","title"],yse={grid:"grid",gridCap:"grid",gridColor:"grid",gridDash:"grid",gridDashOffset:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",aria:"main",description:"main",domain:"main",domainCap:"main",domainColor:"main",domainDash:"main",domainDashOffset:"main",domainOpacity:"main",domainWidth:"main",format:"main",formatType:"main",labelAlign:"main",labelAngle:"main",labelBaseline:"main",labelBound:"main",labelColor:"main",labelFlush:"main",labelFlushOffset:"main",labelFont:"main",labelFontSize:"main",labelFontStyle:"main",labelFontWeight:"main",labelLimit:"main",labelLineHeight:"main",labelOffset:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",labelSeparation:"main",maxExtent:"main",minExtent:"main",offset:"both",position:"main",tickCap:"main",tickColor:"main",tickDash:"main",tickDashOffset:"main",tickMinStep:"both",tickOffset:"both",tickOpacity:"main",tickRound:"both",ticks:"main",tickSize:"main",tickWidth:"both",title:"main",titleAlign:"main",titleAnchor:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontStyle:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",encode:"both",scale:"both",tickBand:"both",tickCount:"both",tickExtra:"both",translate:"both",values:"both",zindex:"both"},QL={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},bse={...QL,style:1,labelExpr:1,encoding:1};function BA(e){return Z(bse,e)}const vse={axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1},ZL=U(vse);function co(e){return q(e,"mark")}class Fm{constructor(t,n){I(this,"name");I(this,"run");this.name=t,this.run=n}hasMatchingType(t){return co(t)?Voe(t.mark)===this.name:!1}}function js(e,t){const n=e==null?void 0:e[t];return n?P(n)?Ou(n,i=>!!i.field):j(n)||km(n):!1}function e6(e,t){const n=e==null?void 0:e[t];return n?P(n)?Ou(n,i=>!!i.field):j(n)||Sr(n)||Vf(n):!1}function t6(e,t){if(it(t)){const n=e[t];if((j(n)||Sr(n))&&($E(n.type)||j(n)&&n.timeUnit)){const i=oE(t);return e6(e,i)}}return!1}function n6(e){return Ou(gie,t=>{if(js(e,t)){const n=e[t];if(P(n))return Ou(n,i=>!!i.aggregate);{const i=Mi(n);return i&&!!i.aggregate}}return!1})}function i6(e,t){const n=[],i=[],r=[],o=[],s={};return UE(e,(a,u)=>{if(j(a)){const{field:l,aggregate:c,bin:f,timeUnit:d,...h}=a;if(c||d||f){const g=IE(a),p=g==null?void 0:g.title;let m=V(a,{forAs:!0});const y={...p?[]:{title:lu(a,t,{allowDisabling:!0})},...h,field:m};if(c){let b;if(cs(c)?(b="argmax",m=V({op:"argmax",field:c.argmax},{forAs:!0}),y.field=`${m}.${l}`):Zr(c)?(b="argmin",m=V({op:"argmin",field:c.argmin},{forAs:!0}),y.field=`${m}.${l}`):c!=="boxplot"&&c!=="errorbar"&&c!=="errorband"&&(b=c),b){const v={op:b,as:m};l&&(v.field=l),o.push(v)}}else if(n.push(m),cn(a)&&Ue(f)){if(i.push({bin:f,field:l,as:m}),n.push(V(a,{binSuffix:"end"})),Xf(a,u)&&n.push(V(a,{binSuffix:"range"})),it(u)){const b={field:`${m}_end`};s[`${u}2`]=b}y.bin="binned",j5(u)||(y.type=ua)}else if(d&&!Ma(d)){r.push({timeUnit:d,field:l,as:m});const b=cn(a)&&a.type!==Iu&&"time";b&&(u===Bf||u===oa?y.formatType=b:$ie(u)?y.legend={formatType:b,...y.legend}:it(u)&&(y.axis={formatType:b,...y.axis}))}s[u]=y}else n.push(l),s[u]=e[u]}else s[u]=e[u]}),{bins:i,timeUnits:r,aggregate:o,groupby:n,encoding:s}}function xse(e,t,n){const i=Aie(t,n);if(i){if(i==="binned"){const r=e[t===Di?We:dt];return!!(j(r)&&j(e[t])&&$t(r.bin))}}else return!1;return!0}function wse(e,t,n,i){const r={};for(const o of U(e))U5(o)||W(yre(o));for(let o of xie){if(!e[o])continue;const s=e[o];if(jf(o)){const a=vie(o),u=r[a];if(j(u)&&yoe(u.type)&&j(s)&&!u.timeUnit){W(fre(a));continue}}if(o==="angle"&&t==="arc"&&!e.theta&&(W(cre),o=ui),!xse(e,o,t)){W(ym(o,t));continue}if(o===ao&&t==="line"){const a=Mi(e[o]);if(a!=null&&a.aggregate){W(mre);continue}}if(o===_n&&(n?"fill"in e:"stroke"in e)){W(sL("encoding",{fill:"fill"in e,stroke:"stroke"in e}));continue}if(o===Uf||o===Pu&&!P(s)&&!Fi(s)||o===oa&&P(s)){if(s){if(o===Pu){const a=e[o];if(qL(a)){r[o]=a;continue}}r[o]=Q(s).reduce((a,u)=>(j(u)?a.push(BE(u,o)):W(Fb(u,o)),a),[])}}else{if(o===oa&&s===null)r[o]=null;else if(!j(s)&&!Sr(s)&&!Fi(s)&&!Yf(s)&&!ne(s)){W(Fb(s,o));continue}r[o]=XL(s,o,i)}}return r}function Mm(e,t){const n={};for(const i of U(e)){const r=XL(e[i],i,t,{compositeMark:!0});n[i]=r}return n}function Ese(e){const t=[];for(const n of U(e))if(js(e,n)){const i=e[n],r=Q(i);for(const o of r)j(o)?t.push(o):km(o)&&t.push(o.condition)}return t}function UE(e,t,n){if(e)for(const i of U(e)){const r=e[i];if(P(r))for(const o of r)t.call(n,o,i);else t.call(n,r,i)}}function _se(e,t,n,i){return e?U(e).reduce((r,o)=>{const s=e[o];return P(s)?s.reduce((a,u)=>t.call(i,a,u,o),r):t.call(i,r,s,o)},n):n}function r6(e,t){return U(t).reduce((n,i)=>{switch(i){case We:case dt:case fm:case hm:case dm:case Di:case vr:return n;case Qr:case pl:{if(e==="line"||e==="area"||e==="trail"){const r=t[i];if(j(r)){const s=t[i===Qr?We:dt];if(j(s)&&!s.aggregate&&!r.aggregate){const a=V(s,{}),u=V(r,{});a&&u&&a!==u&&n.push(a)}}}return n}case ui:case so:case Li:case oo:case os:case Pi:case Ii:case zi:case si:case Bf:case Sn:case $a:case oa:return n;case Pu:if(e==="line"||e==="trail")return n;case Uf:case cm:{const r=t[i];if(P(r)||j(r))for(const o of Q(r))o.aggregate||n.push(V(o,{}));return n}case ao:if(e==="trail")return n;case _n:case xr:case wr:case uo:case ss:case as:case ls:case us:{const r=Mi(t[i]);return r&&!r.aggregate&&n.push(V(r,{})),n}}},[])}function Sse(e){const{tooltip:t,...n}=e;if(!t)return{filteredEncoding:n};let i,r;if(P(t)){for(const o of t)o.aggregate?(i||(i=[]),i.push(o)):(r||(r=[]),r.push(o));i&&(n.tooltip=i)}else t.aggregate?n.tooltip=t:r=t;return P(r)&&r.length===1&&(r=r[0]),{customTooltipWithoutAggregatedField:r,filteredEncoding:n}}function Rb(e,t,n,i=!0){if("tooltip"in n)return{tooltip:n.tooltip};const r=e.map(({fieldPrefix:s,titlePrefix:a})=>{const u=i?` of ${jE(t)}`:"";return{field:s+t.field,type:t.type,title:ne(a)?{signal:`${a}"${escape(u)}"`}:a+u}}),o=Ese(n).map(sse);return{tooltip:[...r,...Rn(o,ye)]}}function jE(e){const{title:t,field:n}=e;return nt(t,n)}function qE(e,t,n,i,r){const{scale:o,axis:s}=n;return({partName:a,mark:u,positionPrefix:l,endPositionPrefix:c=void 0,extraEncoding:f={}})=>{const d=jE(n);return o6(e,a,r,{mark:u,encoding:{[t]:{field:`${l}_${n.field}`,type:n.type,...d!==void 0?{title:d}:{},...o!==void 0?{scale:o}:{},...s!==void 0?{axis:s}:{}},...J(c)?{[`${t}2`]:{field:`${c}_${n.field}`}}:{},...i,...f}})}}function o6(e,t,n,i){const{clip:r,color:o,opacity:s}=e,a=e.type;return e[t]||e[t]===void 0&&n[t]?[{...i,mark:{...n[t],...r?{clip:r}:{},...o?{color:o}:{},...s?{opacity:s}:{},...cr(i.mark)?i.mark:{type:i.mark},style:`${a}-${String(t)}`,...pa(e[t])?{}:e[t]}}]:[]}function s6(e,t,n){const{encoding:i}=e,r=t==="vertical"?"y":"x",o=i[r],s=i[`${r}2`],a=i[`${r}Error`],u=i[`${r}Error2`];return{continuousAxisChannelDef:Fd(o,n),continuousAxisChannelDef2:Fd(s,n),continuousAxisChannelDefError:Fd(a,n),continuousAxisChannelDefError2:Fd(u,n),continuousAxis:r}}function Fd(e,t){if(e!=null&&e.aggregate){const{aggregate:n,...i}=e;return n!==t&&W(Gre(n,t)),i}else return e}function a6(e,t){const{mark:n,encoding:i}=e,{x:r,y:o}=i;if(cr(n)&&n.orient)return n.orient;if(No(r)){if(No(o)){const s=j(r)&&r.aggregate,a=j(o)&&o.aggregate;if(!s&&a===t)return"vertical";if(!a&&s===t)return"horizontal";if(s===t&&a===t)throw new Error("Both x and y cannot have aggregate");return qu(o)&&!qu(r)?"horizontal":"vertical"}return"horizontal"}else{if(No(o))return"vertical";throw new Error(`Need a valid continuous axis for ${t}s`)}}const Ig="boxplot",$se=["box","median","outliers","rule","ticks"],kse=new Fm(Ig,l6);function u6(e){return ke(e)?"tukey":e}function l6(e,{config:t}){e={...e,encoding:Mm(e.encoding,t)};const{mark:n,encoding:i,params:r,projection:o,...s}=e,a=cr(n)?n:{type:n};r&&W(rL("boxplot"));const u=a.extent??t.boxplot.extent,l=Te("size",a,t),c=a.invalid,f=u6(u),{bins:d,timeUnits:h,transform:g,continuousAxisChannelDef:p,continuousAxis:m,groupby:y,aggregate:b,encodingWithoutContinuousAxis:v,ticksOrient:x,boxOrient:E,customTooltipWithoutAggregatedField:_}=Ase(e,u,t),w=gl(p.field),{color:S,size:$,...A}=v,F=$r=>qE(a,m,p,$r,t.boxplot),T=F(A),N=F(v),C=(K(t.boxplot.box)?t.boxplot.box.color:t.mark.color)||"#4c78a8",k=F({...A,...$?{size:$}:{},color:{condition:{test:`${Re(`lower_box_${p.field}`)} >= ${Re(`upper_box_${p.field}`)}`,...S||{value:C}}}}),M=Rb([{fieldPrefix:f==="min-max"?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:f==="min-max"?"lower_whisker_":"min_",titlePrefix:"Min"}],p,v),D={type:"tick",color:"black",opacity:1,orient:x,invalid:c,aria:!1},B=f==="min-max"?M:Rb([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],p,v),z=[...T({partName:"rule",mark:{type:"rule",invalid:c,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:B}),...T({partName:"rule",mark:{type:"rule",invalid:c,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:B}),...T({partName:"ticks",mark:D,positionPrefix:"lower_whisker",extraEncoding:B}),...T({partName:"ticks",mark:D,positionPrefix:"upper_whisker",extraEncoding:B})],X=[...f!=="tukey"?z:[],...N({partName:"box",mark:{type:"bar",...l?{size:l}:{},orient:E,invalid:c,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:M}),...k({partName:"median",mark:{type:"tick",invalid:c,...K(t.boxplot.median)&&t.boxplot.median.color?{color:t.boxplot.median.color}:{},...l?{size:l}:{},orient:x,aria:!1},positionPrefix:"mid_box",extraEncoding:M})];if(f==="min-max")return{...s,transform:(s.transform??[]).concat(g),layer:X};const le=Re(`lower_box_${p.field}`),se=Re(`upper_box_${p.field}`),he=`(${se} - ${le})`,Ie=`${le} - ${u} * ${he}`,ge=`${se} + ${u} * ${he}`,Ot=Re(p.field),ds={joinaggregate:c6(p.field),groupby:y},ho={transform:[{filter:`(${Ie} <= ${Ot}) && (${Ot} <= ${ge})`},{aggregate:[{op:"min",field:p.field,as:`lower_whisker_${w}`},{op:"max",field:p.field,as:`upper_whisker_${w}`},{op:"min",field:`lower_box_${p.field}`,as:`lower_box_${w}`},{op:"max",field:`upper_box_${p.field}`,as:`upper_box_${w}`},...b],groupby:y}],layer:z},{tooltip:ee,...me}=A,{scale:ve,axis:H}=p,St=jE(p),Ne=o6(a,"outliers",t.boxplot,{transform:[{filter:`(${Ot} < ${Ie}) || (${Ot} > ${ge})`}],mark:"point",encoding:{[m]:{field:p.field,type:p.type,...St!==void 0?{title:St}:{},...ve!==void 0?{scale:ve}:{},...H!==void 0?{axis:H}:{}},...me,...S?{color:S}:{},..._?{tooltip:_}:{}}})[0];let pt;const Dt=[...d,...h,ds];return Ne?pt={transform:Dt,layer:[Ne,ho]}:(pt=ho,pt.transform.unshift(...Dt)),{...s,layer:[pt,{transform:g,layer:X}]}}function c6(e){const t=gl(e);return[{op:"q1",field:e,as:`lower_box_${t}`},{op:"q3",field:e,as:`upper_box_${t}`}]}function Ase(e,t,n){const i=a6(e,Ig),{continuousAxisChannelDef:r,continuousAxis:o}=s6(e,i,Ig),s=r.field,a=gl(s),u=u6(t),l=[...c6(s),{op:"median",field:s,as:`mid_box_${a}`},{op:"min",field:s,as:(u==="min-max"?"lower_whisker_":"min_")+a},{op:"max",field:s,as:(u==="min-max"?"upper_whisker_":"max_")+a}],c=u==="min-max"||u==="tukey"?[]:[{calculate:`${Re(`upper_box_${a}`)} - ${Re(`lower_box_${a}`)}`,as:`iqr_${a}`},{calculate:`min(${Re(`upper_box_${a}`)} + ${Re(`iqr_${a}`)} * ${t}, ${Re(`max_${a}`)})`,as:`upper_whisker_${a}`},{calculate:`max(${Re(`lower_box_${a}`)} - ${Re(`iqr_${a}`)} * ${t}, ${Re(`min_${a}`)})`,as:`lower_whisker_${a}`}],{[o]:f,...d}=e.encoding,{customTooltipWithoutAggregatedField:h,filteredEncoding:g}=Sse(d),{bins:p,timeUnits:m,aggregate:y,groupby:b,encoding:v}=i6(g,n),x=i==="vertical"?"horizontal":"vertical",E=i,_=[...p,...m,{aggregate:[...y,...l],groupby:b},...c];return{bins:p,timeUnits:m,transform:_,groupby:b,aggregate:y,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:v,ticksOrient:x,boxOrient:E,customTooltipWithoutAggregatedField:h}}const WE="errorbar",Cse=["ticks","rule"],Fse=new Fm(WE,f6);function f6(e,{config:t}){e={...e,encoding:Mm(e.encoding,t)};const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:o,ticksOrient:s,markDef:a,outerSpec:u,tooltipEncoding:l}=d6(e,WE,t);delete o.size;const c=qE(a,r,i,o,t.errorbar),f=a.thickness,d=a.size,h={type:"tick",orient:s,aria:!1,...f!==void 0?{thickness:f}:{},...d!==void 0?{size:d}:{}},g=[...c({partName:"ticks",mark:h,positionPrefix:"lower",extraEncoding:l}),...c({partName:"ticks",mark:h,positionPrefix:"upper",extraEncoding:l}),...c({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...f!==void 0?{size:f}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:l})];return{...u,transform:n,...g.length>1?{layer:g}:{...g[0]}}}function Mse(e,t){const{encoding:n}=e;if(Tse(n))return{orient:a6(e,t),inputType:"raw"};const i=Nse(n),r=Rse(n),o=n.x,s=n.y;if(i){if(r)throw new Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`);const a=n.x2,u=n.y2;if(fe(a)&&fe(u))throw new Error(`${t} cannot have both x2 and y2`);if(fe(a)){if(No(o))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${t}`)}else if(fe(u)){if(No(s))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error(`Both y and y2 have to be quantitative in ${t}`)}throw new Error("No ranged axis")}else{const a=n.xError,u=n.xError2,l=n.yError,c=n.yError2;if(fe(u)&&!fe(a))throw new Error(`${t} cannot have xError2 without xError`);if(fe(c)&&!fe(l))throw new Error(`${t} cannot have yError2 without yError`);if(fe(a)&&fe(l))throw new Error(`${t} cannot have both xError and yError with both are quantiative`);if(fe(a)){if(No(o))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}else if(fe(l)){if(No(s))return{orient:"vertical",inputType:"aggregated-error"};throw new Error("All y, yError, and yError2 (if exist) have to be quantitative")}throw new Error("No ranged axis")}}function Tse(e){return(fe(e.x)||fe(e.y))&&!fe(e.x2)&&!fe(e.y2)&&!fe(e.xError)&&!fe(e.xError2)&&!fe(e.yError)&&!fe(e.yError2)}function Nse(e){return fe(e.x2)||fe(e.y2)}function Rse(e){return fe(e.xError)||fe(e.xError2)||fe(e.yError)||fe(e.yError2)}function d6(e,t,n){const{mark:i,encoding:r,params:o,projection:s,...a}=e,u=cr(i)?i:{type:i};o&&W(rL(t));const{orient:l,inputType:c}=Mse(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:d,continuousAxisChannelDefError:h,continuousAxisChannelDefError2:g,continuousAxis:p}=s6(e,l,t),{errorBarSpecificAggregate:m,postAggregateCalculates:y,tooltipSummary:b,tooltipTitleWithFieldName:v}=Ose(u,f,d,h,g,c,t,n),{[p]:x,[p==="x"?"x2":"y2"]:E,[p==="x"?"xError":"yError"]:_,[p==="x"?"xError2":"yError2"]:w,...S}=r,{bins:$,timeUnits:A,aggregate:F,groupby:T,encoding:N}=i6(S,n),C=[...F,...m],k=c!=="raw"?[]:T,M=Rb(b,f,N,v);return{transform:[...a.transform??[],...$,...A,...C.length===0?[]:[{aggregate:C,groupby:k}],...y],groupby:k,continuousAxisChannelDef:f,continuousAxis:p,encodingWithoutContinuousAxis:N,ticksOrient:l==="vertical"?"horizontal":"vertical",markDef:u,outerSpec:a,tooltipEncoding:M}}function Ose(e,t,n,i,r,o,s,a){let u=[],l=[];const c=t.field;let f,d=!1;if(o==="raw"){const h=e.center?e.center:e.extent?e.extent==="iqr"?"median":"mean":a.errorbar.center,g=e.extent?e.extent:h==="mean"?"stderr":"iqr";if(h==="median"!=(g==="iqr")&&W(Hre(h,g,s)),g==="stderr"||g==="stdev")u=[{op:g,field:c,as:`extent_${c}`},{op:h,field:c,as:`center_${c}`}],l=[{calculate:`${Re(`center_${c}`)} + ${Re(`extent_${c}`)}`,as:`upper_${c}`},{calculate:`${Re(`center_${c}`)} - ${Re(`extent_${c}`)}`,as:`lower_${c}`}],f=[{fieldPrefix:"center_",titlePrefix:zf(h)},{fieldPrefix:"upper_",titlePrefix:UA(h,g,"+")},{fieldPrefix:"lower_",titlePrefix:UA(h,g,"-")}],d=!0;else{let p,m,y;g==="ci"?(p="mean",m="ci0",y="ci1"):(p="median",m="q1",y="q3"),u=[{op:m,field:c,as:`lower_${c}`},{op:y,field:c,as:`upper_${c}`},{op:p,field:c,as:`center_${c}`}],f=[{fieldPrefix:"upper_",titlePrefix:lu({field:c,aggregate:y,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:lu({field:c,aggregate:m,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:lu({field:c,aggregate:p,type:"quantitative"},a,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&W(Wre(e.center,e.extent)),o==="aggregated-upper-lower"?(f=[],l=[{calculate:Re(n.field),as:`upper_${c}`},{calculate:Re(c),as:`lower_${c}`}]):o==="aggregated-error"&&(f=[{fieldPrefix:"",titlePrefix:c}],l=[{calculate:`${Re(c)} + ${Re(i.field)}`,as:`upper_${c}`}],r?l.push({calculate:`${Re(c)} + ${Re(r.field)}`,as:`lower_${c}`}):l.push({calculate:`${Re(c)} - ${Re(i.field)}`,as:`lower_${c}`}));for(const h of l)f.push({fieldPrefix:h.as.substring(0,6),titlePrefix:ra(ra(h.calculate,"datum['",""),"']","")})}return{postAggregateCalculates:l,errorBarSpecificAggregate:u,tooltipSummary:f,tooltipTitleWithFieldName:d}}function UA(e,t,n){return`${zf(e)} ${n} ${t}`}const HE="errorband",Dse=["band","borders"],Lse=new Fm(HE,h6);function h6(e,{config:t}){e={...e,encoding:Mm(e.encoding,t)};const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:o,markDef:s,outerSpec:a,tooltipEncoding:u}=d6(e,HE,t),l=s,c=qE(l,r,i,o,t.errorband),f=e.encoding.x!==void 0&&e.encoding.y!==void 0;let d={type:f?"area":"rect"},h={type:f?"line":"rule"};const g={...l.interpolate?{interpolate:l.interpolate}:{},...l.tension&&l.interpolate?{tension:l.tension}:{}};return f?(d={...d,...g,ariaRoleDescription:"errorband"},h={...h,...g,aria:!1}):l.interpolate?W(NA("interpolate")):l.tension&&W(NA("tension")),{...a,transform:n,layer:[...c({partName:"band",mark:d,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u}),...c({partName:"borders",mark:h,positionPrefix:"lower",extraEncoding:u}),...c({partName:"borders",mark:h,positionPrefix:"upper",extraEncoding:u})]}}const g6={};function GE(e,t,n){const i=new Fm(e,t);g6[e]={normalizer:i,parts:n}}function Pse(){return U(g6)}GE(Ig,l6,$se);GE(WE,f6,Cse);GE(HE,h6,Dse);const Ise=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],p6={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},m6={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelBaseline:"baseline",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelFontWeight:"fontWeight",labelLimit:"limit",labelLineHeight:"lineHeight",labelOrient:"orient",labelPadding:"offset"},zse=U(p6),Bse=U(m6),Use={header:1,headerRow:1,headerColumn:1,headerFacet:1},y6=U(Use),b6=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],jse={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},qse={aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolLimit:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},Ti="_vgsid_",Wse={point:{on:"click",fields:[Ti],toggle:"event.shiftKey",resolve:"global",clear:"dblclick"},interval:{on:"[pointerdown, window:pointerup] > window:pointermove!",encodings:["x","y"],translate:"[pointerdown, window:pointerup] > window:pointermove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function YE(e){return e==="legend"||!!(e!=null&&e.legend)}function l1(e){return YE(e)&&K(e)}function VE(e){return!!(e!=null&&e.select)}function v6(e){const t=[];for(const n of e||[]){if(VE(n))continue;const{expr:i,bind:r,...o}=n;if(r&&i){const s={...o,bind:r,init:i};t.push(s)}else{const s={...o,...i?{update:i}:{},...r?{bind:r}:{}};t.push(s)}}return t}function Hse(e){return Tm(e)||KE(e)||XE(e)}function XE(e){return q(e,"concat")}function Tm(e){return q(e,"vconcat")}function KE(e){return q(e,"hconcat")}function x6({step:e,offsetIsDiscrete:t}){return t?e.for??"offset":"position"}function fr(e){return q(e,"step")}function jA(e){return q(e,"view")||q(e,"width")||q(e,"height")}const qA=20,Gse={align:1,bounds:1,center:1,columns:1,spacing:1},Yse=U(Gse);function Vse(e,t,n){const i=n[t],r={},{spacing:o,columns:s}=i;o!==void 0&&(r.spacing=o),s!==void 0&&($m(e)&&!Gf(e.facet)||XE(e))&&(r.columns=s),Tm(e)&&(r.columns=1);for(const a of Yse)if(e[a]!==void 0)if(a==="spacing"){const u=e[a];r[a]=ke(u)?u:{row:u.row??o,column:u.column??o}}else r[a]=e[a];return r}function Ob(e,t){return e[t]??e[t==="width"?"continuousWidth":"continuousHeight"]}function Db(e,t){const n=zg(e,t);return fr(n)?n.step:w6}function zg(e,t){const n=e[t]??e[t==="width"?"discreteWidth":"discreteHeight"];return nt(n,{step:e.step})}const w6=20,Xse={continuousWidth:300,continuousHeight:300,step:w6},Kse={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:Xse,mark:joe,arc:{},area:{},bar:Goe,circle:{},geoshape:{},image:{},line:{},point:{},rect:TE,rule:{color:"black"},square:{},text:{color:"black"},tick:Yoe,trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:_oe,projection:{},legend:jse,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Wse,style:{},title:{},facet:{spacing:qA},concat:{spacing:qA},normalizedNumberFormat:".0%"},Fr=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],WA={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},HA={blue:Fr[0],orange:Fr[1],red:Fr[2],teal:Fr[3],green:Fr[4],yellow:Fr[5],purple:Fr[6],pink:Fr[7],brown:Fr[8],gray0:"#000",gray1:"#111",gray2:"#222",gray3:"#333",gray4:"#444",gray5:"#555",gray6:"#666",gray7:"#777",gray8:"#888",gray9:"#999",gray10:"#aaa",gray11:"#bbb",gray12:"#ccc",gray13:"#ddd",gray14:"#eee",gray15:"#fff"};function Jse(e={}){return{signals:[{name:"color",value:K(e)?{...HA,...e}:HA}],mark:{color:{signal:"color.blue"}},rule:{color:{signal:"color.gray0"}},text:{color:{signal:"color.gray0"}},style:{"guide-label":{fill:{signal:"color.gray0"}},"guide-title":{fill:{signal:"color.gray0"}},"group-title":{fill:{signal:"color.gray0"}},"group-subtitle":{fill:{signal:"color.gray0"}},cell:{stroke:{signal:"color.gray8"}}},axis:{domainColor:{signal:"color.gray13"},gridColor:{signal:"color.gray8"},tickColor:{signal:"color.gray13"}},range:{category:[{signal:"color.blue"},{signal:"color.orange"},{signal:"color.red"},{signal:"color.teal"},{signal:"color.green"},{signal:"color.yellow"},{signal:"color.purple"},{signal:"color.pink"},{signal:"color.brown"},{signal:"color.grey8"}]}}}function Qse(e){return{signals:[{name:"fontSize",value:K(e)?{...WA,...e}:WA}],text:{fontSize:{signal:"fontSize.text"}},style:{"guide-label":{fontSize:{signal:"fontSize.guideLabel"}},"guide-title":{fontSize:{signal:"fontSize.guideTitle"}},"group-title":{fontSize:{signal:"fontSize.groupTitle"}},"group-subtitle":{fontSize:{signal:"fontSize.groupSubtitle"}}}}}function Zse(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function E6(e){const t=U(e||{}),n={};for(const i of t){const r=e[i];n[i]=Kf(r)?J5(r):Tn(r)}return n}function eae(e){const t=U(e),n={};for(const i of t)n[i]=E6(e[i]);return n}const tae=[...TL,...ZL,...y6,"background","padding","legend","lineBreak","scale","style","title","view"];function _6(e={}){const{color:t,font:n,fontSize:i,selection:r,...o}=e,s=Ju({},ce(Kse),n?Zse(n):{},t?Jse(t):{},i?Qse(i):{},o||{});r&&Qu(s,"selection",r,!0);const a=In(s,tae);for(const u of["background","lineBreak","padding"])s[u]&&(a[u]=Tn(s[u]));for(const u of TL)s[u]&&(a[u]=kt(s[u]));for(const u of ZL)s[u]&&(a[u]=E6(s[u]));for(const u of y6)s[u]&&(a[u]=kt(s[u]));if(s.legend&&(a.legend=kt(s.legend)),s.scale){const{invalid:u,...l}=s.scale,c=kt(u,{level:1});a.scale={...kt(l),...U(c).length>0?{invalid:c}:{}}}return s.style&&(a.style=eae(s.style)),s.title&&(a.title=kt(s.title)),s.view&&(a.view=kt(s.view)),a}const nae=new Set(["view",...Loe]),iae=["color","fontSize","background","padding","facet","concat","numberFormat","numberFormatType","normalizedNumberFormat","normalizedNumberFormatType","timeFormat","countTitle","header","axisQuantitative","axisTemporal","axisDiscrete","axisPoint","axisXBand","axisXPoint","axisXDiscrete","axisXQuantitative","axisXTemporal","axisYBand","axisYPoint","axisYDiscrete","axisYQuantitative","axisYTemporal","scale","selection","overlay"],rae={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],...Uoe};function oae(e){e=ce(e);for(const t of iae)delete e[t];if(e.axis)for(const t in e.axis)Kf(e.axis[t])&&delete e.axis[t];if(e.legend)for(const t of Ise)delete e.legend[t];if(e.mark){for(const t of OA)delete e.mark[t];e.mark.tooltip&&K(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(v6(e.params)),delete e.params);for(const t of nae){for(const i of OA)delete e[t][i];const n=rae[t];if(n)for(const i of n)delete e[t][i];aae(e,t)}for(const t of Pse())delete e[t];sae(e);for(const t in e)K(e[t])&&Be(e[t])&&delete e[t];return Be(e)?void 0:e}function sae(e){const{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:i}=X5(e.title);Be(t)||(e.style["group-title"]={...e.style["group-title"],...t}),Be(n)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...n}),Be(i)?delete e.title:e.title=i}function aae(e,t,n,i){const r=e[t];t==="view"&&(n="cell");const o={...r,...e.style[n??t]};Be(o)||(e.style[n??t]=o),delete e[t]}function Nm(e){return q(e,"layer")}function uae(e){return q(e,"repeat")}function lae(e){return!P(e.repeat)&&q(e.repeat,"layer")}class JE{map(t,n){return $m(t)?this.mapFacet(t,n):uae(t)?this.mapRepeat(t,n):KE(t)?this.mapHConcat(t,n):Tm(t)?this.mapVConcat(t,n):XE(t)?this.mapConcat(t,n):this.mapLayerOrUnit(t,n)}mapLayerOrUnit(t,n){if(Nm(t))return this.mapLayer(t,n);if(co(t))return this.mapUnit(t,n);throw new Error(fE(t))}mapLayer(t,n){return{...t,layer:t.layer.map(i=>this.mapLayerOrUnit(i,n))}}mapHConcat(t,n){return{...t,hconcat:t.hconcat.map(i=>this.map(i,n))}}mapVConcat(t,n){return{...t,vconcat:t.vconcat.map(i=>this.map(i,n))}}mapConcat(t,n){const{concat:i,...r}=t;return{...r,concat:i.map(o=>this.map(o,n))}}mapFacet(t,n){return{...t,spec:this.map(t.spec,n)}}mapRepeat(t,n){return{...t,spec:this.map(t.spec,n)}}}const cae={zero:1,center:1,normalize:1};function fae(e){return Z(cae,e)}const dae=new Set([CL,wm,xm,Rg,_m,FE,ME,Em,FL,CE]),hae=new Set([wm,xm,CL]);function Wa(e){return j(e)&&Bu(e)==="quantitative"&&!e.bin}function GA(e,t,{orient:n,type:i}){const r=t==="x"?"y":"radius",o=t==="x"&&["bar","area"].includes(i),s=e[t],a=e[r];if(j(s)&&j(a))if(Wa(s)&&Wa(a)){if(s.stack)return t;if(a.stack)return r;const u=j(s)&&!!s.aggregate,l=j(a)&&!!a.aggregate;if(u!==l)return u?t:r;if(o){if(n==="vertical")return r;if(n==="horizontal")return t}}else{if(Wa(s))return t;if(Wa(a))return r}else{if(Wa(s))return o&&n==="vertical"?void 0:t;if(Wa(a))return o&&n==="horizontal"?void 0:r}}function gae(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}function S6(e,t){var p,m;const n=cr(e)?e:{type:e},i=n.type;if(!dae.has(i))return null;const r=GA(t,"x",n)||GA(t,"theta",n);if(!r)return null;const o=t[r],s=j(o)?V(o,{}):void 0,a=gae(r),u=[],l=new Set;if(t[a]){const y=t[a],b=j(y)?V(y,{}):void 0;b&&b!==s&&(u.push(a),l.add(b))}const c=a==="x"?"xOffset":"yOffset",f=t[c],d=j(f)?V(f,{}):void 0;d&&d!==s&&(u.push(c),l.add(d));const h=wie.reduce((y,b)=>{if(b!=="tooltip"&&js(t,b)){const v=t[b];for(const x of Q(v)){const E=Mi(x);if(E.aggregate)continue;const _=V(E,{});(!_||!l.has(_))&&y.push({channel:b,fieldDef:E})}}return y},[]);let g;return o.stack!==void 0?pa(o.stack)?g=o.stack?"zero":null:g=o.stack:hae.has(i)&&(g="zero"),!g||!fae(g)||n6(t)&&h.length===0?null:((p=o==null?void 0:o.scale)!=null&&p.type&&((m=o==null?void 0:o.scale)==null?void 0:m.type)!==At.LINEAR&&o!=null&&o.stack&&W(Ure(o.scale.type)),fe(t[Er(r)])?(o.stack!==void 0&&W(Bre(r)),null):(j(o)&&o.aggregate&&!Oie.has(o.aggregate)&&W(jre(o.aggregate)),{groupbyChannels:u,groupbyFields:l,fieldChannel:r,impute:o.impute===null?!1:fs(i),stackBy:h,offset:g}))}function $6(e,t,n){const i=kt(e),r=Te("orient",i,n);if(i.orient=bae(i.type,t,r),r!==void 0&&r!==i.orient&&W(_re(i.orient,r)),i.type==="bar"&&i.orient){const u=Te("cornerRadiusEnd",i,n);if(u!==void 0){const l=i.orient==="horizontal"&&t.x2||i.orient==="vertical"&&t.y2?["cornerRadius"]:Woe[i.orient];for(const c of l)i[c]=u;i.cornerRadiusEnd!==void 0&&delete i.cornerRadiusEnd}}const o=Te("opacity",i,n),s=Te("fillOpacity",i,n);return o===void 0&&s===void 0&&(i.opacity=mae(i.type,t)),Te("cursor",i,n)===void 0&&(i.cursor=pae(i,t,n)),i}function pae(e,t,n){return t.href||e.href||Te("href",e,n)?"pointer":e.cursor}const k6=.7;function mae(e,t){if(we([_m,CE,FE,ME],e)&&!n6(t))return k6}function yae(e,t,{graticule:n}){if(n)return!1;const i=lr("filled",e,t),r=e.type;return nt(i,r!==_m&&r!==Em&&r!==Rg)}function bae(e,t,n){switch(e){case _m:case FE:case ME:case Ooe:case Roe:return}const{x:i,y:r,x2:o,y2:s}=t;switch(e){case FL:case wm:if(j(i)&&($t(i.bin)||j(r)&&r.aggregate&&!i.aggregate))return"vertical";if(j(r)&&($t(r.bin)||j(i)&&i.aggregate&&!r.aggregate))return"horizontal";if(s||o){if(n)return n;if(!o)return(j(i)&&i.type===ua&&!Ue(i.bin)||Dg(i))&&j(r)&&$t(r.bin)?"horizontal":"vertical";if(!s)return(j(r)&&r.type===ua&&!Ue(r.bin)||Dg(r))&&j(i)&&$t(i.bin)?"vertical":"horizontal"}case Rg:if(o&&!(j(i)&&$t(i.bin))&&s&&!(j(r)&&$t(r.bin)))return;case xm:if(s)return j(r)&&$t(r.bin)?"horizontal":"vertical";if(o)return j(i)&&$t(i.bin)?"vertical":"horizontal";if(e===Rg){if(i&&!r)return"vertical";if(r&&!i)return"horizontal"}case Em:case CE:{const a=IA(i),u=IA(r);if(n)return n;if(a&&!u)return e!=="tick"?"horizontal":"vertical";if(!a&&u)return e!=="tick"?"vertical":"horizontal";if(a&&u)return"vertical";{const l=cn(i)&&i.type===Iu,c=cn(r)&&r.type===Iu;if(l&&!c)return"vertical";if(!l&&c)return"horizontal"}return}}return"vertical"}function vae(e){const{point:t,line:n,...i}=e;return U(i).length>1?i:i.type}function xae(e){for(const t of["line","area","rule","trail"])e[t]&&(e={...e,[t]:In(e[t],["point","line"])});return e}function c1(e,t={},n){return e.point==="transparent"?{opacity:0}:e.point?K(e.point)?e.point:{}:e.point!==void 0?null:t.point||n.shape?K(t.point)?t.point:{}:void 0}function YA(e,t={}){return e.line?e.line===!0?{}:e.line:e.line!==void 0?null:t.line?t.line===!0?{}:t.line:void 0}class wae{constructor(){I(this,"name","path-overlay")}hasMatchingType(t,n){if(co(t)){const{mark:i,encoding:r}=t,o=cr(i)?i:{type:i};switch(o.type){case"line":case"rule":case"trail":return!!c1(o,n[o.type],r);case"area":return!!c1(o,n[o.type],r)||!!YA(o,n[o.type])}}return!1}run(t,n,i){const{config:r}=n,{params:o,projection:s,mark:a,name:u,encoding:l,...c}=t,f=Mm(l,r),d=cr(a)?a:{type:a},h=c1(d,r[d.type],f),g=d.type==="area"&&YA(d,r[d.type]),p=[{name:u,...o?{params:o}:{},mark:vae({...d.type==="area"&&Te("opacity",d,r)==null&&Te("fillOpacity",d,r)==null?{opacity:k6}:{},...d}),encoding:In(f,["shape"])}],m=S6($6(d,f,r),f);let y=f;if(m){const{fieldChannel:b,offset:v}=m;y={...f,[b]:{...f[b],...v?{stack:v}:{}}}}return y=In(y,["y2","x2"]),g&&p.push({...s?{projection:s}:{},mark:{type:"line",...Ru(d,["clip","interpolate","tension","tooltip"]),...g},encoding:y}),h&&p.push({...s?{projection:s}:{},mark:{type:"point",opacity:1,filled:!0,...Ru(d,["clip","tooltip"]),...h},encoding:y}),i({...c,layer:p},{...n,config:xae(r)})}}function Eae(e,t){return t?Gf(e)?C6(e,t):A6(e,t):e}function f1(e,t){return t?C6(e,t):e}function Lb(e,t,n){const i=t[e];if(rse(i)){if(i.repeat in n)return{...t,[e]:n[i.repeat]};W(ere(i.repeat));return}return t}function A6(e,t){if(e=Lb("field",e,t),e!==void 0){if(e===null)return null;if(PE(e)&&Gr(e.sort)){const n=Lb("field",e.sort,t);e={...e,...n?{sort:n}:{}}}return e}}function VA(e,t){if(j(e))return A6(e,t);{const n=Lb("datum",e,t);return n!==e&&!n.type&&(n.type="nominal"),n}}function XA(e,t){if(fe(e)){const n=VA(e,t);if(n)return n;if(Yf(e))return{condition:e.condition}}else{if(Vf(e)){const n=VA(e.condition,t);if(n)return{...e,condition:n};{const{condition:i,...r}=e;return r}}return e}}function C6(e,t){const n={};for(const i in e)if(q(e,i)){const r=e[i];if(P(r))n[i]=r.map(o=>XA(o,t)).filter(o=>o);else{const o=XA(r,t);o!==void 0&&(n[i]=o)}}return n}class _ae{constructor(){I(this,"name","RuleForRangedLine")}hasMatchingType(t){if(co(t)){const{encoding:n,mark:i}=t;if(i==="line"||cr(i)&&i.type==="line")for(const r of bie){const o=ka(r),s=n[o];if(n[r]&&(j(s)&&!$t(s.bin)||Sr(s)))return!0}}return!1}run(t,n,i){const{encoding:r,mark:o}=t;return W(Ere(!!r.x2,!!r.y2)),i({...t,mark:K(o)?{...o,type:"rule"}:"rule"},n)}}class Sae extends JE{constructor(){super(...arguments);I(this,"nonFacetUnitNormalizers",[kse,Fse,Lse,new wae,new _ae])}map(n,i){if(co(n)){const r=js(n.encoding,Wr),o=js(n.encoding,Hr),s=js(n.encoding,lm);if(r||o||s)return this.mapFacetedUnit(n,i)}return super.map(n,i)}mapUnit(n,i){const{parentEncoding:r,parentProjection:o}=i,s=f1(n.encoding,i.repeater),a={...n,...n.name?{name:[i.repeaterPrefix,n.name].filter(l=>l).join("_")}:{},...s?{encoding:s}:{}};if(r||o)return this.mapUnitWithParentEncodingOrProjection(a,i);const u=this.mapLayerOrUnit.bind(this);for(const l of this.nonFacetUnitNormalizers)if(l.hasMatchingType(a,i.config))return l.run(a,i,u);return a}mapRepeat(n,i){return lae(n)?this.mapLayerRepeat(n,i):this.mapNonLayerRepeat(n,i)}mapLayerRepeat(n,i){const{repeat:r,spec:o,...s}=n,{row:a,column:u,layer:l}=r,{repeater:c={},repeaterPrefix:f=""}=i;return a||u?this.mapRepeat({...n,repeat:{...a?{row:a}:{},...u?{column:u}:{}},spec:{repeat:{layer:l},spec:o}},i):{...s,layer:l.map(d=>{const h={...c,layer:d},g=`${(o.name?`${o.name}_`:"")+f}child__layer_${Ye(d)}`,p=this.mapLayerOrUnit(o,{...i,repeater:h,repeaterPrefix:g});return p.name=g,p})}}mapNonLayerRepeat(n,i){const{repeat:r,spec:o,data:s,...a}=n;!P(r)&&n.columns&&(n=In(n,["columns"]),W(CA("repeat")));const u=[],{repeater:l={},repeaterPrefix:c=""}=i,f=!P(r)&&r.row||[l?l.row:null],d=!P(r)&&r.column||[l?l.column:null],h=P(r)&&r||[l?l.repeat:null];for(const p of h)for(const m of f)for(const y of d){const b={repeat:p,row:m,column:y,layer:l.layer},v=`${(o.name?`${o.name}_`:"")+c}child__${P(r)?`${Ye(p)}`:(r.row?`row_${Ye(m)}`:"")+(r.column?`column_${Ye(y)}`:"")}`,x=this.map(o,{...i,repeater:b,repeaterPrefix:v});x.name=v,u.push(In(x,["data"]))}const g=P(r)?n.columns:r.column?r.column.length:1;return{data:o.data??s,align:"all",...a,columns:g,concat:u}}mapFacet(n,i){const{facet:r}=n;return Gf(r)&&n.columns&&(n=In(n,["columns"]),W(CA("facet"))),super.mapFacet(n,i)}mapUnitWithParentEncodingOrProjection(n,i){const{encoding:r,projection:o}=n,{parentEncoding:s,parentProjection:a,config:u}=i,l=JA({parentProjection:a,projection:o}),c=KA({parentEncoding:s,encoding:f1(r,i.repeater)});return this.mapUnit({...n,...l?{projection:l}:{},...c?{encoding:c}:{}},{config:u})}mapFacetedUnit(n,i){const{row:r,column:o,facet:s,...a}=n.encoding,{mark:u,width:l,projection:c,height:f,view:d,params:h,encoding:g,...p}=n,{facetMapping:m,layout:y}=this.getFacetMappingAndLayout({row:r,column:o,facet:s},i),b=f1(a,i.repeater);return this.mapFacet({...p,...y,facet:m,spec:{...l?{width:l}:{},...f?{height:f}:{},...d?{view:d}:{},...c?{projection:c}:{},mark:u,encoding:b,...h?{params:h}:{}}},i)}getFacetMappingAndLayout(n,i){const{row:r,column:o,facet:s}=n;if(r||o){s&&W(xre([...r?[Wr]:[],...o?[Hr]:[]]));const a={},u={};for(const l of[Wr,Hr]){const c=n[l];if(c){const{align:f,center:d,spacing:h,columns:g,...p}=c;a[l]=p;for(const m of["align","center","spacing"])c[m]!==void 0&&(u[m]??(u[m]={}),u[m][l]=c[m])}}return{facetMapping:a,layout:u}}else{const{align:a,center:u,spacing:l,columns:c,...f}=s;return{facetMapping:Eae(f,i.repeater),layout:{...a?{align:a}:{},...u?{center:u}:{},...l?{spacing:l}:{},...c?{columns:c}:{}}}}}mapLayer(n,{parentEncoding:i,parentProjection:r,...o}){const{encoding:s,projection:a,...u}=n,l={...o,parentEncoding:KA({parentEncoding:i,encoding:s,layer:!0}),parentProjection:JA({parentProjection:r,projection:a})};return super.mapLayer({...u,...n.name?{name:[l.repeaterPrefix,n.name].filter(c=>c).join("_")}:{}},l)}}function KA({parentEncoding:e,encoding:t={},layer:n}){let i={};if(e){const r=new Set([...U(e),...U(t)]);for(const o of r){const s=t[o],a=e[o];if(fe(s)){const u={...a,...s};i[o]=u}else Vf(s)?i[o]={...s,condition:{...a,...s.condition}}:s||s===null?i[o]=s:(n||Fi(a)||ne(a)||fe(a)||P(a))&&(i[o]=a)}}else i=t;return!i||Be(i)?void 0:i}function JA(e){const{parentProjection:t,projection:n}=e;return t&&n&&W(lre({parentProjection:t,projection:n})),n??t}function QE(e){return q(e,"filter")}function $ae(e){return q(e,"stop")}function F6(e){return q(e,"lookup")}function kae(e){return q(e,"data")}function Aae(e){return q(e,"param")}function Cae(e){return q(e,"pivot")}function Fae(e){return q(e,"density")}function Mae(e){return q(e,"quantile")}function Tae(e){return q(e,"regression")}function Nae(e){return q(e,"loess")}function Rae(e){return q(e,"sample")}function Oae(e){return q(e,"window")}function Dae(e){return q(e,"joinaggregate")}function Lae(e){return q(e,"flatten")}function Pae(e){return q(e,"calculate")}function M6(e){return q(e,"bin")}function Iae(e){return q(e,"impute")}function zae(e){return q(e,"timeUnit")}function Bae(e){return q(e,"aggregate")}function Uae(e){return q(e,"stack")}function jae(e){return q(e,"fold")}function qae(e){return q(e,"extent")&&!q(e,"density")&&!q(e,"regression")}function Wae(e){return e.map(t=>QE(t)?{filter:au(t.filter,moe)}:t)}class Hae extends JE{map(t,n){return n.emptySelections??(n.emptySelections={}),n.selectionPredicates??(n.selectionPredicates={}),t=QA(t,n),super.map(t,n)}mapLayerOrUnit(t,n){if(t=QA(t,n),t.encoding){const i={};for(const[r,o]of Xo(t.encoding))i[r]=T6(o,n);t={...t,encoding:i}}return super.mapLayerOrUnit(t,n)}mapUnit(t,n){const{selection:i,...r}=t;return i?{...r,params:Xo(i).map(([o,s])=>{const{init:a,bind:u,empty:l,...c}=s;c.type==="single"?(c.type="point",c.toggle=!1):c.type==="multi"&&(c.type="point"),n.emptySelections[o]=l!=="none";for(const f of ot(n.selectionPredicates[o]??{}))f.empty=l!=="none";return{name:o,value:a,select:c,bind:u}})}:t}}function QA(e,t){const{transform:n,...i}=e;if(n){const r=n.map(o=>{if(QE(o))return{filter:Pb(o,t)};if(M6(o)&&Aa(o.bin))return{...o,bin:N6(o.bin)};if(F6(o)){const{selection:s,...a}=o.from;return s?{...o,from:{param:s,...a}}:o}return o});return{...i,transform:r}}return e}function T6(e,t){var i,r;const n=ce(e);if(j(n)&&Aa(n.bin)&&(n.bin=N6(n.bin)),Ta(n)&&((r=(i=n.scale)==null?void 0:i.domain)!=null&&r.selection)){const{selection:o,...s}=n.scale.domain;n.scale.domain={...s,...o?{param:o}:{}}}if(Yf(n))if(P(n.condition))n.condition=n.condition.map(o=>{const{selection:s,param:a,test:u,...l}=o;return a?o:{...l,test:Pb(o,t)}});else{const{selection:o,param:s,test:a,...u}=T6(n.condition,t);n.condition=s?n.condition:{...u,test:Pb(n.condition,t)}}return n}function N6(e){const t=e.extent;if(t!=null&&t.selection){const{selection:n,...i}=t;return{...e,extent:{...i,param:n}}}return e}function Pb(e,t){const n=i=>au(i,r=>{var a;const o=t.emptySelections[r]??!0,s={param:r,empty:o};return(a=t.selectionPredicates)[r]??(a[r]=[]),t.selectionPredicates[r].push(s),s});return e.selection?n(e.selection):au(e.test||e.filter,i=>i.selection?n(i.selection):i)}class Ib extends JE{map(t,n){const i=n.selections??[];if(t.params&&!co(t)){const r=[];for(const o of t.params)VE(o)?i.push(o):r.push(o);t.params=r}return n.selections=i,super.map(t,n)}mapUnit(t,n){const i=n.selections;if(!i||!i.length)return t;const r=(n.path??[]).concat(t.name),o=[];for(const s of i)if(!s.views||!s.views.length)o.push(s);else for(const a of s.views)(J(a)&&(a===t.name||r.includes(a))||P(a)&&a.map(u=>r.indexOf(u)).every((u,l,c)=>u!==-1&&(l===0||u>c[l-1])))&&o.push(s);return o.length&&(t.params=o),t}}for(const e of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const t=Ib.prototype[e];Ib.prototype[e]=function(n,i){return t.call(this,n,Gae(n,i))}}function Gae(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function R6(e,t){t===void 0&&(t=_6(e.config));const n=Kae(e,t),{width:i,height:r}=e,o=Jae(n,{width:i,height:r,autosize:e.autosize},t);return{...n,...o?{autosize:o}:{}}}const Yae=new Sae,Vae=new Hae,Xae=new Ib;function Kae(e,t={}){const n={config:t};return Xae.map(Yae.map(Vae.map(e,n),n),n)}function ZA(e){return J(e)?{type:e}:e??{}}function Jae(e,t,n){let{width:i,height:r}=t;const o=co(e)||Nm(e),s={};o?i=="container"&&r=="container"?(s.type="fit",s.contains="padding"):i=="container"?(s.type="fit-x",s.contains="padding"):r=="container"&&(s.type="fit-y",s.contains="padding"):(i=="container"&&(W(SA("width")),i=void 0),r=="container"&&(W(SA("height")),r=void 0));const a={type:"pad",...s,...n?ZA(n.autosize):{},...ZA(e.autosize)};if(a.type==="fit"&&!o&&(W(qie),a.type="pad"),i=="container"&&!(a.type=="fit"||a.type=="fit-x")&&W($A("width")),r=="container"&&!(a.type=="fit"||a.type=="fit-y")&&W($A("height")),!On(a,{type:"pad"}))return a}function Qae(e){return["fit","fit-x","fit-y"].includes(e)}function Zae(e){return e?`fit-${gm(e)}`:"fit"}const eue=["background","padding"];function eC(e,t){const n={};for(const i of eue)e&&e[i]!==void 0&&(n[i]=Tn(e[i]));return t&&(n.params=e.params),n}class fo{constructor(t={},n={}){I(this,"explicit");I(this,"implicit");this.explicit=t,this.implicit=n}clone(){return new fo(ce(this.explicit),ce(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(t){return nt(this.explicit[t],this.implicit[t])}getWithExplicit(t){return this.explicit[t]!==void 0?{explicit:!0,value:this.explicit[t]}:this.implicit[t]!==void 0?{explicit:!1,value:this.implicit[t]}:{explicit:!1,value:void 0}}setWithExplicit(t,{value:n,explicit:i}){n!==void 0&&this.set(t,n,i)}set(t,n,i){return delete this[i?"implicit":"explicit"][t],this[i?"explicit":"implicit"][t]=n,this}copyKeyFromSplit(t,{explicit:n,implicit:i}){n[t]!==void 0?this.set(t,n[t],!0):i[t]!==void 0&&this.set(t,i[t],!1)}copyKeyFromObject(t,n){n[t]!==void 0&&this.set(t,n[t],!0)}copyAll(t){for(const n of U(t.combine())){const i=t.getWithExplicit(n);this.setWithExplicit(n,i)}}}function Hi(e){return{explicit:!0,value:e}}function Cn(e){return{explicit:!1,value:e}}function O6(e){return(t,n,i,r)=>{const o=e(t.value,n.value);return o>0?t:o<0?n:Rm(t,n,i,r)}}function Rm(e,t,n,i){return e.explicit&&t.explicit&&W(Nre(n,i,e.value,t.value)),e}function Jo(e,t,n,i,r=Rm){return e===void 0||e.value===void 0?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:On(e.value,t.value)?e:r(e,t,n,i)}class tue extends fo{constructor(n={},i={},r=!1){super(n,i);I(this,"explicit");I(this,"implicit");I(this,"parseNothing");this.explicit=n,this.implicit=i,this.parseNothing=r}clone(){const n=super.clone();return n.parseNothing=this.parseNothing,n}}function Wu(e){return q(e,"url")}function nf(e){return q(e,"values")}function D6(e){return q(e,"name")&&!Wu(e)&&!nf(e)&&!Io(e)}function Io(e){return e&&(L6(e)||P6(e)||ZE(e))}function L6(e){return q(e,"sequence")}function P6(e){return q(e,"sphere")}function ZE(e){return q(e,"graticule")}var Xe;(function(e){e[e.Raw=0]="Raw",e[e.Main=1]="Main",e[e.Row=2]="Row",e[e.Column=3]="Column",e[e.Lookup=4]="Lookup",e[e.PreFilterInvalid=5]="PreFilterInvalid",e[e.PostFilterInvalid=6]="PostFilterInvalid"})(Xe||(Xe={}));function I6({invalid:e,isPath:t}){switch(NL(e,{isPath:t})){case"filter":return{marks:"exclude-invalid-values",scales:"exclude-invalid-values"};case"break-paths-show-domains":return{marks:t?"include-invalid-values":"exclude-invalid-values",scales:"include-invalid-values"};case"break-paths-filter-domains":return{marks:t?"include-invalid-values":"exclude-invalid-values",scales:"exclude-invalid-values"};case"show":return{marks:"include-invalid-values",scales:"include-invalid-values"}}}function nue(e){const{marks:t,scales:n}=I6(e);return t===n?Xe.Main:n==="include-invalid-values"?Xe.PreFilterInvalid:Xe.PostFilterInvalid}class Le{constructor(t,n){I(this,"debugName");I(this,"_children",[]);I(this,"_parent",null);I(this,"_hash");this.debugName=n,t&&(this.parent=t)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(t){this._parent=t,t&&t.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(t,n){if(this._children.includes(t)){W(sre);return}n!==void 0?this._children.splice(n,0,t):this._children.push(t)}removeChild(t){const n=this._children.indexOf(t);return this._children.splice(n,1),n}remove(){let t=this._parent.removeChild(this);for(const n of this._children)n._parent=this._parent,this._parent.addChild(n,t++)}insertAsParentOf(t){const n=t.parent;n.removeChild(this),this.parent=n,t.parent=this}swapWithParent(){const t=this._parent,n=t.parent;for(const r of this._children)r.parent=t;this._children=[],t.removeChild(this);const i=t.parent.removeChild(t);this._parent=n,n.addChild(this,i),t.parent=this}}class bn extends Le{constructor(n,i,r,o){super(n,i);I(this,"type");I(this,"refCounts");I(this,"_source");I(this,"_name");this.type=r,this.refCounts=o,this._source=this._name=i,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}clone(){const n=new this.constructor;return n.debugName=`clone_${this.debugName}`,n._source=this._source,n._name=`clone_${this._name}`,n.type=this.type,n.refCounts=this.refCounts,n.refCounts[n._name]=0,n}dependentFields(){return new Set}producedFields(){return new Set}hash(){return this._hash===void 0&&(this._hash=`Output ${R5()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(n){this._source=n}}function d1(e){return e.as!==void 0}function tC(e){return`${e}_end`}class er extends Le{constructor(n,i){super(n);I(this,"timeUnits");this.timeUnits=i}clone(){return new er(null,ce(this.timeUnits))}static makeFromEncoding(n,i){const r=i.reduceFieldDef((o,s,a)=>{const{field:u,timeUnit:l}=s;if(l){let c;if(Ma(l)){if(Ge(i)){const{mark:f,markDef:d,config:h}=i,g=eo({fieldDef:s,markDef:d,config:h});(tf(f)||g)&&(c={timeUnit:Et(l),field:u})}}else c={as:V(s,{forAs:!0}),field:u,timeUnit:l};if(Ge(i)){const{mark:f,markDef:d,config:h}=i,g=eo({fieldDef:s,markDef:d,config:h});tf(f)&&it(a)&&g!==.5&&(c.rectBandPosition=g)}c&&(o[ye(c)]=c)}return o},{});return Be(r)?null:new er(n,r)}static makeFromTransform(n,i){const{timeUnit:r,...o}={...i},s=Et(r),a={...o,timeUnit:s};return new er(n,{[ye(a)]:a})}merge(n){this.timeUnits={...this.timeUnits};for(const i in n.timeUnits)this.timeUnits[i]||(this.timeUnits[i]=n.timeUnits[i]);for(const i of n.children)n.removeChild(i),i.parent=this;n.remove()}removeFormulas(n){const i={};for(const[r,o]of Xo(this.timeUnits)){const s=d1(o)?o.as:`${o.field}_end`;n.has(s)||(i[r]=o)}this.timeUnits=i}producedFields(){return new Set(ot(this.timeUnits).map(n=>d1(n)?n.as:tC(n.field)))}dependentFields(){return new Set(ot(this.timeUnits).map(n=>n.field))}hash(){return`TimeUnit ${ye(this.timeUnits)}`}assemble(){const n=[];for(const i of ot(this.timeUnits)){const{rectBandPosition:r}=i,o=Et(i.timeUnit);if(d1(i)){const{field:s,as:a}=i,{unit:u,utc:l,...c}=o,f=[a,`${a}_end`];n.push({field:oi(s),type:"timeunit",...u?{units:bm(u)}:{},...l?{timezone:"utc"}:{},...c,as:f}),n.push(...nC(f,r,o))}else if(i){const{field:s}=i,a=T5(s),u=z6({timeUnit:o,field:a}),l=tC(a);n.push({type:"formula",expr:u,as:l}),n.push(...nC([a,l],r,o))}}return n}}const Om="offsetted_rect_start",Dm="offsetted_rect_end";function z6({timeUnit:e,field:t,reverse:n}){const{unit:i,utc:r}=e,o=pL(i),{part:s,step:a}=vL(o,e.step);return`${r?"utcOffset":"timeOffset"}('${s}', ${Re(t)}, ${n?-a:a})`}function nC([e,t],n,i){if(n!==void 0&&n!==.5){const r=Re(e),o=Re(t);return[{type:"formula",expr:iC([z6({timeUnit:i,field:e,reverse:!0}),r],n+.5),as:`${e}_${Om}`},{type:"formula",expr:iC([r,o],n+.5),as:`${e}_${Dm}`}]}return[]}function iC([e,t],n){return`${1-n} * ${e} + ${n} * ${t}`}const Jf="_tuple_fields";class iue{constructor(...t){I(this,"hasChannel");I(this,"hasField");I(this,"hasSelectionId");I(this,"timeUnit");I(this,"items");this.items=t,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}}const rue={defined:()=>!0,parse:(e,t,n)=>{const i=t.name,r=t.project??(t.project=new iue),o={},s={},a=new Set,u=(g,p)=>{const m=p==="visual"?g.channel:g.field;let y=Ye(`${i}_${m}`);for(let b=1;a.has(y);b++)y=Ye(`${i}_${m}_${b}`);return a.add(y),{[p]:y}},l=t.type,c=e.config.selection[l],f=n.value!==void 0?Q(n.value):null;let{fields:d,encodings:h}=K(n.select)?n.select:{};if(!d&&!h&&f){for(const g of f)if(K(g))for(const p of U(g))yie(p)?(h||(h=[])).push(p):l==="interval"?(W(Zie),h=c.encodings):(d??(d=[])).push(p)}!d&&!h&&(h=c.encodings,"fields"in c&&(d=c.fields));for(const g of h??[]){const p=e.fieldDef(g);if(p){let m=p.field;if(p.aggregate){W(Wie(g,p.aggregate));continue}else if(!m){W(AA(g));continue}if(p.timeUnit&&!Ma(p.timeUnit)){m=e.vgField(g);const y={timeUnit:p.timeUnit,as:m,field:p.field};s[ye(y)]=y}if(!o[m]){const y=l==="interval"&&_r(g)&&Ci(e.getScaleComponent(g).get("type"))?"R":p.bin?"R-RE":"E",b={field:m,channel:g,type:y,index:r.items.length};b.signals={...u(b,"data"),...u(b,"visual")},r.items.push(o[m]=b),r.hasField[m]=o[m],r.hasSelectionId=r.hasSelectionId||m===Ti,z5(g)?(b.geoChannel=g,b.channel=I5(g),r.hasChannel[b.channel]=o[m]):r.hasChannel[g]=o[m]}}else W(AA(g))}for(const g of d??[]){if(r.hasField[g])continue;const p={type:"E",field:g,index:r.items.length};p.signals={...u(p,"data")},r.items.push(p),r.hasField[g]=p,r.hasSelectionId=r.hasSelectionId||g===Ti}f&&(t.init=f.map(g=>r.items.map(p=>K(g)?g[p.geoChannel||p.channel]!==void 0?g[p.geoChannel||p.channel]:g[p.field]:g))),Be(s)||(r.timeUnit=new er(null,s))},signals:(e,t,n)=>{const i=t.name+Jf;return n.filter(o=>o.name===i).length>0||t.project.hasSelectionId?n:n.concat({name:i,value:t.project.items.map(q6)})}},B6="_curr",dh="anim_value",Va="anim_clock",zb="eased_anim_clock",U6="min_extent",j6="max_range_extent",h1="last_tick_at",g1="is_playing",oue=1/60*1e3,sue=(e,t)=>[{name:zb,update:Va},{name:`${e}_domain`,init:`domain('${t}')`},{name:U6,init:`extent(${e}_domain)[0]`},{name:j6,init:`extent(range('${t}'))[1]`},{name:dh,update:`invert('${t}', ${zb})`}],aue={defined:e=>e.type==="point",topLevelSignals:(e,t,n)=>(tr(t)&&(n=n.concat([{name:Va,init:"0",on:[{events:{type:"timer",throttle:oue},update:`${g1} ? (${Va} + (now() - ${h1}) > ${j6} ? 0 : ${Va} + (now() - ${h1})) : ${Va}`}]},{name:h1,init:"now()",on:[{events:[{signal:Va},{signal:g1}],update:"now()"}]},{name:g1,init:"true"}])),n),signals:(e,t,n)=>{const i=t.name,r=i+Jf,o=t.project,s="(item().isVoronoi ? datum.datum : datum)",a=ot(e.component.selection??{}).reduce((c,f)=>f.type==="interval"?c.concat(f.name+cu):c,[]).map(c=>`indexof(item().mark.name, '${c}') < 0`).join(" && "),u=`datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${a?` && ${a}`:""}`;let l=`unit: ${qs(e)}, `;if(t.project.hasSelectionId)l+=`${Ti}: ${s}[${G(Ti)}]`;else if(tr(t))l+=`fields: ${r}, values: [${dh} ? ${dh} : ${U6}]`;else{const c=o.items.map(f=>{const d=e.fieldDef(f.channel);return d!=null&&d.bin?`[${s}[${G(e.vgField(f.channel,{}))}], ${s}[${G(e.vgField(f.channel,{binSuffix:"end"}))}]]`:`${s}[${G(f.field)}]`}).join(", ");l+=`fields: ${r}, values: [${c}]`}if(tr(t))return n.concat(sue(t.name,e.scaleName(os)),[{name:i+no,on:[{events:[{signal:zb},{signal:dh}],update:`{${l}}`,force:!0}]}]);{const c=t.events;return n.concat([{name:i+no,on:c?[{events:c,update:`${u} ? {${l}} : null`,force:!0}]:[]}])}}};function q6(e){const{signals:t,hasLegend:n,index:i,...r}=e;return r.field=oi(r.field),r}function fa(e,t=!0,n=vn){if(P(e)){const i=e.map(r=>fa(r,t,n));return t?`[${i.join(", ")}]`:i}else if(Fa(e))return n(t?aa(e):roe(e));return t?n(De(e)):e}function uue(e,t){for(const n of ot(e.component.selection??{})){const i=n.name;let r=`${i}${no}, ${n.resolve==="global"?"true":`{unit: ${qs(e)}}`}`;for(const o of Lm)o.defined(n)&&(o.signals&&(t=o.signals(e,n,t)),o.modifyExpr&&(r=o.modifyExpr(e,n,r)));t.push({name:i+Due,on:[{events:{signal:n.name+no},update:`modify(${G(n.name+da)}, ${r})`}]})}return e_(t)}function lue(e,t){if(e.component.selection&&U(e.component.selection).length){const n=G(e.getName("cell"));t.unshift({name:"facet",value:{},on:[{events:rs("pointermove","scope"),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return e_(t)}function cue(e,t){let n=!1;for(const i of ot(e.component.selection??{})){const r=i.name,o=G(r+da);if(t.filter(a=>a.name===r).length===0){const a=i.resolve==="global"?"union":i.resolve,u=i.type==="point"?", true, true)":")";t.push({name:i.name,update:`${aP}(${o}, ${G(a)}${u}`})}n=!0;for(const a of Lm)a.defined(i)&&a.topLevelSignals&&(t=a.topLevelSignals(e,i,t))}return n&&t.filter(r=>r.name==="unit").length===0&&t.unshift({name:"unit",value:{},on:[{events:"pointermove",update:"isTuple(group()) ? group() : unit"}]}),e_(t)}function fue(e,t){const n=[],i=[],r=qs(e,{escape:!1});for(const o of ot(e.component.selection??{})){const s={name:o.name+da};if(o.project.hasSelectionId&&(s.transform=[{type:"collect",sort:{field:Ti}}]),o.init){const u=o.project.items.map(q6);s.values=o.project.hasSelectionId?o.init.map(l=>({unit:r,[Ti]:fa(l,!1)[0]})):o.init.map(l=>({unit:r,fields:u,values:fa(l,!1)}))}if([...n,...t].filter(u=>u.name===o.name+da).length||n.push(s),tr(o)&&t.length){const u=e.lookupDataSource(e.getDataName(Xe.Main)),l=t.find(f=>f.name===u),c=l.transform.find(f=>f.type==="filter"&&f.expr.includes("vlSelectionTest"));if(c){l.transform=l.transform.filter(d=>d!==c);const f={name:l.name+B6,source:l.name,transform:[c]};i.push(f)}}}return n.concat(t,i)}function W6(e,t){for(const n of ot(e.component.selection??{}))for(const i of Lm)i.defined(n)&&i.marks&&(t=i.marks(e,n,t));return t}function due(e,t){for(const n of e.children)Ge(n)&&(t=W6(n,t));return t}function hue(e,t,n,i){const r=dP(e,t.param,t);return{signal:Ci(n.get("type"))&&P(i)&&i[0]>i[1]?`isValid(${r}) && reverse(${r})`:r}}function e_(e){return e.map(t=>(t.on&&!t.on.length&&delete t.on,t))}const Yr={defined:e=>e.type==="interval"&&e.resolve==="global"&&e.bind&&e.bind==="scales",parse:(e,t)=>{const n=t.scales=[];for(const i of t.project.items){const r=i.channel;if(!_r(r))continue;const o=e.getScaleComponent(r),s=o?o.get("type"):void 0;if(s=="sequential"&&W(Vie),!o||!Ci(s)){W(Yie);continue}o.set("selectionExtent",{param:t.name,field:i.field},!0),n.push(i)}},topLevelSignals:(e,t,n)=>{const i=t.scales.filter(s=>n.filter(a=>a.name===s.signals.data).length===0);if(!e.parent||Ub(e)||i.length===0)return n;const r=n.find(s=>s.name===t.name);let o=r.update;if(o.includes(aP))r.update=`{${i.map(s=>`${G(oi(s.field))}: ${s.signals.data}`).join(", ")}}`;else{for(const s of i){const a=`${G(oi(s.field))}: ${s.signals.data}`;o.includes(a)||(o=`${o.substring(0,o.length-1)}, ${a}}`)}r.update=o}return n.concat(i.map(s=>({name:s.signals.data})))},signals:(e,t,n)=>{if(e.parent&&!Ub(e))for(const i of t.scales){const r=n.find(o=>o.name===i.signals.data);r.push="outer",delete r.value,delete r.update}return n}};function Bb(e,t){return`domain(${G(e.scaleName(t))})`}function Ub(e){return e.parent&&wl(e.parent)&&(!e.parent.parent||Ub(e.parent.parent))}const cu="_brush",H6="_scale_trigger",ql="geo_interval_init_tick",G6="_init",gue="_center",pue={defined:e=>e.type==="interval",parse:(e,t,n)=>{var i;if(e.hasProjection){const r={...K(n.select)?n.select:{}};r.fields=[Ti],r.encodings||(r.encodings=n.value?U(n.value):[Ii,Pi]),n.select={type:"interval",...r}}if(t.translate&&!Yr.defined(t)){const r=`!event.item || event.item.mark.name !== ${G(t.name+cu)}`;for(const o of t.events){if(!o.between){W(`${o} is not an ordered event stream for interval selections.`);continue}const s=Q((i=o.between[0]).filter??(i.filter=[]));s.includes(r)||s.push(r)}}},signals:(e,t,n)=>{const i=t.name,r=i+no,o=ot(t.project.hasChannel).filter(a=>a.channel===We||a.channel===dt),s=t.init?t.init[0]:null;if(n.push(...o.reduce((a,u)=>a.concat(mue(e,t,u,s==null?void 0:s[u.index])),[])),e.hasProjection){const a=G(e.projectionName()),u=e.projectionName()+gue,{x:l,y:c}=t.project.hasChannel,f=l==null?void 0:l.signals.visual,d=c==null?void 0:c.signals.visual,h=l?s==null?void 0:s[l.index]:`${u}[0]`,g=c?s==null?void 0:s[c.index]:`${u}[1]`,p=E=>e.getSizeSignalRef(E).signal,m=`[[${f?`${f}[0]`:"0"}, ${d?`${d}[0]`:"0"}],[${f?`${f}[1]`:p("width")}, ${d?`${d}[1]`:p("height")}]]`;s&&(n.unshift({name:i+G6,init:`[scale(${a}, [${l?h[0]:h}, ${c?g[0]:g}]), scale(${a}, [${l?h[1]:h}, ${c?g[1]:g}])]`}),(!l||!c)&&(n.find(_=>_.name===u)||n.unshift({name:u,update:`invert(${a}, [${p("width")}/2, ${p("height")}/2])`})));const y=`intersect(${m}, {markname: ${G(e.getName("marks"))}}, unit.mark)`,b=`{unit: ${qs(e)}}`,v=`vlSelectionTuples(${y}, ${b})`,x=o.map(E=>E.signals.visual);return n.concat({name:r,on:[{events:[...x.length?[{signal:x.join(" || ")}]:[],...s?[{signal:ql}]:[]],update:v}]})}else{if(!Yr.defined(t)){const l=i+H6,c=o.map(f=>{const d=f.channel,{data:h,visual:g}=f.signals,p=G(e.scaleName(d)),m=e.getScaleComponent(d).get("type"),y=Ci(m)?"+":"";return`(!isArray(${h}) || (${y}invert(${p}, ${g})[0] === ${y}${h}[0] && ${y}invert(${p}, ${g})[1] === ${y}${h}[1]))`});c.length&&n.push({name:l,value:{},on:[{events:o.map(f=>({scale:e.scaleName(f.channel)})),update:`${c.join(" && ")} ? ${l} : {}`}]})}const a=o.map(l=>l.signals.data),u=`unit: ${qs(e)}, fields: ${i+Jf}, values`;return n.concat({name:r,...s?{init:`{${u}: ${fa(s)}}`}:{},...a.length?{on:[{events:[{signal:a.join(" || ")}],update:`${a.join(" && ")} ? {${u}: [${a}]} : null`}]}:{}})}},topLevelSignals:(e,t,n)=>(Ge(e)&&e.hasProjection&&t.init&&(n.filter(r=>r.name===ql).length||n.unshift({name:ql,value:null,on:[{events:"timer{1}",update:`${ql} === null ? {} : ${ql}`}]})),n),marks:(e,t,n)=>{const i=t.name,{x:r,y:o}=t.project.hasChannel,s=r==null?void 0:r.signals.visual,a=o==null?void 0:o.signals.visual,u=`data(${G(t.name+da)})`;if(Yr.defined(t)||!r&&!o)return n;const l={x:r!==void 0?{signal:`${s}[0]`}:{value:0},y:o!==void 0?{signal:`${a}[0]`}:{value:0},x2:r!==void 0?{signal:`${s}[1]`}:{field:{group:"width"}},y2:o!==void 0?{signal:`${a}[1]`}:{field:{group:"height"}}};if(t.resolve==="global")for(const m of U(l))l[m]=[{test:`${u}.length && ${u}[0].unit === ${qs(e)}`,...l[m]},{value:0}];const{fill:c,fillOpacity:f,cursor:d,...h}=t.mark,g=U(h).reduce((m,y)=>(m[y]=[{test:[r!==void 0&&`${s}[0] !== ${s}[1]`,o!==void 0&&`${a}[0] !== ${a}[1]`].filter(b=>b).join(" && "),value:h[y]},{value:null}],m),{}),p=d??(t.translate?"move":null);return[{name:`${i+cu}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:c},fillOpacity:{value:f}},update:l}},...n,{name:i+cu,type:"rect",clip:!0,encode:{enter:{...p?{cursor:{value:p}}:{},fill:{value:"transparent"}},update:{...l,...g}}}]}};function mue(e,t,n,i){const r=!e.hasProjection,o=n.channel,s=n.signals.visual,a=G(r?e.scaleName(o):e.projectionName()),u=d=>`scale(${a}, ${d})`,l=e.getSizeSignalRef(o===We?"width":"height").signal,c=`${o}(unit)`,f=t.events.reduce((d,h)=>[...d,{events:h.between[0],update:`[${c}, ${c}]`},{events:h,update:`[${s}[0], clamp(${c}, 0, ${l})]`}],[]);if(r){const d=n.signals.data,h=Yr.defined(t),g=e.getScaleComponent(o),p=g?g.get("type"):void 0,m=i?{init:fa(i,!0,u)}:{value:[]};return f.push({events:{signal:t.name+H6},update:Ci(p)?`[${u(`${d}[0]`)}, ${u(`${d}[1]`)}]`:"[0, 0]"}),h?[{name:d,on:[]}]:[{name:s,...m,on:f},{name:d,...i?{init:fa(i)}:{},on:[{events:{signal:s},update:`${s}[0] === ${s}[1] ? null : invert(${a}, ${s})`}]}]}else{const d=o===We?0:1,h=t.name+G6,g=i?{init:`[${h}[0][${d}], ${h}[1][${d}]]`}:{value:[]};return[{name:s,...g,on:f}]}}function yl({model:e,channelDef:t,vgChannel:n,invalidValueRef:i,mainRefFn:r}){const o=Yf(t)&&t.condition;let s=[];o&&(s=Q(o).map(l=>{const c=r(l);if(ise(l)){const{param:f,empty:d}=l;return{test:fP(e,{param:f,empty:d}),...c}}else return{test:jg(e,l.test),...c}})),i!==void 0&&s.push(i);const a=r(t);return a!==void 0&&s.push(a),s.length>1||s.length===1&&s[0].test?{[n]:s}:s.length===1?{[n]:s[0]}:{}}function t_(e,t="text"){const n=e.encoding[t];return yl({model:e,channelDef:n,vgChannel:t,mainRefFn:i=>n_(i,e.config),invalidValueRef:void 0})}function n_(e,t,n="datum"){if(e){if(Fi(e))return qe(e.value);if(fe(e)){const{format:i,formatType:r}=ju(e);return DE({fieldOrDatumDef:e,format:i,formatType:r,expr:n,config:t})}}}function Y6(e,t={}){const{encoding:n,markDef:i,config:r,stack:o}=e,s=n.tooltip;if(P(s))return{tooltip:rC({tooltip:s},o,r,t)};{const a=t.reactiveGeom?"datum.datum":"datum";return yl({model:e,channelDef:s,vgChannel:"tooltip",mainRefFn:l=>{const c=X6(l,r,a);if(c)return c;if(l===null)return;let f=Te("tooltip",i,r);if(f===!0&&(f={content:"encoding"}),J(f))return{value:f};if(K(f))return ne(f)?f:f.content==="encoding"?rC(n,o,r,t):{signal:a}},invalidValueRef:void 0})}}function V6(e,t,n,{reactiveGeom:i}={}){const r={...n,...n.tooltipFormat},o=new Set,s=i?"datum.datum":"datum",a=[];function u(c,f){const d=ka(f),h=cn(c)?c:{...c,type:e[d].type},g=h.title||zE(h,r),p=Q(g).join(", ").replaceAll(/"/g,'\\"');let m;if(it(f)){const y=f==="x"?"x2":"y2",b=Mi(e[y]);if($t(h.bin)&&b){const v=V(h,{expr:s}),x=V(b,{expr:s}),{format:E,formatType:_}=ju(h);m=Hf(v,x,E,_,r),o.add(y)}}if((it(f)||f===ui||f===Li)&&t&&t.fieldChannel===f&&t.offset==="normalize"){const{format:y,formatType:b}=ju(h);m=DE({fieldOrDatumDef:h,format:y,formatType:b,expr:s,config:r,normalizeStack:!0}).signal}m??(m=X6(h,r,s).signal),a.push({channel:f,key:p,value:m})}UE(e,(c,f)=>{j(c)?u(c,f):km(c)&&u(c.condition,f)});const l={};for(const{channel:c,key:f,value:d}of a)!o.has(c)&&!l[f]&&(l[f]=d);return l}function rC(e,t,n,{reactiveGeom:i}={}){const r=V6(e,t,n,{reactiveGeom:i}),o=Xo(r).map(([s,a])=>`"${s}": ${a}`);return o.length>0?{signal:`{${o.join(", ")}}`}:void 0}function X6(e,t,n="datum"){if(j(e)&&$E(e.type)&&!e.timeUnit&&!ju(e).format&&!ju(e).formatType){const i=`${n}["${e.field}"]`;return{signal:`isValid(${i}) ? isArray(${i}) ? join(${i}, '\\n') : ${i} : ""+${i}`}}return n_(e,t,n)}function yue(e){const{markDef:t,config:n}=e,i=Te("aria",t,n);return i===!1?{}:{...i?{aria:i}:{},...bue(e),...vue(e)}}function bue(e){const{mark:t,markDef:n,config:i}=e;if(i.aria===!1)return{};const r=Te("ariaRoleDescription",n,i);return r!=null?{ariaRoleDescription:{value:r}}:Z(zie,t)?{}:{ariaRoleDescription:{value:t}}}function vue(e){const{encoding:t,markDef:n,config:i,stack:r}=e,o=t.description;if(o)return yl({model:e,channelDef:o,vgChannel:"description",mainRefFn:u=>n_(u,e.config),invalidValueRef:void 0});const s=Te("description",n,i);if(s!=null)return{description:qe(s)};if(i.aria===!1)return{};const a=V6(t,r,i);if(!Be(a))return{description:{signal:Xo(a).filter(([u])=>!u.startsWith("_")).map(([u,l])=>[u,l.replaceAll("\\n"," ")]).map(([u,l],c)=>`"${c>0?"; ":""}${u}: " + (${l})`).join(" + ")}}}function Ct(e,t,n={}){const{markDef:i,encoding:r,config:o}=t,{vgChannel:s}=n;let{defaultRef:a,defaultValue:u}=n;const l=r[e];a===void 0&&(u??(u=Te(e,i,o,{vgChannel:s,ignoreVgConfig:!Yf(l)})),u!==void 0&&(a=qe(u)));const c={markDef:i,config:o,scaleName:t.scaleName(e),scale:t.getScaleComponent(e)},f=OL({...c,scaleChannel:e,channelDef:l});return yl({model:t,channelDef:l,vgChannel:s??e,invalidValueRef:f,mainRefFn:h=>OE({...c,channel:e,channelDef:h,stack:null,defaultRef:a})})}function K6(e,t={filled:void 0}){const{markDef:n,encoding:i,config:r}=e,{type:o}=n,s=t.filled??Te("filled",n,r),a=we(["bar","point","circle","square","geoshape"],o)?"transparent":void 0,u=Te(s===!0?"color":void 0,n,r,{vgChannel:"fill"})??r.mark[s===!0&&"color"]??a,l=Te(s===!1?"color":void 0,n,r,{vgChannel:"stroke"})??r.mark[s===!1&&"color"],c=s?"fill":"stroke",f={...u?{fill:qe(u)}:{},...l?{stroke:qe(l)}:{}};return n.color&&(s?n.fill:n.stroke)&&W(sL("property",{fill:"fill"in n,stroke:"stroke"in n})),{...f,...Ct("color",e,{vgChannel:c,defaultValue:s?u:l}),...Ct("fill",e,{defaultValue:i.fill?u:void 0}),...Ct("stroke",e,{defaultValue:i.stroke?l:void 0})}}function xue(e){const{encoding:t,mark:n}=e,i=t.order;return!fs(n)&&Fi(i)?yl({model:e,channelDef:i,vgChannel:"zindex",mainRefFn:r=>qe(r.value),invalidValueRef:void 0}):{}}function Hu({channel:e,markDef:t,encoding:n={},model:i,bandPosition:r}){const o=`${e}Offset`,s=t[o],a=n[o];if((o==="xOffset"||o==="yOffset")&&a)return{offsetType:"encoding",offset:OE({channel:o,channelDef:a,markDef:t,config:i==null?void 0:i.config,scaleName:i.scaleName(o),scale:i.getScaleComponent(o),stack:null,defaultRef:qe(s),bandPosition:r})};const u=t[o];return u?{offsetType:"visual",offset:u}:{}}function on(e,t,{defaultPos:n,vgChannel:i}){const{encoding:r,markDef:o,config:s,stack:a}=t,u=r[e],l=r[Er(e)],c=t.scaleName(e),f=t.getScaleComponent(e),{offset:d,offsetType:h}=Hu({channel:e,markDef:o,encoding:r,model:t,bandPosition:.5}),g=i_({model:t,defaultPos:n,channel:e,scaleName:c,scale:f}),p=!u&&it(e)&&(r.latitude||r.longitude)?{field:t.getName(e)}:wue({channel:e,channelDef:u,channel2Def:l,markDef:o,config:s,scaleName:c,scale:f,stack:a,offset:d,defaultRef:g,bandPosition:h==="encoding"?0:void 0});return p?{[i||e]:p}:void 0}function wue(e){const{channel:t,channelDef:n,scaleName:i,stack:r,offset:o,markDef:s}=e;if(fe(n)&&r&&t===r.fieldChannel){if(j(n)){let a=n.bandPosition;if(a===void 0&&s.type==="text"&&(t==="radius"||t==="theta")&&(a=.5),a!==void 0)return Og({scaleName:i,fieldOrDatumDef:n,startSuffix:"start",bandPosition:a,offset:o})}return Us(n,i,{suffix:"end"},{offset:o})}return RE(e)}function i_({model:e,defaultPos:t,channel:n,scaleName:i,scale:r}){const{markDef:o,config:s}=e;return()=>{const a=ka(n),u=Ko(n),l=Te(n,o,s,{vgChannel:u});if(l!==void 0)return Fc(n,l);switch(t){case"zeroOrMin":return oC({scaleName:i,scale:r,mode:"zeroOrMin",mainChannel:a,config:s});case"zeroOrMax":return oC({scaleName:i,scale:r,mode:{zeroOrMax:{widthSignal:e.width.signal,heightSignal:e.height.signal}},mainChannel:a,config:s});case"mid":return{...e[$n(n)],mult:.5}}}}function oC({mainChannel:e,config:t,...n}){const i=RL(n),{mode:r}=n;if(i)return i;switch(e){case"radius":{if(r==="zeroOrMin")return{value:0};const{widthSignal:o,heightSignal:s}=r.zeroOrMax;return{signal:`min(${o},${s})/2`}}case"theta":return r==="zeroOrMin"?{value:0}:{signal:"2*PI"};case"x":return r==="zeroOrMin"?{value:0}:{field:{group:"width"}};case"y":return r==="zeroOrMin"?{field:{group:"height"}}:{value:0}}}const Eue={left:"x",center:"xc",right:"x2"},_ue={top:"y",middle:"yc",bottom:"y2"};function J6(e,t,n,i="middle"){if(e==="radius"||e==="theta")return Ko(e);const r=e==="x"?"align":"baseline",o=Te(r,t,n);let s;return ne(o)?(W(wre(r)),s=void 0):s=o,e==="x"?Eue[s||(i==="top"?"left":"center")]:_ue[s||i]}function Bg(e,t,{defaultPos:n,defaultPos2:i,range:r}){return r?Q6(e,t,{defaultPos:n,defaultPos2:i}):on(e,t,{defaultPos:n})}function Q6(e,t,{defaultPos:n,defaultPos2:i}){const{markDef:r,config:o}=t,s=Er(e),a=$n(e),u=Sue(t,i,s),l=u[a]?J6(e,r,o):Ko(e);return{...on(e,t,{defaultPos:n,vgChannel:l}),...u}}function Sue(e,t,n){const{encoding:i,mark:r,markDef:o,stack:s,config:a}=e,u=ka(n),l=$n(n),c=Ko(n),f=i[u],d=e.scaleName(u),h=e.getScaleComponent(u),{offset:g}=n in i||n in o?Hu({channel:n,markDef:o,encoding:i,model:e}):Hu({channel:u,markDef:o,encoding:i,model:e});if(!f&&(n==="x2"||n==="y2")&&(i.latitude||i.longitude)){const m=$n(n),y=e.markDef[m];return y!=null?{[m]:{value:y}}:{[c]:{field:e.getName(n)}}}const p=$ue({channel:n,channelDef:f,channel2Def:i[n],markDef:o,config:a,scaleName:d,scale:h,stack:s,offset:g,defaultRef:void 0});return p!==void 0?{[c]:p}:Md(n,o)||Md(n,{[n]:Cb(n,o,a.style),[l]:Cb(l,o,a.style)})||Md(n,a[r])||Md(n,a.mark)||{[c]:i_({model:e,defaultPos:t,channel:n,scaleName:d,scale:h})()}}function $ue({channel:e,channelDef:t,channel2Def:n,markDef:i,config:r,scaleName:o,scale:s,stack:a,offset:u,defaultRef:l}){return fe(t)&&a&&e.charAt(0)===a.fieldChannel.charAt(0)?Us(t,o,{suffix:"start"},{offset:u}):RE({channel:e,channelDef:n,scaleName:o,scale:s,stack:a,markDef:i,config:r,offset:u,defaultRef:l})}function Md(e,t){const n=$n(e),i=Ko(e);if(t[i]!==void 0)return{[i]:Fc(e,t[i])};if(t[e]!==void 0)return{[i]:Fc(e,t[e])};if(t[n]){const r=t[n];if(la(r))W(pre(n));else return{[n]:Fc(e,r)}}}function to(e,t){const{config:n,encoding:i,markDef:r}=e,o=r.type,s=Er(t),a=$n(t),u=i[t],l=i[s],c=e.getScaleComponent(t),f=c?c.get("type"):void 0,d=r.orient,h=i[a]??i.size??Te("size",r,n,{vgChannel:a}),g=q5(t),p=o==="bar"&&(t==="x"?d==="vertical":d==="horizontal")||o==="tick"&&(t==="y"?d==="vertical":d==="horizontal");return j(u)&&(Ue(u.bin)||$t(u.bin)||u.timeUnit&&!l)&&!(h&&!la(h))&&!i[g]&&!et(f)?Cue({fieldDef:u,fieldDef2:l,channel:t,model:e}):(fe(u)&&et(f)||p)&&!l?Aue(u,t,e):Q6(t,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"})}function kue(e,t,n,i,r,o,s){if(la(r))if(n){const u=n.get("type");if(u==="band"){let l=`bandwidth('${t}')`;r.band!==1&&(l=`${r.band} * ${l}`);const c=lr("minBandSize",{type:s},i);return{signal:c?`max(${wi(c)}, ${l})`:l}}else r.band!==1&&W($re(u))}else return{mult:r.band,field:{group:e}};else{if(ne(r))return r;if(r)return{value:r}}if(n){const u=n.get("range");if(Ca(u)&&ke(u.step))return{value:u.step-2}}if(!o){const{bandPaddingInner:u,barBandPaddingInner:l,rectBandPaddingInner:c,tickBandPaddingInner:f}=i.scale,d=nt(u,s==="tick"?f:s==="bar"?l:c);if(ne(d))return{signal:`(1 - (${d.signal})) * ${e}`};if(ke(d))return{signal:`${1-d} * ${e}`}}return{value:Db(i.view,e)-2}}function Aue(e,t,n){var F,T;const{markDef:i,encoding:r,config:o,stack:s}=n,a=i.orient,u=n.scaleName(t),l=n.getScaleComponent(t),c=$n(t),f=Er(t),d=q5(t),h=n.scaleName(d),g=n.getScaleComponent(oE(t)),p=i.type==="tick"||a==="horizontal"&&t==="y"||a==="vertical"&&t==="x";let m;(r.size||i.size)&&(p?m=Ct("size",n,{vgChannel:c,defaultRef:qe(i.size)}):W(Fre(i.type)));const y=!!m,b=UL({channel:t,fieldDef:e,markDef:i,config:o,scaleType:(F=l||g)==null?void 0:F.get("type"),useVlSizeChannel:p});m=m||{[c]:kue(c,h||u,g||l,o,b,!!e,i.type)};const v=((T=l||g)==null?void 0:T.get("type"))==="band"&&la(b)&&!y?"top":"middle",x=J6(t,i,o,v),E=x==="xc"||x==="yc",{offset:_,offsetType:w}=Hu({channel:t,markDef:i,encoding:r,model:n,bandPosition:E?.5:0}),$=(E&&w!=="encoding"&&j(e)&&e.timeUnit&&!r[f]?eo({fieldDef:e,markDef:i,config:o}):void 0)??(E?w==="encoding"?0:.5:ne(b)?{signal:`(1-${b})/2`}:la(b)?(1-b.band)/2:0),A=RE({channel:t,channelDef:e,markDef:i,config:o,scaleName:u,scale:l,stack:s,offset:_,defaultRef:i_({model:n,defaultPos:"mid",channel:t,scaleName:u,scale:l}),bandPosition:$});if(c)return{[x]:A,...m};{const N=Ko(f),C=m[c],k=_?{...C,offset:_}:C;return{[x]:A,[N]:P(A)?[A[0],{...A[1],offset:k}]:{...A,offset:k}}}}function sC(e,t,n,i,r,o,s){if(P5(e))return 0;const a=e==="x"||e==="y2",u=a?-t/2:t/2;if(ne(n)||ne(r)||ne(i)||o){const l=wi(n),c=wi(r),f=wi(i),d=wi(o),g=o?`(${s} < ${d} ? ${a?"":"-"}0.5 * (${d} - (${s})) : ${u})`:u,p=f?`${f} + `:"",m=l?`(${l} ? -1 : 1) * `:"",y=c?`(${c} + ${g})`:g;return{signal:p+m+y}}else return r=r||0,i+(n?-r-u:+r+u)}function Cue({fieldDef:e,fieldDef2:t,channel:n,model:i}){var A;const{config:r,markDef:o,encoding:s}=i,a=i.getScaleComponent(n),u=i.scaleName(n),l=a?a.get("type"):void 0,c=a.get("reverse"),f=UL({channel:n,fieldDef:e,markDef:o,config:r,scaleType:l}),d=(A=i.component.axes[n])==null?void 0:A[0],h=(d==null?void 0:d.get("translate"))??.5,g=it(n)?Te("binSpacing",o,r)??0:0,p=Er(n),m=Ko(n),y=Ko(p),b=lr("minBandSize",o,r),{offset:v}=Hu({channel:n,markDef:o,encoding:s,model:i,bandPosition:0}),{offset:x}=Hu({channel:p,markDef:o,encoding:s,model:i,bandPosition:0}),E=Qoe({fieldDef:e,scaleName:u}),_=sC(n,g,c,h,v,b,E),w=sC(p,g,c,h,x??v,b,E),S=ne(f)?{signal:`(1-${f.signal})/2`}:la(f)?(1-f.band)/2:.5,$=eo({fieldDef:e,fieldDef2:t,markDef:o,config:r});if(Ue(e.bin)||e.timeUnit){const F=e.timeUnit&&$!==.5;return{[y]:aC({fieldDef:e,scaleName:u,bandPosition:S,offset:w,useRectOffsetField:F}),[m]:aC({fieldDef:e,scaleName:u,bandPosition:ne(S)?{signal:`1-${S.signal}`}:1-S,offset:_,useRectOffsetField:F})}}else if($t(e.bin)){const F=Us(e,u,{},{offset:w});if(j(t))return{[y]:F,[m]:Us(t,u,{},{offset:_})};if(Aa(e.bin)&&e.bin.step)return{[y]:F,[m]:{signal:`scale("${u}", ${V(e,{expr:"datum"})} + ${e.bin.step})`,offset:_}}}W(lL(p))}function aC({fieldDef:e,scaleName:t,bandPosition:n,offset:i,useRectOffsetField:r}){return Og({scaleName:t,fieldOrDatumDef:e,bandPosition:n,offset:i,...r?{startSuffix:Om,endSuffix:Dm}:{}})}const Fue=new Set(["aria","width","height"]);function li(e,t){const{fill:n=void 0,stroke:i=void 0}=t.color==="include"?K6(e):{};return{...Mue(e.markDef,t),...uC("fill",n),...uC("stroke",i),...Ct("opacity",e),...Ct("fillOpacity",e),...Ct("strokeOpacity",e),...Ct("strokeWidth",e),...Ct("strokeDash",e),...xue(e),...Y6(e),...t_(e,"href"),...yue(e)}}function uC(e,t){return t?{[e]:t}:{}}function Mue(e,t){return Iie.reduce((n,i)=>(!Fue.has(i)&&q(e,i)&&t[i]!=="ignore"&&(n[i]=qe(e[i])),n),{})}function r_(e){const{config:t,markDef:n}=e,i=new Set;if(e.forEachFieldDef((r,o)=>{var l;let s;if(!_r(o)||!(s=e.getScaleType(o)))return;const a=pm(r.aggregate),u=NE({scaleChannel:o,markDef:n,config:t,scaleType:s,isCountAggregate:a});if(Xoe(u)){const c=e.vgField(o,{expr:"datum",binSuffix:(l=e.stack)!=null&&l.impute?"mid":void 0});c&&i.add(c)}}),i.size>0)return{defined:{signal:[...i].map(o=>vm(o,!0)).join(" && ")}}}function lC(e,t){if(t!==void 0)return{[e]:qe(t)}}const p1="voronoi",Z6={defined:e=>e.type==="point"&&e.nearest,parse:(e,t)=>{if(t.events)for(const n of t.events)n.markname=e.getName(p1)},marks:(e,t,n)=>{const{x:i,y:r}=t.project.hasChannel,o=e.mark;if(fs(o))return W(Hie(o)),n;const s={name:e.getName(p1),type:"path",interactive:!0,aria:!1,from:{data:e.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},...Y6(e,{reactiveGeom:!0})}},transform:[{type:"voronoi",x:{expr:i||!r?"datum.datum.x || 0":"0"},y:{expr:r||!i?"datum.datum.y || 0":"0"},size:[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]}]};let a=0,u=!1;return n.forEach((l,c)=>{const f=l.name??"";f===e.component.mark[0].name?a=c:f.includes(p1)&&(u=!0)}),u||n.splice(a+1,0,s),n}},eP={defined:e=>e.type==="point"&&e.resolve==="global"&&e.bind&&e.bind!=="scales"&&!YE(e.bind),parse:(e,t,n)=>uP(t,n),topLevelSignals:(e,t,n)=>{var u;const i=t.name,r=t.project,o=t.bind,s=(u=t.init)==null?void 0:u[0],a=Z6.defined(t)?"(item().isVoronoi ? datum.datum : datum)":"datum";return r.items.forEach((l,c)=>{const f=Ye(`${i}_${l.field}`);n.filter(h=>h.name===f).length||n.unshift({name:f,...s?{init:fa(s[c])}:{value:null},on:t.events?[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${a}[${G(l.field)}] : null`}]:[],bind:o[l.field]??o[l.channel]??o})}),n},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.find(l=>l.name===i+no),s=i+Jf,a=r.items.map(l=>Ye(`${i}_${l.field}`)),u=a.map(l=>`${l} !== null`).join(" && ");return a.length&&(o.update=`${u} ? {fields: ${s}, values: [${a.join(", ")}]} : null`),delete o.value,delete o.on,n}},Ug="_toggle",tP={defined:e=>e.type==="point"&&!tr(e)&&!!e.toggle,signals:(e,t,n)=>n.concat({name:t.name+Ug,value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{const n=t.name+no,i=t.name+Ug;return`${i} ? null : ${n}, ${t.resolve==="global"?`${i} ? null : true, `:`${i} ? null : {unit: ${qs(e)}}, `}${i} ? ${n} : null`}},Tue={defined:e=>e.clear!==void 0&&e.clear!==!1&&!tr(e),parse:(e,t)=>{t.clear&&(t.clear=J(t.clear)?rs(t.clear,"view"):t.clear)},topLevelSignals:(e,t,n)=>{if(eP.defined(t))for(const i of t.project.items){const r=n.findIndex(o=>o.name===Ye(`${t.name}_${i.field}`));r!==-1&&n[r].on.push({events:t.clear,update:"null"})}return n},signals:(e,t,n)=>{function i(r,o){r!==-1&&n[r].on&&n[r].on.push({events:t.clear,update:o})}if(t.type==="interval")for(const r of t.project.items){const o=n.findIndex(s=>s.name===r.signals.visual);if(i(o,"[0, 0]"),o===-1){const s=n.findIndex(a=>a.name===r.signals.data);i(s,"null")}}else{let r=n.findIndex(o=>o.name===t.name+no);i(r,"null"),tP.defined(t)&&(r=n.findIndex(o=>o.name===t.name+Ug),i(r,"false"))}return n}},nP={defined:e=>{const t=e.resolve==="global"&&e.bind&&YE(e.bind),n=e.project.items.length===1&&e.project.items[0].field!==Ti;return t&&!n&&W(Xie),t&&n},parse:(e,t,n)=>{const i=ce(n);if(i.select=J(i.select)?{type:i.select,toggle:t.toggle}:{...i.select,toggle:t.toggle},uP(t,i),K(n.select)&&(n.select.on||n.select.clear)){const s='event.item && indexof(event.item.mark.role, "legend") < 0';for(const a of t.events)a.filter=Q(a.filter??[]),a.filter.includes(s)||a.filter.push(s)}const r=l1(t.bind)?t.bind.legend:"click",o=J(r)?rs(r,"view"):Q(r);t.bind={legend:{merge:o}}},topLevelSignals:(e,t,n)=>{const i=t.name,r=l1(t.bind)&&t.bind.legend,o=s=>a=>{const u=ce(a);return u.markname=s,u};for(const s of t.project.items){if(!s.hasLegend)continue;const a=`${Ye(s.field)}_legend`,u=`${i}_${a}`;if(n.filter(c=>c.name===u).length===0){const c=r.merge.map(o(`${a}_symbols`)).concat(r.merge.map(o(`${a}_labels`))).concat(r.merge.map(o(`${a}_entries`)));n.unshift({name:u,...t.init?{}:{value:null},on:[{events:c,update:"isDefined(datum.value) ? datum.value : item().items[0].items[0].datum.value",force:!0},{events:r.merge,update:`!event.item || !datum ? null : ${u}`,force:!0}]})}}return n},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.find(d=>d.name===i+no),s=i+Jf,a=r.items.filter(d=>d.hasLegend).map(d=>Ye(`${i}_${Ye(d.field)}_legend`)),l=`${a.map(d=>`${d} !== null`).join(" && ")} ? {fields: ${s}, values: [${a.join(", ")}]} : null`;t.events&&a.length>0?o.on.push({events:a.map(d=>({signal:d})),update:l}):a.length>0&&(o.update=l,delete o.value,delete o.on);const c=n.find(d=>d.name===i+Ug),f=l1(t.bind)&&t.bind.legend;return c&&(t.events?c.on.push({...c.on[0],events:f}):c.on[0].events=f),n}};function Nue(e,t,n){var r;const i=(r=e.fieldDef(t))==null?void 0:r.field;for(const o of ot(e.component.selection??{})){const s=o.project.hasField[i]??o.project.hasChannel[t];if(s&&nP.defined(o)){const a=n.get("selections")??[];a.push(o.name),n.set("selections",a,!1),s.hasLegend=!0}}}const iP="_translate_anchor",rP="_translate_delta",Rue={defined:e=>e.type==="interval"&&e.translate,signals:(e,t,n)=>{const i=t.name,r=Yr.defined(t),o=i+iP,{x:s,y:a}=t.project.hasChannel;let u=rs(t.translate,"scope");return r||(u=u.map(l=>(l.between[0].markname=i+cu,l))),n.push({name:o,value:{},on:[{events:u.map(l=>l.between[0]),update:`{x: x(unit), y: y(unit)${s!==void 0?`, extent_x: ${r?Bb(e,We):`slice(${s.signals.visual})`}`:""}${a!==void 0?`, extent_y: ${r?Bb(e,dt):`slice(${a.signals.visual})`}`:""}}`}]},{name:i+rP,value:{},on:[{events:u,update:`{x: ${o}.x - x(unit), y: ${o}.y - y(unit)}`}]}),s!==void 0&&cC(e,t,s,"width",n),a!==void 0&&cC(e,t,a,"height",n),n}};function cC(e,t,n,i,r){const o=t.name,s=o+iP,a=o+rP,u=n.channel,l=Yr.defined(t),c=r.find(E=>E.name===n.signals[l?"data":"visual"]),f=e.getSizeSignalRef(i).signal,d=e.getScaleComponent(u),h=d==null?void 0:d.get("type"),g=d==null?void 0:d.get("reverse"),p=l?u===We?g?"":"-":g?"-":"":"",m=`${s}.extent_${u}`,y=`${p}${a}.${u} / ${l?`${f}`:`span(${m})`}`,b=!l||!d?"panLinear":h==="log"?"panLog":h==="symlog"?"panSymlog":h==="pow"?"panPow":"panLinear",v=l?h==="pow"?`, ${d.get("exponent")??1}`:h==="symlog"?`, ${d.get("constant")??1}`:"":"",x=`${b}(${m}, ${y}${v})`;c.on.push({events:{signal:a},update:l?x:`clampRange(${x}, 0, ${f})`})}const oP="_zoom_anchor",sP="_zoom_delta",Oue={defined:e=>e.type==="interval"&&e.zoom,signals:(e,t,n)=>{const i=t.name,r=Yr.defined(t),o=i+sP,{x:s,y:a}=t.project.hasChannel,u=G(e.scaleName(We)),l=G(e.scaleName(dt));let c=rs(t.zoom,"scope");return r||(c=c.map(f=>(f.markname=i+cu,f))),n.push({name:i+oP,on:[{events:c,update:r?`{${[u?`x: invert(${u}, x(unit))`:"",l?`y: invert(${l}, y(unit))`:""].filter(f=>f).join(", ")}}`:"{x: x(unit), y: y(unit)}"}]},{name:o,on:[{events:c,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),s!==void 0&&fC(e,t,s,"width",n),a!==void 0&&fC(e,t,a,"height",n),n}};function fC(e,t,n,i,r){const o=t.name,s=n.channel,a=Yr.defined(t),u=r.find(b=>b.name===n.signals[a?"data":"visual"]),l=e.getSizeSignalRef(i).signal,c=e.getScaleComponent(s),f=c==null?void 0:c.get("type"),d=a?Bb(e,s):u.name,h=o+sP,g=`${o}${oP}.${s}`,p=!a||!c?"zoomLinear":f==="log"?"zoomLog":f==="symlog"?"zoomSymlog":f==="pow"?"zoomPow":"zoomLinear",m=a?f==="pow"?`, ${c.get("exponent")??1}`:f==="symlog"?`, ${c.get("constant")??1}`:"":"",y=`${p}(${d}, ${g}, ${h}${m})`;u.on.push({events:{signal:h},update:a?y:`clampRange(${y}, 0, ${l})`})}const da="_store",no="_tuple",Due="_modify",aP="vlSelectionResolve",Lm=[aue,pue,rue,tP,eP,Yr,nP,Tue,Rue,Oue,Z6];function Lue(e){let t=e.parent;for(;t&&!zn(t);)t=t.parent;return t}function qs(e,{escape:t}={escape:!0}){let n=t?G(e.name):e.name;const i=Lue(e);if(i){const{facet:r}=i;for(const o of Jn)r[o]&&(n+=` + '__facet_${o}_' + (facet[${G(i.vgField(o))}])`)}return n}function o_(e){return ot(e.component.selection??{}).reduce((t,n)=>t||n.project.hasSelectionId,!1)}function uP(e,t){(J(t.select)||!t.select.on)&&delete e.events,(J(t.select)||!t.select.clear)&&delete e.clear,(J(t.select)||!t.select.toggle)&&delete e.toggle}function tr(e){var t;return(t=e.events)==null?void 0:t.find(n=>"type"in n&&n.type==="timer")}function jb(e){const t=[];return e.type==="Identifier"?[e.name]:e.type==="Literal"?[e.value]:(e.type==="MemberExpression"&&(t.push(...jb(e.object)),t.push(...jb(e.property))),t)}function lP(e){return e.object.type==="MemberExpression"?lP(e.object):e.object.name==="datum"}function cP(e){const t=Ew(e),n=new Set;return t.visit(i=>{i.type==="MemberExpression"&&lP(i)&&n.add(jb(i).slice(1).join("."))}),n}class bl extends Le{constructor(n,i,r){super(n);I(this,"model");I(this,"filter");I(this,"expr");I(this,"_dependentFields");this.model=i,this.filter=r,this.expr=jg(this.model,this.filter,this),this._dependentFields=cP(this.expr)}clone(){return new bl(null,this.model,ce(this.filter))}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function Pue(e,t){const n={},i=e.config.selection;if(!t||!t.length)return n;let r=0;for(const o of t){const s=Ye(o.name),a=o.select,u=J(a)?a:a.type,l=K(a)?ce(a):{type:u},c=i[u];for(const h in c)h==="fields"||h==="encodings"||(h==="mark"&&(l.mark={...c.mark,...l.mark}),(l[h]===void 0||l[h]===!0)&&(l[h]=ce(c[h]??l[h])));const f=n[s]={...l,name:s,type:u,init:o.value,bind:o.bind,events:J(l.on)?rs(l.on,"scope"):Q(ce(l.on))};if(tr(f)&&(r++,r>1)){delete n[s];continue}const d=ce(o);for(const h of Lm)h.defined(f)&&h.parse&&h.parse(e,f,d)}return r>1&&W(tre),n}function fP(e,t,n,i="datum"){const r=J(t)?t:t.param,o=Ye(r),s=G(o+da);let a;try{a=e.getSelectionComponent(o,r)}catch{return`!!${o}`}if(a.project.timeUnit){const d=n??e.component.data.raw,h=a.project.timeUnit.clone();d.parent?h.insertAsParentOf(d):d.parent=h}const u=a.project.hasSelectionId?"vlSelectionIdTest(":"vlSelectionTest(",l=a.resolve==="global"?")":`, ${G(a.resolve)})`,c=`${u}${s}, ${i}${l}`,f=`length(data(${s}))`;return t.empty===!1?`${f} && ${c}`:`!${f} || ${c}`}function dP(e,t,n){const i=Ye(t),r=n.encoding;let o=n.field,s;try{s=e.getSelectionComponent(i,t)}catch{return i}if(!r&&!o)o=s.project.items[0].field,s.project.items.length>1&&W(nre(o));else if(r&&!o){const a=s.project.items.filter(u=>u.channel===r);!a.length||a.length>1?(o=s.project.items[0].field,W(ire(a,r,n,o))):o=a[0].field}return`${s.name}[${G(oi(o))}]`}function Iue(e,t){for(const[n,i]of Xo(e.component.selection??{})){const r=e.getName(`lookup_${n}`);e.component.data.outputNodes[r]=i.materialized=new bn(new bl(t,e,{param:n}),r,Xe.Lookup,e.component.data.outputNodeRefCounts)}}function jg(e,t,n){return Cc(t,i=>J(i)?i:hoe(i)?fP(e,i,n):wL(i))}function zue(e,t){if(e)return P(e)&&!Eo(e)?e.map(n=>zE(n,t)).join(", "):e}function m1(e,t,n,i){var r,o;e.encode??(e.encode={}),(r=e.encode)[t]??(r[t]={}),(o=e.encode[t]).update??(o.update={}),e.encode[t].update[n]=i}function pc(e,t,n,i={header:!1}){var f,d;const{disable:r,orient:o,scale:s,labelExpr:a,title:u,zindex:l,...c}=e.combine();if(!r){for(const h in c){const g=h,p=yse[g],m=c[g];if(p&&p!==t&&p!=="both")delete c[g];else if(Kf(m)){const{condition:y,...b}=m,v=Q(y),x=zA[g];if(x){const{vgProp:E,part:_}=x,w=[...v.map(S=>{const{test:$,...A}=S;return{test:jg(null,$),...A}}),b];m1(c,_,E,w),delete c[g]}else if(x===null){const E={signal:v.map(_=>{const{test:w,...S}=_;return`${jg(null,w)} ? ${_A(S)} : `}).join("")+_A(b)};c[g]=E}}else if(ne(m)){const y=zA[g];if(y){const{vgProp:b,part:v}=y;m1(c,v,b,m),delete c[g]}}we(["labelAlign","labelBaseline"],g)&&c[g]===null&&delete c[g]}if(t==="grid"){if(!c.grid)return;if(c.encode){const{grid:h}=c.encode;c.encode={...h?{grid:h}:{}},Be(c.encode)&&delete c.encode}return{scale:s,orient:o,...c,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:nt(l,0)}}else{if(!i.header&&e.mainExtracted)return;if(a!==void 0){let g=a;(d=(f=c.encode)==null?void 0:f.labels)!=null&&d.update&&ne(c.encode.labels.update.text)&&(g=ra(a,"datum.label",c.encode.labels.update.text.signal)),m1(c,"labels","text",{signal:g})}if(c.labelAlign===null&&delete c.labelAlign,c.encode){for(const g of JL)e.hasAxisPart(g)||delete c.encode[g];Be(c.encode)&&delete c.encode}const h=zue(u,n);return{scale:s,orient:o,grid:!1,...h?{title:h}:{},...c,...n.aria===!1?{aria:!1}:{},zindex:nt(l,0)}}}}function hP(e){const{axes:t}=e.component,n=[];for(const i of lo)if(t[i]){for(const r of t[i])if(!r.get("disable")&&!r.get("gridScale")){const o=i==="x"?"height":"width",s=e.getSizeSignalRef(o).signal;o!==s&&n.push({name:o,update:s})}}return n}function Bue(e,t){const{x:n=[],y:i=[]}=e;return[...n.map(r=>pc(r,"grid",t)),...i.map(r=>pc(r,"grid",t)),...n.map(r=>pc(r,"main",t)),...i.map(r=>pc(r,"main",t))].filter(r=>r)}function dC(e,t,n,i){return Object.assign.apply(null,[{},...e.map(r=>{if(r==="axisOrient"){const o=n==="x"?"bottom":"left",s=t[n==="x"?"axisBottom":"axisLeft"]||{},a=t[n==="x"?"axisTop":"axisRight"]||{},u=new Set([...U(s),...U(a)]),l={};for(const c of u.values())l[c]={signal:`${i.signal} === "${o}" ? ${wi(s[c])} : ${wi(a[c])}`};return l}return t[r]})])}function Uue(e,t,n,i){const r=t==="band"?["axisDiscrete","axisBand"]:t==="point"?["axisDiscrete","axisPoint"]:SL(t)?["axisQuantitative"]:t==="time"||t==="utc"?["axisTemporal"]:[],o=e==="x"?"axisX":"axisY",s=ne(n)?"axisOrient":`axis${zf(n)}`,a=[...r,...r.map(l=>o+l.substr(4))],u=["axis",s,o];return{vlOnlyAxisConfig:dC(a,i,e,n),vgAxisConfig:dC(u,i,e,n),axisConfigStyle:jue([...u,...a],i)}}function jue(e,t){var i;const n=[{}];for(const r of e){let o=(i=t[r])==null?void 0:i.style;if(o){o=Q(o);for(const s of o)n.push(t.style[s])}}return Object.assign.apply(null,n)}function qb(e,t,n,i={}){var o;const r=Z5(e,n,t);if(r!==void 0)return{configFrom:"style",configValue:r};for(const s of["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"])if(((o=i[s])==null?void 0:o[e])!==void 0)return{configFrom:s,configValue:i[s][e]};return{}}const hC={scale:({model:e,channel:t})=>e.scaleName(t),format:({format:e})=>e,formatType:({formatType:e})=>e,grid:({fieldOrDatumDef:e,axis:t,scaleType:n})=>t.grid??que(n,e),gridScale:({model:e,channel:t})=>Wue(e,t),labelAlign:({axis:e,labelAngle:t,orient:n,channel:i})=>e.labelAlign||pP(t,n,i),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:t,orient:n,channel:i})=>e.labelBaseline||gP(t,n,i),labelFlush:({axis:e,fieldOrDatumDef:t,channel:n})=>e.labelFlush??Gue(t.type,n),labelOverlap:({axis:e,fieldOrDatumDef:t,scaleType:n})=>e.labelOverlap??Yue(t.type,n,j(t)&&!!t.timeUnit,j(t)?t.sort:void 0),orient:({orient:e})=>e,tickCount:({channel:e,model:t,axis:n,fieldOrDatumDef:i,scaleType:r})=>{const o=e==="x"?"width":e==="y"?"height":void 0,s=o?t.getSizeSignalRef(o):void 0;return n.tickCount??Xue({fieldOrDatumDef:i,scaleType:r,size:s,values:n.values})},tickMinStep:({axis:e,format:t,fieldOrDatumDef:n})=>e.tickMinStep??Kue({format:t,fieldOrDatumDef:n}),title:({axis:e,model:t,channel:n})=>{if(e.title!==void 0)return e.title;const i=mP(t,n);if(i!==void 0)return i;const r=t.typedFieldDef(n),o=n==="x"?"x2":"y2",s=t.fieldDef(o);return tL(r?[PA(r)]:[],j(s)?[PA(s)]:[])},values:({axis:e,fieldOrDatumDef:t})=>Jue(e,t),zindex:({axis:e,fieldOrDatumDef:t,mark:n})=>e.zindex??Que(n,t)};function que(e,t){return!et(e)&&j(t)&&!Ue(t==null?void 0:t.bin)&&!$t(t==null?void 0:t.bin)}function Wue(e,t){const n=t==="x"?"y":"x";if(e.getScaleComponent(n))return e.scaleName(n)}function Hue(e,t,n,i,r){const o=t==null?void 0:t.labelAngle;if(o!==void 0)return ne(o)?o:ef(o);{const{configValue:s}=qb("labelAngle",i,t==null?void 0:t.style,r);return s!==void 0?ef(s):n===We&&we([AE,kE],e.type)&&!(j(e)&&e.timeUnit)?270:void 0}}function Wb(e){return`(((${e.signal} % 360) + 360) % 360)`}function gP(e,t,n,i){if(e!==void 0)if(n==="x"){if(ne(e)){const r=Wb(e),o=ne(t)?`(${t.signal} === "top")`:t==="top";return{signal:`(45 < ${r} && ${r} < 135) || (225 < ${r} && ${r} < 315) ? "middle" :(${r} <= 45 || 315 <= ${r}) === ${o} ? "bottom" : "top"`}}if(45{if(Ta(r)&&BL(r.sort)){const{field:s,timeUnit:a}=r,u=r.sort,l=u.map((c,f)=>`${wL({field:s,timeUnit:a,equal:c})} ? ${f} : `).join("")+u.length;n=new Gu(n,{calculate:l,as:Yu(r,o,{forAs:!0})})}}),n}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:"formula",expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${ye(this.transform)}`}}function Yu(e,t,n){return V(e,{prefix:t,suffix:"sort_index",...n})}function Pm(e,t){return we(["top","bottom"],t)?"column":we(["left","right"],t)||e==="row"?"row":"column"}function Vu(e,t,n,i){const r=i==="row"?n.headerRow:i==="column"?n.headerColumn:n.headerFacet;return nt((t||{})[e],r[e],n.header[e])}function Im(e,t,n,i){const r={};for(const o of e){const s=Vu(o,t||{},n,i);s!==void 0&&(r[o]=s)}return r}const s_=["row","column"],a_=["header","footer"];function Zue(e,t){const n=e.component.layoutHeaders[t].title,i=e.config?e.config:void 0,r=e.component.layoutHeaders[t].facetFieldDef?e.component.layoutHeaders[t].facetFieldDef:void 0,{titleAnchor:o,titleAngle:s,titleOrient:a}=Im(["titleAnchor","titleAngle","titleOrient"],r.header,i,t),u=Pm(t,a),l=ef(s);return{name:`${t}-title`,type:"group",role:`${u}-title`,title:{text:n,...t==="row"?{orient:"left"}:{},style:"guide-title",...bP(l,u),...yP(u,l,o),...vP(i,r,t,zse,p6)}}}function yP(e,t,n="middle"){switch(n){case"start":return{align:"left"};case"end":return{align:"right"}}const i=pP(t,e==="row"?"left":"top",e==="row"?"y":"x");return i?{align:i}:{}}function bP(e,t){const n=gP(e,t==="row"?"left":"top",t==="row"?"y":"x",!0);return n?{baseline:n}:{}}function ele(e,t){const n=e.component.layoutHeaders[t],i=[];for(const r of a_)if(n[r])for(const o of n[r]){const s=nle(e,t,r,n,o);s!=null&&i.push(s)}return i}function tle(e,t){const{sort:n}=e;return Gr(n)?{field:V(n,{expr:"datum"}),order:n.order??"ascending"}:P(n)?{field:Yu(e,t,{expr:"datum"}),order:"ascending"}:{field:V(e,{expr:"datum"}),order:n??"ascending"}}function Hb(e,t,n){const{format:i,formatType:r,labelAngle:o,labelAnchor:s,labelOrient:a,labelExpr:u}=Im(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],e.header,n,t),l=DE({fieldOrDatumDef:e,format:i,formatType:r,expr:"parent",config:n}).signal,c=Pm(t,a);return{text:{signal:u?ra(ra(u,"datum.label",l),"datum.value",V(e,{expr:"parent"})):l},...t==="row"?{orient:"left"}:{},style:"guide-label",frame:"group",...bP(o,c),...yP(c,o,s),...vP(n,e,t,Bse,m6)}}function nle(e,t,n,i,r){if(r){let o=null;const{facetFieldDef:s}=i,a=e.config?e.config:void 0;if(s&&r.labels){const{labelOrient:f}=Im(["labelOrient"],s.header,a,t);(t==="row"&&!we(["top","bottom"],f)||t==="column"&&!we(["left","right"],f))&&(o=Hb(s,t,a))}const u=zn(e)&&!Gf(e.facet),l=r.axes,c=(l==null?void 0:l.length)>0;if(o||c){const f=t==="row"?"height":"width";return{name:e.getName(`${t}_${n}`),type:"group",role:`${t}-${n}`,...i.facetFieldDef?{from:{data:e.getName(`${t}_domain`)},sort:tle(s,t)}:{},...c&&u?{from:{data:e.getName(`facet_domain_${t}`)}}:{},...o?{title:o}:{},...r.sizeSignal?{encode:{update:{[f]:r.sizeSignal}}}:{},...c?{axes:l}:{}}}}return null}const ile={column:{start:0,end:1},row:{start:1,end:0}};function rle(e,t){return ile[t][e]}function ole(e,t){const n={};for(const i of Jn){const r=e[i];if(r!=null&&r.facetFieldDef){const{titleAnchor:o,titleOrient:s}=Im(["titleAnchor","titleOrient"],r.facetFieldDef.header,t,i),a=Pm(i,s),u=rle(o,a);u!==void 0&&(n[a]=u)}}return Be(n)?void 0:n}function vP(e,t,n,i,r){const o={};for(const s of i){if(!r[s])continue;const a=Vu(s,t==null?void 0:t.header,e,n);a!==void 0&&(o[r[s]]=a)}return o}function u_(e){return[...Td(e,"width"),...Td(e,"height"),...Td(e,"childWidth"),...Td(e,"childHeight")]}function Td(e,t){const n=t==="width"?"x":"y",i=e.component.layoutSize.get(t);if(i==null||i==="merged")return[];const r=e.getSizeSignalRef(t).signal;if(i==="step"){const o=e.getScaleComponent(n);if(o){const s=o.get("type"),a=o.get("range");if(et(s)&&Ca(a)){const u=e.scaleName(n);return zn(e.parent)&&e.parent.component.resolve.scale[n]==="independent"?[gC(u,a)]:[gC(u,a),{name:r,update:xP(u,o,`domain('${u}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}else if(i=="container"){const o=r.endsWith("width"),s=o?"containerSize()[0]":"containerSize()[1]",a=Ob(e.config.view,o?"width":"height"),u=`isFinite(${s}) ? ${s} : ${a}`;return[{name:r,init:u,on:[{update:u,events:"window:resize"}]}]}else return[{name:r,value:i}]}function gC(e,t){const n=`${e}_step`;return ne(t.step)?{name:n,update:t.step.signal}:{name:n,value:t.step}}function xP(e,t,n){const i=t.get("type"),r=t.get("padding"),o=nt(t.get("paddingOuter"),r);let s=t.get("paddingInner");return s=i==="band"?s!==void 0?s:r:1,`bandspace(${n}, ${wi(s)}, ${wi(o)}) * ${e}_step`}function wP(e){return e==="childWidth"?"width":e==="childHeight"?"height":e}function EP(e,t){return U(e).reduce((n,i)=>({...n,...yl({model:t,channelDef:e[i],vgChannel:i,mainRefFn:r=>qe(r.value),invalidValueRef:void 0})}),{})}function _P(e,t){if(zn(t))return e==="theta"?"independent":"shared";if(wl(t))return"shared";if(p_(t))return it(e)||e==="theta"||e==="radius"?"independent":"shared";throw new Error("invalid model type for resolve")}function l_(e,t){const n=e.scale[t],i=it(t)?"axis":"legend";return n==="independent"?(e[i][t]==="shared"&&W(Ore(t)),"independent"):e[i][t]||"shared"}const sle={...qse,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1},SP=U(sle);class ale extends fo{}const pC={symbols:ule,gradient:lle,labels:cle,entries:fle};function ule(e,{fieldOrDatumDef:t,model:n,channel:i,legendCmpt:r,legendType:o}){if(o!=="symbol")return;const{markDef:s,encoding:a,config:u,mark:l}=n,c=s.filled&&l!=="trail";let f={...jie({},n,zoe),...K6(n,{filled:c})};const d=r.get("symbolOpacity")??u.legend.symbolOpacity,h=r.get("symbolFillColor")??u.legend.symbolFillColor,g=r.get("symbolStrokeColor")??u.legend.symbolStrokeColor,p=d===void 0?$P(a.opacity)??s.opacity:void 0;if(f.fill){if(i==="fill"||c&&i===_n)delete f.fill;else if(q(f.fill,"field"))h?delete f.fill:(f.fill=qe(u.legend.symbolBaseFillColor??"black"),f.fillOpacity=qe(p??1));else if(P(f.fill)){const m=Gb(a.fill??a.color)??s.fill??(c&&s.color);m&&(f.fill=qe(m))}}if(f.stroke){if(i==="stroke"||!c&&i===_n)delete f.stroke;else if(q(f.stroke,"field")||g)delete f.stroke;else if(P(f.stroke)){const m=nt(Gb(a.stroke||a.color),s.stroke,c?s.color:void 0);m&&(f.stroke={value:m})}}if(i!==uo){const m=j(t)&&AP(n,r,t);m?f.opacity=[{test:m,...qe(p??1)},qe(u.legend.unselectedOpacity)]:p&&(f.opacity=qe(p))}return f={...f,...e},Be(f)?void 0:f}function lle(e,{model:t,legendType:n,legendCmpt:i}){if(n!=="gradient")return;const{config:r,markDef:o,encoding:s}=t;let a={};const l=(i.get("gradientOpacity")??r.legend.gradientOpacity)===void 0?$P(s.opacity)||o.opacity:void 0;return l&&(a.opacity=qe(l)),a={...a,...e},Be(a)?void 0:a}function cle(e,{fieldOrDatumDef:t,model:n,channel:i,legendCmpt:r}){const o=n.legend(i)||{},s=n.config,a=j(t)?AP(n,r,t):void 0,u=a?[{test:a,value:1},{value:s.legend.unselectedOpacity}]:void 0,{format:l,formatType:c}=o;let f;ca(c)?f=Ei({fieldOrDatumDef:t,field:"datum.value",format:l,formatType:c,config:s}):l===void 0&&c===void 0&&s.customFormatTypes&&(t.type==="quantitative"&&s.numberFormatType?f=Ei({fieldOrDatumDef:t,field:"datum.value",format:s.numberFormat,formatType:s.numberFormatType,config:s}):t.type==="temporal"&&s.timeFormatType&&j(t)&&t.timeUnit===void 0&&(f=Ei({fieldOrDatumDef:t,field:"datum.value",format:s.timeFormat,formatType:s.timeFormatType,config:s})));const d={...u?{opacity:u}:{},...f?{text:f}:{},...e};return Be(d)?void 0:d}function fle(e,{legendCmpt:t}){const n=t.get("selections");return n!=null&&n.length?{...e,fill:{value:"transparent"}}:e}function $P(e){return kP(e,(t,n)=>Math.max(t,n.value))}function Gb(e){return kP(e,(t,n)=>nt(t,n.value))}function kP(e,t){if(ose(e))return Q(e.condition).reduce(t,e.value);if(Fi(e))return e.value}function AP(e,t,n){const i=t.get("selections");if(!(i!=null&&i.length))return;const r=G(n.field);return i.map(o=>`(!length(data(${G(Ye(o)+da)})) || (${o}[${r}] && indexof(${o}[${r}], datum.value) >= 0))`).join(" || ")}const mC={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:t,config:n})=>{const{format:i,formatType:r}=t;return PL(e,e.type,i,r,n,!1)},formatType:({legend:e,fieldOrDatumDef:t,scaleType:n})=>{const{formatType:i}=e;return IL(i,t,n)},gradientLength:e=>{const{legend:t,legendConfig:n}=e;return t.gradientLength??n.gradientLength??ble(e)},labelOverlap:({legend:e,legendConfig:t,scaleType:n})=>e.labelOverlap??t.labelOverlap??vle(n),symbolType:({legend:e,markDef:t,channel:n,encoding:i})=>e.symbolType??hle(t.type,n,i.shape,t.shape),title:({fieldOrDatumDef:e,config:t})=>lu(e,t,{allowDisabling:!0}),type:({legendType:e,scaleType:t,channel:n})=>{if(uu(n)&&Ki(t)){if(e==="gradient")return}else if(e==="symbol")return;return e},values:({fieldOrDatumDef:e,legend:t})=>dle(t,e)};function dle(e,t){const n=e.values;if(P(n))return KL(t,n);if(ne(n))return n}function hle(e,t,n,i){if(t!=="shape"){const r=Gb(n)??i;if(r)return r}switch(e){case"bar":case"rect":case"image":case"square":return"square";case"line":case"trail":case"rule":return"stroke";case"arc":case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return"circle"}}function gle(e){const{legend:t}=e;return nt(t.type,ple(e))}function ple({channel:e,timeUnit:t,scaleType:n}){if(uu(e)){if(we(["quarter","month","day"],t))return"symbol";if(Ki(n))return"gradient"}return"symbol"}function mle({legendConfig:e,legendType:t,orient:n,legend:i}){return i.direction??e[t?"gradientDirection":"symbolDirection"]??yle(n,t)}function yle(e,t){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return t==="gradient"?"horizontal":void 0}}function ble({legendConfig:e,model:t,direction:n,orient:i,scaleType:r}){const{gradientHorizontalMaxLength:o,gradientHorizontalMinLength:s,gradientVerticalMaxLength:a,gradientVerticalMinLength:u}=e;if(Ki(r))return n==="horizontal"?i==="top"||i==="bottom"?yC(t,"width",s,o):s:yC(t,"height",u,a)}function yC(e,t,n,i){return{signal:`clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${i})`}}function vle(e){if(we(["quantile","threshold","log","symlog"],e))return"greedy"}function CP(e){const t=Ge(e)?xle(e):Sle(e);return e.component.legends=t,t}function xle(e){const{encoding:t}=e,n={};for(const i of[_n,...b6]){const r=ct(t[i]);!r||!e.getScaleComponent(i)||i===Sn&&j(r)&&r.type===ml||(n[i]=_le(e,i))}return n}function wle(e,t){const n=e.scaleName(t);if(e.mark==="trail"){if(t==="color")return{stroke:n};if(t==="size")return{strokeWidth:n}}return t==="color"?e.markDef.filled?{fill:n}:{stroke:n}:{[t]:n}}function Ele(e,t,n,i){switch(t){case"disable":return n!==void 0;case"values":return!!(n!=null&&n.values);case"title":if(t==="title"&&e===(i==null?void 0:i.title))return!0}return e===(n||{})[t]}function _le(e,t){var x;let n=e.legend(t);const{markDef:i,encoding:r,config:o}=e,s=o.legend,a=new ale({},wle(e,t));Nue(e,t,a);const u=n!==void 0?!n:s.disable;if(a.set("disable",u,n!==void 0),u)return a;n=n||{};const l=e.getScaleComponent(t).get("type"),c=ct(r[t]),f=j(c)?(x=Et(c.timeUnit))==null?void 0:x.unit:void 0,d=n.orient||o.legend.orient||"right",h=gle({legend:n,channel:t,timeUnit:f,scaleType:l}),g=mle({legend:n,legendType:h,orient:d,legendConfig:s}),p={legend:n,channel:t,model:e,markDef:i,encoding:r,fieldOrDatumDef:c,legendConfig:s,config:o,scaleType:l,orient:d,legendType:h,direction:g};for(const E of SP){if(h==="gradient"&&E.startsWith("symbol")||h==="symbol"&&E.startsWith("gradient"))continue;const _=E in mC?mC[E](p):n[E];if(_!==void 0){const w=Ele(_,E,n,e.fieldDef(t));(w||o.legend[E]===void 0)&&a.set(E,_,w)}}const m=(n==null?void 0:n.encoding)??{},y=a.get("selections"),b={},v={fieldOrDatumDef:c,model:e,channel:t,legendCmpt:a,legendType:h};for(const E of["labels","legend","title","symbols","gradient","entries"]){const _=EP(m[E]??{},e),w=E in pC?pC[E](_,v):_;w!==void 0&&!Be(w)&&(b[E]={...y!=null&&y.length&&j(c)?{name:`${Ye(c.field)}_legend_${E}`}:{},...y!=null&&y.length?{interactive:!0}:{},update:y!=null&&y.length?{...w,cursor:{value:"pointer"}}:w})}return Be(b)||a.set("encode",b,!!(n!=null&&n.encoding)),a}function Sle(e){const{legends:t,resolve:n}=e.component;for(const i of e.children){CP(i);for(const r of U(i.component.legends))n.legend[r]=l_(e.component.resolve,r),n.legend[r]==="shared"&&(t[r]=FP(t[r],i.component.legends[r]),t[r]||(n.legend[r]="independent",delete t[r]))}for(const i of U(t))for(const r of e.children)r.component.legends[i]&&n.legend[i]==="shared"&&delete r.component.legends[i];return t}function FP(e,t){var o,s,a,u;if(!e)return t.clone();const n=e.getWithExplicit("orient"),i=t.getWithExplicit("orient");if(n.explicit&&i.explicit&&n.value!==i.value)return;let r=!1;for(const l of SP){const c=Jo(e.getWithExplicit(l),t.getWithExplicit(l),l,"legend",(f,d)=>{switch(l){case"symbolType":return $le(f,d);case"title":return iL(f,d);case"type":return r=!0,Cn("symbol")}return Rm(f,d,l,"legend")});e.setWithExplicit(l,c)}return r&&((s=(o=e.implicit)==null?void 0:o.encode)!=null&&s.gradient&&Tg(e.implicit,["encode","gradient"]),(u=(a=e.explicit)==null?void 0:a.encode)!=null&&u.gradient&&Tg(e.explicit,["encode","gradient"])),e}function $le(e,t){return t.value==="circle"?t:e}function kle(e,t,n,i){if(Xf(t,n)){const r=Ge(e)?e.axis(n)??e.legend(n)??{}:{},o=V(t,{expr:"datum"}),s=V(t,{expr:"datum",binSuffix:"end"});return{formulaAs:V(t,{binSuffix:"range",forAs:!0}),formula:Hf(o,s,r.format,r.formatType,i)}}return{}}function MP(e,t){return`${V5(e)}_${t}`}function Ale(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}function c_(e,t,n){const i=Am(n,void 0)??{},r=MP(i,t);return e.getName(`${r}_bins`)}function Cle(e){return"as"in e}function bC(e,t,n){let i,r;Cle(e)?i=J(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:i=[V(e,{forAs:!0}),V(e,{binSuffix:"end",forAs:!0})];const o={...Am(t,void 0)},s=MP(o,e.field),{signal:a,extentSignal:u}=Ale(n,s);if(mm(o.extent)){const c=o.extent;r=dP(n,c.param,c),delete o.extent}const l={bin:o,field:e.field,as:[i],...a?{signal:a}:{},...u?{extentSignal:u}:{},...r?{span:r}:{}};return{key:s,binComponent:l}}class nr extends Le{constructor(n,i){super(n);I(this,"bins");this.bins=i}clone(){return new nr(null,ce(this.bins))}static makeFromEncoding(n,i){const r=i.reduceFieldDef((o,s,a)=>{if(cn(s)&&Ue(s.bin)){const{key:u,binComponent:l}=bC(s,s.bin,i);o[u]={...l,...o[u],...kle(i,s,a,i.config)}}return o},{});return Be(r)?null:new nr(n,r)}static makeFromTransform(n,i,r){const{key:o,binComponent:s}=bC(i,i.bin,r);return new nr(n,{[o]:s})}merge(n,i){for(const r of U(n.bins))r in this.bins?(i(n.bins[r].signal,this.bins[r].signal),this.bins[r].as=Rn([...this.bins[r].as,...n.bins[r].as],ye)):this.bins[r]=n.bins[r];for(const r of n.children)n.removeChild(r),r.parent=this;n.remove()}producedFields(){return new Set(ot(this.bins).map(n=>n.as).flat(2))}dependentFields(){return new Set(ot(this.bins).map(n=>n.field))}hash(){return`Bin ${ye(this.bins)}`}assemble(){return ot(this.bins).flatMap(n=>{const i=[],[r,...o]=n.as,{extent:s,...a}=n.bin,u={type:"bin",field:oi(n.field),as:r,signal:n.signal,...mm(s)?{extent:null}:{extent:s},...n.span?{span:{signal:`span(${n.span})`}}:{},...a};!s&&n.extentSignal&&(i.push({type:"extent",field:oi(n.field),signal:n.extentSignal}),u.extent={signal:n.extentSignal}),i.push(u);for(const l of o)for(let c=0;c<2;c++)i.push({type:"formula",expr:V({field:r[c]},{expr:"datum"}),as:l[c]});return n.formula&&i.push({type:"formula",expr:n.formula,as:n.formulaAs}),i})}}function Fle(e,t,n,i){var o;const r=Ge(i)?i.encoding[Er(t)]:void 0;if(cn(n)&&Ge(i)&&jL(n,r,i.markDef,i.config)){e.add(V(n,{})),e.add(V(n,{suffix:"end"}));const{mark:s,markDef:a,config:u}=i,l=eo({fieldDef:n,markDef:a,config:u});tf(s)&&l!==.5&&it(t)&&(e.add(V(n,{suffix:Om})),e.add(V(n,{suffix:Dm}))),n.bin&&Xf(n,t)&&e.add(V(n,{binSuffix:"range"}))}else if(z5(t)){const s=I5(t);e.add(i.getName(s))}else e.add(V(n));return Ta(n)&&koe((o=n.scale)==null?void 0:o.range)&&e.add(n.scale.range.field),e}function Mle(e,t){for(const n of U(t)){const i=t[n];for(const r of U(i))n in e?e[n][r]=new Set([...e[n][r]??[],...i[r]]):e[n]={[r]:i[r]}}}class Si extends Le{constructor(n,i,r){super(n);I(this,"dimensions");I(this,"measures");this.dimensions=i,this.measures=r}clone(){return new Si(null,new Set(this.dimensions),ce(this.measures))}get groupBy(){return this.dimensions}static makeFromEncoding(n,i){let r=!1;i.forEachFieldDef(a=>{a.aggregate&&(r=!0)});const o={},s=new Set;return!r||(i.forEachFieldDef((a,u)=>{const{aggregate:l,field:c}=a;if(l)if(l==="count")o["*"]??(o["*"]={}),o["*"].count=new Set([V(a,{forAs:!0})]);else{if(Zr(l)||cs(l)){const f=Zr(l)?"argmin":"argmax",d=l[f];o[d]??(o[d]={}),o[d][f]=new Set([V({op:f,field:d},{forAs:!0})])}else o[c]??(o[c]={}),o[c][l]=new Set([V(a,{forAs:!0})]);_r(u)&&i.scaleDomain(u)==="unaggregated"&&(o[c]??(o[c]={}),o[c].min=new Set([V({field:c,aggregate:"min"},{forAs:!0})]),o[c].max=new Set([V({field:c,aggregate:"max"},{forAs:!0})]))}else Fle(s,u,a,i)}),s.size+U(o).length===0)?null:new Si(n,s,o)}static makeFromTransform(n,i){var s;const r=new Set,o={};for(const a of i.aggregate){const{op:u,field:l,as:c}=a;u&&(u==="count"?(o["*"]??(o["*"]={}),o["*"].count=new Set([c||V(a,{forAs:!0})])):(o[l]??(o[l]={}),(s=o[l])[u]??(s[u]=new Set),o[l][u].add(c||V(a,{forAs:!0}))))}for(const a of i.groupby??[])r.add(a);return r.size+U(o).length===0?null:new Si(n,r,o)}merge(n){return F5(this.dimensions,n.dimensions)?(Mle(this.measures,n.measures),!0):(Jre("different dimensions, cannot merge"),!1)}addDimensions(n){n.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...U(this.measures)])}producedFields(){const n=new Set;for(const i of U(this.measures))for(const r of U(this.measures[i])){const o=this.measures[i][r];o.size===0?n.add(`${r}_${i}`):o.forEach(n.add,n)}return n}hash(){return`Aggregate ${ye({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const n=[],i=[],r=[];for(const s of U(this.measures))for(const a of U(this.measures[s]))for(const u of this.measures[s][a])r.push(u),n.push(a),i.push(s==="*"?null:oi(s));return{type:"aggregate",groupby:[...this.dimensions].map(oi),ops:n,fields:i,as:r}}}class vl extends Le{constructor(n,i,r,o){super(n);I(this,"model");I(this,"name");I(this,"data");I(this,"column");I(this,"row");I(this,"facet");I(this,"childModel");this.model=i,this.name=r,this.data=o;for(const s of Jn){const a=i.facet[s];if(a){const{bin:u,sort:l}=a;this[s]={name:i.getName(`${s}_domain`),fields:[V(a),...Ue(u)?[V(a,{binSuffix:"end"})]:[]],...Gr(l)?{sortField:l}:P(l)?{sortIndexField:Yu(a,s)}:{}}}}this.childModel=i.child}hash(){let n="Facet";for(const i of Jn)this[i]&&(n+=` ${i.charAt(0)}:${ye(this[i])}`);return n}get fields(){var i;const n=[];for(const r of Jn)(i=this[r])!=null&&i.fields&&n.push(...this[r].fields);return n}dependentFields(){const n=new Set(this.fields);for(const i of Jn)this[i]&&(this[i].sortField&&n.add(this[i].sortField.field),this[i].sortIndexField&&n.add(this[i].sortIndexField));return n}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const n={};for(const i of lo){const r=this.childModel.component.scales[i];if(r&&!r.merged){const o=r.get("type"),s=r.get("range");if(et(o)&&Ca(s)){const a=ga(this.childModel,i),u=g_(a);u?n[i]=u:W(dE(i))}}}return n}assembleRowColumnHeaderData(n,i,r){const o={row:"y",column:"x",facet:void 0}[n],s=[],a=[],u=[];o&&r&&r[o]&&(i?(s.push(`distinct_${r[o]}`),a.push("max")):(s.push(r[o]),a.push("distinct")),u.push(`distinct_${r[o]}`));const{sortField:l,sortIndexField:c}=this[n];if(l){const{op:f=Sm,field:d}=l;s.push(d),a.push(f),u.push(V(l,{forAs:!0}))}else c&&(s.push(c),a.push("max"),u.push(c));return{name:this[n].name,source:i??this.data,transform:[{type:"aggregate",groupby:this[n].fields,...s.length?{fields:s,ops:a,as:u}:{}}]}}assembleFacetHeaderData(n){var l,c;const{columns:i}=this.model.layout,{layoutHeaders:r}=this.model.component,o=[],s={};for(const f of s_){for(const d of a_){const h=((l=r[f])==null?void 0:l[d])??[];for(const g of h)if(((c=g.axes)==null?void 0:c.length)>0){s[f]=!0;break}}if(s[f]){const d=`length(data("${this.facet.name}"))`,h=f==="row"?i?{signal:`ceil(${d} / ${i})`}:1:i?{signal:`min(${d}, ${i})`}:{signal:d};o.push({name:`${this.facet.name}_${f}`,transform:[{type:"sequence",start:0,stop:h}]})}}const{row:a,column:u}=s;return(a||u)&&o.unshift(this.assembleRowColumnHeaderData("facet",null,n)),o}assemble(){const n=[];let i=null;const r=this.getChildIndependentFieldsWithStep(),{column:o,row:s,facet:a}=this;if(o&&s&&(r.x||r.y)){i=`cross_${this.column.name}_${this.row.name}`;const u=[].concat(r.x??[],r.y??[]),l=u.map(()=>"distinct");n.push({name:i,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:u,ops:l}]})}for(const u of[Hr,Wr])this[u]&&n.push(this.assembleRowColumnHeaderData(u,i,r));if(a){const u=this.assembleFacetHeaderData(r);u&&n.push(...u)}return n}}function vC(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Tle(e,t){const n=tE(e);if(t==="number")return`toNumber(${n})`;if(t==="boolean")return`toBoolean(${n})`;if(t==="string")return`toString(${n})`;if(t==="date")return`toDate(${n})`;if(t==="flatten")return n;if(t.startsWith("date:")){const i=vC(t.slice(5,t.length));return`timeParse(${n},'${i}')`}else if(t.startsWith("utc:")){const i=vC(t.slice(4,t.length));return`utcParse(${n},'${i}')`}else return W(ore(t)),null}function Nle(e){const t={};return fh(e.filter,n=>{if(xL(n)){let i=null;bE(n)?i=Tn(n.equal):xE(n)?i=Tn(n.lte):vE(n)?i=Tn(n.lt):wE(n)?i=Tn(n.gt):EE(n)?i=Tn(n.gte):_E(n)?i=n.range[0]:SE(n)&&(i=(n.oneOf??n.in)[0]),i&&(Fa(i)?t[n.field]="date":ke(i)?t[n.field]="number":J(i)&&(t[n.field]="string")),n.timeUnit&&(t[n.field]="date")}}),t}function Rle(e){const t={};function n(i){qu(i)?t[i.field]="date":i.type==="quantitative"&&Rie(i.aggregate)?t[i.field]="number":Lu(i.field)>1?i.field in t||(t[i.field]="flatten"):Ta(i)&&Gr(i.sort)&&Lu(i.sort.field)>1&&(i.sort.field in t||(t[i.sort.field]="flatten"))}if((Ge(e)||zn(e))&&e.forEachFieldDef((i,r)=>{if(cn(i))n(i);else{const o=ka(r),s=e.fieldDef(o);n({...i,type:s.type})}}),Ge(e)){const{mark:i,markDef:r,encoding:o}=e;if(fs(i)&&!e.encoding.order){const s=r.orient==="horizontal"?"y":"x",a=o[s];j(a)&&a.type==="quantitative"&&!(a.field in t)&&(t[a.field]="number")}}return t}function Ole(e){const t={};if(Ge(e)&&e.component.selection)for(const n of U(e.component.selection)){const i=e.component.selection[n];for(const r of i.project.items)!r.channel&&Lu(r.field)>1&&(t[r.field]="flatten")}return t}class jt extends Le{constructor(n,i){super(n);I(this,"_parse");this._parse=i}clone(){return new jt(null,ce(this._parse))}hash(){return`Parse ${ye(this._parse)}`}static makeExplicit(n,i,r){var a;let o={};const s=i.data;return!Io(s)&&((a=s==null?void 0:s.format)!=null&&a.parse)&&(o=s.format.parse),this.makeWithAncestors(n,o,{},r)}static makeWithAncestors(n,i,r,o){for(const u of U(r)){const l=o.getWithExplicit(u);l.value!==void 0&&(l.explicit||l.value===r[u]||l.value==="derived"||r[u]==="flatten"?delete r[u]:W(FA(u,r[u],l.value)))}for(const u of U(i)){const l=o.get(u);l!==void 0&&(l===i[u]?delete i[u]:W(FA(u,i[u],l)))}const s=new fo(i,r);o.copyAll(s);const a={};for(const u of U(s.combine())){const l=s.get(u);l!==null&&(a[u]=l)}return U(a).length===0||o.parseNothing?null:new jt(n,a)}get parse(){return this._parse}merge(n){this._parse={...this._parse,...n.parse},n.remove()}assembleFormatParse(){const n={};for(const i of U(this._parse)){const r=this._parse[i];Lu(i)===1&&(n[i]=r)}return n}producedFields(){return new Set(U(this._parse))}dependentFields(){return new Set(U(this._parse))}assembleTransforms(n=!1){return U(this._parse).filter(i=>n?Lu(i)>1:!0).map(i=>{const r=Tle(i,this._parse[i]);return r?{type:"formula",expr:r,as:gl(i)}:null}).filter(i=>i!==null)}}class Qo extends Le{clone(){return new Qo(null)}constructor(t){super(t)}dependentFields(){return new Set}producedFields(){return new Set([Ti])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:Ti}}}class Qf extends Le{constructor(n,i){super(n);I(this,"params");this.params=i}clone(){return new Qf(null,this.params)}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${ye(this.params)}`}assemble(){return{type:"graticule",...this.params===!0?{}:this.params}}}class Zf extends Le{constructor(n,i){super(n);I(this,"params");this.params=i}clone(){return new Zf(null,this.params)}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??"data"])}hash(){return`Hash ${ye(this.params)}`}assemble(){return{type:"sequence",...this.params}}}class ha extends Le{constructor(n){super(null);I(this,"_data");I(this,"_name");I(this,"_generator");n??(n={name:"source"});let i;if(Io(n)||(i=n.format?{...In(n.format,["parse"])}:{}),nf(n))this._data={values:n.values};else if(Wu(n)){if(this._data={url:n.url},!i.type){let r=/(?:\.([^.]+))?$/.exec(n.url)[1];we(["json","csv","tsv","dsv","topojson"],r)||(r="json"),i.type=r}}else P6(n)?this._data={values:[{type:"Sphere"}]}:(D6(n)||Io(n))&&(this._data={});this._generator=Io(n),n.name&&(this._name=n.name),i&&!Be(i)&&(this._data.format=i)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(n){this._name=n}set parent(n){throw new Error("Source nodes have to be roots.")}remove(){throw new Error("Source nodes are roots and cannot be removed.")}hash(){throw new Error("Cannot hash sources")}assemble(){return{name:this._name,...this._data,transform:[]}}}function f_(e){return e instanceof ha||e instanceof Qf||e instanceof Zf}var du;class d_{constructor(){O_(this,du);Qm(this,du,!1)}setModified(){Qm(this,du,!0)}get modifiedFlag(){return R_(this,du)}}du=new WeakMap;class Na extends d_{getNodeDepths(t,n,i){i.set(t,n);for(const r of t.children)this.getNodeDepths(r,n+1,i);return i}optimize(t){const i=[...this.getNodeDepths(t,0,new Map).entries()].sort((r,o)=>o[1]-r[1]);for(const r of i)this.run(r[0]);return this.modifiedFlag}}class h_ extends d_{optimize(t){this.run(t);for(const n of t.children)this.optimize(n);return this.modifiedFlag}}class Dle extends h_{mergeNodes(t,n){const i=n.shift();for(const r of n)t.removeChild(r),r.parent=i,r.remove()}run(t){const n=t.children.map(r=>r.hash()),i={};for(let r=0;r1&&(this.setModified(),this.mergeNodes(t,i[r]))}}class Lle extends h_{constructor(n){super();I(this,"requiresSelectionId");this.requiresSelectionId=n&&o_(n)}run(n){n instanceof Qo&&(this.requiresSelectionId&&(f_(n.parent)||n.parent instanceof Si||n.parent instanceof jt)||(this.setModified(),n.remove()))}}class Ple extends d_{optimize(t){return this.run(t,new Set),this.modifiedFlag}run(t,n){let i=new Set;t instanceof er&&(i=t.producedFields(),Zw(i,n)&&(this.setModified(),t.removeFormulas(n),t.producedFields.length===0&&t.remove()));for(const r of t.children)this.run(r,new Set([...n,...i]))}}class Ile extends h_{constructor(){super()}run(t){t instanceof bn&&!t.isRequired()&&(this.setModified(),t.remove())}}class zle extends Na{run(t){if(!f_(t)&&!(t.numChildren()>1)){for(const n of t.children)if(n instanceof jt)if(t instanceof jt)this.setModified(),t.merge(n);else{if(eE(t.producedFields(),n.dependentFields()))continue;this.setModified(),n.swapWithParent()}}}}class Ble extends Na{run(t){const n=[...t.children],i=t.children.filter(r=>r instanceof jt);if(t.numChildren()>1&&i.length>=1){const r={},o=new Set;for(const s of i){const a=s.parse;for(const u of U(a))u in r?r[u]!==a[u]&&o.add(u):r[u]=a[u]}for(const s of o)delete r[s];if(!Be(r)){this.setModified();const s=new jt(t,r);for(const a of n){if(a instanceof jt)for(const u of U(r))delete a.parse[u];t.removeChild(a),a.parent=s,a instanceof jt&&U(a.parse).length===0&&a.remove()}}}}}class Ule extends Na{run(t){t instanceof bn||t.numChildren()>0||t instanceof vl||t instanceof ha||(this.setModified(),t.remove())}}class jle extends Na{run(t){const n=t.children.filter(r=>r instanceof er),i=n.pop();for(const r of n)this.setModified(),i.merge(r)}}class qle extends Na{run(t){const n=t.children.filter(r=>r instanceof Si),i={};for(const r of n){const o=ye(r.groupBy);o in i||(i[o]=[]),i[o].push(r)}for(const r of U(i)){const o=i[r];if(o.length>1){const s=o.pop();for(const a of o)s.merge(a)&&(t.removeChild(a),a.parent=s,a.remove(),this.setModified())}}}}class Wle extends Na{constructor(n){super();I(this,"model");this.model=n}run(n){const i=!(f_(n)||n instanceof bl||n instanceof jt||n instanceof Qo),r=[],o=[];for(const s of n.children)s instanceof nr&&(i&&!eE(n.producedFields(),s.dependentFields())?r.push(s):o.push(s));if(r.length>0){const s=r.pop();for(const a of r)s.merge(a,this.model.renameSignal.bind(this.model));this.setModified(),n instanceof nr?n.merge(s,this.model.renameSignal.bind(this.model)):s.swapWithParent()}if(o.length>1){const s=o.pop();for(const a of o)s.merge(a,this.model.renameSignal.bind(this.model));this.setModified()}}}class Hle extends Na{run(t){const n=[...t.children];if(!Ou(n,s=>s instanceof bn)||t.numChildren()<=1)return;const r=[];let o;for(const s of n)if(s instanceof bn){let a=s;for(;a.numChildren()===1;){const[u]=a.children;if(u instanceof bn)a=u;else break}r.push(...a.children),o?(t.removeChild(s),s.parent=o.parent,o.parent.removeChild(o),o.parent=a,this.setModified()):o=a}else r.push(s);if(r.length){this.setModified();for(const s of r)s.parent.removeChild(s),s.parent=o}}}class Ra extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i}clone(){return new Ra(null,ce(this.transform))}addDimensions(n){this.transform.groupby=Rn(this.transform.groupby.concat(n),i=>i)}dependentFields(){const n=new Set;return this.transform.groupby&&this.transform.groupby.forEach(n.add,n),this.transform.joinaggregate.map(i=>i.field).filter(i=>i!==void 0).forEach(n.add,n),n}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(n){return n.as??V(n)}hash(){return`JoinAggregateTransform ${ye(this.transform)}`}assemble(){const n=[],i=[],r=[];for(const s of this.transform.joinaggregate)i.push(s.op),r.push(this.getDefaultName(s)),n.push(s.field===void 0?null:s.field);const o=this.transform.groupby;return{type:"joinaggregate",as:r,ops:i,fields:n,...o!==void 0?{groupby:o}:{}}}}class Xu extends Le{constructor(n,i){super(n);I(this,"filter");this.filter=i}clone(){return new Xu(null,{...this.filter})}static make(n,i,r){const{config:o,markDef:s}=i,{marks:a,scales:u}=r;if(a==="include-invalid-values"&&u==="include-invalid-values")return null;const l=i.reduceFieldDef((c,f,d)=>{const h=_r(d)&&i.getScaleComponent(d);if(h){const g=h.get("type"),{aggregate:p}=f,m=NE({scaleChannel:d,markDef:s,config:o,scaleType:g,isCountAggregate:pm(p)});m!=="show"&&m!=="always-valid"&&(c[f.field]=f)}return c},{});return U(l).length?new Xu(n,l):null}dependentFields(){return new Set(U(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${ye(this.filter)}`}assemble(){const n=U(this.filter).reduce((i,r)=>{const o=this.filter[r],s=V(o,{expr:"datum"});return o!==null&&(o.type==="temporal"?i.push(`(isDate(${s}) || (${Yb(s)}))`):o.type==="quantitative"&&i.push(Yb(s))),i},[]);return n.length>0?{type:"filter",expr:n.join(" && ")}:null}}function Yb(e){return`isValid(${e}) && isFinite(+${e})`}function Gle(e){return e.stack.stackBy.reduce((t,n)=>{const i=n.fieldDef,r=V(i);return r&&t.push(r),t},[])}function Yle(e){return P(e)&&e.every(t=>J(t))&&e.length>1}class Vr extends Le{constructor(n,i){super(n);I(this,"_stack");this._stack=i}clone(){return new Vr(null,ce(this._stack))}static makeFromTransform(n,i){const{stack:r,groupby:o,as:s,offset:a="zero"}=i,u=[],l=[];if(i.sort!==void 0)for(const d of i.sort)u.push(d.field),l.push(nt(d.order,"ascending"));const c={field:u,order:l};let f;return Yle(s)?f=s:J(s)?f=[s,`${s}_end`]:f=[`${i.stack}_start`,`${i.stack}_end`],new Vr(n,{dimensionFieldDefs:[],stackField:r,groupby:o,offset:a,sort:c,facetby:[],as:f})}static makeFromEncoding(n,i){const r=i.stack,{encoding:o}=i;if(!r)return null;const{groupbyChannels:s,fieldChannel:a,offset:u,impute:l}=r,c=s.map(g=>{const p=o[g];return Mi(p)}).filter(g=>!!g),f=Gle(i),d=i.encoding.order;let h;if(P(d)||j(d))h=eL(d);else{const g=qL(d)?d.sort:a==="y"?"descending":"ascending";h=f.reduce((p,m)=>(p.field.includes(m)||(p.field.push(m),p.order.push(g)),p),{field:[],order:[]})}return new Vr(n,{dimensionFieldDefs:c,stackField:i.vgField(a),facetby:[],stackby:f,sort:h,offset:u,impute:l,as:[i.vgField(a,{suffix:"start",forAs:!0}),i.vgField(a,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(n){this._stack.facetby.push(...n)}dependentFields(){const n=new Set;return n.add(this._stack.stackField),this.getGroupbyFields().forEach(n.add,n),this._stack.facetby.forEach(n.add,n),this._stack.sort.field.forEach(n.add,n),n}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${ye(this._stack)}`}getGroupbyFields(){const{dimensionFieldDefs:n,impute:i,groupby:r}=this._stack;return n.length>0?n.map(o=>o.bin?i?[V(o,{binSuffix:"mid"})]:[V(o,{}),V(o,{binSuffix:"end"})]:[V(o)]).flat():r??[]}assemble(){const n=[],{facetby:i,dimensionFieldDefs:r,stackField:o,stackby:s,sort:a,offset:u,impute:l,as:c}=this._stack;if(l)for(const f of r){const{bandPosition:d=.5,bin:h}=f;if(h){const g=V(f,{expr:"datum"}),p=V(f,{expr:"datum",binSuffix:"end"});n.push({type:"formula",expr:`${Yb(g)} ? ${d}*${g}+${1-d}*${p} : ${g}`,as:V(f,{binSuffix:"mid",forAs:!0})})}n.push({type:"impute",field:o,groupby:[...s,...i],key:V(f,{binSuffix:"mid"}),method:"value",value:0})}return n.push({type:"stack",groupby:[...this.getGroupbyFields(),...i],field:o,sort:a,as:c,offset:u}),n}}class xl extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i}clone(){return new xl(null,ce(this.transform))}addDimensions(n){this.transform.groupby=Rn(this.transform.groupby.concat(n),i=>i)}dependentFields(){const n=new Set;return(this.transform.groupby??[]).forEach(n.add,n),(this.transform.sort??[]).forEach(i=>n.add(i.field)),this.transform.window.map(i=>i.field).filter(i=>i!==void 0).forEach(n.add,n),n}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(n){return n.as??V(n)}hash(){return`WindowTransform ${ye(this.transform)}`}assemble(){const n=[],i=[],r=[],o=[];for(const d of this.transform.window)i.push(d.op),r.push(this.getDefaultName(d)),o.push(d.param===void 0?null:d.param),n.push(d.field===void 0?null:d.field);const s=this.transform.frame,a=this.transform.groupby;if(s&&s[0]===null&&s[1]===null&&i.every(d=>cE(d)))return{type:"joinaggregate",as:r,ops:i,fields:n,...a!==void 0?{groupby:a}:{}};const u=[],l=[];if(this.transform.sort!==void 0)for(const d of this.transform.sort)u.push(d.field),l.push(d.order??"ascending");const c={field:u,order:l},f=this.transform.ignorePeers;return{type:"window",params:o,as:r,ops:i,fields:n,sort:c,...f!==void 0?{ignorePeers:f}:{},...a!==void 0?{groupby:a}:{},...s!==void 0?{frame:s}:{}}}}function Vle(e){function t(n){if(!(n instanceof vl)){const i=n.clone();if(i instanceof bn){const r=Xb+i.getSource();i.setSource(r),e.model.component.data.outputNodes[r]=i}else(i instanceof Si||i instanceof Vr||i instanceof xl||i instanceof Ra)&&i.addDimensions(e.fields);for(const r of n.children.flatMap(t))r.parent=i;return[i]}return n.children.flatMap(t)}return t}function Vb(e){if(e instanceof vl)if(e.numChildren()===1&&!(e.children[0]instanceof bn)){const t=e.children[0];(t instanceof Si||t instanceof Vr||t instanceof xl||t instanceof Ra)&&t.addDimensions(e.fields),t.swapWithParent(),Vb(e)}else{const t=e.model.component.data.main;TP(t);const n=Vle(e),i=e.children.map(n).flat();for(const r of i)r.parent=t}else e.children.map(Vb)}function TP(e){if(e instanceof bn&&e.type===Xe.Main&&e.numChildren()===1){const t=e.children[0];t instanceof vl||(t.swapWithParent(),TP(e))}}const Xb="scale_",Nd=5;function Kb(e){for(const t of e){for(const n of t.children)if(n.parent!==t)return!1;if(!Kb(t.children))return!1}return!0}function ci(e,t){let n=!1;for(const i of t)n=e.optimize(i)||n;return n}function xC(e,t,n){let i=e.sources,r=!1;return r=ci(new Ile,i)||r,r=ci(new Lle(t),i)||r,i=i.filter(o=>o.numChildren()>0),r=ci(new Ule,i)||r,i=i.filter(o=>o.numChildren()>0),n||(r=ci(new zle,i)||r,r=ci(new Wle(t),i)||r,r=ci(new Ple,i)||r,r=ci(new Ble,i)||r,r=ci(new qle,i)||r,r=ci(new jle,i)||r,r=ci(new Dle,i)||r,r=ci(new Hle,i)||r),e.sources=i,r}function Xle(e,t){Kb(e.sources);let n=0,i=0;for(let r=0;rt(n))}}function NP(e){Ge(e)?Kle(e):Jle(e)}function Kle(e){const t=e.component.scales;for(const n of U(t)){const i=Zle(e,n);if(t[n].setWithExplicit("domains",i),tce(e,n),e.component.data.isFaceted){let o=e;for(;!zn(o)&&o.parent;)o=o.parent;if(o.component.resolve.scale[n]==="shared")for(const a of i.value)Br(a)&&(a.data=Xb+a.data.replace(Xb,""))}}}function Jle(e){for(const n of e.children)NP(n);const t=e.component.scales;for(const n of U(t)){let i,r=null;for(const o of e.children){const s=o.component.scales[n];if(s){i===void 0?i=s.getWithExplicit("domains"):i=Jo(i,s.getWithExplicit("domains"),"domains","scale",Jb);const a=s.get("selectionExtent");r&&a&&r.param!==a.param&&W(Qie),r=a}}t[n].setWithExplicit("domains",i),r&&t[n].set("selectionExtent",r,!0)}}function Qle(e,t,n,i){if(e==="unaggregated"){const{valid:r,reason:o}=wC(t,n);if(!r){W(o);return}}else if(e===void 0&&i.useUnaggregatedDomain){const{valid:r}=wC(t,n);if(r)return"unaggregated"}return e}function Zle(e,t){const n=e.getScaleComponent(t).get("type"),{encoding:i}=e,r=Qle(e.scaleDomain(t),e.typedFieldDef(t),n,e.config.scale);return r!==e.scaleDomain(t)&&(e.specifiedScales[t]={...e.specifiedScales[t],domain:r}),t==="x"&&ct(i.x2)?ct(i.x)?Jo(yo(n,r,e,"x"),yo(n,r,e,"x2"),"domain","scale",Jb):yo(n,r,e,"x2"):t==="y"&&ct(i.y2)?ct(i.y)?Jo(yo(n,r,e,"y"),yo(n,r,e,"y2"),"domain","scale",Jb):yo(n,r,e,"y2"):yo(n,r,e,t)}function ece(e,t,n){return e.map(i=>({signal:`{data: ${Cm(i,{timeUnit:n,type:t})}}`}))}function y1(e,t,n){var r;const i=(r=Et(n))==null?void 0:r.unit;return t==="temporal"||i?ece(e,t,i):[e]}function yo(e,t,n,i){const{encoding:r,markDef:o,mark:s,config:a,stack:u}=n,l=ct(r[i]),{type:c}=l,f=l.timeUnit,d=nue({invalid:lr("invalid",o,a),isPath:fs(s)});if($oe(t)){const p=yo(e,void 0,n,i),m=y1(t.unionWith,c,f);return Hi([...m,...p.value])}else{if(ne(t))return Hi([t]);if(t&&t!=="unaggregated"&&!kL(t))return Hi(y1(t,c,f))}if(u&&i===u.fieldChannel){if(u.offset==="normalize")return Cn([[0,1]]);const p=n.requestDataName(d);return Cn([{data:p,field:n.vgField(i,{suffix:"start"})},{data:p,field:n.vgField(i,{suffix:"end"})}])}const h=_r(i)&&j(l)?nce(n,i,e):void 0;if(Sr(l)){const p=y1([l.datum],c,f);return Cn(p)}const g=l;if(t==="unaggregated"){const{field:p}=l;return Cn([{data:n.requestDataName(d),field:V({field:p,aggregate:"min"})},{data:n.requestDataName(d),field:V({field:p,aggregate:"max"})}])}else if(Ue(g.bin)){if(et(e))return Cn(e==="bin-ordinal"?[]:[{data:Du(h)?n.requestDataName(d):n.requestDataName(Xe.Raw),field:n.vgField(i,Xf(g,i)?{binSuffix:"range"}:{}),sort:h===!0||!K(h)?{field:n.vgField(i,{}),op:"min"}:h}]);{const{bin:p}=g;if(Ue(p)){const m=c_(n,g.field,p);return Cn([new mt(()=>{const y=n.getSignalName(m);return`[${y}.start, ${y}.stop]`})])}else return Cn([{data:n.requestDataName(d),field:n.vgField(i,{})}])}}else if(g.timeUnit&&we(["time","utc"],e)){const p=r[Er(i)];if(jL(g,p,o,a)){const m=n.requestDataName(d),y=eo({fieldDef:g,fieldDef2:p,markDef:o,config:a}),b=tf(s)&&y!==.5&&it(i);return Cn([{data:m,field:n.vgField(i,b?{suffix:Om}:{})},{data:m,field:n.vgField(i,{suffix:b?Dm:"end"})}])}}return Cn(h?[{data:Du(h)?n.requestDataName(d):n.requestDataName(Xe.Raw),field:n.vgField(i),sort:h}]:[{data:n.requestDataName(d),field:n.vgField(i)}])}function b1(e,t){const{op:n,field:i,order:r}=e;return{op:n??(t?"sum":Sm),...i?{field:oi(i)}:{},...r?{order:r}:{}}}function tce(e,t){var a;const n=e.component.scales[t],i=e.specifiedScales[t].domain,r=(a=e.fieldDef(t))==null?void 0:a.bin,o=kL(i)?i:void 0,s=Aa(r)&&mm(r.extent)?r.extent:void 0;(o||s)&&n.set("selectionExtent",o??s,!0)}function nce(e,t,n){if(!et(n))return;const i=e.fieldDef(t),r=i.sort;if(BL(r))return{op:"min",field:Yu(i,t),order:"ascending"};const{stack:o}=e,s=o?new Set([...o.groupbyFields,...o.stackBy.map(a=>a.fieldDef.field)]):void 0;if(Gr(r)){const a=o&&!s.has(r.field);return b1(r,a)}else if(nse(r)){const{encoding:a,order:u}=r,l=e.fieldDef(a),{aggregate:c,field:f}=l,d=o&&!s.has(f);if(Zr(c)||cs(c))return b1({field:V(l),order:u},d);if(cE(c)||!c)return b1({op:c,field:f,order:u},d)}else{if(r==="descending")return{op:"min",field:e.vgField(t),order:"descending"};if(we(["ascending",void 0],r))return!0}}function wC(e,t){const{aggregate:n,type:i}=e;return n?J(n)&&!Die.has(n)?{valid:!1,reason:Are(n)}:i==="quantitative"&&t==="log"?{valid:!1,reason:Cre(e)}:{valid:!0}:{valid:!1,reason:kre(e)}}function Jb(e,t,n,i){return e.explicit&&t.explicit&&W(Rre(n,i,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function ice(e){const t=Rn(e.map(s=>{if(Br(s)){const{sort:a,...u}=s;return u}return s}),ye),n=Rn(e.map(s=>{if(Br(s)){const a=s.sort;return a!==void 0&&!Du(a)&&("op"in a&&a.op==="count"&&delete a.field,a.order==="ascending"&&delete a.order),a}}).filter(s=>s!==void 0),ye);if(t.length===0)return;if(t.length===1){const s=e[0];if(Br(s)&&n.length>0){let a=n[0];if(n.length>1){W(TA);const u=n.filter(l=>K(l)&&"op"in l&&l.op!=="min");n.every(l=>K(l)&&"op"in l)&&u.length===1?a=u[0]:a=!0}else if(K(a)&&"field"in a){const u=a.field;s.field===u&&(a=a.order?{order:a.order}:!0)}return{...s,sort:a}}return s}const i=Rn(n.map(s=>Du(s)||!("op"in s)||J(s.op)&&Z(Tie,s.op)?s:(W(Dre(s)),!0)),ye);let r;i.length===1?r=i[0]:i.length>1&&(W(TA),r=!0);const o=Rn(e.map(s=>Br(s)?s.data:null),s=>s);return o.length===1&&o[0]!==null?{data:o[0],fields:t.map(a=>a.field),...r?{sort:r}:{}}:{fields:t,...r?{sort:r}:{}}}function g_(e){if(Br(e)&&J(e.field))return e.field;if(K5(e)){let t;for(const n of e.fields)if(Br(n)&&J(n.field)){if(!t)t=n.field;else if(t!==n.field)return W(Lre),t}return W(Pre),t}else if(Lie(e)){W(Ire);const t=e.fields[0];return J(t)?t:void 0}}function ga(e,t){const i=e.component.scales[t].get("domains").map(r=>(Br(r)&&(r.data=e.lookupDataSource(r.data)),r));return ice(i)}function rce(e,t,n,i){var r,o;e.encode??(e.encode={}),(r=e.encode)[t]??(r[t]={}),(o=e.encode[t]).update??(o.update={}),e.encode[t].update[n]=i}function RP(e,t){if(Ge(e)){const i=e.fieldDef(t);if(i!=null&&i.field)return i.field}const n=(e.children??[]).map(i=>RP(i,t)).filter(i=>!!i);if(n.length>0){const i=Rn(n,ye);return i.length===1?i[0]:void 0}}function oce(e,t,n){if(t===n)return!0;const i=e.getScaleType(t),r=e.getScaleType(n);if(!i||!r)return!1;const o=et(i),s=et(r);return o===s}function sce(e,t){return e?`field:${e}`:`channel:${String(t)}`}function ace(e){if(P(e)){const t=e.filter(Mg);return t.length>0?t:null}if(K5(e)){const t=[];if(t.push(...e.fields.flatMap(n=>P(n)?n.filter(Mg):[])),t.length>0)return Rn(t,ye)}return null}function Qb(e,t){try{const n=ga(e,t);return ace(n)}catch{return null}}function uce(e,t,n){const i=Qb(e,t),r=Qb(e,n);return i&&r?Rn([...i,...r],ye):null}function EC(e,t,n){if(t&&t.length>0){const i=e.getWithExplicit("values");i!=null&&i.explicit||(n&&W(n),e.set("values",t,!1))}}function lce(e,t,n){const i=e.getScaleComponent(t),r=e.getScaleComponent(n);if(!i||!r)return!1;const o=i.getWithExplicit("domains"),s=r.getWithExplicit("domains");if(!(o!=null&&o.explicit&&(s!=null&&s.explicit)))return!1;const a=ga(e,t),u=ga(e,n);return ye(a)===ye(u)}function OP(e){const t=e.component.legends,n={};for(const r of U(t)){const o=RP(e,r),s=sce(o,r);if(!n[s]){n[s]=[{channel:r,cmpt:t[r].clone()}];continue}let a=!1;for(const u of n[s]){if(!oce(e,u.channel,r))continue;if(FP(u.cmpt,t[r])){const c=e.getScaleType(u.channel),f=e.getScaleType(r);c&&f&&et(c)&&et(f)&&(lce(e,u.channel,r)?EC(u.cmpt,Qb(e,u.channel)):EC(u.cmpt,uce(e,u.channel,r),zre(u.channel,r))),a=!0;break}}a||n[s].push({channel:r,cmpt:t[r].clone()})}return ot(n).flat().map(r=>cce(r.cmpt,e.config)).filter(r=>r!==void 0)}function cce(e,t){var s,a,u;const{disable:n,labelExpr:i,selections:r,...o}=e.combine();if(!n){if(t.aria===!1&&o.aria==null&&(o.aria=!1),(s=o.encode)!=null&&s.symbols){const l=o.encode.symbols.update;l.fill&&l.fill.value!=="transparent"&&!l.stroke&&!o.stroke&&(l.stroke={value:"transparent"});for(const c of b6)o[c]&&delete l[c]}if(o.title||delete o.title,i!==void 0){let l=i;(u=(a=o.encode)==null?void 0:a.labels)!=null&&u.update&&ne(o.encode.labels.update.text)&&(l=ra(i,"datum.label",o.encode.labels.update.text.signal)),rce(o,"labels","text",{signal:l})}return o}}function fce(e){return wl(e)||p_(e)?dce(e):DP(e)}function dce(e){return e.children.reduce((t,n)=>t.concat(n.assembleProjections()),DP(e))}function DP(e){const t=e.component.projection;if(!t||t.merged)return[];const n=t.combine(),{name:i}=n;if(t.data){const r={signal:`[${t.size.map(s=>s.signal).join(", ")}]`},o=t.data.reduce((s,a)=>{const u=ne(a)?a.signal:`data('${e.lookupDataSource(a)}')`;return we(s,u)||s.push(u),s},[]);if(o.length<=0)throw new Error("Projection's fit didn't find any data sources");return[{name:i,size:r,fit:{signal:o.length>1?`[${o.join(", ")}]`:o[0]},...n}]}else return[{name:i,translate:{signal:"[width / 2, height / 2]"},...n}]}const hce=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class LP extends fo{constructor(n,i,r,o){super({...i},{name:n});I(this,"specifiedProjection");I(this,"size");I(this,"data");I(this,"merged",!1);this.specifiedProjection=i,this.size=r,this.data=o}get isFit(){return!!this.data}}function PP(e){e.component.projection=Ge(e)?gce(e):yce(e)}function gce(e){if(e.hasProjection){const t=kt(e.specifiedProjection),n=!(t&&(t.scale!=null||t.translate!=null)),i=n?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,r=n?pce(e):void 0,o=new LP(e.projectionName(!0),{...kt(e.config.projection),...t},i,r);return o.get("type")||o.set("type","equalEarth",!1),o}}function pce(e){const t=[],{encoding:n}=e;for(const i of[[Ii,Pi],[si,zi]])(ct(n[i[0]])||ct(n[i[1]]))&&t.push({signal:e.getName(`geojson_${t.length}`)});return e.channelHasField(Sn)&&e.typedFieldDef(Sn).type===ml&&t.push({signal:e.getName(`geojson_${t.length}`)}),t.length===0&&t.push(e.requestDataName(Xe.Main)),t}function mce(e,t){const n=Qw(hce,r=>!!(!Z(e.explicit,r)&&!Z(t.explicit,r)||Z(e.explicit,r)&&Z(t.explicit,r)&&On(e.get(r),t.get(r))));if(On(e.size,t.size)){if(n)return e;if(On(e.explicit,{}))return t;if(On(t.explicit,{}))return e}return null}function yce(e){if(e.children.length===0)return;let t;for(const i of e.children)PP(i);const n=Qw(e.children,i=>{const r=i.component.projection;if(r)if(t){const o=mce(t,r);return o&&(t=o),!!o}else return t=r,!0;else return!0});if(t&&n){const i=e.projectionName(!0),r=new LP(i,t.specifiedProjection,t.size,ce(t.data));for(const o of e.children){const s=o.component.projection;s&&(s.isFit&&r.data.push(...o.component.projection.data),o.renameProjection(s.get("name"),i),s.merged=!0)}return r}}function IP(e){return wl(e)||p_(e)?e.children.reduce((t,n)=>t.concat(IP(n)),_C(e)):_C(e)}function _C(e){return U(e.component.scales).reduce((t,n)=>{const i=e.component.scales[n];if(i.merged)return t;const r=i.combine(),{name:o,type:s,selectionExtent:a,domains:u,range:l,reverse:c,...f}=r,d=bce(r.range,o,n,e),h=ga(e,n),g=a?hue(e,a,i,h):null;return t.push({name:o,type:s,...h?{domain:h}:{},...g?{domainRaw:g}:{},range:d,...c!==void 0?{reverse:c}:{},...f}),t},[])}function bce(e,t,n,i){if(it(n)){if(Ca(e))return{step:{signal:`${t}_step`}}}else if(K(e)&&Br(e))return{...e,data:i.lookupDataSource(e.data)};return e}class zP extends fo{constructor(n,i){super({},{name:n});I(this,"merged",!1);this.setWithExplicit("type",i)}domainHasZero(){const n=this.get("type");if(we([At.LOG,At.TIME,At.UTC],n))return"definitely-not";const i=this.get("zero");if(i===!0||i===void 0&&we([At.LINEAR,At.SQRT,At.POW],n))return"definitely";const r=this.get("domains");if(r.length>0){let o=!1,s=!1,a=!1;for(const u of r){if(P(u)){const l=u[0],c=u[u.length-1];if(ke(l)&&ke(c))if(l<=0&&c>=0){o=!0;continue}else{s=!0;continue}}a=!0}if(o)return"definitely";if(s&&!a)return"definitely-not"}return"maybe"}}const vce=["range","scheme"];function xce(e){const t=e.component.scales;for(const n of lE){const i=t[n];if(!i)continue;const r=wce(n,e);i.setWithExplicit("range",r)}}function SC(e,t){const n=e.fieldDef(t);if(n!=null&&n.bin){const{bin:i,field:r}=n,o=$n(t),s=e.getName(o);if(K(i)&&i.binned&&i.step!==void 0)return new mt(()=>{const a=e.scaleName(t),u=`(domain("${a}")[1] - domain("${a}")[0]) / ${i.step}`;return`${e.getSignalName(s)} / (${u})`});if(Ue(i)){const a=c_(e,r,i);return new mt(()=>{const u=e.getSignalName(a),l=`(${u}.stop - ${u}.start) / ${u}.step`;return`${e.getSignalName(s)} / (${l})`})}}}function wce(e,t){const n=t.specifiedScales[e],{size:i}=t,o=t.getScaleComponent(e).get("type");for(const f of vce)if(n[f]!==void 0){const d=Tb(o,f),h=AL(e,f);if(!d)W(aL(o,f,e));else if(h)W(h);else switch(f){case"range":{const g=n.range;if(P(g)){if(it(e))return Hi(g.map(p=>{if(p==="width"||p==="height"){const m=t.getName(p),y=t.getSignalName.bind(t);return mt.fromName(y,m)}return p}))}else if(K(g))return Hi({data:t.requestDataName(Xe.Main),field:g.field,sort:{op:"min",field:t.vgField(e)}});return Hi(g)}case"scheme":return Hi(Ece(n[f]))}}const s=e===We||e==="xOffset"?"width":"height",a=i[s];if(fr(a)){if(it(e))if(et(o)){const f=UP(a,t,e);if(f)return Hi({step:f})}else W(uL(s));else if(jf(e)){const f=e===Qr?"x":"y";if(t.getScaleComponent(f).get("type")==="band"){const g=jP(a,o);if(g)return Hi(g)}}}const{rangeMin:u,rangeMax:l}=n,c=_ce(e,t);return(u!==void 0||l!==void 0)&&Tb(o,"rangeMin")&&P(c)&&c.length===2?Hi([u??c[0],l??c[1]]):Cn(c)}function Ece(e){return Soe(e)?{scheme:e.name,...In(e,["name"])}:{scheme:e}}function BP(e,t,n,{center:i}={}){const r=$n(e),o=t.getName(r),s=t.getSignalName.bind(t);return e===dt&&Ci(n)?i?[mt.fromName(a=>`${s(a)}/2`,o),mt.fromName(a=>`-${s(a)}/2`,o)]:[mt.fromName(s,o),0]:i?[mt.fromName(a=>`-${s(a)}/2`,o),mt.fromName(a=>`${s(a)}/2`,o)]:[0,mt.fromName(s,o)]}function _ce(e,t){const{size:n,config:i,mark:r,encoding:o}=t,{type:s}=ct(o[e]),u=t.getScaleComponent(e).get("type"),{domain:l,domainMid:c}=t.specifiedScales[e];switch(e){case We:case dt:{if(we(["point","band"],u)){const f=qP(e,n,i.view);if(fr(f))return{step:UP(f,t,e)}}return BP(e,t,u)}case Qr:case pl:return Sce(e,t,u);case ao:{const f=Ace(r,i),d=Cce(r,n,t,i);return zu(u)?kce(f,d,$ce(u,i,l,e)):[f,d]}case ui:return[0,Math.PI*2];case $a:return[0,360];case Li:return[0,new mt(()=>{const f=t.getSignalName(zn(t.parent)?"child_width":"width"),d=t.getSignalName(zn(t.parent)?"child_height":"height");return`min(${f},${d})/2`})];case os:return{step:1e3/i.scale.framesPerSecond};case us:return[i.scale.minStrokeWidth,i.scale.maxStrokeWidth];case ls:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case Sn:return"symbol";case _n:case xr:case wr:return u==="ordinal"?s==="nominal"?"category":"ordinal":c!==void 0?"diverging":r==="rect"||r==="geoshape"?"heatmap":"ramp";case uo:case ss:case as:return[i.scale.minOpacity,i.scale.maxOpacity]}}function UP(e,t,n){const{encoding:i}=t,r=t.getScaleComponent(n),o=oE(n),s=i[o];if(x6({step:e,offsetIsDiscrete:fe(s)&&$E(s.type)})==="offset"&&e6(i,o)){const u=t.getScaleComponent(o);let c=`domain('${t.scaleName(o)}').length`;if(u.get("type")==="band"){const d=u.get("paddingInner")??u.get("padding")??0,h=u.get("paddingOuter")??u.get("padding")??0;c=`bandspace(${c}, ${d}, ${h})`}const f=r.get("paddingInner")??r.get("padding");return{signal:`${e.step} * ${c} / (1-${Uie(f)})`}}else return e.step}function jP(e,t){if(x6({step:e,offsetIsDiscrete:et(t)})==="offset")return{step:e.step}}function Sce(e,t,n){const i=e===Qr?"x":"y",r=t.getScaleComponent(i);if(!r)return BP(i,t,n,{center:!0});const o=r.get("type"),s=t.scaleName(i),{markDef:a,config:u}=t;if(o==="band"){const l=qP(i,t.size,t.config.view);if(fr(l)){const c=jP(l,n);if(c)return c}return[0,{signal:`bandwidth('${s}')`}]}else{const l=t.encoding[i];if(j(l)&&l.timeUnit){const c=bL(l.timeUnit,g=>`scale('${s}', ${g})`),f=t.config.scale.bandWithNestedOffsetPaddingInner,d=eo({fieldDef:l,markDef:a,config:u})-.5,h=d!==0?` + ${d}`:"";if(f){const g=ne(f)?`${f.signal}/2${h}`:`${f/2+d}`,p=ne(f)?`(1 - ${f.signal}/2)${h}`:`${1-f/2+d}`;return[{signal:`${g} * (${c})`},{signal:`${p} * (${c})`}]}return[0,{signal:c}]}return A5(`Cannot use ${e} scale if ${i} scale is not discrete.`)}}function qP(e,t,n){const i=e===We?"width":"height",r=t[i];return r!==void 0?r:zg(n,i)}function $ce(e,t,n,i){switch(e){case"quantile":return t.scale.quantileCount;case"quantize":return t.scale.quantizeCount;case"threshold":return n!==void 0&&P(n)?n.length+1:(W(Vre(i)),3)}}function kce(e,t,n){const i=()=>{const r=wi(t),o=wi(e),s=`(${r} - ${o}) / (${n} - 1)`;return`sequence(${o}, ${r} + ${s}, ${s})`};return ne(t)?new mt(i):{signal:i()}}function Ace(e,t){switch(e){case"bar":case"tick":return t.scale.minBandSize;case"line":case"trail":case"rule":return t.scale.minStrokeWidth;case"text":return t.scale.minFontSize;case"point":case"square":case"circle":return t.scale.minSize}throw new Error(ym("size",e))}const $C=.95;function Cce(e,t,n,i){const r={x:SC(n,"x"),y:SC(n,"y")};switch(e){case"bar":case"tick":{if(i.scale.maxBandSize!==void 0)return i.scale.maxBandSize;const o=kC(t,r,i.view);return ke(o)?o-1:new mt(()=>`${o.signal} - 1`)}case"line":case"trail":case"rule":return i.scale.maxStrokeWidth;case"text":return i.scale.maxFontSize;case"point":case"square":case"circle":{if(i.scale.maxSize)return i.scale.maxSize;const o=kC(t,r,i.view);return ke(o)?Math.pow($C*o,2):new mt(()=>`pow(${$C} * ${o.signal}, 2)`)}}throw new Error(ym("size",e))}function kC(e,t,n){const i=fr(e.width)?e.width.step:Db(n,"width"),r=fr(e.height)?e.height.step:Db(n,"height");return t.x||t.y?new mt(()=>`min(${[t.x?t.x.signal:i,t.y?t.y.signal:r].join(", ")})`):Math.min(i,r)}function WP(e,t){Ge(e)?Fce(e,t):GP(e,t)}function Fce(e,t){const n=e.component.scales,{config:i,encoding:r,markDef:o,specifiedScales:s}=e;for(const a of U(n)){const u=s[a],l=n[a],c=e.getScaleComponent(a),f=ct(r[a]),d=u[t],h=c.get("type"),g=c.get("padding"),p=c.get("paddingInner"),m=Tb(h,t),y=AL(a,t);if(d!==void 0&&(m?y&&W(y):W(aL(h,t,a))),m&&y===void 0)if(d!==void 0){const b=f.timeUnit,v=f.type;switch(t){case"domainMax":case"domainMin":Fa(u[t])||v==="temporal"||b?l.set(t,{signal:Cm(u[t],{type:v,timeUnit:b})},!0):l.set(t,u[t],!0);break;default:l.copyKeyFromObject(t,u)}}else{const b=q(AC,t)?AC[t]({model:e,channel:a,fieldOrDatumDef:f,scaleType:h,scalePadding:g,scalePaddingInner:p,domain:u.domain,domainMin:u.domainMin,domainMax:u.domainMax,markDef:o,config:i,hasNestedOffsetScale:t6(r,a),hasSecondaryRangeChannel:!!r[Er(a)]}):i.scale[t];b!==void 0&&l.set(t,b,!1)}}}const AC={bins:({model:e,fieldOrDatumDef:t})=>j(t)?Mce(e,t):void 0,interpolate:({channel:e,fieldOrDatumDef:t})=>Tce(e,t.type),nice:({scaleType:e,channel:t,domain:n,domainMin:i,domainMax:r,fieldOrDatumDef:o})=>Nce(e,t,n,i,r,o),padding:({channel:e,scaleType:t,fieldOrDatumDef:n,markDef:i,config:r})=>Rce(e,t,r.scale,n,i,r.bar),paddingInner:({scalePadding:e,channel:t,markDef:n,scaleType:i,config:r,hasNestedOffsetScale:o})=>Oce(e,t,n.type,i,r.scale,o),paddingOuter:({scalePadding:e,channel:t,scaleType:n,scalePaddingInner:i,config:r,hasNestedOffsetScale:o})=>Dce(e,t,n,i,r.scale,o),reverse:({fieldOrDatumDef:e,scaleType:t,channel:n,config:i})=>{const r=j(e)?e.sort:void 0;return Lce(t,r,n,i.scale)},zero:({channel:e,fieldOrDatumDef:t,domain:n,markDef:i,scaleType:r,config:o,hasSecondaryRangeChannel:s})=>Pce(e,t,n,i,r,o.scale,s)};function HP(e){Ge(e)?xce(e):GP(e,"range")}function GP(e,t){const n=e.component.scales;for(const i of e.children)t==="range"?HP(i):WP(i,t);for(const i of U(n)){let r;for(const o of e.children){const s=o.component.scales[i];if(s){const a=s.getWithExplicit(t);r=Jo(r,a,t,"scale",O6((u,l)=>{switch(t){case"range":return u.step&&l.step?u.step-l.step:0}return 0}))}}n[i].setWithExplicit(t,r)}}function Mce(e,t){const n=t.bin;if(Ue(n)){const i=c_(e,t.field,n);return new mt(()=>e.getSignalName(i))}else if($t(n)&&Aa(n)&&n.step!==void 0)return{step:n.step}}function Tce(e,t){if(we([_n,xr,wr],e)&&t!=="nominal")return"hcl"}function Nce(e,t,n,i,r,o){var s;if(!((s=Mi(o))!=null&&s.bin||P(n)||r!=null||i!=null||we([At.TIME,At.UTC],e)))return it(t)?!0:void 0}function Rce(e,t,n,i,r,o){if(it(e)){if(Ki(t)){if(n.continuousPadding!==void 0)return n.continuousPadding;const{type:s,orient:a}=r;if(s==="bar"&&!(j(i)&&(i.bin||i.timeUnit))&&(a==="vertical"&&e==="x"||a==="horizontal"&&e==="y"))return o.continuousBandSize}if(t===At.POINT)return n.pointPadding}}function Oce(e,t,n,i,r,o=!1){if(e===void 0){if(it(t)){const{bandPaddingInner:s,barBandPaddingInner:a,rectBandPaddingInner:u,tickBandPaddingInner:l,bandWithNestedOffsetPaddingInner:c}=r;return o?c:nt(s,n==="bar"?a:n==="tick"?l:u)}else if(jf(t)&&i===At.BAND)return r.offsetBandPaddingInner}}function Dce(e,t,n,i,r,o=!1){if(e===void 0){if(it(t)){const{bandPaddingOuter:s,bandWithNestedOffsetPaddingOuter:a}=r;if(o)return a;if(n===At.BAND)return nt(s,ne(i)?{signal:`${i.signal}/2`}:i/2)}else if(jf(t)){if(n===At.POINT)return .5;if(n===At.BAND)return r.offsetBandPaddingOuter}}}function Lce(e,t,n,i){if(n==="x"&&i.xReverse!==void 0)return Ci(e)&&t==="descending"?ne(i.xReverse)?{signal:`!${i.xReverse.signal}`}:!i.xReverse:i.xReverse;if(Ci(e)&&t==="descending")return!0}function Pce(e,t,n,i,r,o,s){if(!!n&&n!=="unaggregated"&&Ci(r)){if(P(n)){const u=n[0],l=n[n.length-1];if(ke(u)&&u<=0&&ke(l)&&l>=0)return!0}return!1}if(e==="size"&&t.type==="quantitative"&&!zu(r))return!0;if(!(j(t)&&t.bin)&&we([...lo,...Eie],e)){const{orient:u,type:l}=i;return we(["bar","area","line","trail"],l)&&(u==="horizontal"&&e==="y"||u==="vertical"&&e==="x")?!1:we(["bar","area"],l)&&!s?!0:o==null?void 0:o.zero}return!1}function Ice(e,t,n,i,r=!1){const o=zce(t,n,i,r),{type:s}=e;return _r(t)?s!==void 0?Toe(t,s)?j(n)&&!Moe(s,n.type)?(W(Tre(s,o)),o):s:(W(Mre(t,s,o)),o):o:null}function zce(e,t,n,i){var r;switch(t.type){case"nominal":case"ordinal":{if(uu(e)||s1(e)==="discrete")return e==="shape"&&t.type==="ordinal"&&W(a1(e,"ordinal")),"ordinal";if(o1(e))return"band";if(it(e)||jf(e)){if(we(["rect","bar","image","rule","tick"],n.type)||i)return"band"}else if(n.type==="arc"&&e in uE)return"band";const o=n[$n(e)];return la(o)||Uu(t)&&((r=t.axis)!=null&&r.tickBand)?"band":"point"}case"temporal":return uu(e)?"time":s1(e)==="discrete"?(W(a1(e,"temporal")),"ordinal"):j(t)&&t.timeUnit&&Et(t.timeUnit).utc?"utc":o1(e)?"band":"time";case"quantitative":return uu(e)?j(t)&&Ue(t.bin)?"bin-ordinal":"linear":s1(e)==="discrete"?(W(a1(e,"quantitative")),"ordinal"):o1(e)?"band":"linear";case"geojson":return}throw new Error(oL(t.type))}function Bce(e,{ignoreRange:t}={}){YP(e),NP(e);for(const n of Foe)WP(e,n);t||HP(e)}function YP(e){Ge(e)?e.component.scales=Uce(e):e.component.scales=qce(e)}function Uce(e){const{encoding:t,mark:n,markDef:i}=e,r={};for(const o of lE){const s=ct(t[o]);if(s&&n===ML&&o===Sn&&s.type===ml)continue;let a=s&&s.scale;if(s&&a!==null&&a!==!1){a??(a={});const u=t6(t,o),l=Ice(a,o,s,i,u);r[o]=new zP(e.scaleName(`${o}`,!0),{value:l,explicit:a.type===l})}}return r}const jce=O6((e,t)=>RA(e)-RA(t));function qce(e){var r;const t=e.component.scales={},n={},i=e.component.resolve;for(const o of e.children){YP(o);for(const s of U(o.component.scales))if((r=i.scale)[s]??(r[s]=_P(s,e)),i.scale[s]==="shared"){const a=n[s],u=o.component.scales[s].getWithExplicit("type");a?voe(a.value,u.value)?n[s]=Jo(a,u,"type","scale",jce):(i.scale[s]="independent",delete n[s]):n[s]=u}}for(const o of U(n)){const s=e.scaleName(o,!0),a=n[o];t[o]=new zP(s,a);for(const u of e.children){const l=u.component.scales[o];l&&(u.renameScale(l.get("name"),s),l.merged=!0)}}return t}class v1{constructor(){I(this,"nameMap");this.nameMap={}}rename(t,n){this.nameMap[t]=n}has(t){return this.nameMap[t]!==void 0}get(t){for(;this.nameMap[t]&&t!==this.nameMap[t];)t=this.nameMap[t];return t}}function Ge(e){return(e==null?void 0:e.type)==="unit"}function zn(e){return(e==null?void 0:e.type)==="facet"}function p_(e){return(e==null?void 0:e.type)==="concat"}function wl(e){return(e==null?void 0:e.type)==="layer"}class m_{constructor(t,n,i,r,o,s,a){I(this,"type");I(this,"parent");I(this,"config");I(this,"name");I(this,"size");I(this,"title");I(this,"description");I(this,"data");I(this,"transforms");I(this,"layout");I(this,"scaleNameMap");I(this,"projectionNameMap");I(this,"signalNameMap");I(this,"component");I(this,"view");this.type=n,this.parent=i,this.config=o,this.parent=i,this.config=o,this.view=kt(a),this.name=t.name??r,this.title=Eo(t.title)?{text:t.title}:t.title?kt(t.title):void 0,this.scaleNameMap=i?i.scaleNameMap:new v1,this.projectionNameMap=i?i.projectionNameMap:new v1,this.signalNameMap=i?i.signalNameMap:new v1,this.data=t.data,this.description=t.description,this.transforms=Wae(t.transform??[]),this.layout=n==="layer"||n==="unit"?{}:Vse(t,n,o),this.component={data:{sources:i?i.component.data.sources:[],outputNodes:i?i.component.data.outputNodes:{},outputNodeRefCounts:i?i.component.data.outputNodeRefCounts:{},isFaceted:$m(t)||(i==null?void 0:i.component.data.isFaceted)&&t.data===void 0},layoutSize:new fo,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...s?ce(s):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){Bce(this)}parseProjection(){PP(this)}renameTopLevelLayoutSizeSignal(){this.getName("width")!=="width"&&this.renameSignal(this.getName("width"),"width"),this.getName("height")!=="height"&&this.renameSignal(this.getName("height"),"height")}parseLegends(){CP(this)}assembleEncodeFromView(t){const{style:n,...i}=t,r={};for(const o of U(i)){const s=i[o];s!==void 0&&(r[o]=qe(s))}return r}assembleGroupEncodeEntry(t){let n={};return this.view&&(n=this.assembleEncodeFromView(this.view)),!t&&(this.description&&(n.description=qe(this.description)),this.type==="unit"||this.type==="layer")?{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),...n}:Be(n)?void 0:n}assembleLayout(){if(!this.layout)return;const{spacing:t,...n}=this.layout,{component:i,config:r}=this,o=ole(i.layoutHeaders,r);return{padding:t,...this.assembleDefaultLayout(),...n,...o?{titleBand:o}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:t}=this.component;let n=[];for(const i of Jn)t[i].title&&n.push(Zue(this,i));for(const i of s_)n=n.concat(ele(this,i));return n}assembleAxes(){return Bue(this.component.axes,this.config)}assembleLegends(){return OP(this)}assembleProjections(){return fce(this)}assembleTitle(){const{encoding:t,...n}=this.title??{},i={...X5(this.config.title).nonMarkTitleProperties,...n,...t?{encode:{update:t}}:{}};if(i.text)return we(["unit","layer"],this.type)?we(["middle",void 0],i.anchor)&&(i.frame??(i.frame="group")):i.anchor??(i.anchor="start"),Be(i)?void 0:i}assembleGroup(t=[]){const n={};t=t.concat(this.assembleSignals()),t.length>0&&(n.signals=t);const i=this.assembleLayout();i&&(n.layout=i),n.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const r=!this.parent||zn(this.parent)?IP(this):[];r.length>0&&(n.scales=r);const o=this.assembleAxes();o.length>0&&(n.axes=o);const s=this.assembleLegends();return s.length>0&&(n.legends=s),n}getName(t){return Ye((this.name?`${this.name}_`:"")+t)}getDataName(t){return this.getName(Xe[t].toLowerCase())}requestDataName(t){const n=this.getDataName(t),i=this.component.data.outputNodeRefCounts;return i[n]=(i[n]||0)+1,n}getSizeSignalRef(t){if(zn(this.parent)){const n=wP(t),i=gm(n),r=this.component.scales[i];if(r&&!r.merged){const o=r.get("type"),s=r.get("range");if(et(o)&&Ca(s)){const a=r.get("name"),u=ga(this,i),l=g_(u);if(l){const c=V({aggregate:"distinct",field:l},{expr:"datum"});return{signal:xP(a,r,c)}}else return W(dE(i)),null}}}return{signal:this.signalNameMap.get(this.getName(t))}}lookupDataSource(t){const n=this.component.data.outputNodes[t];return n?n.getSource():t}getSignalName(t){return this.signalNameMap.get(t)}renameSignal(t,n){this.signalNameMap.rename(t,n)}renameScale(t,n){this.scaleNameMap.rename(t,n)}renameProjection(t,n){this.projectionNameMap.rename(t,n)}scaleName(t,n){if(n)return this.getName(t);if(U5(t)&&_r(t)&&this.component.scales[t]||this.scaleNameMap.has(this.getName(t)))return this.scaleNameMap.get(this.getName(t))}projectionName(t){if(t)return this.getName("projection");if(this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName("projection")))return this.projectionNameMap.get(this.getName("projection"))}getScaleComponent(t){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const n=this.component.scales[t];return n&&!n.merged?n:this.parent?this.parent.getScaleComponent(t):void 0}getScaleType(t){const n=this.getScaleComponent(t);return n?n.get("type"):void 0}getSelectionComponent(t,n){let i=this.component.selection[t];if(!i&&this.parent&&(i=this.parent.getSelectionComponent(t,n)),!i)throw new Error(Gie(n));return i}hasAxisOrientSignalRef(){var t,n;return((t=this.component.axes.x)==null?void 0:t.some(i=>i.hasOrientSignalRef()))||((n=this.component.axes.y)==null?void 0:n.some(i=>i.hasOrientSignalRef()))}}class VP extends m_{vgField(t,n={}){const i=this.fieldDef(t);if(i)return V(i,n)}reduceFieldDef(t,n){return _se(this.getMapping(),(i,r,o)=>{const s=Mi(r);return s?t(i,s,o):i},n)}forEachFieldDef(t,n){UE(this.getMapping(),(i,r)=>{const o=Mi(i);o&&t(o,r)},n)}}class zm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??"value",r[1]??"density"];const o=this.transform.resolve??"shared";this.transform.resolve=o}clone(){return new zm(null,ce(this.transform))}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${ye(this.transform)}`}assemble(){const{density:n,...i}=this.transform,r={type:"kde",field:n,...i};return r.resolve=this.transform.resolve,r}}class Bm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i)}clone(){return new Bm(null,ce(this.transform))}dependentFields(){return new Set([this.transform.extent])}producedFields(){return new Set([])}hash(){return`ExtentTransform ${ye(this.transform)}`}assemble(){const{extent:n,param:i}=this.transform;return{type:"extent",field:n,signal:i}}}class Um extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i);const{flatten:r,as:o=[]}=this.transform;this.transform.as=r.map((s,a)=>o[a]??s)}clone(){return new Um(this.parent,ce(this.transform))}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${ye(this.transform)}`}assemble(){const{flatten:n,as:i}=this.transform;return{type:"flatten",fields:n,as:i}}}class jm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??"key",r[1]??"value"]}clone(){return new jm(null,ce(this.transform))}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${ye(this.transform)}`}assemble(){const{fold:n,as:i}=this.transform;return{type:"fold",fields:n,as:i}}}class fu extends Le{constructor(n,i,r,o){super(n);I(this,"fields");I(this,"geojson");I(this,"signal");this.fields=i,this.geojson=r,this.signal=o}clone(){return new fu(null,ce(this.fields),this.geojson,this.signal)}static parseAll(n,i){if(i.component.projection&&!i.component.projection.isFit)return n;let r=0;for(const o of[[Ii,Pi],[si,zi]]){const s=o.map(a=>{const u=ct(i.encoding[a]);return j(u)?u.field:Sr(u)?{expr:`${u.datum}`}:Fi(u)?{expr:`${u.value}`}:void 0});(s[0]||s[1])&&(n=new fu(n,s,null,i.getName(`geojson_${r++}`)))}if(i.channelHasField(Sn)){const o=i.typedFieldDef(Sn);o.type===ml&&(n=new fu(n,null,o.field,i.getName(`geojson_${r}`)))}return n}dependentFields(){const n=(this.fields??[]).filter(J);return new Set([...this.geojson?[this.geojson]:[],...n])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${ye(this.fields)}`}assemble(){return[...this.geojson?[{type:"filter",expr:`isValid(datum["${this.geojson}"])`}]:[],{type:"geojson",...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}}class rf extends Le{constructor(n,i,r,o){super(n);I(this,"projection");I(this,"fields");I(this,"as");this.projection=i,this.fields=r,this.as=o}clone(){return new rf(null,this.projection,ce(this.fields),ce(this.as))}static parseAll(n,i){if(!i.projectionName())return n;for(const r of[[Ii,Pi],[si,zi]]){const o=r.map(a=>{const u=ct(i.encoding[a]);return j(u)?u.field:Sr(u)?{expr:`${u.datum}`}:Fi(u)?{expr:`${u.value}`}:void 0}),s=r[0]===si?"2":"";(o[0]||o[1])&&(n=new rf(n,i.projectionName(),o,[i.getName(`x${s}`),i.getName(`y${s}`)]))}return n}dependentFields(){return new Set(this.fields.filter(J))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${ye(this.fields)} ${ye(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class Ws extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i}clone(){return new Ws(null,ce(this.transform))}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(n){const{start:i=0,stop:r,step:o}=n;return{signal:`sequence(${[i,r,...o?[o]:[]].join(",")})`}}static makeFromTransform(n,i){return new Ws(n,i)}static makeFromEncoding(n,i){const r=i.encoding,o=r.x,s=r.y;if(j(o)&&j(s)){const a=o.impute?o:s.impute?s:void 0;if(a===void 0)return;const u=o.impute?s:s.impute?o:void 0,{method:l,value:c,frame:f,keyvals:d}=a.impute,h=r6(i.mark,r);return new Ws(n,{impute:a.field,key:u.field,...l?{method:l}:{},...c!==void 0?{value:c}:{},...f?{frame:f}:{},...d!==void 0?{keyvals:d}:{},...h.length?{groupby:h}:{}})}return null}hash(){return`Impute ${ye(this.transform)}`}assemble(){const{impute:n,key:i,keyvals:r,method:o,groupby:s,value:a,frame:u=[null,null]}=this.transform,l={type:"impute",field:n,key:i,...r?{keyvals:$ae(r)?this.processSequence(r):r}:{},method:"value",...s?{groupby:s}:{},value:!o||o==="value"?a:null};if(o&&o!=="value"){const c={type:"window",as:[`imputed_${n}_value`],ops:[o],fields:[n],frame:u,ignorePeers:!1,...s?{groupby:s}:{}},f={type:"formula",expr:`datum.${n} === null ? datum.imputed_${n}_value : datum.${n}`,as:n};return[l,c,f]}else return[l]}}class qm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??i.on,r[1]??i.loess]}clone(){return new qm(null,ce(this.transform))}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${ye(this.transform)}`}assemble(){const{loess:n,on:i,...r}=this.transform;return{type:"loess",x:i,y:n,...r}}}class of extends Le{constructor(n,i,r){super(n);I(this,"transform");I(this,"secondary");this.transform=i,this.secondary=r}clone(){return new of(null,ce(this.transform),this.secondary)}static make(n,i,r,o){const s=i.component.data.sources,{from:a}=r;let u=null;if(kae(a)){let l=JP(a.data,s);l||(l=new ha(a.data),s.push(l));const c=i.getName(`lookup_${o}`);u=new bn(l,c,Xe.Lookup,i.component.data.outputNodeRefCounts),i.component.data.outputNodes[c]=u}else if(Aae(a)){const l=a.param;r={as:l,...r};let c;try{c=i.getSelectionComponent(Ye(l),l)}catch{throw new Error(Kie(l))}if(u=c.materialized,!u)throw new Error(Jie(l))}return new of(n,r,u.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?Q(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${ye({transform:this.transform,secondary:this.secondary})}`}assemble(){let n;if(this.transform.from.fields)n={values:this.transform.from.fields,...this.transform.as?{as:Q(this.transform.as)}:{}};else{let i=this.transform.as;J(i)||(W(ure),i="_lookup"),n={as:[i]}}return{type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...n,...this.transform.default?{default:this.transform.default}:{}}}}class Wm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??"prob",r[1]??"value"]}clone(){return new Wm(null,ce(this.transform))}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${ye(this.transform)}`}assemble(){const{quantile:n,...i}=this.transform;return{type:"quantile",field:n,...i}}}class Hm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i,this.transform=ce(i);const r=this.transform.as??[void 0,void 0];this.transform.as=[r[0]??i.on,r[1]??i.regression]}clone(){return new Hm(null,ce(this.transform))}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${ye(this.transform)}`}assemble(){const{regression:n,on:i,...r}=this.transform;return{type:"regression",x:i,y:n,...r}}}class Gm extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i}clone(){return new Gm(null,ce(this.transform))}addDimensions(n){this.transform.groupby=Rn((this.transform.groupby??[]).concat(n),i=>i)}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${ye(this.transform)}`}assemble(){const{pivot:n,value:i,groupby:r,limit:o,op:s}=this.transform;return{type:"pivot",field:n,value:i,...o!==void 0?{limit:o}:{},...s!==void 0?{op:s}:{},...r!==void 0?{groupby:r}:{}}}}class Ym extends Le{constructor(n,i){super(n);I(this,"transform");this.transform=i}clone(){return new Ym(null,ce(this.transform))}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${ye(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function XP(e){let t=0;function n(i,r){if(i instanceof ha&&!i.isGenerator&&!Wu(i.data)&&(e.push(r),r={name:null,source:r.name,transform:[]}),i instanceof jt&&(i.parent instanceof ha&&!r.source?(r.format={...r.format,parse:i.assembleFormatParse()},r.transform.push(...i.assembleTransforms(!0))):r.transform.push(...i.assembleTransforms())),i instanceof vl){r.name||(r.name=`data_${t++}`),!r.source||r.transform.length>0?(e.push(r),i.data=r.name):i.data=r.source,e.push(...i.assemble());return}switch((i instanceof Qf||i instanceof Zf||i instanceof Xu||i instanceof bl||i instanceof Gu||i instanceof rf||i instanceof Si||i instanceof of||i instanceof xl||i instanceof Ra||i instanceof jm||i instanceof Um||i instanceof zm||i instanceof qm||i instanceof Wm||i instanceof Hm||i instanceof Qo||i instanceof Ym||i instanceof Gm||i instanceof Bm)&&r.transform.push(i.assemble()),(i instanceof nr||i instanceof er||i instanceof Ws||i instanceof Vr||i instanceof fu)&&r.transform.push(...i.assemble()),i instanceof bn&&(r.source&&r.transform.length===0?i.setSource(r.source):i.parent instanceof bn?i.setSource(r.name):(r.name||(r.name=`data_${t++}`),i.setSource(r.name),i.numChildren()===1&&(e.push(r),r={name:null,source:r.name,transform:[]}))),i.numChildren()){case 0:i instanceof bn&&(!r.source||r.transform.length>0)&&e.push(r);break;case 1:n(i.children[0],r);break;default:{r.name||(r.name=`data_${t++}`);let o=r.name;!r.source||r.transform.length>0?e.push(r):o=r.source;for(const s of i.children)n(s,{name:null,source:o,transform:[]});break}}}return n}function Wce(e){const t=[],n=XP(t);for(const i of e.children)n(i,{source:e.name,name:null,transform:[]});return t}function Hce(e,t){const n=[],i=XP(n);let r=0;for(const s of e.sources){s.hasName()||(s.dataName=`source_${r++}`);const a=s.assemble();i(s,a)}for(const s of n)s.transform.length===0&&delete s.transform;let o=0;for(const[s,a]of n.entries())(a.transform??[]).length===0&&!a.source&&n.splice(o++,0,n.splice(s,1)[0]);for(const s of n)for(const a of s.transform??[])a.type==="lookup"&&(a.from=e.outputNodes[a.from].getSource());for(const s of n)s.name in t&&(s.values=t[s.name]);return n}function Gce(e){return e==="top"||e==="left"||ne(e)?"header":"footer"}function Yce(e){for(const t of Jn)Vce(e,t);CC(e,"x"),CC(e,"y")}function Vce(e,t){var s;const{facet:n,config:i,child:r,component:o}=e;if(e.channelHasField(t)){const a=n[t],u=Vu("title",null,i,t);let l=lu(a,i,{allowDisabling:!0,includeDefault:u===void 0||!!u});r.component.layoutHeaders[t].title&&(l=P(l)?l.join(", "):l,l+=` / ${r.component.layoutHeaders[t].title}`,r.component.layoutHeaders[t].title=null);const c=Vu("labelOrient",a.header,i,t),f=a.header!==null?nt((s=a.header)==null?void 0:s.labels,i.header.labels,!0):!1,d=we(["bottom","right"],c)?"footer":"header";o.layoutHeaders[t]={title:a.header!==null?l:null,facetFieldDef:a,[d]:t==="facet"?[]:[KP(e,t,f)]}}}function KP(e,t,n){const i=t==="row"?"height":"width";return{labels:n,sizeSignal:e.child.component.layoutSize.get(i)?e.child.getSizeSignalRef(i):void 0,axes:[]}}function CC(e,t){const{child:n}=e;if(n.component.axes[t]){const{layoutHeaders:i,resolve:r}=e.component;if(r.axis[t]=l_(r,t),r.axis[t]==="shared"){const o=t==="x"?"column":"row",s=i[o];for(const a of n.component.axes[t]){const u=Gce(a.get("orient"));s[u]??(s[u]=[KP(e,o,!1)]);const l=pc(a,"main",e.config,{header:!0});l&&s[u][0].axes.push(l),a.mainExtracted=!0}}}}function Xce(e){y_(e),qg(e,"width"),qg(e,"height")}function Kce(e){y_(e);const t=e.layout.columns===1?"width":"childWidth",n=e.layout.columns===void 0?"height":"childHeight";qg(e,t),qg(e,n)}function y_(e){for(const t of e.children)t.parseLayoutSize()}function qg(e,t){const n=wP(t),i=gm(n),r=e.component.resolve,o=e.component.layoutSize;let s;for(const a of e.children){const u=a.component.layoutSize.getWithExplicit(n),l=r.scale[i]??_P(i,e);if(l==="independent"&&u.value==="step"){s=void 0;break}if(s){if(l==="independent"&&s.value!==u.value){s=void 0;break}s=Jo(s,u,n,"")}else s=u}if(s){for(const a of e.children)e.renameSignal(a.getName(n),e.getName(t)),a.component.layoutSize.set(n,"merged",!1);o.setWithExplicit(t,s)}else o.setWithExplicit(t,{explicit:!1,value:void 0})}function Jce(e){const{size:t,component:n}=e;for(const i of lo){const r=$n(i);if(t[r]!=null&&t[r]!=null){const o=t[r];n.layoutSize.set(r,fr(o)?"step":o,!0)}else{const o=Qce(e,r);n.layoutSize.set(r,o,!1)}}}function Qce(e,t){const n=t==="width"?"x":"y",i=e.config,r=e.getScaleComponent(n);if(r){const o=r.get("type"),s=r.get("range");if(et(o)){const a=zg(i.view,t);return Ca(s)||fr(a)?"step":a}else return Ob(i.view,t)}else{if(e.hasProjection||e.mark==="arc")return Ob(i.view,t);{const o=zg(i.view,t);return fr(o)?o.step:o}}}function Zb(e,t,n){return V(t,{suffix:`by_${V(e)}`,...n})}class Mc extends VP{constructor(n,i,r,o){super(n,"facet",i,r,o,n.resolve);I(this,"facet");I(this,"child");I(this,"children");this.child=E_(n.spec,this,this.getName("child"),void 0,o),this.children=[this.child],this.facet=this.initFacet(n.facet)}initFacet(n){if(!Gf(n))return{facet:this.initFacetFieldDef(n,"facet")};const i=U(n),r={};for(const o of i){if(![Wr,Hr].includes(o)){W(ym(o,"facet"));break}const s=n[o];if(s.field===void 0){W(Fb(s,o));break}r[o]=this.initFacetFieldDef(s,o)}return r}initFacetFieldDef(n,i){const r=BE(n,i);return r.header?r.header=kt(r.header):r.header===null&&(r.header=null),r}channelHasField(n){return q(this.facet,n)}fieldDef(n){return this.facet[n]}parseData(){this.component.data=Vm(this),this.child.parseData()}parseLayoutSize(){y_(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection,ot(this.component.selection).some(n=>tr(n))&&gE(hE)}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),Yce(this)}assembleSelectionTopLevelSignals(n){return this.child.assembleSelectionTopLevelSignals(n)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(n){return this.child.assembleSelectionData(n)}getHeaderLayoutMixins(){const n={};for(const i of Jn)for(const r of a_){const o=this.component.layoutHeaders[i],s=o[r],{facetFieldDef:a}=o;if(a){const u=Vu("titleOrient",a.header,this.config,i);if(["right","bottom"].includes(u)){const l=Pm(i,u);n.titleAnchor??(n.titleAnchor={}),n.titleAnchor[l]="end"}}if(s!=null&&s[0]){const u=i==="row"?"height":"width",l=r==="header"?"headerBand":"footerBand";i!=="facet"&&!this.child.component.layoutSize.get(u)&&(n[l]??(n[l]={}),n[l][i]=.5),o.title&&(n.offset??(n.offset={}),n.offset[i==="row"?"rowTitle":"columnTitle"]=10)}}return n}assembleDefaultLayout(){const{column:n,row:i}=this.facet,r=n?this.columnDistinctSignal():i?1:void 0;let o="all";return(!i&&this.component.resolve.scale.x==="independent"||!n&&this.component.resolve.scale.y==="independent")&&(o="none"),{...this.getHeaderLayoutMixins(),...r?{columns:r}:{},bounds:"full",align:o}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof Mc))return{signal:`length(data('${this.getName("column_domain")}'))`}}assembleGroupStyle(){}assembleGroup(n){return this.parent&&this.parent instanceof Mc?{...this.channelHasField("column")?{encode:{update:{columns:{field:V(this.facet.column,{prefix:"distinct"})}}}}:{},...super.assembleGroup(n)}:super.assembleGroup(n)}getCardinalityAggregateForChild(){const n=[],i=[],r=[];if(this.child instanceof Mc){if(this.child.channelHasField("column")){const o=V(this.child.facet.column);n.push(o),i.push("distinct"),r.push(`distinct_${o}`)}}else for(const o of lo){const s=this.child.component.scales[o];if(s&&!s.merged){const a=s.get("type"),u=s.get("range");if(et(a)&&Ca(u)){const l=ga(this.child,o),c=g_(l);c?(n.push(c),i.push("distinct"),r.push(`distinct_${c}`)):W(dE(o))}}}return{fields:n,ops:i,as:r}}assembleFacet(){const{name:n,data:i}=this.component.data.facetRoot,{row:r,column:o}=this.facet,{fields:s,ops:a,as:u}=this.getCardinalityAggregateForChild(),l=[];for(const f of Jn){const d=this.facet[f];if(d){l.push(V(d));const{bin:h,sort:g}=d;if(Ue(h)&&l.push(V(d,{binSuffix:"end"})),Gr(g)){const{field:p,op:m=Sm}=g,y=Zb(d,g);r&&o?(s.push(y),a.push("max"),u.push(y)):(s.push(p),a.push(m),u.push(y))}else if(P(g)){const p=Yu(d,f);s.push(p),a.push("max"),u.push(p)}}}const c=!!r&&!!o;return{name:n,data:i,groupby:l,...c||s.length>0?{aggregate:{...c?{cross:c}:{},...s.length?{fields:s,ops:a,as:u}:{}}}:{}}}facetSortFields(n){const{facet:i}=this,r=i[n];return r?Gr(r.sort)?[Zb(r,r.sort,{expr:"datum"})]:P(r.sort)?[Yu(r,n,{expr:"datum"})]:[V(r,{expr:"datum"})]:[]}facetSortOrder(n){const{facet:i}=this,r=i[n];if(r){const{sort:o}=r;return[(Gr(o)?o.order:!P(o)&&o)||"ascending"]}return[]}assembleLabelTitle(){var o;const{facet:n,config:i}=this;if(n.facet)return Hb(n.facet,"facet",i);const r={row:["top","bottom"],column:["left","right"]};for(const s of s_)if(n[s]){const a=Vu("labelOrient",(o=n[s])==null?void 0:o.header,i,s);if(r[s].includes(a))return Hb(n[s],s,i)}}assembleMarks(){const{child:n}=this,i=this.component.data.facetRoot,r=Wce(i),o=n.assembleGroupEncodeEntry(!1),s=this.assembleLabelTitle()||n.assembleTitle(),a=n.assembleGroupStyle();return[{name:this.getName("cell"),type:"group",...s?{title:s}:{},...a?{style:a}:{},from:{facet:this.assembleFacet()},sort:{field:Jn.map(l=>this.facetSortFields(l)).flat(),order:Jn.map(l=>this.facetSortOrder(l)).flat()},...r.length>0?{data:r}:{},...o?{encode:{update:o}}:{},...n.assembleGroup(lue(this,[]))}]}getMapping(){return this.facet}}function Zce(e,t){const{row:n,column:i}=t;if(n&&i){let r=null;for(const o of[n,i])if(Gr(o.sort)){const{field:s,op:a=Sm}=o.sort;e=r=new Ra(e,{joinaggregate:[{op:a,field:s,as:Zb(o,o.sort,{forAs:!0})}],groupby:[V(o)]})}return r}return null}function JP(e,t){var n,i,r,o;for(const s of t){const a=s.data;if(e.name&&s.hasName()&&e.name!==s.dataName)continue;const u=(n=e.format)==null?void 0:n.mesh,l=(i=a.format)==null?void 0:i.feature;if(u&&l)continue;const c=(r=e.format)==null?void 0:r.feature;if((c||l)&&c!==l)continue;const f=(o=a.format)==null?void 0:o.mesh;if(!((u||f)&&u!==f)){if(nf(e)&&nf(a)){if(On(e.values,a.values))return s}else if(Wu(e)&&Wu(a)){if(e.url===a.url)return s}else if(D6(e)&&e.name===s.dataName)return s}}return null}function efe(e,t){if(e.data||!e.parent){if(e.data===null){const i=new ha({values:[]});return t.push(i),i}const n=JP(e.data,t);if(n)return Io(e.data)||(n.data.format=C5({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const i=new ha(e.data);return t.push(i),i}}else return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function tfe(e,t,n){let i=0;for(const r of t.transforms){let o,s;if(Pae(r))s=e=new Gu(e,r),o="derived";else if(QE(r)){const a=Nle(r);s=e=jt.makeWithAncestors(e,{},a,n)??e,e=new bl(e,t,r.filter)}else if(M6(r))s=e=nr.makeFromTransform(e,r,t),o="number";else if(zae(r))o="date",n.getWithExplicit(r.field).value===void 0&&(e=new jt(e,{[r.field]:o}),n.set(r.field,o,!1)),s=e=er.makeFromTransform(e,r);else if(Bae(r))s=e=Si.makeFromTransform(e,r),o="number",o_(t)&&(e=new Qo(e));else if(F6(r))s=e=of.make(e,t,r,i++),o="derived";else if(Oae(r))s=e=new xl(e,r),o="number";else if(Dae(r))s=e=new Ra(e,r),o="number";else if(Uae(r))s=e=Vr.makeFromTransform(e,r),o="derived";else if(jae(r))s=e=new jm(e,r),o="derived";else if(qae(r))s=e=new Bm(e,r),o="derived";else if(Lae(r))s=e=new Um(e,r),o="derived";else if(Cae(r))s=e=new Gm(e,r),o="derived";else if(Rae(r))e=new Ym(e,r);else if(Iae(r))s=e=Ws.makeFromTransform(e,r),o="derived";else if(Fae(r))s=e=new zm(e,r),o="derived";else if(Mae(r))s=e=new Wm(e,r),o="derived";else if(Tae(r))s=e=new Hm(e,r),o="derived";else if(Nae(r))s=e=new qm(e,r),o="derived";else{W(are(r));continue}if(s&&o!==void 0)for(const a of s.producedFields()??[])n.set(a,o,!1)}return e}function Vm(e){var m;let t=efe(e,e.component.data.sources);const{outputNodes:n,outputNodeRefCounts:i}=e.component.data,r=e.data,s=!(r&&(Io(r)||Wu(r)||nf(r)))&&e.parent?e.parent.component.data.ancestorParse.clone():new tue;Io(r)?(L6(r)?t=new Zf(t,r.sequence):ZE(r)&&(t=new Qf(t,r.graticule)),s.parseNothing=!0):((m=r==null?void 0:r.format)==null?void 0:m.parse)===null&&(s.parseNothing=!0),t=jt.makeExplicit(t,e,s)??t,t=new Qo(t);const a=e.parent&&wl(e.parent);(Ge(e)||zn(e))&&a&&(t=nr.makeFromEncoding(t,e)??t),e.transforms.length>0&&(t=tfe(t,e,s));const u=Ole(e),l=Rle(e);t=jt.makeWithAncestors(t,{},{...u,...l},s)??t,Ge(e)&&(t=fu.parseAll(t,e),t=rf.parseAll(t,e)),(Ge(e)||zn(e))&&(a||(t=nr.makeFromEncoding(t,e)??t),t=er.makeFromEncoding(t,e)??t,t=Gu.parseAllForSortIndex(t,e));const c=t=Rd(Xe.Raw,e,t);if(Ge(e)){const y=Si.makeFromEncoding(t,e);y&&(t=y,o_(e)&&(t=new Qo(t))),t=Ws.makeFromEncoding(t,e)??t,t=Vr.makeFromEncoding(t,e)??t}let f,d;if(Ge(e)){const{markDef:y,mark:b,config:v}=e,x=Te("invalid",y,v),{marks:E,scales:_}=d=I6({invalid:x,isPath:fs(b)});E!==_&&_==="include-invalid-values"&&(f=t=Rd(Xe.PreFilterInvalid,e,t)),E==="exclude-invalid-values"&&(t=Xu.make(t,e,d)??t)}const h=t=Rd(Xe.Main,e,t);let g;if(Ge(e)&&d){const{marks:y,scales:b}=d;y==="include-invalid-values"&&b==="exclude-invalid-values"&&(t=Xu.make(t,e,d)??t,g=t=Rd(Xe.PostFilterInvalid,e,t))}Ge(e)&&Iue(e,h);let p=null;if(zn(e)){const y=e.getName("facet");t=Zce(t,e.facet)??t,p=new vl(t,e,y,h.getSource()),n[y]=p}return{...e.component.data,outputNodes:n,outputNodeRefCounts:i,raw:c,main:h,facetRoot:p,ancestorParse:s,preFilterInvalid:f,postFilterInvalid:g}}function Rd(e,t,n){const{outputNodes:i,outputNodeRefCounts:r}=t.component.data,o=t.getDataName(e),s=new bn(n,o,e,r);return i[o]=s,s}class nfe extends m_{constructor(n,i,r,o){var s,a,u,l;super(n,"concat",i,r,o,n.resolve);I(this,"children");(((a=(s=n.resolve)==null?void 0:s.axis)==null?void 0:a.x)==="shared"||((l=(u=n.resolve)==null?void 0:u.axis)==null?void 0:l.y)==="shared")&&W(rre),this.children=this.getChildren(n).map((c,f)=>E_(c,this,this.getName(`concat_${f}`),void 0,o))}parseData(){this.component.data=Vm(this);for(const n of this.children)n.parseData()}parseSelections(){this.component.selection={};for(const n of this.children){n.parseSelections();for(const i of U(n.component.selection))this.component.selection[i]=n.component.selection[i]}ot(this.component.selection).some(n=>tr(n))&&gE(hE)}parseMarkGroup(){for(const n of this.children)n.parseMarkGroup()}parseAxesAndHeaders(){for(const n of this.children)n.parseAxesAndHeaders()}getChildren(n){return Tm(n)?n.vconcat:KE(n)?n.hconcat:n.concat}parseLayoutSize(){Kce(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(n){return this.children.reduce((i,r)=>r.assembleSelectionTopLevelSignals(i),n)}assembleSignals(){return this.children.forEach(n=>n.assembleSignals()),[]}assembleLayoutSignals(){const n=u_(this);for(const i of this.children)n.push(...i.assembleLayoutSignals());return n}assembleSelectionData(n){return this.children.reduce((i,r)=>r.assembleSelectionData(i),n)}assembleMarks(){return this.children.map(n=>{const i=n.assembleTitle(),r=n.assembleGroupStyle(),o=n.assembleGroupEncodeEntry(!1);return{type:"group",name:n.getName("group"),...i?{title:i}:{},...r?{style:r}:{},...o?{encode:{update:o}}:{},...n.assembleGroup()}})}assembleGroupStyle(){}assembleDefaultLayout(){const n=this.layout.columns;return{...n!=null?{columns:n}:{},bounds:"full",align:"each"}}}function ife(e){return e===!1||e===null}const rfe={disable:1,gridScale:1,scale:1,...QL,labelExpr:1,encode:1},QP=U(rfe);class b_ extends fo{constructor(n={},i={},r=!1){super();I(this,"explicit");I(this,"implicit");I(this,"mainExtracted");this.explicit=n,this.implicit=i,this.mainExtracted=r}clone(){return new b_(ce(this.explicit),ce(this.implicit),this.mainExtracted)}hasAxisPart(n){return n==="axis"?!0:n==="grid"||n==="title"?!!this.get(n):!ife(this.get(n))}hasOrientSignalRef(){return ne(this.explicit.orient)}}function ofe(e,t,n){const{encoding:i,config:r}=e,o=ct(i[t])??ct(i[Er(t)]),s=e.axis(t)||{},{format:a,formatType:u}=s;if(ca(u))return{text:Ei({fieldOrDatumDef:o,field:"datum.value",format:a,formatType:u,config:r}),...n};if(a===void 0&&u===void 0&&r.customFormatTypes){if(Bu(o)==="quantitative"){if(Uu(o)&&o.stack==="normalize"&&r.normalizedNumberFormatType)return{text:Ei({fieldOrDatumDef:o,field:"datum.value",format:r.normalizedNumberFormat,formatType:r.normalizedNumberFormatType,config:r}),...n};if(r.numberFormatType)return{text:Ei({fieldOrDatumDef:o,field:"datum.value",format:r.numberFormat,formatType:r.numberFormatType,config:r}),...n}}if(Bu(o)==="temporal"&&r.timeFormatType&&j(o)&&!o.timeUnit)return{text:Ei({fieldOrDatumDef:o,field:"datum.value",format:r.timeFormat,formatType:r.timeFormatType,config:r}),...n}}return n}function sfe(e){return lo.reduce((t,n)=>(e.component.scales[n]&&(t[n]=[hfe(n,e)]),t),{})}const afe={bottom:"top",top:"bottom",left:"right",right:"left"};function ufe(e){const{axes:t,resolve:n}=e.component,i={top:0,bottom:0,right:0,left:0};for(const r of e.children){r.parseAxesAndHeaders();for(const o of U(r.component.axes))n.axis[o]=l_(e.component.resolve,o),n.axis[o]==="shared"&&(t[o]=lfe(t[o],r.component.axes[o]),t[o]||(n.axis[o]="independent",delete t[o]))}for(const r of lo){for(const o of e.children)if(o.component.axes[r]){if(n.axis[r]==="independent"){t[r]=(t[r]??[]).concat(o.component.axes[r]);for(const s of o.component.axes[r]){const{value:a,explicit:u}=s.getWithExplicit("orient");if(!ne(a)){if(i[a]>0&&!u){const l=afe[a];i[a]>i[l]&&s.set("orient",l,!1)}i[a]++}}}delete o.component.axes[r]}if(n.axis[r]==="independent"&&t[r]&&t[r].length>1)for(const[o,s]of(t[r]||[]).entries())o>0&&s.get("grid")&&!s.explicit.grid&&(s.implicit.grid=!1)}}function lfe(e,t){if(e){if(e.length!==t.length)return;const n=e.length;for(let i=0;in.clone());return e}function cfe(e,t){for(const n of QP){const i=Jo(e.getWithExplicit(n),t.getWithExplicit(n),n,"axis",(r,o)=>{switch(n){case"title":return iL(r,o);case"gridScale":return{explicit:r.explicit,value:nt(r.value,o.value)}}return Rm(r,o,n,"axis")});e.setWithExplicit(n,i)}return e}function ffe(e,t,n,i,r){if(t==="disable")return n!==void 0;switch(n=n||{},t){case"titleAngle":case"labelAngle":return e===(ne(n.labelAngle)?n.labelAngle:ef(n.labelAngle));case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===mP(i,r))return!0}return e===n[t]}const dfe=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function hfe(e,t){var y,b;let n=t.axis(e);const i=new b_,r=ct(t.encoding[e]),{mark:o,config:s}=t,a=(n==null?void 0:n.orient)||((y=s[e==="x"?"axisX":"axisY"])==null?void 0:y.orient)||((b=s.axis)==null?void 0:b.orient)||Vue(e),u=t.getScaleComponent(e).get("type"),l=Uue(e,u,a,t.config),c=n!==void 0?!n:qb("disable",s.style,n==null?void 0:n.style,l).configValue;if(i.set("disable",c,n!==void 0),c)return i;n=n||{};const f=Hue(r,n,e,s.style,l),d=IL(n.formatType,r,u),h=PL(r,r.type,n.format,n.formatType,s,!0),g={fieldOrDatumDef:r,axis:n,channel:e,model:t,scaleType:u,orient:a,labelAngle:f,format:h,formatType:d,mark:o,config:s};for(const v of QP){const x=v in hC?hC[v](g):BA(v)?n[v]:void 0,E=x!==void 0,_=ffe(x,v,n,t,e);if(E&&_)i.set(v,x,_);else{const{configValue:w=void 0,configFrom:S=void 0}=BA(v)&&v!=="values"?qb(v,s.style,n.style,l):{},$=w!==void 0;E&&!$?i.set(v,x,_):(S!=="vgAxisConfig"||dfe.has(v)&&$||Kf(w)||ne(w))&&i.set(v,w,!1)}}const p=n.encoding??{},m=JL.reduce((v,x)=>{if(!i.hasAxisPart(x))return v;const E=EP(p[x]??{},t),_=x==="labels"?ofe(t,e,E):E;return _!==void 0&&!Be(_)&&(v[x]={update:_}),v},{});return Be(m)||i.set("encode",m,!!n.encoding||n.labelAngle!==void 0),i}function gfe({encoding:e,size:t}){for(const n of lo){const i=$n(n);fr(t[i])&&No(e[n])&&(delete t[i],W(uL(i)))}return t}const pfe={vgMark:"arc",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...on("x",e,{defaultPos:"mid"}),...on("y",e,{defaultPos:"mid"}),...to(e,"radius"),...to(e,"theta")})},mfe={vgMark:"area",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"}),...Bg("x",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="horizontal"}),...Bg("y",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="vertical"}),...r_(e)})},yfe={vgMark:"rect",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...to(e,"x"),...to(e,"y")})},bfe={vgMark:"shape",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})}),postEncodingTransform:e=>{const{encoding:t}=e,n=t.shape;return[{type:"geoshape",projection:e.projectionName(),...n&&j(n)&&n.type===ml?{field:V(n,{expr:"datum"})}:{}}]}},vfe={vgMark:"image",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...to(e,"x"),...to(e,"y"),...t_(e,"url")})},xfe={vgMark:"line",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...on("x",e,{defaultPos:"mid"}),...on("y",e,{defaultPos:"mid"}),...Ct("size",e,{vgChannel:"strokeWidth"}),...r_(e)})},wfe={vgMark:"trail",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...on("x",e,{defaultPos:"mid"}),...on("y",e,{defaultPos:"mid"}),...Ct("size",e),...r_(e)})};function v_(e,t){const{config:n}=e;return{...li(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...on("x",e,{defaultPos:"mid"}),...on("y",e,{defaultPos:"mid"}),...Ct("size",e),...Ct("angle",e),...Efe(e,n,t)}}function Efe(e,t,n){return n?{shape:{value:n}}:Ct("shape",e)}const _fe={vgMark:"symbol",encodeEntry:e=>v_(e)},Sfe={vgMark:"symbol",encodeEntry:e=>v_(e,"circle")},$fe={vgMark:"symbol",encodeEntry:e=>v_(e,"square")},kfe={vgMark:"rect",encodeEntry:e=>({...li(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...to(e,"x"),...to(e,"y")})},Afe={vgMark:"rule",encodeEntry:e=>{const{markDef:t}=e,n=t.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...li(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Bg("x",e,{defaultPos:n==="horizontal"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:n!=="vertical"}),...Bg("y",e,{defaultPos:n==="vertical"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:n!=="horizontal"}),...Ct("size",e,{vgChannel:"strokeWidth"})}}},Cfe={vgMark:"text",encodeEntry:e=>{const{config:t,encoding:n}=e;return{...li(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...on("x",e,{defaultPos:"mid"}),...on("y",e,{defaultPos:"mid"}),...t_(e),...Ct("size",e,{vgChannel:"fontSize"}),...Ct("angle",e),...lC("align",Ffe(e.markDef,n,t)),...lC("baseline",Mfe(e.markDef,n,t)),...on("radius",e,{defaultPos:null}),...on("theta",e,{defaultPos:null})}}};function Ffe(e,t,n){if(Te("align",e,n)===void 0)return"center"}function Mfe(e,t,n){if(Te("baseline",e,n)===void 0)return"middle"}const Tfe={vgMark:"rect",encodeEntry:e=>{const{config:t,markDef:n}=e,i=n.orient,r=i==="horizontal"?"x":"y",o=i==="horizontal"?"y":"x",s=i==="horizontal"?"height":"width";return{...li(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...to(e,r),...on(o,e,{defaultPos:"mid",vgChannel:o==="y"?"yc":"xc"}),[s]:qe(Te("thickness",n,t))}}},Od={arc:pfe,area:mfe,bar:yfe,circle:Sfe,geoshape:bfe,image:vfe,line:xfe,point:_fe,rect:kfe,rule:Afe,square:$fe,text:Cfe,tick:Tfe,trail:wfe};function Nfe(e){if(we([Em,xm,Doe],e.mark)){const t=r6(e.mark,e.encoding);if(t.length>0)return Rfe(e,t)}else if(e.mark===wm){const t=Ab.some(n=>Te(n,e.markDef,e.config));if(e.stack&&!e.fieldDef("size")&&t)return Ofe(e)}return x_(e)}const FC="faceted_path_";function Rfe(e,t){return[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:FC+e.requestDataName(Xe.Main),data:e.requestDataName(Xe.Main),groupby:t}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:x_(e,{fromPrefix:FC})}]}const MC="stack_group_";function Ofe(e){var l;const[t]=x_(e,{fromPrefix:MC}),n=e.scaleName(e.stack.fieldChannel),i=(c={})=>e.vgField(e.stack.fieldChannel,c),r=(c,f)=>{const d=[i({prefix:"min",suffix:"start",expr:f}),i({prefix:"max",suffix:"start",expr:f}),i({prefix:"min",suffix:"end",expr:f}),i({prefix:"max",suffix:"end",expr:f})];return`${c}(${d.map(h=>`scale('${n}',${h})`).join(",")})`};let o,s;e.stack.fieldChannel==="x"?(o={...Ru(t.encode.update,["y","yc","y2","height",...Ab]),x:{signal:r("min","datum")},x2:{signal:r("max","datum")},clip:{value:!0}},s={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},t.encode.update={...In(t.encode.update,["y","yc","y2"]),height:{field:{group:"height"}}}):(o={...Ru(t.encode.update,["x","xc","x2","width"]),y:{signal:r("min","datum")},y2:{signal:r("max","datum")},clip:{value:!0}},s={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},t.encode.update={...In(t.encode.update,["x","xc","x2"]),width:{field:{group:"width"}}});for(const c of Ab){const f=lr(c,e.markDef,e.config);t.encode.update[c]?(o[c]=t.encode.update[c],delete t.encode.update[c]):f&&(o[c]=qe(f)),f&&(t.encode.update[c]={value:0})}const a=[];if(((l=e.stack.groupbyChannels)==null?void 0:l.length)>0)for(const c of e.stack.groupbyChannels){const f=e.fieldDef(c),d=V(f);d&&a.push(d),(f!=null&&f.bin||f!=null&&f.timeUnit)&&a.push(V(f,{binSuffix:"end"}))}return o=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"].reduce((c,f)=>{if(t.encode.update[f])return{...c,[f]:t.encode.update[f]};{const d=lr(f,e.markDef,e.config);return d!==void 0?{...c,[f]:qe(d)}:c}},o),o.stroke&&(o.strokeForeground={value:!0},o.strokeOffset={value:0}),[{type:"group",from:{facet:{data:e.requestDataName(Xe.Main),name:MC+e.requestDataName(Xe.Main),groupby:a,aggregate:{fields:[i({suffix:"start"}),i({suffix:"start"}),i({suffix:"end"}),i({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:o},marks:[{type:"group",encode:{update:s},marks:[t]}]}]}function Dfe(e){const{encoding:t,stack:n,mark:i,markDef:r,config:o}=e,s=t.order;if(!(!P(s)&&Fi(s)&&$b(s.value)||!s&&$b(Te("order",r,o)))){if((P(s)||j(s))&&!n)return eL(s,{expr:"datum"});if(fs(i)){const a=r.orient==="horizontal"?"y":"x",u=t[a];if(j(u))return{field:a}}}}function x_(e,t={fromPrefix:""}){var h;const{mark:n,markDef:i,encoding:r,config:o}=e,s=nt(i.clip,Lfe(e),Pfe(e)),a=Q5(i),u=r.key,l=Dfe(e),c=Ife(e);c&&Object.values(e.component.selection).some(g=>g.type==="point"&&!g.bind&&g.on!=="pointerover")&&((h=e.markDef).cursor??(h.cursor="pointer"));const f=Te("aria",i,o),d=Od[n].postEncodingTransform?Od[n].postEncodingTransform(e):null;return[{name:e.getName("marks"),type:Od[n].vgMark,...s?{clip:s}:{},...a?{style:a}:{},...u?{key:u.field}:{},...l?{sort:l}:{},...c||{},...f===!1?{aria:f}:{},from:{data:t.fromPrefix+e.requestDataName(Xe.Main)},encode:{update:Od[n].encodeEntry(e)},...d?{transform:d}:{}}]}function Lfe(e){const t=e.getScaleComponent("x"),n=e.getScaleComponent("y");return t!=null&&t.get("selectionExtent")||n!=null&&n.get("selectionExtent")?!0:void 0}function Pfe(e){const t=e.component.projection;return t&&!t.isFit?!0:void 0}function Ife(e){if(!e.component.selection)return null;const t=U(e.component.selection).length;let n=t,i=e.parent;for(;i&&n===0;)n=U(i.component.selection).length,i=i.parent;return n?{interactive:t>0||e.mark==="geoshape"||!!e.encoding.tooltip||!!e.markDef.tooltip}:null}class ZP extends VP{constructor(n,i,r,o={},s){super(n,"unit",i,r,s,void 0,jA(n)?n.view:void 0);I(this,"markDef");I(this,"encoding");I(this,"specifiedScales",{});I(this,"stack");I(this,"specifiedAxes",{});I(this,"specifiedLegends",{});I(this,"specifiedProjection",{});I(this,"selection",[]);I(this,"children",[]);I(this,"correctDataNames",n=>{var i,r,o;return(i=n.from)!=null&&i.data&&(n.from.data=this.lookupDataSource(n.from.data),"time"in this.encoding&&(n.from.data=n.from.data+B6)),(o=(r=n.from)==null?void 0:r.facet)!=null&&o.data&&(n.from.facet.data=this.lookupDataSource(n.from.facet.data)),n});const a=cr(n.mark)?{...n.mark}:{type:n.mark},u=a.type;a.filled===void 0&&(a.filled=yae(a,s,{graticule:n.data&&ZE(n.data)}));const l=this.encoding=wse(n.encoding||{},u,a.filled,s);this.markDef=$6(a,l,s),this.size=gfe({encoding:l,size:jA(n)?{...o,...n.width!==void 0?{width:n.width}:{},...n.height!==void 0?{height:n.height}:{}}:o}),this.stack=S6(this.markDef,l),this.specifiedScales=this.initScales(u,l),this.specifiedAxes=this.initAxes(l),this.specifiedLegends=this.initLegends(l),this.specifiedProjection=n.projection,this.selection=(n.params??[]).filter(c=>VE(c)),this.alignStackOrderWithColorDomain()}get hasProjection(){const{encoding:n}=this,i=this.mark===ML,r=n&&hie.some(o=>fe(n[o]));return i||r}scaleDomain(n){const i=this.specifiedScales[n];return i?i.domain:void 0}axis(n){return this.specifiedAxes[n]}legend(n){return this.specifiedLegends[n]}initScales(n,i){return lE.reduce((r,o)=>{const s=ct(i[o]);return s&&(r[o]=this.initScale(s.scale??{})),r},{})}initScale(n){const{domain:i,range:r}=n,o=kt(n);return P(i)&&(o.domain=i.map(Tn)),P(r)&&(o.range=r.map(Tn)),o}initAxes(n){return lo.reduce((i,r)=>{const o=n[r];if(fe(o)||r===We&&fe(n.x2)||r===dt&&fe(n.y2)){const s=fe(o)?o.axis:void 0;i[r]=s&&this.initAxis({...s})}return i},{})}initAxis(n){const i=U(n),r={};for(const o of i){const s=n[o];r[o]=Kf(s)?J5(s):Tn(s)}return r}initLegends(n){return Sie.reduce((i,r)=>{const o=ct(n[r]);if(o&&kie(r)){const s=o.legend;i[r]=s&&kt(s)}return i},{})}alignStackOrderWithColorDomain(){var m;const{color:n,fill:i,order:r,xOffset:o,yOffset:s}=this.encoding,a=i||n,u=j(a)?a:void 0,l=u==null?void 0:u.field,c=u==null?void 0:u.scale,f=u==null?void 0:u.type,d=c==null?void 0:c.domain,h=o||s,g=j(h)?h:void 0,p=`_${l}_sort_index`;if(!r&&Array.isArray(d)&&typeof l=="string"&&f==="nominal")if(g&&!g.sort)g.sort=d;else{if(!this.stack)return;const y=`indexof(${G(d)}, datum['${l}'])`,b=((m=this.markDef)==null?void 0:m.orient)==="horizontal"?"ascending":"descending";this.transforms.push({calculate:y,as:p}),this.encoding.order={field:p,type:"quantitative",sort:b}}}parseData(){this.component.data=Vm(this)}parseLayoutSize(){Jce(this)}parseSelections(){this.component.selection=Pue(this,this.selection)}parseMarkGroup(){this.component.mark=Nfe(this)}parseAxesAndHeaders(){this.component.axes=sfe(this)}assembleSelectionTopLevelSignals(n){return cue(this,n)}assembleSignals(){return[...hP(this),...uue(this,[])]}assembleSelectionData(n){return fue(this,n)}assembleLayout(){return null}assembleLayoutSignals(){return u_(this)}assembleMarks(){let n=this.component.mark??[];return(!this.parent||!wl(this.parent))&&(n=W6(this,n)),n.map(this.correctDataNames)}assembleGroupStyle(){const{style:n}=this.view||{};return n!==void 0?n:this.encoding.x||this.encoding.y?"cell":"view"}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(n){return js(this.encoding,n)}fieldDef(n){const i=this.encoding[n];return Mi(i)}typedFieldDef(n){const i=this.fieldDef(n);return cn(i)?i:null}}class w_ extends m_{constructor(n,i,r,o,s){super(n,"layer",i,r,s,n.resolve,n.view);I(this,"children");const a={...o,...n.width?{width:n.width}:{},...n.height?{height:n.height}:{}};this.children=n.layer.map((u,l)=>{if(Nm(u))return new w_(u,this,this.getName(`layer_${l}`),a,s);if(co(u))return new ZP(u,this,this.getName(`layer_${l}`),a,s);throw new Error(fE(u))})}parseData(){this.component.data=Vm(this);for(const n of this.children)n.parseData()}parseLayoutSize(){Xce(this)}parseSelections(){this.component.selection={};for(const n of this.children){n.parseSelections();for(const i of U(n.component.selection))this.component.selection[i]=n.component.selection[i]}ot(this.component.selection).some(n=>tr(n))&&gE(hE)}parseMarkGroup(){for(const n of this.children)n.parseMarkGroup()}parseAxesAndHeaders(){ufe(this)}assembleSelectionTopLevelSignals(n){return this.children.reduce((i,r)=>r.assembleSelectionTopLevelSignals(i),n)}assembleSignals(){return this.children.reduce((n,i)=>n.concat(i.assembleSignals()),hP(this))}assembleLayoutSignals(){return this.children.reduce((n,i)=>n.concat(i.assembleLayoutSignals()),u_(this))}assembleSelectionData(n){return this.children.reduce((i,r)=>r.assembleSelectionData(i),n)}assembleGroupStyle(){const n=new Set;for(const r of this.children)for(const o of Q(r.assembleGroupStyle()))n.add(o);const i=Array.from(n);return i.length>1?i:i.length===1?i[0]:void 0}assembleTitle(){let n=super.assembleTitle();if(n)return n;for(const i of this.children)if(n=i.assembleTitle(),n)return n}assembleLayout(){return null}assembleMarks(){return due(this,this.children.flatMap(n=>n.assembleMarks()))}assembleLegends(){return this.children.reduce((n,i)=>n.concat(i.assembleLegends()),OP(this))}}function E_(e,t,n,i,r){if($m(e))return new Mc(e,t,n,r);if(Nm(e))return new w_(e,t,n,i,r);if(co(e))return new ZP(e,t,n,i,r);if(Hse(e))return new nfe(e,t,n,r);throw new Error(fE(e))}function zfe(e,t={}){t.logger&&Xre(t.logger),t.fieldTitle&&VL(t.fieldTitle);try{const n=_6(Ju(t.config,e.config)),i=R6(e,n),r=E_(i,null,"",void 0,n);return r.parse(),Xle(r.component.data,r),{spec:Ufe(r,Bfe(e,i.autosize,n,r),e.datasets,e.usermeta),normalized:i}}finally{t.logger&&Kre(),t.fieldTitle&&dse()}}function Bfe(e,t,n,i){const r=i.component.layoutSize.get("width"),o=i.component.layoutSize.get("height");if(t===void 0?(t={type:"pad"},i.hasAxisOrientSignalRef()&&(t.resize=!0)):J(t)&&(t={type:t}),r&&o&&Qae(t.type)){if(r==="step"&&o==="step")W(kA()),t.type="pad";else if(r==="step"||o==="step"){const s=r==="step"?"width":"height";W(kA(gm(s)));const a=s==="width"?"height":"width";t.type=Zae(a)}}return{...U(t).length===1&&t.type?t.type==="pad"?{}:{autosize:t.type}:{autosize:t},...eC(n,!1),...eC(e,!0)}}function Ufe(e,t,n={},i){const r=e.config?oae(e.config):void 0,o=Hce(e.component.data,n),s=e.assembleSelectionData(o),a=e.assembleProjections(),u=e.assembleTitle(),l=e.assembleGroupStyle(),c=e.assembleGroupEncodeEntry(!0);let f=e.assembleLayoutSignals();f=f.filter(g=>(g.name==="width"||g.name==="height")&&g.value!==void 0?(t[g.name]=+g.value,!1):!0);const{params:d,...h}=t;return{$schema:"https://vega.github.io/schema/vega/v6.json",...e.description?{description:e.description}:{},...h,...u?{title:u}:{},...l?{style:l}:{},...c?{encode:{update:c}}:{},data:s,...a.length>0?{projections:a}:{},...e.assembleGroup([...f,...e.assembleSelectionTopLevelSignals([]),...v6(d)]),...r?{config:r}:{},...i?{usermeta:i}:{}}}const jfe=aie.version,qfe=Object.freeze(Object.defineProperty({__proto__:null,accessPathDepth:Lu,accessPathWithDatum:tE,accessWithDatumToUnescapedPath:Re,compile:zfe,contains:we,deepEqual:On,deleteNestedProperty:Tg,duplicate:ce,entries:Xo,every:Qw,fieldIntersection:eE,flatAccessWithDatum:M5,getFirstDefined:nt,hasIntersection:Zw,hasProperty:q,hash:ye,internalField:O5,isBoolean:Du,isEmpty:Be,isEqual:lie,isInternalField:D5,isNullOrFalse:$b,isNumeric:um,isPrimitive:Mg,keys:U,logicalExpr:Cc,mergeDeep:C5,never:A5,normalize:R6,normalizeAngle:ef,omit:In,pick:Ru,prefixGenerator:kb,removePathFromField:gl,replaceAll:ra,replacePathInField:oi,resetIdCounter:fie,setEqual:F5,some:Ou,stringify:De,titleCase:zf,unescapeSingleQuoteAndPathDot:T5,unique:Rn,uniqueId:R5,vals:ot,varName:Ye,version:jfe},Symbol.toStringTag,{value:"Module"}));function eI(e){const[t,n]=/schema\/([\w-]+)\/([\w\.\-]+)\.json$/g.exec(e).slice(1,3);return{library:t,version:n}}var Wfe="3.0.0",Hfe={version:Wfe};const Ha="#fff",TC="#888",Gfe={background:"#333",view:{stroke:TC},title:{color:Ha,subtitleColor:Ha},style:{"guide-label":{fill:Ha},"guide-title":{fill:Ha}},axis:{domainColor:Ha,gridColor:TC,tickColor:Ha}},ys="#4572a7",Yfe={background:"#fff",arc:{fill:ys},area:{fill:ys},line:{stroke:ys,strokeWidth:2},path:{stroke:ys},rect:{fill:ys},shape:{stroke:ys},symbol:{fill:ys,strokeWidth:1.5,size:50},axis:{bandPosition:.5,grid:!0,gridColor:"#000000",gridOpacity:1,gridWidth:.5,labelPadding:10,tickSize:5,tickWidth:.5},axisBand:{grid:!1,tickExtra:!0},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:50,symbolType:"square"},range:{category:["#4572a7","#aa4643","#8aa453","#71598e","#4598ae","#d98445","#94aace","#d09393","#b9cc98","#a99cbc"]}},bs="#30a2da",x1="#cbcbcb",Vfe="#999",Xfe="#333",NC="#f0f0f0",RC="#333",Kfe={arc:{fill:bs},area:{fill:bs},axis:{domainColor:x1,grid:!0,gridColor:x1,gridWidth:1,labelColor:Vfe,labelFontSize:10,titleColor:Xfe,tickColor:x1,tickSize:10,titleFontSize:14,titlePadding:10,labelPadding:4},axisBand:{grid:!1},background:NC,group:{fill:NC},legend:{labelColor:RC,labelFontSize:11,padding:1,symbolSize:30,symbolType:"square",titleColor:RC,titleFontSize:14,titlePadding:10},line:{stroke:bs,strokeWidth:2},path:{stroke:bs,strokeWidth:.5},rect:{fill:bs},range:{category:["#30a2da","#fc4f30","#e5ae38","#6d904f","#8b8b8b","#b96db8","#ff9e27","#56cc60","#52d2ca","#52689e","#545454","#9fe4f8"],diverging:["#cc0020","#e77866","#f6e7e1","#d6e8ed","#91bfd9","#1d78b5"],heatmap:["#d6e8ed","#cee0e5","#91bfd9","#549cc6","#1d78b5"]},point:{filled:!0,shape:"circle"},shape:{stroke:bs},bar:{binSpacing:2,fill:bs,stroke:null},title:{anchor:"start",fontSize:24,fontWeight:600,offset:20}},vs="#000",Jfe={group:{fill:"#e5e5e5"},arc:{fill:vs},area:{fill:vs},line:{stroke:vs},path:{stroke:vs},rect:{fill:vs},shape:{stroke:vs},symbol:{fill:vs,size:40},axis:{domain:!1,grid:!0,gridColor:"#FFFFFF",gridOpacity:1,labelColor:"#7F7F7F",labelPadding:4,tickColor:"#7F7F7F",tickSize:5.67,titleFontSize:16,titleFontWeight:"normal"},legend:{labelBaseline:"middle",labelFontSize:11,symbolSize:40},range:{category:["#000000","#7F7F7F","#1A1A1A","#999999","#333333","#B0B0B0","#4D4D4D","#C9C9C9","#666666","#DCDCDC"]}},Qfe=22,Zfe="normal",OC="Benton Gothic, sans-serif",DC=11.5,ede="normal",xs="#82c6df",w1="Benton Gothic Bold, sans-serif",LC="normal",PC=13,Wl={"category-6":["#ec8431","#829eb1","#c89d29","#3580b1","#adc839","#ab7fb4"],"fire-7":["#fbf2c7","#f9e39c","#f8d36e","#f4bb6a","#e68a4f","#d15a40","#ab4232"],"fireandice-6":["#e68a4f","#f4bb6a","#f9e39c","#dadfe2","#a6b7c6","#849eae"]},tde={background:"#ffffff",title:{anchor:"start",color:"#000000",font:w1,fontSize:Qfe,fontWeight:Zfe},arc:{fill:xs},area:{fill:xs},line:{stroke:xs,strokeWidth:2},path:{stroke:xs},rect:{fill:xs},shape:{stroke:xs},symbol:{fill:xs,size:30},axis:{labelFont:OC,labelFontSize:DC,labelFontWeight:ede,titleFont:w1,titleFontSize:PC,titleFontWeight:LC},axisX:{labelAngle:0,labelPadding:4,tickSize:3},axisY:{labelBaseline:"middle",maxExtent:45,minExtent:45,tickSize:2,titleAlign:"left",titleAngle:0,titleX:-45,titleY:-11},legend:{labelFont:OC,labelFontSize:DC,symbolType:"square",titleFont:w1,titleFontSize:PC,titleFontWeight:LC},range:{category:Wl["category-6"],diverging:Wl["fireandice-6"],heatmap:Wl["fire-7"],ordinal:Wl["fire-7"],ramp:Wl["fire-7"]}},ws="#ab5787",Dd="#979797",nde={background:"#f9f9f9",arc:{fill:ws},area:{fill:ws},line:{stroke:ws},path:{stroke:ws},rect:{fill:ws},shape:{stroke:ws},symbol:{fill:ws,size:30},axis:{domainColor:Dd,domainWidth:.5,gridWidth:.2,labelColor:Dd,tickColor:Dd,tickWidth:.2,titleColor:Dd},axisBand:{grid:!1},axisX:{grid:!0,tickSize:10},axisY:{domain:!1,grid:!0,tickSize:0},legend:{labelFontSize:11,padding:1,symbolSize:30,symbolType:"square"},range:{category:["#ab5787","#51b2e5","#703c5c","#168dd9","#d190b6","#00609f","#d365ba","#154866","#666666","#c4c4c4"]}},Es="#3e5c69",ide={background:"#fff",arc:{fill:Es},area:{fill:Es},line:{stroke:Es},path:{stroke:Es},rect:{fill:Es},shape:{stroke:Es},symbol:{fill:Es},axis:{domainWidth:.5,grid:!0,labelPadding:2,tickSize:5,tickWidth:.5,titleFontWeight:"normal"},axisBand:{grid:!1},axisX:{gridWidth:.2},axisY:{gridDash:[3],gridWidth:.4},legend:{labelFontSize:11,padding:1,symbolType:"square"},range:{category:["#3e5c69","#6793a6","#182429","#0570b0","#3690c0","#74a9cf","#a6bddb","#e2ddf2"]}},Hn="#1696d2",IC="#000000",rde="#FFFFFF",Ld="Lato",E1="Lato",ode="Lato",sde="#DEDDDD",ade=18,Hl={"shades-blue":["#CFE8F3","#A2D4EC","#73BFE2","#46ABDB","#1696D2","#12719E","#0A4C6A","#062635"],"six-groups-cat-1":["#1696d2","#ec008b","#fdbf11","#000000","#d2d2d2","#55b748"],"six-groups-seq":["#cfe8f3","#a2d4ec","#73bfe2","#46abdb","#1696d2","#12719e"],"diverging-colors":["#ca5800","#fdbf11","#fdd870","#fff2cf","#cfe8f3","#73bfe2","#1696d2","#0a4c6a"]},ude={background:rde,title:{anchor:"start",fontSize:ade,font:Ld},axisX:{domain:!0,domainColor:IC,domainWidth:1,grid:!1,labelFontSize:12,labelFont:E1,labelAngle:0,tickColor:IC,tickSize:5,titleFontSize:12,titlePadding:10,titleFont:Ld},axisY:{domain:!1,domainWidth:1,grid:!0,gridColor:sde,gridWidth:1,labelFontSize:12,labelFont:E1,labelPadding:8,ticks:!1,titleFontSize:12,titlePadding:10,titleFont:Ld,titleAngle:0,titleY:-10,titleX:18},legend:{labelFontSize:12,labelFont:E1,symbolSize:100,titleFontSize:12,titlePadding:10,titleFont:Ld,orient:"right",offset:10},view:{stroke:"transparent"},range:{category:Hl["six-groups-cat-1"],diverging:Hl["diverging-colors"],heatmap:Hl["diverging-colors"],ordinal:Hl["six-groups-seq"],ramp:Hl["shades-blue"]},area:{fill:Hn},rect:{fill:Hn},line:{color:Hn,stroke:Hn,strokeWidth:5},trail:{color:Hn,stroke:Hn,strokeWidth:0,size:1},path:{stroke:Hn,strokeWidth:.5},point:{filled:!0},text:{font:ode,color:Hn,fontSize:11,align:"center",fontWeight:400,size:11},style:{bar:{fill:Hn,stroke:null}},arc:{fill:Hn},shape:{stroke:Hn},symbol:{fill:Hn,size:30}},_s="#3366CC",zC="#ccc",Pd="Arial, sans-serif",lde={arc:{fill:_s},area:{fill:_s},path:{stroke:_s},rect:{fill:_s},shape:{stroke:_s},symbol:{stroke:_s},circle:{fill:_s},background:"#fff",padding:{top:10,right:10,bottom:10,left:10},style:{"guide-label":{font:Pd,fontSize:12},"guide-title":{font:Pd,fontSize:12},"group-title":{font:Pd,fontSize:12}},title:{font:Pd,fontSize:14,fontWeight:"bold",dy:-3,anchor:"start"},axis:{gridColor:zC,tickColor:zC,domain:!1,grid:!0},range:{category:["#4285F4","#DB4437","#F4B400","#0F9D58","#AB47BC","#00ACC1","#FF7043","#9E9D24","#5C6BC0","#F06292","#00796B","#C2185B"],heatmap:["#c6dafc","#5e97f6","#2a56c6"]}},__=e=>e*(1/3+1),BC=__(9),UC=__(10),jC=__(12),Gl="Segoe UI",qC="wf_standard-font, helvetica, arial, sans-serif",WC="#252423",Yl="#605E5C",HC="transparent",cde="#C8C6C4",di="#118DFF",fde="#12239E",dde="#E66C37",hde="#6B007B",gde="#E044A7",pde="#744EC2",mde="#D9B300",yde="#D64550",tI=di,nI="#DEEFFF",GC=[nI,tI],bde=[nI,"#c7e4ff","#b0d9ff","#9aceff","#83c3ff","#6cb9ff","#55aeff","#3fa3ff","#2898ff",tI],vde={view:{stroke:HC},background:HC,font:Gl,header:{titleFont:qC,titleFontSize:jC,titleColor:WC,labelFont:Gl,labelFontSize:UC,labelColor:Yl},axis:{ticks:!1,grid:!1,domain:!1,labelColor:Yl,labelFontSize:BC,titleFont:qC,titleColor:WC,titleFontSize:jC,titleFontWeight:"normal"},axisQuantitative:{tickCount:3,grid:!0,gridColor:cde,gridDash:[1,5],labelFlush:!1},axisBand:{tickExtra:!0},axisX:{labelPadding:5},axisY:{labelPadding:10},bar:{fill:di},line:{stroke:di,strokeWidth:3,strokeCap:"round",strokeJoin:"round"},text:{font:Gl,fontSize:BC,fill:Yl},arc:{fill:di},area:{fill:di,line:!0,opacity:.6},path:{stroke:di},rect:{fill:di},point:{fill:di,filled:!0,size:75},shape:{stroke:di},symbol:{fill:di,strokeWidth:1.5,size:50},legend:{titleFont:Gl,titleFontWeight:"bold",titleColor:Yl,labelFont:Gl,labelFontSize:UC,labelColor:Yl,symbolType:"circle",symbolSize:75},range:{category:[di,fde,dde,hde,gde,pde,mde,yde],diverging:GC,heatmap:GC,ordinal:bde}},_1='IBM Plex Sans,system-ui,-apple-system,BlinkMacSystemFont,".sfnstext-regular",sans-serif',xde='IBM Plex Sans Condensed, system-ui, -apple-system, BlinkMacSystemFont, ".SFNSText-Regular", sans-serif',S1=400,Id={textPrimary:{g90:"#f4f4f4",g100:"#f4f4f4",white:"#161616",g10:"#161616"},textSecondary:{g90:"#c6c6c6",g100:"#c6c6c6",white:"#525252",g10:"#525252"},layerAccent01:{white:"#e0e0e0",g10:"#e0e0e0",g90:"#525252",g100:"#393939"},gridBg:{white:"#ffffff",g10:"#ffffff",g90:"#161616",g100:"#161616"}},wde=["#8a3ffc","#33b1ff","#007d79","#ff7eb6","#fa4d56","#fff1f1","#6fdc8c","#4589ff","#d12771","#d2a106","#08bdba","#bae6ff","#ba4e00","#d4bbff"],Ede=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"];function Xm({theme:e,background:t}){const n=["white","g10"].includes(e)?"light":"dark",i=Id.gridBg[e],r=Id.textPrimary[e],o=Id.textSecondary[e],s=n==="dark"?wde:Ede,a=n==="dark"?"#d4bbff":"#6929c4";return{background:t,arc:{fill:a},area:{fill:a},path:{stroke:a},rect:{fill:a},shape:{stroke:a},symbol:{stroke:a},circle:{fill:a},view:{fill:i,stroke:i},group:{fill:i},title:{color:r,anchor:"start",dy:-15,fontSize:16,font:_1,fontWeight:600},axis:{labelColor:o,labelFontSize:12,labelFont:xde,labelFontWeight:S1,titleColor:r,titleFontWeight:600,titleFontSize:12,grid:!0,gridColor:Id.layerAccent01[e],labelAngle:0},axisX:{titlePadding:10},axisY:{titlePadding:2.5},style:{"guide-label":{font:_1,fill:o,fontWeight:S1},"guide-title":{font:_1,fill:o,fontWeight:S1}},range:{category:s,diverging:["#750e13","#a2191f","#da1e28","#fa4d56","#ff8389","#ffb3b8","#ffd7d9","#fff1f1","#e5f6ff","#bae6ff","#82cfff","#33b1ff","#1192e8","#0072c3","#00539a","#003a6d"],heatmap:["#f6f2ff","#e8daff","#d4bbff","#be95ff","#a56eff","#8a3ffc","#6929c4","#491d8b","#31135e","#1c0f30"]}}}const _de=Xm({theme:"white",background:"#ffffff"}),Sde=Xm({theme:"g10",background:"#f4f4f4"}),$de=Xm({theme:"g90",background:"#262626"}),kde=Xm({theme:"g100",background:"#161616"}),Ade=Hfe.version,Cde=Object.freeze(Object.defineProperty({__proto__:null,carbong10:Sde,carbong100:kde,carbong90:$de,carbonwhite:_de,dark:Gfe,excel:Yfe,fivethirtyeight:Kfe,ggplot2:Jfe,googlecharts:lde,latimes:tde,powerbi:vde,quartz:nde,urbaninstitute:ude,version:Ade,vox:ide},Symbol.toStringTag,{value:"Module"}));function Fde(e,t,n,i){if(P(e))return`[${e.map(r=>t(J(r)?r:YC(r,n))).join(", ")}]`;if(K(e)){let r="";const{title:o,image:s,...a}=e;o&&(r+=`

${t(o)}

`),s&&(r+=``);const u=Object.keys(a);if(u.length>0){r+="";for(const l of u){let c=a[l];c!==void 0&&(K(c)&&(c=YC(c,n)),r+=``)}r+="
${t(l)}${t(c)}
"}return r||"{}"}return t(e)}function Mde(e){const t=[];return function(n,i){if(typeof i!="object"||i===null)return i;const r=t.indexOf(this)+1;return t.length=r,t.length>e?"[Object]":t.indexOf(i)>=0?"[Circular]":(t.push(i),i)}}function YC(e,t){return JSON.stringify(e,Mde(t))}var Tde=`#vg-tooltip-element { + visibility: hidden; + padding: 8px; + position: fixed; + z-index: 1000; + font-family: sans-serif; + font-size: 11px; + border-radius: 3px; + box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1); + /* The default theme is the light theme. */ + background-color: rgba(255, 255, 255, 0.95); + border: 1px solid #d9d9d9; + color: black; +} +#vg-tooltip-element.visible { + visibility: visible; +} +#vg-tooltip-element h2 { + margin-top: 0; + margin-bottom: 10px; + font-size: 13px; +} +#vg-tooltip-element table { + border-spacing: 0; +} +#vg-tooltip-element table tr { + border: none; +} +#vg-tooltip-element table tr td { + overflow: hidden; + text-overflow: ellipsis; + padding-top: 2px; + padding-bottom: 2px; +} +#vg-tooltip-element table tr td.key { + color: #808080; + max-width: 150px; + text-align: right; + padding-right: 4px; +} +#vg-tooltip-element table tr td.value { + display: block; + max-width: 300px; + max-height: 7em; + text-align: left; +} +#vg-tooltip-element.dark-theme { + background-color: rgba(32, 32, 32, 0.9); + border: 1px solid #f5f5f5; + color: white; +} +#vg-tooltip-element.dark-theme td.key { + color: #bfbfbf; +} +`;const iI="vg-tooltip-element",Nde={offsetX:10,offsetY:10,id:iI,styleId:"vega-tooltip-style",theme:"light",disableDefaultStyle:!1,sanitize:Rde,maxDepth:2,formatTooltip:Fde,baseURL:"",anchor:"cursor",position:["top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"]};function Rde(e){return String(e).replace(/&/g,"&").replace(/=0&&e.y>=0&&e.x+t.width<=window.innerWidth&&e.y+t.height<=window.innerHeight}function Pde(e,t,n){return e.clientX>=t.x&&e.clientX<=t.x+n.width&&e.clientY>=t.y&&e.clientY<=t.y+n.height}class Ide{constructor(t){I(this,"call");I(this,"options");I(this,"el");this.options={...Nde,...t};const n=this.options.id;if(this.el=null,this.call=this.tooltipHandler.bind(this),!this.options.disableDefaultStyle&&!document.getElementById(this.options.styleId)){const i=document.createElement("style");i.setAttribute("id",this.options.styleId),i.innerHTML=Ode(n);const r=document.head;r.childNodes.length>0?r.insertBefore(i,r.childNodes[0]):r.appendChild(i)}}tooltipHandler(t,n,i,r){if(this.el=document.getElementById(this.options.id),this.el||(this.el=document.createElement("div"),this.el.setAttribute("id",this.options.id),this.el.classList.add("vg-tooltip"),(document.fullscreenElement??document.body).appendChild(this.el)),r==null||r===""){this.el.classList.remove("visible",`${this.options.theme}-theme`);return}this.el.innerHTML=this.options.formatTooltip(r,this.options.sanitize,this.options.maxDepth,this.options.baseURL),this.el.classList.add("visible",`${this.options.theme}-theme`);const{x:o,y:s}=this.options.anchor==="mark"?Dde(t,n,i,this.el.getBoundingClientRect(),this.options):rI(n,this.el.getBoundingClientRect(),this.options);this.el.style.top=`${s}px`,this.el.style.left=`${o}px`}}var $1={};/*! + * https://github.com/Starcounter-Jack/JSON-Patch + * (c) 2017-2022 Joachim Wester + * MIT licensed + */var zde=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var o in r)r.hasOwnProperty(o)&&(i[o]=r[o])},e(t,n)};return function(t,n){e(t,n);function i(){this.constructor=t}t.prototype=n===null?Object.create(n):(i.prototype=n.prototype,new i)}}(),Bde=Object.prototype.hasOwnProperty;function ev(e,t){return Bde.call(e,t)}function tv(e){if(Array.isArray(e)){for(var t=new Array(e.length),n=0;n=48&&i<=57){t++;continue}return!1}return!0}function ks(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function aI(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function iv(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t0&&u[c-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(l[h]===void 0?d=u.slice(0,c).join("/"):c==f-1&&(d=t.path),d!==void 0&&g(t,0,e,d)),c++,Array.isArray(l)){if(h==="-")h=l.length;else{if(n&&!nv(h))throw new Je("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",o,t,e);nv(h)&&(h=~~h)}if(c>=f){if(n&&t.op==="add"&&h>l.length)throw new Je("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",o,t,e);var s=jde[t.op].call(t,l,h,e);if(s.test===!1)throw new Je("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return s}}else if(c>=f){var s=tu[t.op].call(t,l,h,e);if(s.test===!1)throw new Je("Test operation failed","TEST_OPERATION_FAILED",o,t,e);return s}if(l=l[h],n&&c0)throw new Je('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,n);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new Je("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new Je("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,n);if((e.op==="add"||e.op==="replace"||e.op==="test")&&iv(e.value))throw new Je("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,n);if(n){if(e.op=="add"){var r=e.path.split("/").length,o=i.split("/").length;if(r!==o+1&&r!==o)throw new Je("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,n)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==i)throw new Je("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,n)}else if(e.op==="move"||e.op==="copy"){var s={op:"_get",path:e.from,value:void 0},a=lI([s],n);if(a&&a.name==="OPERATION_PATH_UNRESOLVABLE")throw new Je("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,n)}}}else throw new Je("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,n)}function lI(e,t,n){try{if(!Array.isArray(e))throw new Je("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Km(Dn(t),Dn(e),n||!0);else{n=n||Hg;for(var i=0;i0&&(e.patches=[],e.callback&&e.callback(i)),i}function $_(e,t,n,i,r){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var o=tv(t),s=tv(e),a=!1,u=s.length-1;u>=0;u--){var l=s[u],c=e[l];if(ev(t,l)&&!(t[l]===void 0&&c!==void 0&&Array.isArray(t)===!1)){var f=t[l];typeof c=="object"&&c!=null&&typeof f=="object"&&f!=null&&Array.isArray(c)===Array.isArray(f)?$_(c,f,n,i+"/"+ks(l),r):c!==f&&(r&&n.push({op:"test",path:i+"/"+ks(l),value:Dn(c)}),n.push({op:"replace",path:i+"/"+ks(l),value:Dn(f)}))}else Array.isArray(e)===Array.isArray(t)?(r&&n.push({op:"test",path:i+"/"+ks(l),value:Dn(c)}),n.push({op:"remove",path:i+"/"+ks(l)}),a=!0):(r&&n.push({op:"test",path:i,value:e}),n.push({op:"replace",path:i,value:t}))}if(!(!a&&o.length==s.length))for(var u=0;u=this.max){const o=this.map.keys().next().value;this.delete(o)}this.map.set(n,i)}return this}}return k1=e,k1}var A1,KC;function k_(){if(KC)return A1;KC=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return A1=i=>i?typeof i!="object"?e:i:t,A1}var zd={exports:{}},C1,JC;function A_(){if(JC)return C1;JC=1;const e="2.0.0",t=256,n=Number.MAX_SAFE_INTEGER||9007199254740991,i=16,r=t-6;return C1={MAX_LENGTH:t,MAX_SAFE_COMPONENT_LENGTH:i,MAX_SAFE_BUILD_LENGTH:r,MAX_SAFE_INTEGER:n,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:e,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},C1}var F1,QC;function Jm(){return QC||(QC=1,F1=typeof process=="object"&&$1&&$1.NODE_DEBUG&&/\bsemver\b/i.test($1.NODE_DEBUG)?(...t)=>console.error("SEMVER",...t):()=>{}),F1}var ZC;function C_(){return ZC||(ZC=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:i,MAX_LENGTH:r}=A_(),o=Jm();t=e.exports={};const s=t.re=[],a=t.safeRe=[],u=t.src=[],l=t.safeSrc=[],c=t.t={};let f=0;const d="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",r],[d,i]],g=m=>{for(const[y,b]of h)m=m.split(`${y}*`).join(`${y}{0,${b}}`).split(`${y}+`).join(`${y}{1,${b}}`);return m},p=(m,y,b)=>{const v=g(y),x=f++;o(m,x,y),c[m]=x,u[x]=y,l[x]=v,s[x]=new RegExp(y,b?"g":void 0),a[x]=new RegExp(v,b?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${d}*`),p("MAINVERSION",`(${u[c.NUMERICIDENTIFIER]})\\.(${u[c.NUMERICIDENTIFIER]})\\.(${u[c.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${u[c.NUMERICIDENTIFIERLOOSE]})\\.(${u[c.NUMERICIDENTIFIERLOOSE]})\\.(${u[c.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${u[c.NONNUMERICIDENTIFIER]}|${u[c.NUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${u[c.NONNUMERICIDENTIFIER]}|${u[c.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASE",`(?:-(${u[c.PRERELEASEIDENTIFIER]}(?:\\.${u[c.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${u[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${u[c.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${d}+`),p("BUILD",`(?:\\+(${u[c.BUILDIDENTIFIER]}(?:\\.${u[c.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${u[c.MAINVERSION]}${u[c.PRERELEASE]}?${u[c.BUILD]}?`),p("FULL",`^${u[c.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${u[c.MAINVERSIONLOOSE]}${u[c.PRERELEASELOOSE]}?${u[c.BUILD]}?`),p("LOOSE",`^${u[c.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${u[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${u[c.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${u[c.XRANGEIDENTIFIER]})(?:\\.(${u[c.XRANGEIDENTIFIER]})(?:\\.(${u[c.XRANGEIDENTIFIER]})(?:${u[c.PRERELEASE]})?${u[c.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${u[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${u[c.XRANGEIDENTIFIERLOOSE]})(?:${u[c.PRERELEASELOOSE]})?${u[c.BUILD]}?)?)?`),p("XRANGE",`^${u[c.GTLT]}\\s*${u[c.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${u[c.GTLT]}\\s*${u[c.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),p("COERCE",`${u[c.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",u[c.COERCEPLAIN]+`(?:${u[c.PRERELEASE]})?(?:${u[c.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",u[c.COERCE],!0),p("COERCERTLFULL",u[c.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${u[c.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",p("TILDE",`^${u[c.LONETILDE]}${u[c.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${u[c.LONETILDE]}${u[c.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${u[c.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",p("CARET",`^${u[c.LONECARET]}${u[c.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${u[c.LONECARET]}${u[c.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${u[c.GTLT]}\\s*(${u[c.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${u[c.GTLT]}\\s*(${u[c.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${u[c.GTLT]}\\s*(${u[c.LOOSEPLAIN]}|${u[c.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${u[c.XRANGEPLAIN]})\\s+-\\s+(${u[c.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${u[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${u[c.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(zd,zd.exports)),zd.exports}var M1,eF;function nhe(){if(eF)return M1;eF=1;const e=/^[0-9]+$/,t=(i,r)=>{const o=e.test(i),s=e.test(r);return o&&s&&(i=+i,r=+r),i===r?0:o&&!s?-1:s&&!o?1:it(r,i)},M1}var T1,tF;function F_(){if(tF)return T1;tF=1;const e=Jm(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=A_(),{safeRe:i,t:r}=C_(),o=k_(),{compareIdentifiers:s}=nhe();class a{constructor(l,c){if(c=o(c),l instanceof a){if(l.loose===!!c.loose&&l.includePrerelease===!!c.includePrerelease)return l;l=l.version}else if(typeof l!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof l}".`);if(l.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",l,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const f=l.trim().match(c.loose?i[r.LOOSE]:i[r.FULL]);if(!f)throw new TypeError(`Invalid Version: ${l}`);if(this.raw=l,this.major=+f[1],this.minor=+f[2],this.patch=+f[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");f[4]?this.prerelease=f[4].split(".").map(d=>{if(/^[0-9]+$/.test(d)){const h=+d;if(h>=0&&h=0;)typeof this.prerelease[h]=="number"&&(this.prerelease[h]++,h=-2);if(h===-1){if(c===this.prerelease.join(".")&&f===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(d)}}if(c){let h=[c,d];f===!1&&(h=[c]),s(this.prerelease[0],c)===0?isNaN(this.prerelease[1])&&(this.prerelease=h):this.prerelease=h}break}default:throw new Error(`invalid increment argument: ${l}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return T1=a,T1}var N1,nF;function El(){if(nF)return N1;nF=1;const e=F_();return N1=(n,i,r)=>new e(n,r).compare(new e(i,r)),N1}var R1,iF;function ihe(){if(iF)return R1;iF=1;const e=El();return R1=(n,i,r)=>e(n,i,r)===0,R1}var O1,rF;function rhe(){if(rF)return O1;rF=1;const e=El();return O1=(n,i,r)=>e(n,i,r)!==0,O1}var D1,oF;function ohe(){if(oF)return D1;oF=1;const e=El();return D1=(n,i,r)=>e(n,i,r)>0,D1}var L1,sF;function she(){if(sF)return L1;sF=1;const e=El();return L1=(n,i,r)=>e(n,i,r)>=0,L1}var P1,aF;function ahe(){if(aF)return P1;aF=1;const e=El();return P1=(n,i,r)=>e(n,i,r)<0,P1}var I1,uF;function uhe(){if(uF)return I1;uF=1;const e=El();return I1=(n,i,r)=>e(n,i,r)<=0,I1}var z1,lF;function lhe(){if(lF)return z1;lF=1;const e=ihe(),t=rhe(),n=ohe(),i=she(),r=ahe(),o=uhe();return z1=(a,u,l,c)=>{switch(u){case"===":return typeof a=="object"&&(a=a.version),typeof l=="object"&&(l=l.version),a===l;case"!==":return typeof a=="object"&&(a=a.version),typeof l=="object"&&(l=l.version),a!==l;case"":case"=":case"==":return e(a,l,c);case"!=":return t(a,l,c);case">":return n(a,l,c);case">=":return i(a,l,c);case"<":return r(a,l,c);case"<=":return o(a,l,c);default:throw new TypeError(`Invalid operator: ${u}`)}},z1}var B1,cF;function che(){if(cF)return B1;cF=1;const e=Symbol("SemVer ANY");class t{static get ANY(){return e}constructor(c,f){if(f=n(f),c instanceof t){if(c.loose===!!f.loose)return c;c=c.value}c=c.trim().split(/\s+/).join(" "),s("comparator",c,f),this.options=f,this.loose=!!f.loose,this.parse(c),this.semver===e?this.value="":this.value=this.operator+this.semver.version,s("comp",this)}parse(c){const f=this.options.loose?i[r.COMPARATORLOOSE]:i[r.COMPARATOR],d=c.match(f);if(!d)throw new TypeError(`Invalid comparator: ${c}`);this.operator=d[1]!==void 0?d[1]:"",this.operator==="="&&(this.operator=""),d[2]?this.semver=new a(d[2],this.options.loose):this.semver=e}toString(){return this.value}test(c){if(s("Comparator.test",c,this.options.loose),this.semver===e||c===e)return!0;if(typeof c=="string")try{c=new a(c,this.options)}catch{return!1}return o(c,this.operator,this.semver,this.options)}intersects(c,f){if(!(c instanceof t))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new u(c.value,f).test(this.value):c.operator===""?c.value===""?!0:new u(this.value,f).test(c.semver):(f=n(f),f.includePrerelease&&(this.value==="<0.0.0-0"||c.value==="<0.0.0-0")||!f.includePrerelease&&(this.value.startsWith("<0.0.0")||c.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&c.operator.startsWith(">")||this.operator.startsWith("<")&&c.operator.startsWith("<")||this.semver.version===c.semver.version&&this.operator.includes("=")&&c.operator.includes("=")||o(this.semver,"<",c.semver,f)&&this.operator.startsWith(">")&&c.operator.startsWith("<")||o(this.semver,">",c.semver,f)&&this.operator.startsWith("<")&&c.operator.startsWith(">")))}}B1=t;const n=k_(),{safeRe:i,t:r}=C_(),o=lhe(),s=Jm(),a=F_(),u=cI();return B1}var U1,fF;function cI(){if(fF)return U1;fF=1;const e=/\s+/g;class t{constructor(k,M){if(M=r(M),k instanceof t)return k.loose===!!M.loose&&k.includePrerelease===!!M.includePrerelease?k:new t(k.raw,M);if(k instanceof o)return this.raw=k.value,this.set=[[k]],this.formatted=void 0,this;if(this.options=M,this.loose=!!M.loose,this.includePrerelease=!!M.includePrerelease,this.raw=k.trim().replace(e," "),this.set=this.raw.split("||").map(D=>this.parseRange(D.trim())).filter(D=>D.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const D=this.set[0];if(this.set=this.set.filter(B=>!p(B[0])),this.set.length===0)this.set=[D];else if(this.set.length>1){for(const B of this.set)if(B.length===1&&m(B[0])){this.set=[B];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let k=0;k0&&(this.formatted+="||");const M=this.set[k];for(let D=0;D0&&(this.formatted+=" "),this.formatted+=M[D].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(k){const D=((this.options.includePrerelease&&h)|(this.options.loose&&g))+":"+k,B=i.get(D);if(B)return B;const z=this.options.loose,X=z?u[l.HYPHENRANGELOOSE]:u[l.HYPHENRANGE];k=k.replace(X,T(this.options.includePrerelease)),s("hyphen replace",k),k=k.replace(u[l.COMPARATORTRIM],c),s("comparator trim",k),k=k.replace(u[l.TILDETRIM],f),s("tilde trim",k),k=k.replace(u[l.CARETTRIM],d),s("caret trim",k);let le=k.split(" ").map(ge=>b(ge,this.options)).join(" ").split(/\s+/).map(ge=>F(ge,this.options));z&&(le=le.filter(ge=>(s("loose invalid filter",ge,this.options),!!ge.match(u[l.COMPARATORLOOSE])))),s("range list",le);const se=new Map,he=le.map(ge=>new o(ge,this.options));for(const ge of he){if(p(ge))return[ge];se.set(ge.value,ge)}se.size>1&&se.has("")&&se.delete("");const Ie=[...se.values()];return i.set(D,Ie),Ie}intersects(k,M){if(!(k instanceof t))throw new TypeError("a Range is required");return this.set.some(D=>y(D,M)&&k.set.some(B=>y(B,M)&&D.every(z=>B.every(X=>z.intersects(X,M)))))}test(k){if(!k)return!1;if(typeof k=="string")try{k=new a(k,this.options)}catch{return!1}for(let M=0;MC.value==="<0.0.0-0",m=C=>C.value==="",y=(C,k)=>{let M=!0;const D=C.slice();let B=D.pop();for(;M&&D.length;)M=D.every(z=>B.intersects(z,k)),B=D.pop();return M},b=(C,k)=>(s("comp",C,k),C=_(C,k),s("caret",C),C=x(C,k),s("tildes",C),C=S(C,k),s("xrange",C),C=A(C,k),s("stars",C),C),v=C=>!C||C.toLowerCase()==="x"||C==="*",x=(C,k)=>C.trim().split(/\s+/).map(M=>E(M,k)).join(" "),E=(C,k)=>{const M=k.loose?u[l.TILDELOOSE]:u[l.TILDE];return C.replace(M,(D,B,z,X,le)=>{s("tilde",C,D,B,z,X,le);let se;return v(B)?se="":v(z)?se=`>=${B}.0.0 <${+B+1}.0.0-0`:v(X)?se=`>=${B}.${z}.0 <${B}.${+z+1}.0-0`:le?(s("replaceTilde pr",le),se=`>=${B}.${z}.${X}-${le} <${B}.${+z+1}.0-0`):se=`>=${B}.${z}.${X} <${B}.${+z+1}.0-0`,s("tilde return",se),se})},_=(C,k)=>C.trim().split(/\s+/).map(M=>w(M,k)).join(" "),w=(C,k)=>{s("caret",C,k);const M=k.loose?u[l.CARETLOOSE]:u[l.CARET],D=k.includePrerelease?"-0":"";return C.replace(M,(B,z,X,le,se)=>{s("caret",C,B,z,X,le,se);let he;return v(z)?he="":v(X)?he=`>=${z}.0.0${D} <${+z+1}.0.0-0`:v(le)?z==="0"?he=`>=${z}.${X}.0${D} <${z}.${+X+1}.0-0`:he=`>=${z}.${X}.0${D} <${+z+1}.0.0-0`:se?(s("replaceCaret pr",se),z==="0"?X==="0"?he=`>=${z}.${X}.${le}-${se} <${z}.${X}.${+le+1}-0`:he=`>=${z}.${X}.${le}-${se} <${z}.${+X+1}.0-0`:he=`>=${z}.${X}.${le}-${se} <${+z+1}.0.0-0`):(s("no pr"),z==="0"?X==="0"?he=`>=${z}.${X}.${le}${D} <${z}.${X}.${+le+1}-0`:he=`>=${z}.${X}.${le}${D} <${z}.${+X+1}.0-0`:he=`>=${z}.${X}.${le} <${+z+1}.0.0-0`),s("caret return",he),he})},S=(C,k)=>(s("replaceXRanges",C,k),C.split(/\s+/).map(M=>$(M,k)).join(" ")),$=(C,k)=>{C=C.trim();const M=k.loose?u[l.XRANGELOOSE]:u[l.XRANGE];return C.replace(M,(D,B,z,X,le,se)=>{s("xRange",C,D,B,z,X,le,se);const he=v(z),Ie=he||v(X),ge=Ie||v(le),Ot=ge;return B==="="&&Ot&&(B=""),se=k.includePrerelease?"-0":"",he?B===">"||B==="<"?D="<0.0.0-0":D="*":B&&Ot?(Ie&&(X=0),le=0,B===">"?(B=">=",Ie?(z=+z+1,X=0,le=0):(X=+X+1,le=0)):B==="<="&&(B="<",Ie?z=+z+1:X=+X+1),B==="<"&&(se="-0"),D=`${B+z}.${X}.${le}${se}`):Ie?D=`>=${z}.0.0${se} <${+z+1}.0.0-0`:ge&&(D=`>=${z}.${X}.0${se} <${z}.${+X+1}.0-0`),s("xRange return",D),D})},A=(C,k)=>(s("replaceStars",C,k),C.trim().replace(u[l.STAR],"")),F=(C,k)=>(s("replaceGTE0",C,k),C.trim().replace(u[k.includePrerelease?l.GTE0PRE:l.GTE0],"")),T=C=>(k,M,D,B,z,X,le,se,he,Ie,ge,Ot)=>(v(D)?M="":v(B)?M=`>=${D}.0.0${C?"-0":""}`:v(z)?M=`>=${D}.${B}.0${C?"-0":""}`:X?M=`>=${M}`:M=`>=${M}${C?"-0":""}`,v(he)?se="":v(Ie)?se=`<${+he+1}.0.0-0`:v(ge)?se=`<${he}.${+Ie+1}.0-0`:Ot?se=`<=${he}.${Ie}.${ge}-${Ot}`:C?se=`<${he}.${Ie}.${+ge+1}-0`:se=`<=${se}`,`${M} ${se}`.trim()),N=(C,k,M)=>{for(let D=0;D0){const B=C[D].semver;if(B.major===k.major&&B.minor===k.minor&&B.patch===k.patch)return!0}return!1}return!0};return U1}var j1,dF;function fhe(){if(dF)return j1;dF=1;const e=cI();return j1=(n,i,r)=>{try{i=new e(i,r)}catch{return!1}return i.test(n)},j1}var dhe=fhe(),fI=ehe(dhe);function hhe(e,t,n){const i=e.open(t),r=250,{origin:o}=new URL(t);let s=40;function a(l){l.source===i&&(s=0,e.removeEventListener("message",a,!1))}e.addEventListener("message",a,!1);function u(){s<=0||(i.postMessage(n,o),setTimeout(u,r),s-=1)}setTimeout(u,r)}var ghe=`.vega-embed { + position: relative; + display: inline-block; + box-sizing: border-box; +} +.vega-embed.has-actions { + padding-right: 38px; +} +.vega-embed details:not([open]) > :not(summary) { + display: none !important; +} +.vega-embed summary { + list-style: none; + position: absolute; + top: 0; + right: 0; + padding: 6px; + z-index: 1000; + background: white; + box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1); + color: #1b1e23; + border: 1px solid #aaa; + border-radius: 999px; + opacity: 0.2; + transition: opacity 0.4s ease-in; + cursor: pointer; + line-height: 0px; +} +.vega-embed summary::-webkit-details-marker { + display: none; +} +.vega-embed summary:active { + box-shadow: #aaa 0px 0px 0px 1px inset; +} +.vega-embed summary svg { + width: 14px; + height: 14px; +} +.vega-embed details[open] summary { + opacity: 0.7; +} +.vega-embed:hover summary, .vega-embed:focus-within summary { + opacity: 1 !important; + transition: opacity 0.2s ease; +} +.vega-embed .vega-actions { + position: absolute; + z-index: 1001; + top: 35px; + right: -9px; + display: flex; + flex-direction: column; + padding-bottom: 8px; + padding-top: 8px; + border-radius: 4px; + box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.2); + border: 1px solid #d9d9d9; + background: white; + animation-duration: 0.15s; + animation-name: scale-in; + animation-timing-function: cubic-bezier(0.2, 0, 0.13, 1.5); + text-align: left; +} +.vega-embed .vega-actions a { + padding: 8px 16px; + font-family: sans-serif; + font-size: 14px; + font-weight: 600; + white-space: nowrap; + color: #434a56; + text-decoration: none; +} +.vega-embed .vega-actions a:hover, .vega-embed .vega-actions a:focus { + background-color: #f7f7f9; + color: black; +} +.vega-embed .vega-actions::before, .vega-embed .vega-actions::after { + content: ""; + display: inline-block; + position: absolute; +} +.vega-embed .vega-actions::before { + left: auto; + right: 14px; + top: -16px; + border: 8px solid rgba(0, 0, 0, 0); + border-bottom-color: #d9d9d9; +} +.vega-embed .vega-actions::after { + left: auto; + right: 15px; + top: -14px; + border: 7px solid rgba(0, 0, 0, 0); + border-bottom-color: #fff; +} +.vega-embed .chart-wrapper.fit-x { + width: 100%; +} +.vega-embed .chart-wrapper.fit-y { + height: 100%; +} + +.vega-embed-wrapper { + max-width: 100%; + overflow: auto; + padding-right: 14px; +} + +@keyframes scale-in { + from { + opacity: 0; + transform: scale(0.6); + } + to { + opacity: 1; + transform: scale(1); + } +} +`;function dI(e,...t){for(const n of t)phe(e,n);return e}function phe(e,t){for(const n of Object.keys(t))Qu(e,n,t[n],!0)}var mhe="7.1.0",yhe={version:mhe};const hge=yhe.version,qi=Xne;let af=qfe;const Bd=typeof window<"u"?window:void 0;var mF;af===void 0&&((mF=Bd==null?void 0:Bd.vl)!=null&&mF.compile)&&(af=Bd.vl);const bhe={export:{svg:!0,png:!0},source:!0,compiled:!0,editor:!0},vhe={CLICK_TO_VIEW_ACTIONS:"Click to view actions",COMPILED_ACTION:"View Compiled Vega",EDITOR_ACTION:"Open in Vega Editor",PNG_ACTION:"Save as PNG",SOURCE_ACTION:"View Source",SVG_ACTION:"Save as SVG"},mc={vega:"Vega","vega-lite":"Vega-Lite"},Gg={vega:qi.version,"vega-lite":af?af.version:"not available"},xhe={vega:e=>e,"vega-lite":(e,t,n)=>af.compile(e,{config:n,logger:t}).spec},whe=` + + + + +`,Ehe="chart-wrapper";function _he(e){return typeof e=="function"}function hF(e,t,n,i){const r=`${t}
`,o=`
${n}`,s=window.open("");s.document.write(r+e+o),s.document.title=`${mc[i]} JSON Source`}function She(e,t,n){if(e.$schema){const i=eI(e.$schema);n&&n!==i.library&&t.warn(`The given visualization spec is written in ${mc[i.library]}, but mode argument sets ${mc[n]??n}.`);const r=i.library;return fI(Gg[r],`^${i.version.slice(1)}`)||t.warn(`The input spec uses ${mc[r]} ${i.version}, but the current version of ${mc[r]} is v${Gg[r]}.`),r}return"mark"in e||"encoding"in e||"layer"in e||"hconcat"in e||"vconcat"in e||"facet"in e||"repeat"in e?"vega-lite":"marks"in e||"signals"in e||"scales"in e||"axes"in e?"vega":n??"vega"}function hI(e){return!!(e&&"load"in e)}function gF(e){return hI(e)?e:qi.loader(e)}function $he(e){var n;const t=((n=e.usermeta)==null?void 0:n.embedOptions)??{};return J(t.defaultStyle)&&(t.defaultStyle=!1),t}async function gge(e,t,n={}){let i,r;J(t)?(r=gF(n.loader),i=JSON.parse(await r.load(t))):i=t;const o=$he(i),s=o.loader;(!r||s)&&(r=gF(n.loader??s));const a=await pF(o,r),u=await pF(n,r),l={...dI(u,a),config:Ju(u.config??{},a.config??{})};return await Ahe(e,i,l,r)}async function pF(e,t){const n=J(e.config)?JSON.parse(await t.load(e.config)):e.config??{},i=J(e.patch)?JSON.parse(await t.load(e.patch)):e.patch;return{...e,...i?{patch:i}:{},...n?{config:n}:{}}}function khe(e){const t=e.getRootNode?e.getRootNode():document;return t instanceof ShadowRoot?{root:t,rootContainer:t}:{root:document,rootContainer:document.head??document.body}}async function Ahe(e,t,n={},i){const r=n.theme?Ju(Cde[n.theme],n.config??{}):n.config,o=pa(n.actions)?n.actions:dI({},bhe,n.actions??{}),s={...vhe,...n.i18n},a=n.renderer??"svg",u=n.logger??Yg(qi.Warn);n.logLevel!==void 0&&u.level(n.logLevel);const l=n.downloadFileName??"visualization",c=typeof e=="string"?document.querySelector(e):e;if(!c)throw new Error(`${e} does not exist`);if(n.defaultStyle!==!1){const E="vega-embed-style",{root:_,rootContainer:w}=khe(c);if(!_.getElementById(E)){const S=document.createElement("style");S.id=E,S.innerHTML=n.defaultStyle===void 0||n.defaultStyle===!0?ghe.toString():n.defaultStyle,w.appendChild(S)}}const f=She(t,u,n.mode);let d=xhe[f](t,u,r);if(f==="vega-lite"&&d.$schema){const E=eI(d.$schema);fI(Gg.vega,`^${E.version.slice(1)}`)||u.warn(`The compiled spec uses Vega ${E.version}, but current version is v${Gg.vega}.`)}c.classList.add("vega-embed"),o&&c.classList.add("has-actions"),c.innerHTML="";let h=c;if(o){const E=document.createElement("div");E.classList.add(Ehe),c.appendChild(E),h=E}const g=n.patch;if(g&&(d=g instanceof Function?g(d):Km(d,g,!0,!1).newDocument),n.formatLocale&&qi.formatLocale(n.formatLocale),n.timeFormatLocale&&qi.timeFormatLocale(n.timeFormatLocale),n.expressionFunctions)for(const E in n.expressionFunctions){const _=n.expressionFunctions[E];"fn"in _?qi.expressionFunction(E,_.fn,_.visitor):_ instanceof Function&&qi.expressionFunction(E,_)}const{ast:p}=n,m=qi.parse(d,f==="vega-lite"?{}:r,{ast:p}),y=new(n.viewClass||qi.View)(m,{loader:i,logger:u,renderer:a,...p?{expr:qi.expressionInterpreter??n.expr??oie}:{}});if(y.addSignalListener("autosize",(E,_)=>{const{type:w}=_;w=="fit-x"?(h.classList.add("fit-x"),h.classList.remove("fit-y")):w=="fit-y"?(h.classList.remove("fit-x"),h.classList.add("fit-y")):w=="fit"?h.classList.add("fit-x","fit-y"):h.classList.remove("fit-x","fit-y")}),n.tooltip!==!1){const{loader:E,tooltip:_}=n,w=E&&!hI(E)?E==null?void 0:E.baseURL:void 0,S=_he(_)?_:new Ide({baseURL:w,..._===!0?{}:_}).call;y.tooltip(S)}let{hover:b}=n;if(b===void 0&&(b=f==="vega"),b){const{hoverSet:E,updateSet:_}=typeof b=="boolean"?{}:b;y.hover(E,_)}n&&(n.width!=null&&y.width(n.width),n.height!=null&&y.height(n.height),n.padding!=null&&y.padding(n.padding)),await y.initialize(h,n.bind).runAsync();let v;if(o!==!1){let E=c;if(n.defaultStyle!==!1||n.forceActionsMenu){const w=document.createElement("details");w.title=s.CLICK_TO_VIEW_ACTIONS,c.append(w),E=w;const S=document.createElement("summary");S.innerHTML=whe,w.append(S),v=$=>{w.contains($.target)||w.removeAttribute("open")},document.addEventListener("click",v)}const _=document.createElement("div");if(E.append(_),_.classList.add("vega-actions"),o===!0||o.export!==!1){for(const w of["svg","png"])if(o===!0||o.export===!0||o.export[w]){const S=s[`${w.toUpperCase()}_ACTION`],$=document.createElement("a"),A=K(n.scaleFactor)?n.scaleFactor[w]:n.scaleFactor;$.text=S,$.href="#",$.target="_blank",$.download=`${l}.${w}`,$.addEventListener("mousedown",async function(F){F.preventDefault();const T=await y.toImageURL(w,A);this.href=T}),_.append($)}}if(o===!0||o.source!==!1){const w=document.createElement("a");w.text=s.SOURCE_ACTION,w.href="#",w.addEventListener("click",function(S){hF(Zm(t),n.sourceHeader??"",n.sourceFooter??"",f),S.preventDefault()}),_.append(w)}if(f==="vega-lite"&&(o===!0||o.compiled!==!1)){const w=document.createElement("a");w.text=s.COMPILED_ACTION,w.href="#",w.addEventListener("click",function(S){hF(Zm(d),n.sourceHeader??"",n.sourceFooter??"","vega"),S.preventDefault()}),_.append(w)}if(o===!0||o.editor!==!1){const w=n.editorUrl??"https://vega.github.io/editor/",S=document.createElement("a");S.text=s.EDITOR_ACTION,S.href="#",S.addEventListener("click",function($){hhe(window,w,{config:r,mode:g?"vega":f,renderer:a,spec:Zm(g?d:t)}),$.preventDefault()}),_.append(S)}}function x(){v&&document.removeEventListener("click",v),y.finalize()}return{view:y,spec:t,vgSpec:d,finalize:x,embedOptions:n}}export{bhe as DEFAULT_ACTIONS,gge as default,She as guessMode,qi as vega,af as vegaLite,hge as version}; diff --git a/apps/api/field_notes_api/_web/assets/index-Cgs-dOlY.css b/apps/api/field_notes_api/_web/assets/index-Cgs-dOlY.css new file mode 100644 index 0000000..b1ac06f --- /dev/null +++ b/apps/api/field_notes_api/_web/assets/index-Cgs-dOlY.css @@ -0,0 +1 @@ +:root{--paper: #ffffff;--paper-2: #ffffff;--paper-3: #f4f4f4;--paper-4: #e8e8e8;--ink: #000000;--ink-2: #333333;--ink-3: #666666;--ink-4: #999999;--rule: #e0e0e0;--rule-2: #c8c8c8;--c-amber: oklch(.66 .16 70);--c-amber-bg: oklch(.93 .05 80);--c-blue: oklch(.5 .14 250);--c-blue-bg: oklch(.93 .035 250);--c-green: oklch(.5 .13 150);--c-green-bg: oklch(.93 .045 150);--c-red: oklch(.52 .17 28);--c-red-bg: oklch(.93 .04 28);--sans: "Google Sans", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;--mono: "Roboto Mono", ui-monospace, "SF Mono", Menlo, monospace;--serif: "Newsreader", Georgia, serif;--top-h: 150px}*{box-sizing:border-box}html,body{margin:0;padding:0}body{font-family:var(--sans);color:var(--ink);background:var(--paper);font-size:15px;line-height:1.5;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;min-height:100vh}.mono{font-family:var(--mono)}.dim{color:var(--ink-3)}.page{max-width:1480px;margin:0 auto;padding:0 28px 80px}.page-body{display:grid;grid-template-columns:clamp(220px,22vw,300px) minmax(0,1fr);gap:28px;align-items:start}.page-body.toc-hidden{grid-template-columns:minmax(0,1fr)}.toc-toggle{position:sticky;top:calc(var(--top-h) + 12px);align-self:flex-start;margin-left:-6px;margin-bottom:-50px;z-index:5;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;border:1px solid var(--rule);background:#fff;color:var(--ink-2);border-radius:6px;cursor:pointer;box-shadow:0 1px 2px #0000000a}.toc-toggle:hover{color:var(--ink);border-color:var(--ink)}.toc-toggle:focus-visible{outline:2px solid var(--ink);outline-offset:2px}@media (max-width: 880px){.toc-toggle{display:none}}.top{position:sticky;top:0;z-index:10;margin-left:calc(-50vw + 50%);margin-right:calc(-50vw + 50%);padding:14px calc(50vw - 50% + 28px) 18px;background:linear-gradient(to bottom,var(--paper) 78%,color-mix(in oklch,var(--paper) 60%,transparent));border-bottom:1px solid var(--rule);margin-bottom:28px;-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px)}.ptab-strip{display:flex;align-items:flex-end;gap:2px;margin:0 0 8px;padding:0;border-bottom:1px solid var(--rule);overflow-x:auto;scrollbar-width:thin}.ptab-folder{display:inline-flex;align-items:center;gap:6px;padding:0 14px 10px 4px;color:var(--ink-3);font-size:10px;letter-spacing:.16em;text-transform:uppercase;flex-shrink:0}.ptab-folder svg{color:var(--ink-3)}.ptab-list{display:flex;gap:2px;flex:1;min-width:0;overflow:visible}.ptab{position:relative;display:flex;align-items:center;gap:10px;padding:9px 14px 10px;background:transparent;border:1px solid transparent;border-bottom:none;border-top-left-radius:8px;border-top-right-radius:8px;cursor:pointer;color:var(--ink-3);min-width:0;max-width:280px;flex-shrink:1;transition:background .14s,color .14s,border-color .14s;margin-bottom:-1px}.ptab:hover{color:var(--ink-2);background:color-mix(in oklch,var(--paper-2) 60%,transparent)}.ptab.is-active{background:var(--paper-3);color:var(--ink);border-color:var(--rule);box-shadow:0 -3px 0 var(--c-blue) inset}.ptab[draggable=true]{cursor:grab}.ptab.is-dragging{opacity:.4;cursor:grabbing}.ptab.is-drag-over{box-shadow:3px 0 0 var(--c-blue) inset;background:color-mix(in oklch,var(--c-blue) 10%,transparent)}.ptab-body{display:flex;flex-direction:column;gap:2px;min-width:0}.ptab-name{font-size:13px;font-weight:500;letter-spacing:-.005em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px}.ptab-meta{display:flex;align-items:center;gap:6px;font-size:10.5px}.ptab-counts{display:inline-flex;gap:5px}.ptab-pip{display:inline-flex;align-items:center;gap:4px;font-variant-numeric:tabular-nums;color:var(--ink-2)}.ptab-pip.dim{color:var(--ink-4)}.pip-dot{width:6px;height:6px;border-radius:50%;display:inline-block}.pip-amber{background:var(--c-amber)}.pip-blue{background:var(--c-blue)}.pip-green{background:var(--c-green)}.pip-red{background:var(--c-red)}.pip-rest{background:var(--ink-4)}.pip-dot.pulse{box-shadow:0 0 color-mix(in oklch,var(--c-amber) 60%,transparent);animation:pulse-amber 1.8s ease-out infinite}@keyframes pulse-amber{0%{box-shadow:0 0 color-mix(in oklch,var(--c-amber) 60%,transparent)}70%{box-shadow:0 0 0 5px color-mix(in oklch,var(--c-amber) 0%,transparent)}to{box-shadow:0 0 color-mix(in oklch,var(--c-amber) 0%,transparent)}}.ptab-sub{font-size:10.5px}.ptab-close{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:none;color:var(--ink-3);cursor:pointer;width:18px;height:18px;display:grid;place-items:center;border-radius:6px;flex-shrink:0}.ptab-close:hover{background:var(--paper-3);color:var(--ink)}.ptab-add{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:1px dashed var(--rule-2);color:var(--ink-3);width:30px;height:30px;display:grid;place-items:center;cursor:pointer;border-radius:8px;margin:0 0 6px 8px;flex-shrink:0}.ptab-add:hover{color:var(--ink);border-color:var(--ink-3);border-style:solid;background:var(--paper-2)}.filter-bar{display:flex;align-items:center;justify-content:space-between;padding:12px 0 14px;gap:12px;flex-wrap:wrap}.filter-title{font-size:16px;font-weight:600;letter-spacing:-.01em;line-height:1.2;margin:0;color:var(--ink)}.filter-pills{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.pill-sep{width:1px;height:18px;background:var(--rule-2);margin:0 6px}.pill{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:1px solid var(--rule-2);color:var(--ink-2);font-family:var(--mono);font-size:13px;padding:6px 10px 6px 9px;display:inline-flex;align-items:center;gap:7px;cursor:pointer;border-radius:20px;transition:background .12s,color .12s,border-color .12s}.pill:hover{border-color:var(--ink-3);color:var(--ink)}.pill.is-active{background:var(--paper-4);border-color:var(--c-blue);color:var(--ink)}.pill-dot{width:7px;height:7px;border-radius:50%;background:var(--c);display:inline-block}.pill.is-active .pill-dot{outline:2px solid color-mix(in oklch,var(--c) 50%,transparent);outline-offset:1px}.pill-count{color:var(--ink-4);font-variant-numeric:tabular-nums;margin-left:2px}.pill.is-active .pill-count{color:var(--ink-3)}.ghost-btn{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:1px dashed var(--rule-2);color:var(--ink-2);font-size:13px;font-family:var(--mono);padding:6px 12px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border-radius:8px}.ghost-btn:hover{border-color:var(--ink);color:var(--ink);border-style:solid}.cells{display:flex;flex-direction:column;gap:22px}.cell{position:relative;background:#fff;border:1px solid var(--rule);border-radius:10px;padding:22px 26px 22px 38px;box-shadow:0 1px #00000005,0 12px 28px -22px #0000002e}.cell .metrics,.cell .chart-wrap,.cell .video-slot,.cell .logs{background:#fafafa}.rail{position:absolute;top:-1px;left:-1px;bottom:-1px;width:8px;background:var(--rail);border-top-left-radius:10px;border-bottom-left-radius:10px}.cell--in_progress .rail{background:repeating-linear-gradient(135deg,var(--c-amber) 0 6px,color-mix(in oklch,var(--c-amber) 65%,black) 6px 12px)}.cell--empty .rail{background:var(--rule-2)}.cell-head{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:14px}.cell-head-left{min-width:0;flex:1}.cell-meta{display:flex;gap:8px;align-items:center;margin-bottom:6px;font-size:12px;flex-wrap:wrap}.cell-meta .sep{color:var(--ink-4)}.cell-title{font-size:20px;font-weight:500;margin:0;letter-spacing:-.01em;line-height:1.25;color:var(--ink)}.cell-title.dim{color:var(--ink-3);font-style:italic;font-weight:400}.cell-head-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;border-radius:6px;outline:none}.cell-head-toggle:focus-visible{box-shadow:0 0 0 2px var(--ink)}.cell-collapse-chevron{display:inline-block;width:14px;margin-right:6px;color:var(--ink-3);font-size:12px;vertical-align:1px;transition:color .12s}.cell-head-toggle:hover .cell-collapse-chevron{color:var(--ink)}.cell--collapsed .cell-head{margin-bottom:0}.cell--collapsed{padding-top:16px;padding-bottom:16px}.cell-head-right{display:flex;gap:4px;align-items:center}.reorder{display:flex;border:1px solid var(--rule-2);border-radius:6px;overflow:hidden}.reorder .icon-btn{border:none;border-radius:0}.reorder .icon-btn+.icon-btn{border-left:1px solid var(--rule-2)}.icon-btn{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:1px solid var(--rule-2);color:var(--ink-2);width:26px;height:26px;display:grid;place-items:center;cursor:pointer;border-radius:6px;transition:background .12s,color .12s}.icon-btn:hover:not(:disabled){background:var(--paper-3);color:var(--ink)}.icon-btn:disabled{opacity:.3;color:var(--ink-2);cursor:not-allowed}.status-badge{display:inline-flex;align-items:center;gap:6px;font-family:var(--mono);font-size:12px;font-weight:500;padding:3px 8px 3px 7px;background:var(--bg);color:var(--c);border:1px solid color-mix(in oklch,var(--c) 28%,transparent);letter-spacing:.02em;border-radius:20px;white-space:nowrap}.status-dot{width:6px;height:6px;border-radius:50%;background:var(--c, currentColor)}.status-dot.pulse{box-shadow:0 0 color-mix(in oklch,var(--c) 60%,transparent);animation:pulse 1.8s ease-out infinite}@keyframes pulse{0%{box-shadow:0 0 color-mix(in oklch,var(--c) 50%,transparent)}70%{box-shadow:0 0 0 8px color-mix(in oklch,var(--c) 0%,transparent)}to{box-shadow:0 0 color-mix(in oklch,var(--c) 0%,transparent)}}.status-badge--empty{background:var(--paper-3);color:var(--ink-3);border-color:var(--rule-2)}.status-badge--empty .status-dot{background:var(--ink-4)}.agent-block{display:grid;grid-template-columns:24px 1fr;gap:14px;margin-bottom:16px}.agent-rail{position:relative;border-left:1px solid var(--rule)}.agent-rail-label{position:absolute;top:4px;left:-8px;font-size:9px;letter-spacing:.15em;text-transform:uppercase;color:var(--ink-4);background:#fff;padding:2px 4px;writing-mode:vertical-rl;transform:rotate(180deg)}.agent-content{min-width:0}.conclusion{margin:0 0 14px;font-size:15.5px;line-height:1.55;color:var(--ink);text-wrap:pretty}.conclusion--placeholder{color:var(--ink-4);font-style:italic}input.inline-edit-input{font:inherit;color:var(--ink);background:var(--paper);border:1px solid var(--c-blue);border-radius:8px;padding:2px 8px;outline:none;box-shadow:0 0 0 3px color-mix(in oklch,var(--c-blue) 20%,transparent)}.outputs{display:flex;flex-direction:column;gap:14px}.metrics{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));border:1px solid var(--rule);background:var(--paper);border-radius:8px;overflow:hidden}.metric{padding:10px 14px;border-right:1px solid var(--rule);min-width:0;overflow:hidden}.metric:last-child{border-right:none}.metric-k,.metric-v,.metric-d{overflow-wrap:anywhere;word-break:break-word}.metric-k{font-family:var(--mono);font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--ink-3);margin-bottom:4px}.metric-v{font-family:var(--mono);font-size:19px;font-weight:500;color:var(--ink);font-variant-numeric:tabular-nums;line-height:1.1}.metric-d{font-family:var(--mono);font-size:11.5px;color:var(--ink-3);margin-top:3px}.chart-wrap{border:1px solid var(--rule);background:var(--paper);padding:14px 16px 8px;border-radius:8px}.chart{display:block;width:100%;height:auto}.chart-tick{font-family:var(--mono);font-size:9.5px;fill:var(--ink-3)}.chart-cap{font-family:var(--mono);font-size:10px;fill:var(--ink-3)}.video-slot{position:relative;border:1px solid var(--rule);border-radius:8px;aspect-ratio:16 / 7;background:var(--paper);overflow:hidden;display:flex;align-items:flex-end;justify-content:space-between}.video-bg{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;opacity:.6}.video-play{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;color:var(--ink)}.video-play svg{background:var(--paper-2);border:1px solid var(--ink-2);border-radius:50%;padding:10px;width:44px;height:44px;color:var(--ink)}.video-meta{position:relative;z-index:1;display:flex;justify-content:space-between;align-items:center;gap:8px;width:100%;padding:8px 10px;font-size:11px;background:linear-gradient(to top,color-mix(in oklch,var(--paper-2) 92%,transparent),transparent)}.video-external{color:var(--c-amber);font-size:10.5px;letter-spacing:.02em;white-space:nowrap}.verdict{position:relative;display:grid;grid-template-columns:80px 1fr;gap:0;margin:18px -26px 0 -38px;padding:16px 26px 16px 38px;background:var(--paper-3);border-top:1px solid var(--rule);border-bottom:1px solid var(--rule);border-bottom-left-radius:10px;border-bottom-right-radius:10px}.verdict--accept{border-top-color:var(--c-green)}.verdict--reject{border-top-color:var(--c-red)}.verdict--stale{border-top-color:var(--c-amber)}.verdict--stale .verdict-tag-label{border-color:var(--c-amber);color:var(--c-amber);background:color-mix(in oklch,var(--c-amber) 12%,var(--paper-2))}.verdict-tag-stale{font-size:11px;color:var(--c-amber);letter-spacing:.02em;text-transform:none;font-family:var(--mono)}.verdict-tag{display:flex;flex-direction:column;align-items:flex-start;padding-top:4px;gap:6px}.verdict-tag-label{font-family:var(--mono);font-size:10.5px;letter-spacing:.18em;color:var(--ink);font-weight:600;border:1px solid var(--ink-3);padding:2px 6px;border-radius:6px;background:var(--paper-2)}.verdict-tag-time{font-size:11px;color:var(--ink-3);letter-spacing:.04em;text-transform:none;font-family:var(--mono)}.verdict--accept .verdict-tag-label{border-color:var(--c-green);color:var(--c-green);background:color-mix(in oklch,var(--c-green) 12%,var(--paper-2))}.verdict--reject .verdict-tag-label{border-color:var(--c-red);color:var(--c-red);background:color-mix(in oklch,var(--c-red) 12%,var(--paper-2))}.verdict-body{min-width:0}.verdict-label{display:flex;gap:6px;align-items:baseline;font-size:9.5px;letter-spacing:.16em;text-transform:uppercase;color:var(--ink-3);margin-bottom:4px}.verdict-label .dim{letter-spacing:.04em;text-transform:none;font-size:11px;font-family:var(--serif);font-style:italic;color:var(--ink-3)}.verdict-row{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:8px;flex-wrap:wrap}.verdict-actions{display:flex;gap:8px}.vbtn{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--paper-4);border:1px solid var(--rule-2);color:var(--ink);font-family:var(--mono);font-size:13px;padding:7px 14px 7px 11px;display:inline-flex;align-items:center;gap:7px;cursor:pointer;border-radius:8px;transition:background .14s,color .14s,border-color .14s,transform .14s}.vbtn:hover{border-color:var(--ink-2);background:color-mix(in oklch,var(--paper-4) 70%,var(--ink-2))}.vbtn--accept.is-on{background:var(--c-green);border-color:var(--c-green);color:var(--paper)}.vbtn--reject.is-on{background:var(--c-red);border-color:var(--c-red);color:var(--paper)}.vbtn:active{transform:translateY(1px)}.verdict-meta{font-size:11px;color:var(--ink-3)}.verdict-note-wrap{position:relative}.verdict-note{width:100%;background:transparent;border:none;resize:vertical;padding:6px 0 4px;font-family:var(--serif);font-style:italic;font-size:15.5px;color:var(--ink);line-height:1.55;outline:none}.verdict-note::placeholder{color:var(--ink-3);font-style:italic}.verdict-note-rule{height:1px;background:linear-gradient(to right,var(--rule-2),transparent);margin-top:2px}.deep-toggle{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:none;width:100%;margin:16px 0 0;padding:0;display:grid;grid-template-columns:1fr auto 1fr;gap:12px;align-items:center;cursor:pointer}.deep-toggle-line{height:1px;background:var(--rule)}.deep-toggle-label{font-family:var(--mono);font-size:11.5px;color:var(--ink-3);letter-spacing:.04em;display:inline-flex;align-items:center;gap:6px}.deep-toggle:hover .deep-toggle-label{color:var(--ink)}.deep{margin-top:16px;padding-top:16px;border-top:1px dashed var(--rule-2);display:flex;flex-direction:column;gap:18px;animation:fade .22s ease}@keyframes fade{0%{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}.deep-grid{display:grid;grid-template-columns:1.1fr 1fr 1fr;gap:22px}.deep-h{font-family:var(--mono);font-size:11.5px;text-transform:uppercase;letter-spacing:.12em;color:var(--ink-3);margin:0 0 8px;font-weight:500;display:flex;justify-content:space-between;align-items:center}.kv{margin:0;display:grid;gap:0;font-family:var(--mono);font-size:13px}.kv-row{display:grid;grid-template-columns:110px 1fr;padding:4px 0;border-bottom:1px dotted var(--rule-2);gap:8px}.kv-row:last-child{border-bottom:none}.kv-row dt{color:var(--ink-3)}.kv-row dd{margin:0;color:var(--ink);word-break:break-word}.list{list-style:none;padding:0;margin:0;display:flex;flex-direction:column;gap:4px}.list-row{display:flex;gap:8px;align-items:center;font-size:12px;padding:3px 0;color:var(--ink-2)}.list-row svg{color:var(--ink-3);flex-shrink:0}.run-dot{width:6px;height:6px;border-radius:50%;background:var(--c-blue);flex-shrink:0}.link{color:var(--ink);text-decoration:none;border-bottom:1px dotted var(--ink-3)}.link:hover{border-bottom-style:solid}.run-url{font-size:10.5px}.link-btn{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:none;color:var(--ink);font-family:var(--mono);font-size:11.5px;cursor:pointer;padding:0;text-decoration:underline;text-underline-offset:2px;text-decoration-color:var(--rule-2)}.link-btn:hover{text-decoration-color:var(--ink)}.logs{background:var(--paper);border:1px solid var(--rule);border-radius:6px;padding:10px 14px;font-size:12.5px;line-height:1.6;color:var(--ink-2);margin:0;overflow-x:auto;white-space:pre;font-family:var(--mono)}.cell--empty{background:repeating-linear-gradient(45deg,transparent 0 8px,color-mix(in oklch,var(--ink-4) 8%,transparent) 8px 9px),#fff}.empty-body{padding:6px 0 4px}.empty-prompt{color:var(--ink-3);font-size:12.5px}.empty-state{text-align:center;padding:60px 0;color:var(--ink-3);border:1px dashed var(--rule-2);background:var(--paper-2);font-family:var(--mono);border-radius:8px}.section-group{display:flex;flex-direction:column;gap:22px;margin:12px 0}.section-group .section-children{margin-left:12px;padding-left:28px;border-left:1px dashed var(--rule-2);display:flex;flex-direction:column;gap:22px;animation:section-open .22s ease}.section-group[data-level="2"]>.section-children{border-left-color:var(--rule)}.section-group[data-level="3"]>.section-children{border-left-color:var(--rule);border-left-style:dotted}.section-body.md-rendered{margin-top:10px}.section-body.md-rendered p{margin:6px 0 8px}@keyframes section-open{0%{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}.section-heading{display:flex;align-items:center;gap:8px;-webkit-user-select:none;user-select:none}.section-caret{display:inline-block;width:12px;color:var(--ink-3);transition:transform .16s ease;font-size:10px;cursor:pointer}.section-caret.is-open{transform:rotate(90deg)}.section-heading h1,.section-heading h2,.section-heading h3{margin:0}.section-heading-text{cursor:pointer;flex:1;min-width:0}.section-heading h1.section-heading-text{font-size:22px;font-weight:500;letter-spacing:-.01em;color:var(--ink)}.section-heading h2.section-heading-text{font-size:17px;font-weight:500;letter-spacing:-.005em;color:var(--ink);padding-bottom:4px;border-bottom:1px solid var(--rule)}.section-heading h3.section-heading-text{font-size:14px;font-weight:500;color:var(--ink-2);text-transform:uppercase;letter-spacing:.06em}.section-actions{display:flex;gap:4px;align-items:center;margin-left:auto;opacity:0;transition:opacity .16s}.section-group:hover>.section-heading>.section-actions,.section-heading:focus-within>.section-actions{opacity:1}.section-editor-wrap{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.section-editor{min-height:80px}.toc{position:sticky;top:calc(var(--top-h) + 12px);width:100%;max-height:calc(100vh - var(--top-h) - 24px);overflow-y:auto;background:transparent;border:none;border-right:1px solid var(--rule);padding:20px 14px 40px 0;z-index:4;font-family:var(--mono);box-shadow:none}.toc-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;padding-bottom:8px}.toc-title{font-size:10.5px;letter-spacing:.18em;text-transform:uppercase;color:var(--ink-3);margin:0;font-weight:500}.toc-count{font-size:11px;color:var(--ink-4);font-variant-numeric:tabular-nums}.toc-list{list-style:none;padding:0;margin:0}.toc-item{position:relative;display:flex;align-items:center;gap:8px;font-size:13px;line-height:1.4;color:var(--ink-2);padding:5px 6px 5px 8px;cursor:pointer;background:transparent;border:none}.toc-item:hover{background:transparent;color:var(--ink-2)}.toc-item.is-current{background:transparent;color:var(--ink)}.toc-item.is-current .toc-label{font-weight:700}.toc-item--1{font-weight:600;color:var(--ink-2)}.toc-item--2{padding-left:22px;font-size:12.5px}.toc-item--3{padding-left:36px;font-size:12px;color:var(--ink-3)}.toc-item--4{padding-left:50px;font-size:11.5px;color:var(--ink-3)}.toc-tier{width:18px;flex-shrink:0;font-size:10px;letter-spacing:.08em;color:var(--ink-3);font-variant-numeric:tabular-nums;font-weight:600}.toc-label{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-2);font-weight:600}.toc-pill{font-size:10px;color:var(--ink-3);font-variant-numeric:tabular-nums;padding:0;background:transparent;border:none;font-weight:500}.toc-empty{font-size:12px;color:var(--ink-4);padding:4px 6px;font-style:italic}@media (max-width: 880px){.page-body{grid-template-columns:minmax(0,1fr)}.toc{display:none}}.md-chevron{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--paper-2);border:1px solid var(--rule-2);color:var(--ink-2);padding:2px 7px 2px 5px;display:inline-flex;align-items:center;gap:4px;cursor:pointer;border-radius:8px;font-family:var(--mono);font-size:11.5px;font-variant-numeric:tabular-nums;transition:color .14s,border-color .14s,background .14s}.md-chevron:hover{color:var(--ink);border-color:var(--ink-3)}.md-chevron svg{transition:transform .18s ease}.md-chevron.is-collapsed svg{transform:rotate(-90deg)}.md-chevron-count{color:var(--ink-3)}.md-chevron.is-collapsed .md-chevron-count{color:var(--ink)}.md-cell{position:relative;display:grid;grid-template-columns:76px 1fr auto;gap:18px;padding:8px 10px 8px 0;margin:-6px 0;align-items:start}.md-gutter{padding-top:8px;display:flex;flex-direction:column;align-items:flex-end;gap:6px;border-right:1px dashed var(--rule);padding-right:12px}.md-tag{font-size:9.5px;letter-spacing:.2em;color:var(--ink-3);padding:1px 7px;border:1px solid var(--rule-2);border-radius:8px;background:var(--paper-2)}.md-body{min-width:0;padding:4px 0 6px}.md-actions{display:flex;gap:4px;opacity:0;transition:opacity .16s;align-items:center;padding-top:6px}.md-cell:hover .md-actions{opacity:1}.md-cell:focus-within .md-actions{opacity:1}.md-cell .icon-btn{background:var(--paper-3);border-color:var(--rule-2);color:var(--ink)}.md-cell .icon-btn:hover:not(:disabled){background:var(--paper-4);color:var(--ink)}.md-rendered{cursor:text;font-family:var(--serif);color:var(--ink);font-size:17px;line-height:1.6;text-wrap:pretty;padding:4px 6px;margin:-4px -6px;border-radius:8px;transition:background .16s}.md-rendered:hover{background:color-mix(in oklch,var(--paper-2) 50%,transparent)}.md-rendered>:first-child{margin-top:0}.md-rendered>:last-child{margin-bottom:0}.md-rendered h1{font-family:var(--sans);font-style:normal;font-size:22px;font-weight:500;letter-spacing:-.01em;margin:18px 0 8px;color:var(--ink)}.md-rendered h2{font-family:var(--sans);font-style:normal;font-size:17px;font-weight:500;letter-spacing:-.005em;margin:16px 0 6px;color:var(--ink);padding-bottom:4px;border-bottom:1px solid var(--rule)}.md-rendered h3{font-family:var(--sans);font-style:normal;font-size:14px;font-weight:500;margin:12px 0 4px;color:var(--ink-2);text-transform:uppercase;letter-spacing:.06em}.md-rendered p{margin:6px 0 8px;font-style:italic}.md-rendered em{font-style:italic;color:var(--ink)}.md-rendered strong{font-weight:600;color:var(--ink);font-style:normal}.md-rendered code{font-family:var(--mono);font-style:normal;font-size:14px;background:var(--paper-3);border:1px solid var(--rule);padding:.5px 5px;border-radius:4px;color:var(--c-blue)}.md-rendered a{color:var(--c-blue);text-decoration:underline;text-underline-offset:2px;text-decoration-color:color-mix(in oklch,var(--c-blue) 50%,transparent)}.md-rendered a:hover{text-decoration-color:var(--c-blue)}.md-rendered ul,.md-rendered ol{margin:6px 0 10px;padding-left:22px;font-style:italic}.md-rendered li{margin:2px 0}.md-rendered blockquote{margin:10px 0;padding:4px 14px;border-left:2px solid var(--c-blue);color:var(--ink-2);background:color-mix(in oklch,var(--c-blue) 6%,transparent);font-style:italic}.md-rendered hr{border:none;border-top:1px dashed var(--rule-2);margin:14px 0}.md-editor{width:100%;background:var(--paper);border:1px solid var(--c-blue);color:var(--ink);font-family:var(--mono);font-size:14px;line-height:1.55;padding:12px 14px;border-radius:10px;resize:vertical;min-height:120px;outline:none;box-shadow:0 0 0 3px color-mix(in oklch,var(--c-blue) 20%,transparent)}.md-editor::placeholder{color:var(--ink-4)}.md-editor-hint{margin-top:6px;font-size:10.5px;color:var(--ink-3);display:flex;justify-content:flex-end}.md-editor-hint kbd{font-family:var(--mono);font-size:11px;background:var(--paper-2);border:1px solid var(--rule-2);border-bottom-width:2px;padding:0 4px;border-radius:4px;color:var(--ink-2);margin:0 1px}.inserter{position:relative;margin:-10px 0;padding:8px 0;z-index:2}.inserter-handle{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:none;width:100%;padding:0;cursor:pointer;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:10px;opacity:0;transition:opacity .18s}.inserter:hover .inserter-handle,.inserter.is-open .inserter-handle{opacity:1}.inserter-line{height:1px;background:var(--rule)}.inserter-plus{display:inline-flex;align-items:center;gap:5px;font-size:10px;color:var(--ink-2);background:var(--paper-3);border:1px solid var(--rule-2);padding:3px 9px;border-radius:12px;letter-spacing:.1em;text-transform:uppercase}.inserter:hover .inserter-plus{color:var(--ink);border-color:var(--c-blue)}.inserter-menu{position:absolute;left:50%;transform:translate(-50%);top:calc(100% - 4px);display:flex;gap:0;background:var(--paper-3);border:1px solid var(--rule-2);border-radius:10px;box-shadow:0 8px 24px -10px #00000080;overflow:hidden;z-index:5}.inserter-menu button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:none;color:var(--ink-2);font-family:var(--mono);font-size:12.5px;padding:8px 14px;cursor:pointer;display:inline-flex;align-items:center;gap:7px}.inserter-menu button+button{border-left:1px solid var(--rule)}.inserter-menu button:hover{background:var(--paper-4);color:var(--ink)}.foot{margin-top:40px;padding-top:16px;border-top:1px solid var(--rule);display:flex;justify-content:space-between;font-size:12px;color:var(--ink-3);font-family:var(--mono)}@media (max-width: 880px){:root{--top-h: 230px}.page{padding:0 18px 60px}.filter-bar{align-items:flex-start}.deep-grid{grid-template-columns:1fr;gap:18px}.cell{padding:18px 18px 18px 28px}.verdict{margin-left:-28px;margin-right:-18px;padding-left:28px;padding-right:18px}.agent-block{grid-template-columns:18px 1fr;gap:10px}}:root{--c-gold: oklch(.65 .13 80);--c-gold-bg: oklch(.93 .05 80)}.cell--locked{border-color:var(--c-gold);box-shadow:0 0 0 1px var(--c-gold-bg) inset,0 1px #1c181405,0 12px 28px -22px #1c18142e}.locked-chip{display:inline-flex;align-items:center;gap:4px;font-family:var(--mono);font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--c-gold);background:var(--c-gold-bg);padding:2px 6px;border-radius:6px}.verdict-locked-actions{display:flex;justify-content:flex-end;width:100%}.unlock-btn{font-family:var(--mono);font-size:12px;background:transparent;color:var(--c-gold);border:1px solid var(--c-gold);padding:4px 10px;border-radius:6px;cursor:pointer;text-transform:lowercase;letter-spacing:.04em}.unlock-btn:hover{background:var(--c-gold-bg)}.sandbox-iframe{width:100%;border:1px solid var(--rule);border-radius:8px;background:var(--paper-2);min-height:120px;display:block}.vega-host{width:100%;min-height:80px}.svg-visual{width:100%;display:block}.key-gate-page{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px}.key-gate-card{background:var(--paper-2);border:1px solid var(--rule);padding:28px;border-radius:10px;width:100%;max-width:380px}.key-gate-card h2{margin:0 0 6px;font-family:var(--sans);font-size:18px}.key-gate-card p{margin:0 0 14px;color:var(--ink-3);font-size:13px}.key-gate-card input{width:100%;background:var(--paper);color:var(--ink);border:1px solid var(--rule);padding:8px 10px;font-family:var(--mono);font-size:14px;border-radius:6px}.key-gate-card button{margin-top:10px;width:100%;background:var(--c-blue-bg);color:var(--c-blue);border:1px solid var(--c-blue);padding:8px 12px;font-family:var(--mono);font-size:13px;border-radius:6px;cursor:pointer}.empty-create-page{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:50vh;gap:12px;color:var(--ink-3)}.empty-create-page button{background:var(--c-blue-bg);color:var(--c-blue);border:1px solid var(--c-blue);padding:8px 14px;font-family:var(--mono);font-size:13px;border-radius:6px;cursor:pointer}.error-banner{margin:16px auto;max-width:1120px;padding:12px 18px;display:flex;justify-content:space-between;align-items:center;gap:16px;background:color-mix(in oklch,var(--c-red) 14%,var(--paper-2));border:1px solid color-mix(in oklch,var(--c-red) 50%,var(--rule-2));border-radius:8px;font-size:13px;color:var(--ink)}.error-banner-body{display:flex;gap:10px;flex-wrap:wrap;align-items:baseline;min-width:0}.error-banner-tag{font-size:10px;letter-spacing:.18em;color:var(--c-red);border:1px solid var(--c-red);padding:2px 7px;border-radius:6px;background:color-mix(in oklch,var(--c-red) 8%,var(--paper-2));font-weight:600}.error-banner-msg{font-family:var(--mono)}.error-banner-hint{font-size:11.5px}.error-banner-actions{display:flex;gap:6px;flex-shrink:0} diff --git a/apps/api/field_notes_api/_web/assets/index-CyAub9oQ.js b/apps/api/field_notes_api/_web/assets/index-CyAub9oQ.js new file mode 100644 index 0000000..e112cad --- /dev/null +++ b/apps/api/field_notes_api/_web/assets/index-CyAub9oQ.js @@ -0,0 +1,63 @@ +var Lp=Object.defineProperty;var Ap=(e,t,n)=>t in e?Lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jl=(e,t,n)=>Ap(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(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 r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function Oc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mc={exports:{}},No={},Rc={exports:{}},V={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var nl=Symbol.for("react.element"),Op=Symbol.for("react.portal"),Mp=Symbol.for("react.fragment"),Rp=Symbol.for("react.strict_mode"),Dp=Symbol.for("react.profiler"),Ip=Symbol.for("react.provider"),zp=Symbol.for("react.context"),Fp=Symbol.for("react.forward_ref"),Bp=Symbol.for("react.suspense"),Up=Symbol.for("react.memo"),$p=Symbol.for("react.lazy"),cu=Symbol.iterator;function Wp(e){return e===null||typeof e!="object"?null:(e=cu&&e[cu]||e["@@iterator"],typeof e=="function"?e:null)}var Dc={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ic=Object.assign,zc={};function sr(e,t,n){this.props=e,this.context=t,this.refs=zc,this.updater=n||Dc}sr.prototype.isReactComponent={};sr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};sr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Fc(){}Fc.prototype=sr.prototype;function Os(e,t,n){this.props=e,this.context=t,this.refs=zc,this.updater=n||Dc}var Ms=Os.prototype=new Fc;Ms.constructor=Os;Ic(Ms,sr.prototype);Ms.isPureReactComponent=!0;var du=Array.isArray,Bc=Object.prototype.hasOwnProperty,Rs={current:null},Uc={key:!0,ref:!0,__self:!0,__source:!0};function $c(e,t,n){var r,l={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)Bc.call(t,r)&&!Uc.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,Z=L[F];if(0>>1;Fl(H,y))hel(ve,H)?(L[F]=ve,L[he]=y,F=he):(L[F]=H,L[fe]=y,F=fe);else if(hel(ve,y))L[F]=ve,L[he]=y,F=he;else break e}}return R}function l(L,R){var y=L.sortIndex-R.sortIndex;return y!==0?y:L.id-R.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var u=[],c=[],v=1,m=null,p=3,x=!1,j=!1,N=!1,P=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function g(L){for(var R=n(c);R!==null;){if(R.callback===null)r(c);else if(R.startTime<=L)r(c),R.sortIndex=R.expirationTime,t(u,R);else break;R=n(c)}}function k(L){if(N=!1,g(L),!j)if(n(u)!==null)j=!0,at(S);else{var R=n(c);R!==null&&Q(k,R.startTime-L)}}function S(L,R){j=!1,N&&(N=!1,h(I),I=-1),x=!0;var y=p;try{for(g(R),m=n(u);m!==null&&(!(m.expirationTime>R)||L&&!Ce());){var F=m.callback;if(typeof F=="function"){m.callback=null,p=m.priorityLevel;var Z=F(m.expirationTime<=R);R=e.unstable_now(),typeof Z=="function"?m.callback=Z:m===n(u)&&r(u),g(R)}else r(u);m=n(u)}if(m!==null)var D=!0;else{var fe=n(c);fe!==null&&Q(k,fe.startTime-R),D=!1}return D}finally{m=null,p=y,x=!1}}var C=!1,O=null,I=-1,K=5,$=-1;function Ce(){return!(e.unstable_now()-$L||125F?(L.sortIndex=y,t(c,L),n(u)===null&&L===n(c)&&(N?(h(I),I=-1):N=!0,Q(k,y-F))):(L.sortIndex=Z,t(u,L),j||x||(j=!0,at(S))),L},e.unstable_shouldYield=Ce,e.unstable_wrapCallback=function(L){var R=p;return function(){var y=p;p=R;try{return L.apply(this,arguments)}finally{p=y}}}})(Gc);Kc.exports=Gc;var bp=Kc.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var em=U,Je=bp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),zi=Object.prototype.hasOwnProperty,tm=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,pu={},mu={};function nm(e){return zi.call(mu,e)?!0:zi.call(pu,e)?!1:tm.test(e)?mu[e]=!0:(pu[e]=!0,!1)}function rm(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function lm(e,t,n,r){if(t===null||typeof t>"u"||rm(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Fe(e,t,n,r,l,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var Ne={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ne[e]=new Fe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ne[t]=new Fe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ne[e]=new Fe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ne[e]=new Fe(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ne[e]=new Fe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ne[e]=new Fe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ne[e]=new Fe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ne[e]=new Fe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ne[e]=new Fe(e,5,!1,e.toLowerCase(),null,!1,!1)});var Is=/[\-:]([a-z])/g;function zs(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Is,zs);Ne[t]=new Fe(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Is,zs);Ne[t]=new Fe(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Is,zs);Ne[t]=new Fe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ne[e]=new Fe(e,1,!1,e.toLowerCase(),null,!1,!1)});Ne.xlinkHref=new Fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ne[e]=new Fe(e,1,!1,e.toLowerCase(),null,!0,!0)});function Fs(e,t,n,r){var l=Ne.hasOwnProperty(t)?Ne[t]:null;(l!==null?l.type!==0:r||!(2s||l[i]!==o[s]){var u=` +`+l[i].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=i&&0<=s);break}}}finally{ci=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Nr(e):""}function om(e){switch(e.tag){case 5:return Nr(e.type);case 16:return Nr("Lazy");case 13:return Nr("Suspense");case 19:return Nr("SuspenseList");case 0:case 2:case 15:return e=di(e.type,!1),e;case 11:return e=di(e.type.render,!1),e;case 1:return e=di(e.type,!0),e;default:return""}}function $i(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case zn:return"Fragment";case In:return"Portal";case Fi:return"Profiler";case Bs:return"StrictMode";case Bi:return"Suspense";case Ui:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Xc:return(e.displayName||"Context")+".Consumer";case Yc:return(e._context.displayName||"Context")+".Provider";case Us:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case $s:return t=e.displayName||null,t!==null?t:$i(e.type)||"Memo";case Gt:t=e._payload,e=e._init;try{return $i(e(t))}catch{}}return null}function im(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $i(t);case 8:return t===Bs?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function sn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Jc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function sm(e){var t=Jc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Cl(e){e._valueTracker||(e._valueTracker=sm(e))}function qc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Jc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function to(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Wi(e,t){var n=t.checked;return se({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function vu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=sn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function bc(e,t){t=t.checked,t!=null&&Fs(e,"checked",t,!1)}function Hi(e,t){bc(e,t);var n=sn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Vi(e,t.type,n):t.hasOwnProperty("defaultValue")&&Vi(e,t.type,sn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function gu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Vi(e,t,n){(t!=="number"||to(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Cr=Array.isArray;function Yn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Tl.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ur(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Lr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},am=["Webkit","ms","Moz","O"];Object.keys(Lr).forEach(function(e){am.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Lr[t]=Lr[e]})});function rd(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Lr.hasOwnProperty(e)&&Lr[e]?(""+t).trim():t+"px"}function ld(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=rd(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var um=se({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Qi(e,t){if(t){if(um[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Yi(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Xi=null;function Ws(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zi=null,Xn=null,Zn=null;function wu(e){if(e=ol(e)){if(typeof Zi!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Ao(t),Zi(e.stateNode,e.type,t))}}function od(e){Xn?Zn?Zn.push(e):Zn=[e]:Xn=e}function id(){if(Xn){var e=Xn,t=Zn;if(Zn=Xn=null,wu(e),t)for(e=0;e>>=0,e===0?32:31-(wm(e)/km|0)|0}var Pl=64,Ll=4194304;function Tr(e){switch(e&-e){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:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function oo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var s=i&~l;s!==0?r=Tr(s):(o&=i,o!==0&&(r=Tr(o)))}else i=n&~l,i!==0?r=Tr(i):o!==0&&(r=Tr(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function rl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ht(t),e[t]=n}function _m(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Or),Pu=" ",Lu=!1;function Nd(e,t){switch(e){case"keyup":return bm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Fn=!1;function th(e,t){switch(e){case"compositionend":return Cd(t);case"keypress":return t.which!==32?null:(Lu=!0,Pu);case"textInput":return e=t.data,e===Pu&&Lu?null:e;default:return null}}function nh(e,t){if(Fn)return e==="compositionend"||!Zs&&Nd(e,t)?(e=jd(),Kl=Qs=Zt=null,Fn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ru(n)}}function Ad(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ad(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Od(){for(var e=window,t=to();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=to(e.document)}return t}function Js(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function dh(e){var t=Od(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ad(n.ownerDocument.documentElement,n)){if(r!==null&&Js(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Du(n,o);var i=Du(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Bn=null,ns=null,Rr=null,rs=!1;function Iu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;rs||Bn==null||Bn!==to(r)||(r=Bn,"selectionStart"in r&&Js(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Rr&&Gr(Rr,r)||(Rr=r,r=ao(ns,"onSelect"),0Wn||(e.current=us[Wn],us[Wn]=null,Wn--)}function ee(e,t){Wn++,us[Wn]=e.current,e.current=t}var an={},Oe=cn(an),We=cn(!1),En=an;function tr(e,t){var n=e.type.contextTypes;if(!n)return an;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function He(e){return e=e.childContextTypes,e!=null}function co(){ne(We),ne(Oe)}function Hu(e,t,n){if(Oe.current!==an)throw Error(E(168));ee(Oe,t),ee(We,n)}function $d(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(E(108,im(e)||"Unknown",l));return se({},n,r)}function fo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||an,En=Oe.current,ee(Oe,e),ee(We,We.current),!0}function Vu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=$d(e,t,En),r.__reactInternalMemoizedMergedChildContext=e,ne(We),ne(Oe),ee(Oe,e)):ne(We),ee(We,n)}var Lt=null,Oo=!1,_i=!1;function Wd(e){Lt===null?Lt=[e]:Lt.push(e)}function Eh(e){Oo=!0,Wd(e)}function dn(){if(!_i&&Lt!==null){_i=!0;var e=0,t=b;try{var n=Lt;for(b=1;e>=i,l-=i,At=1<<32-ht(t)+l|n<I?(K=O,O=null):K=O.sibling;var $=p(h,O,g[I],k);if($===null){O===null&&(O=K);break}e&&O&&$.alternate===null&&t(h,O),f=o($,f,I),C===null?S=$:C.sibling=$,C=$,O=K}if(I===g.length)return n(h,O),le&&vn(h,I),S;if(O===null){for(;II?(K=O,O=null):K=O.sibling;var Ce=p(h,O,$.value,k);if(Ce===null){O===null&&(O=K);break}e&&O&&Ce.alternate===null&&t(h,O),f=o(Ce,f,I),C===null?S=Ce:C.sibling=Ce,C=Ce,O=K}if($.done)return n(h,O),le&&vn(h,I),S;if(O===null){for(;!$.done;I++,$=g.next())$=m(h,$.value,k),$!==null&&(f=o($,f,I),C===null?S=$:C.sibling=$,C=$);return le&&vn(h,I),S}for(O=r(h,O);!$.done;I++,$=g.next())$=x(O,h,I,$.value,k),$!==null&&(e&&$.alternate!==null&&O.delete($.key===null?I:$.key),f=o($,f,I),C===null?S=$:C.sibling=$,C=$);return e&&O.forEach(function(Be){return t(h,Be)}),le&&vn(h,I),S}function P(h,f,g,k){if(typeof g=="object"&&g!==null&&g.type===zn&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case Nl:e:{for(var S=g.key,C=f;C!==null;){if(C.key===S){if(S=g.type,S===zn){if(C.tag===7){n(h,C.sibling),f=l(C,g.props.children),f.return=h,h=f;break e}}else if(C.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Gt&&Qu(S)===C.type){n(h,C.sibling),f=l(C,g.props),f.ref=Sr(h,C,g),f.return=h,h=f;break e}n(h,C);break}else t(h,C);C=C.sibling}g.type===zn?(f=Sn(g.props.children,h.mode,k,g.key),f.return=h,h=f):(k=bl(g.type,g.key,g.props,null,h.mode,k),k.ref=Sr(h,f,g),k.return=h,h=k)}return i(h);case In:e:{for(C=g.key;f!==null;){if(f.key===C)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(h,f.sibling),f=l(f,g.children||[]),f.return=h,h=f;break e}else{n(h,f);break}else t(h,f);f=f.sibling}f=Mi(g,h.mode,k),f.return=h,h=f}return i(h);case Gt:return C=g._init,P(h,f,C(g._payload),k)}if(Cr(g))return j(h,f,g,k);if(gr(g))return N(h,f,g,k);zl(h,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,f!==null&&f.tag===6?(n(h,f.sibling),f=l(f,g),f.return=h,h=f):(n(h,f),f=Oi(g,h.mode,k),f.return=h,h=f),i(h)):n(h,f)}return P}var rr=Gd(!0),Qd=Gd(!1),ho=cn(null),vo=null,Kn=null,ta=null;function na(){ta=Kn=vo=null}function ra(e){var t=ho.current;ne(ho),e._currentValue=t}function fs(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function qn(e,t){vo=e,ta=Kn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&($e=!0),e.firstContext=null)}function it(e){var t=e._currentValue;if(ta!==e)if(e={context:e,memoizedValue:t,next:null},Kn===null){if(vo===null)throw Error(E(308));Kn=e,vo.dependencies={lanes:0,firstContext:e}}else Kn=Kn.next=e;return t}var xn=null;function la(e){xn===null?xn=[e]:xn.push(e)}function Yd(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,la(t)):(n.next=l.next,l.next=n),t.interleaved=n,It(e,r)}function It(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qt=!1;function oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Xd(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Mt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function nn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,It(e,n)}return l=r.interleaved,l===null?(t.next=t,la(r)):(t.next=l.next,l.next=t),r.interleaved=t,It(e,n)}function Ql(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Vs(e,n)}}function Yu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function go(e,t,n,r){var l=e.updateQueue;Qt=!1;var o=l.firstBaseUpdate,i=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var u=s,c=u.next;u.next=null,i===null?o=c:i.next=c,i=u;var v=e.alternate;v!==null&&(v=v.updateQueue,s=v.lastBaseUpdate,s!==i&&(s===null?v.firstBaseUpdate=c:s.next=c,v.lastBaseUpdate=u))}if(o!==null){var m=l.baseState;i=0,v=c=u=null,s=o;do{var p=s.lane,x=s.eventTime;if((r&p)===p){v!==null&&(v=v.next={eventTime:x,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var j=e,N=s;switch(p=t,x=n,N.tag){case 1:if(j=N.payload,typeof j=="function"){m=j.call(x,m,p);break e}m=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=N.payload,p=typeof j=="function"?j.call(x,m,p):j,p==null)break e;m=se({},m,p);break e;case 2:Qt=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,p=l.effects,p===null?l.effects=[s]:p.push(s))}else x={eventTime:x,lane:p,tag:s.tag,payload:s.payload,callback:s.callback,next:null},v===null?(c=v=x,u=m):v=v.next=x,i|=p;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;p=s,s=p.next,p.next=null,l.lastBaseUpdate=p,l.shared.pending=null}}while(!0);if(v===null&&(u=m),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=v,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Nn|=i,e.lanes=i,e.memoizedState=m}}function Xu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ci.transition;Ci.transition={};try{e(!1),t()}finally{b=n,Ci.transition=r}}function pf(){return st().memoizedState}function Ch(e,t,n){var r=ln(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},mf(e))hf(t,n);else if(n=Yd(e,t,n,r),n!==null){var l=Ie();vt(n,e,r,l),vf(n,t,r)}}function Th(e,t,n){var r=ln(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(mf(e))hf(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,s=o(i,n);if(l.hasEagerState=!0,l.eagerState=s,gt(s,i)){var u=t.interleaved;u===null?(l.next=l,la(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=Yd(e,t,l,r),n!==null&&(l=Ie(),vt(n,e,r,l),vf(n,t,r))}}function mf(e){var t=e.alternate;return e===ie||t!==null&&t===ie}function hf(e,t){Dr=xo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function vf(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Vs(e,n)}}var wo={readContext:it,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useInsertionEffect:Pe,useLayoutEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useMutableSource:Pe,useSyncExternalStore:Pe,useId:Pe,unstable_isNewReconciler:!1},Ph={readContext:it,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:it,useEffect:Ju,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Xl(4194308,4,af.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Xl(4194308,4,e,t)},useInsertionEffect:function(e,t){return Xl(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ch.bind(null,ie,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Zu,useDebugValue:pa,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Zu(!1),t=e[0];return e=Nh.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ie,l=St();if(le){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Se===null)throw Error(E(349));_n&30||bd(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Ju(tf.bind(null,r,o,e),[e]),r.flags|=2048,el(9,ef.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=St(),t=Se.identifierPrefix;if(le){var n=Ot,r=At;n=(r&~(1<<32-ht(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=qr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Et]=t,e[Xr]=r,Nf(e,t,!1,!1),t.stateNode=e;e:{switch(i=Yi(n,r),n){case"dialog":te("cancel",e),te("close",e),l=r;break;case"iframe":case"object":case"embed":te("load",e),l=r;break;case"video":case"audio":for(l=0;lir&&(t.flags|=128,r=!0,Er(o,!1),t.lanes=4194304)}else{if(!r)if(e=yo(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Er(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!le)return Le(t),null}else 2*de()-o.renderingStartTime>ir&&n!==1073741824&&(t.flags|=128,r=!0,Er(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=de(),t.sibling=null,n=oe.current,ee(oe,r?n&1|2:n&1),t):(Le(t),null);case 22:case 23:return xa(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Le(t),t.subtreeFlags&6&&(t.flags|=8192)):Le(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function zh(e,t){switch(bs(t),t.tag){case 1:return He(t.type)&&co(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return lr(),ne(We),ne(Oe),aa(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return sa(t),null;case 13:if(ne(oe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));nr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ne(oe),null;case 4:return lr(),null;case 10:return ra(t.type._context),null;case 22:case 23:return xa(),null;case 24:return null;default:return null}}var Bl=!1,Ae=!1,Fh=typeof WeakSet=="function"?WeakSet:Set,M=null;function Gn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ue(e,t,r)}else n.current=null}function ks(e,t,n){try{n()}catch(r){ue(e,t,r)}}var ac=!1;function Bh(e,t){if(ls=io,e=Od(),Js(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,s=-1,u=-1,c=0,v=0,m=e,p=null;t:for(;;){for(var x;m!==n||l!==0&&m.nodeType!==3||(s=i+l),m!==o||r!==0&&m.nodeType!==3||(u=i+r),m.nodeType===3&&(i+=m.nodeValue.length),(x=m.firstChild)!==null;)p=m,m=x;for(;;){if(m===e)break t;if(p===n&&++c===l&&(s=i),p===o&&++v===r&&(u=i),(x=m.nextSibling)!==null)break;m=p,p=m.parentNode}m=x}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(os={focusedElem:e,selectionRange:n},io=!1,M=t;M!==null;)if(t=M,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,M=e;else for(;M!==null;){t=M;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var N=j.memoizedProps,P=j.memoizedState,h=t.stateNode,f=h.getSnapshotBeforeUpdate(t.elementType===t.type?N:ft(t.type,N),P);h.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(k){ue(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,M=e;break}M=t.return}return j=ac,ac=!1,j}function Ir(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&ks(t,n,o)}l=l.next}while(l!==r)}}function Do(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ss(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Pf(e){var t=e.alternate;t!==null&&(e.alternate=null,Pf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Et],delete t[Xr],delete t[as],delete t[kh],delete t[Sh])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Lf(e){return e.tag===5||e.tag===3||e.tag===4}function uc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Lf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Es(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=uo));else if(r!==4&&(e=e.child,e!==null))for(Es(e,t,n),e=e.sibling;e!==null;)Es(e,t,n),e=e.sibling}function js(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(js(e,t,n),e=e.sibling;e!==null;)js(e,t,n),e=e.sibling}var je=null,pt=!1;function Kt(e,t,n){for(n=n.child;n!==null;)Af(e,t,n),n=n.sibling}function Af(e,t,n){if(jt&&typeof jt.onCommitFiberUnmount=="function")try{jt.onCommitFiberUnmount(Co,n)}catch{}switch(n.tag){case 5:Ae||Gn(n,t);case 6:var r=je,l=pt;je=null,Kt(e,t,n),je=r,pt=l,je!==null&&(pt?(e=je,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):je.removeChild(n.stateNode));break;case 18:je!==null&&(pt?(e=je,n=n.stateNode,e.nodeType===8?ji(e.parentNode,n):e.nodeType===1&&ji(e,n),Vr(e)):ji(je,n.stateNode));break;case 4:r=je,l=pt,je=n.stateNode.containerInfo,pt=!0,Kt(e,t,n),je=r,pt=l;break;case 0:case 11:case 14:case 15:if(!Ae&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&ks(n,t,i),l=l.next}while(l!==r)}Kt(e,t,n);break;case 1:if(!Ae&&(Gn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){ue(n,t,s)}Kt(e,t,n);break;case 21:Kt(e,t,n);break;case 22:n.mode&1?(Ae=(r=Ae)||n.memoizedState!==null,Kt(e,t,n),Ae=r):Kt(e,t,n);break;default:Kt(e,t,n)}}function cc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Fh),t.forEach(function(r){var l=Yh.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function dt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=de()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*$h(r/1960))-r,10e?16:e,Jt===null)var r=!1;else{if(e=Jt,Jt=null,Eo=0,G&6)throw Error(E(331));var l=G;for(G|=4,M=e.current;M!==null;){var o=M,i=o.child;if(M.flags&16){var s=o.deletions;if(s!==null){for(var u=0;ude()-ga?kn(e,0):va|=n),Ve(e,t)}function Bf(e,t){t===0&&(e.mode&1?(t=Ll,Ll<<=1,!(Ll&130023424)&&(Ll=4194304)):t=1);var n=Ie();e=It(e,t),e!==null&&(rl(e,t,n),Ve(e,n))}function Qh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bf(e,n)}function Yh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),Bf(e,n)}var Uf;Uf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)$e=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return $e=!1,Dh(e,t,n);$e=!!(e.flags&131072)}else $e=!1,le&&t.flags&1048576&&Hd(t,mo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Zl(e,t),e=t.pendingProps;var l=tr(t,Oe.current);qn(t,n),l=ca(null,t,r,e,l,n);var o=da();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,He(r)?(o=!0,fo(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,oa(t),l.updater=Ro,t.stateNode=l,l._reactInternals=t,ms(t,r,e,n),t=gs(null,t,r,!0,o,n)):(t.tag=0,le&&o&&qs(t),De(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Zl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Zh(r),e=ft(r,e),l){case 0:t=vs(null,t,r,e,n);break e;case 1:t=oc(null,t,r,e,n);break e;case 11:t=rc(null,t,r,e,n);break e;case 14:t=lc(null,t,r,ft(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ft(r,l),vs(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ft(r,l),oc(e,t,r,l,n);case 3:e:{if(Ef(t),e===null)throw Error(E(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Xd(e,t),go(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=or(Error(E(423)),t),t=ic(e,t,r,n,l);break e}else if(r!==l){l=or(Error(E(424)),t),t=ic(e,t,r,n,l);break e}else for(Xe=tn(t.stateNode.containerInfo.firstChild),Ze=t,le=!0,mt=null,n=Qd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(nr(),r===l){t=zt(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return Zd(t),e===null&&ds(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,is(r,l)?i=null:o!==null&&is(r,o)&&(t.flags|=32),Sf(e,t),De(e,t,i,n),t.child;case 6:return e===null&&ds(t),null;case 13:return jf(e,t,n);case 4:return ia(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=rr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ft(r,l),rc(e,t,r,l,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,ee(ho,r._currentValue),r._currentValue=i,o!==null)if(gt(o.value,i)){if(o.children===l.children&&!We.current){t=zt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){i=o.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=Mt(-1,n&-n),u.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var v=c.pending;v===null?u.next=u:(u.next=v.next,v.next=u),c.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),fs(o.return,n,t),s.lanes|=n;break}u=u.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(E(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),fs(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}De(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,qn(t,n),l=it(l),r=r(l),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,l=ft(r,t.pendingProps),l=ft(r.type,l),lc(e,t,r,l,n);case 15:return wf(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:ft(r,l),Zl(e,t),t.tag=1,He(r)?(e=!0,fo(t)):e=!1,qn(t,n),gf(t,r,l),ms(t,r,l,n),gs(null,t,r,!0,e,n);case 19:return _f(e,t,n);case 22:return kf(e,t,n)}throw Error(E(156,t.tag))};function $f(e,t){return pd(e,t)}function Xh(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new Xh(e,t,n,r)}function ka(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Zh(e){if(typeof e=="function")return ka(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Us)return 11;if(e===$s)return 14}return 2}function on(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function bl(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")ka(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case zn:return Sn(n.children,l,o,t);case Bs:i=8,l|=8;break;case Fi:return e=lt(12,n,t,l|2),e.elementType=Fi,e.lanes=o,e;case Bi:return e=lt(13,n,t,l),e.elementType=Bi,e.lanes=o,e;case Ui:return e=lt(19,n,t,l),e.elementType=Ui,e.lanes=o,e;case Zc:return zo(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Yc:i=10;break e;case Xc:i=9;break e;case Us:i=11;break e;case $s:i=14;break e;case Gt:i=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Sn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function zo(e,t,n,r){return e=lt(22,e,r,t),e.elementType=Zc,e.lanes=n,e.stateNode={isHidden:!1},e}function Oi(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function Mi(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Jh(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pi(0),this.expirationTimes=pi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pi(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Sa(e,t,n,r,l,o,i,s,u){return e=new Jh(e,t,n,s,u),t===1?(t=1,o===!0&&(t|=8)):t=0,o=lt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},oa(o),e}function qh(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Kf)}catch(e){console.error(e)}}Kf(),Vc.exports=qe;var rv=Vc.exports,yc=rv;Ii.createRoot=yc.createRoot,Ii.hydrateRoot=yc.hydrateRoot;const xc=e=>{let t;const n=new Set,r=(c,v)=>{const m=typeof c=="function"?c(t):c;if(!Object.is(m,t)){const p=t;t=v??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(x=>x(t,p))}},l=()=>t,s={setState:r,getState:l,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c))},u=t=e(r,l,s);return s},lv=e=>e?xc(e):xc,ov=e=>e;function iv(e,t=ov){const n=_r.useSyncExternalStore(e.subscribe,_r.useCallback(()=>t(e.getState()),[e,t]),_r.useCallback(()=>t(e.getInitialState()),[e,t]));return _r.useDebugValue(n),n}const wc=e=>{const t=lv(e),n=r=>iv(t,r);return Object.assign(n,t),n},sv=e=>e?wc(e):wc,Gf={VITE_DEFAULT_KEY:"local"},Na="field-notes-key";function Qf(){var n;const e=Gf,t=e==null?void 0:e.VITE_API_URL;return t&&t.length>0?t:typeof window<"u"&&((n=window.location)!=null&&n.origin)?window.location.origin:"http://localhost:8000"}function av(){const e=Gf;return e==null?void 0:e.VITE_DEFAULT_KEY}function Ca(){try{const e=typeof localStorage<"u"?localStorage.getItem(Na):null;if(e&&e.length>0)return e}catch{}return av()??null}function kc(e){try{localStorage.setItem(Na,e)}catch{}}function uv(){try{localStorage.removeItem(Na)}catch{}}class cv extends Error{constructor(n,r,l){super(r);jl(this,"status");jl(this,"body");this.name="ApiError",this.status=n,this.body=l}}async function Ke(e,t={}){const n=Qf().replace(/\/$/,""),r=Ca(),l=t.query?"?"+Object.entries(t.query).filter(([,v])=>v!==void 0).map(([v,m])=>`${encodeURIComponent(v)}=${encodeURIComponent(m)}`).join("&"):"",o=`${n}${e}${l}`,i={};r&&(i["X-Field-Notes-Key"]=r),t.body!==void 0&&(i["Content-Type"]="application/json");const s=await fetch(o,{method:t.method||"GET",headers:i,body:t.body!==void 0?JSON.stringify(t.body):void 0});if(s.status===204)return;const u=await s.text();let c;if(u)try{c=JSON.parse(u)}catch{c=u}if(!s.ok){const v=c&&typeof c=="object"&&c!==null&&"detail"in c?String(c.detail):`HTTP ${s.status}`;throw new cv(s.status,v,c)}return c}function Ps(){return Ke("/projects")}function dv(e){return Ke("/projects",{method:"POST",body:e})}function fv(e){return Ke(`/projects/${e}`,{method:"DELETE"})}function pv(e,t){return Ke(`/projects/${e}/reorder`,{method:"POST",body:t})}function mv(e){return Ke(`/projects/${e}/cells`)}function hv(e,t){return Ke(`/projects/${e}/cells`,{method:"POST",body:t})}function vv(e){return Ke(`/cells/${e}`)}function gv(e,t){return Ke(`/cells/${e}`,{method:"PATCH",body:t})}function yv(e){return Ke(`/cells/${e}`,{method:"DELETE"})}function xv(e,t){return Ke(`/cells/${e}/reorder`,{method:"POST",body:t})}function wv(e,t){return Ke(`/cells/${e}/verdict`,{method:"POST",body:t})}function kv(e){return Ke(`/cells/${e}/verdict`,{method:"POST"})}function Sv(e){return Ke(`/cells/${e}/lock`,{method:"POST"})}function Ev(e){return Ke(`/cells/${e}/unlock`,{method:"POST"})}function Yf(){return Qf().replace(/\/$/,"")}const Ls="field-notes-collapsed",Xf="field-notes-collapsed-cells";function jv(){try{const e=typeof localStorage<"u"?localStorage.getItem(Ls):null;if(!e)return{};const t=JSON.parse(e);let n=!1;for(const r of Object.keys(t)){const l=t[r];for(const o of Object.keys(l)){const i=o.indexOf("#");if(i>0){const s=o.slice(0,i);l[s]=l[s]||l[o],delete l[o],n=!0}}}if(n)try{localStorage.setItem(Ls,JSON.stringify(t))}catch{}return t}catch{}return{}}function _v(e){try{localStorage.setItem(Ls,JSON.stringify(e))}catch{}}function Nv(){try{const e=typeof localStorage<"u"?localStorage.getItem(Xf):null;if(e)return JSON.parse(e)}catch{}return{}}function Cv(e){try{localStorage.setItem(Xf,JSON.stringify(e))}catch{}}function Sc(e){Ps().then(t=>e({projects:t})).catch(()=>{})}function Dn(e,t){for(const n of Object.keys(e)){const r=e[n].findIndex(l=>l.id===t);if(r>=0)return{pid:n,idx:r}}return null}const X=sv((e,t)=>({projects:[],activeProjectId:null,cellsByProject:{},filter:"all",collapsedSections:jv(),collapsedCells:Nv(),loading:!1,error:null,clearError:()=>e({error:null}),loadProjects:async()=>{e({loading:!0,error:null});try{const n=await Ps();e({projects:n,loading:!1})}catch(n){e({loading:!1,error:n.message})}},loadCells:async n=>{try{const r=await mv(n);e(l=>{const o={cellsByProject:{...l.cellsByProject,[n]:r}};if(l.activeProjectId===n){const i=l.projects.find(s=>s.id===n);i!=null&&i.ui_filter&&(o.filter=i.ui_filter)}return o})}catch(r){e({error:r.message})}},setActiveProject:n=>{const r=n?t().projects.find(o=>o.id===n):null,l=(r==null?void 0:r.ui_filter)??"all";e({activeProjectId:n,filter:l})},setFilter:n=>e({filter:n}),applyRemoteFilter:n=>e({filter:n}),createProject:async n=>{try{const r=await dv({name:n});return e(l=>({projects:[...l.projects,r],activeProjectId:r.id,filter:"all"})),e(l=>({cellsByProject:{...l.cellsByProject,[r.id]:[]}})),r}catch(r){return e({error:r.message}),null}},deleteProject:async n=>{var s;const r=t().projects,l=t().activeProjectId,o=r.filter(u=>u.id!==n),i=l===n?((s=o[0])==null?void 0:s.id)??null:l;e({projects:o,activeProjectId:i});try{await fv(n)}catch(u){e({projects:r,activeProjectId:l,error:u.message})}},reorderProject:async(n,r)=>{const l=t().projects,o=l.findIndex(c=>c.id===n);if(o<0)return;const i=Math.max(0,Math.min(r,l.length-1));if(o===i)return;const s=[...l],[u]=s.splice(o,1);s.splice(i,0,u),e({projects:s});try{await pv(n,{position:i});const c=await Ps();e({projects:c})}catch(c){e({projects:l,error:c.message})}},setVerdict:async(n,r,l)=>{const o=Dn(t().cellsByProject,n);if(!o)return;const i=t().cellsByProject[o.pid][o.idx],s={...i,verdict:r?{state:r,note:l,by:"you",at:new Date().toISOString()}:null,status:r?r==="accept"?"verified":"rejected":"open"};e(u=>{const c=[...u.cellsByProject[o.pid]];return c[o.idx]=s,{cellsByProject:{...u.cellsByProject,[o.pid]:c}}});try{const u=r?await wv(n,{state:r,note:l}):await kv(n);t().patchCell(o.pid,u)}catch(u){e(c=>{const v=[...c.cellsByProject[o.pid]];return v[o.idx]=i,{cellsByProject:{...c.cellsByProject,[o.pid]:v},error:u.message}})}},lockCell:async n=>{const r=Dn(t().cellsByProject,n);if(r)try{const l=await Sv(n);t().patchCell(r.pid,l)}catch(l){e({error:l.message})}},unlockCell:async n=>{const r=Dn(t().cellsByProject,n);if(r)try{const l=await Ev(n);t().patchCell(r.pid,l)}catch(l){e({error:l.message})}},reorderCell:async(n,r)=>{const l=Dn(t().cellsByProject,n);if(!l)return;const o=t().cellsByProject[l.pid],i=r==="up"?l.idx-1:l.idx+1;if(i<0||i>=o.length)return;const s=[...o];[s[l.idx],s[i]]=[s[i],s[l.idx]],e(u=>({cellsByProject:{...u.cellsByProject,[l.pid]:s}}));try{await xv(n,{direction:r}),await t().loadCells(l.pid)}catch(u){e(c=>({cellsByProject:{...c.cellsByProject,[l.pid]:o},error:u.message}))}},createCell:async(n,r)=>{try{const l=await hv(n,r);e(o=>{const i=o.cellsByProject[n]||[];if(i.some(v=>v.id===l.id))return o;const s=r.after_cell_id??null;let u;if(s==null)u=0;else{const v=i.findIndex(m=>m.id===s);u=v<0?i.length:v+1}const c=[...i.slice(0,u),l,...i.slice(u)];return{cellsByProject:{...o.cellsByProject,[n]:c}}})}catch(l){e({error:l.message})}},updateCell:async(n,r)=>{const l=Dn(t().cellsByProject,n);if(!l)return;const o=t().cellsByProject[l.pid][l.idx],i={...o,...r};e(s=>{const u=[...s.cellsByProject[l.pid]];return u[l.idx]=i,{cellsByProject:{...s.cellsByProject,[l.pid]:u}}});try{const s=await gv(n,r);t().patchCell(l.pid,s)}catch(s){e(u=>{const c=[...u.cellsByProject[l.pid]];return c[l.idx]=o,{cellsByProject:{...u.cellsByProject,[l.pid]:c},error:s.message}})}},deleteCell:async n=>{const r=Dn(t().cellsByProject,n);if(!r)return;const l=t().cellsByProject[r.pid];e(o=>({cellsByProject:{...o.cellsByProject,[r.pid]:l.filter(i=>i.id!==n)}}));try{await yv(n)}catch(o){e(i=>({cellsByProject:{...i.cellsByProject,[r.pid]:l},error:o.message}))}},addMarkdownCell:async(n,r)=>{var i;const l=t().cellsByProject[n]||[],o=r>0?((i=l[r-1])==null?void 0:i.id)??null:null;await t().createCell(n,{kind:"markdown",after_cell_id:o,body:""})},addEmptyCell:async(n,r)=>{var i;const l=t().cellsByProject[n]||[],o=r>0?((i=l[r-1])==null?void 0:i.id)??null:null;await t().createCell(n,{kind:"empty",after_cell_id:o})},addSectionCell:async(n,r)=>{var i;const l=t().cellsByProject[n]||[],o=r>0?((i=l[r-1])==null?void 0:i.id)??null:null;await t().createCell(n,{kind:"markdown",after_cell_id:o,body:"## "})},addMarkdownCellAfter:async(n,r)=>{await t().createCell(n,{kind:"markdown",after_cell_id:r,body:""})},addEmptyCellAfter:async(n,r)=>{await t().createCell(n,{kind:"empty",after_cell_id:r})},addSectionCellAfter:async(n,r)=>{await t().createCell(n,{kind:"markdown",after_cell_id:r,body:"## "})},toggleSection:(n,r)=>{e(l=>{const o=l.collapsedSections[n]||{},i={...o,[r]:!o[r]},s={...l.collapsedSections,[n]:i};return _v(s),{collapsedSections:s}})},isSectionCollapsed:(n,r)=>{const l=t().collapsedSections[n];return!!(l!=null&&l[r])},toggleCell:(n,r)=>{e(l=>{const o=l.collapsedCells[n]||{},i={...o,[r]:!o[r]},s={...l.collapsedCells,[n]:i};return Cv(s),{collapsedCells:s}})},isCellCollapsed:(n,r)=>{const l=t().collapsedCells[n];return!!(l!=null&&l[r])},applyEvent:async n=>{const r=n.project_id||t().activeProjectId;if(r){if(n.kind==="ui.filter_changed"){if(r!==t().activeProjectId)return;const l=n.payload,o=l==null?void 0:l.filter;(o==="all"||o==="in_progress"||o==="open"||o==="verified"||o==="rejected")&&t().applyRemoteFilter(o);return}if(n.kind.startsWith("project.")){await t().loadProjects();return}if(n.kind==="cell.created"||n.kind==="cell.deleted"){await t().loadCells(r),Sc(e);return}if(n.cell_id&&(n.kind==="cell.updated"||n.kind.startsWith("verdict.")||n.kind.startsWith("cell."))){try{const l=await vv(n.cell_id);t().patchCell(r,l)}catch{await t().loadCells(r)}Sc(e)}}},patchCell:(n,r)=>{e(l=>{const o=l.cellsByProject[n]||[],i=o.findIndex(u=>u.id===r.id),s=i>=0?[...o]:[...o,r];return i>=0&&(s[i]=r),{cellsByProject:{...l.cellsByProject,[n]:s}}})},removeCell:(n,r)=>{e(l=>{const o=l.cellsByProject[n]||[];return{cellsByProject:{...l.cellsByProject,[n]:o.filter(i=>i.id!==r)}}})}})),Ec=3e4,Tv=1e4;async function Pv(){const e=Ca()||"",t=await fetch(`${Yf()}/sse-token`,{method:"POST",headers:{"X-Field-Notes-Key":e}});if(!t.ok)throw new Error(`sse-token: ${t.status}`);return await t.json()}function Lv(e,t,n){let r=!1,l=null,o=1e3,i=null,s=null;const u=p=>{const x=new URLSearchParams({token:p});return e&&x.set("project",e),`${Yf()}/events?${x.toString()}`},c=p=>{try{t(JSON.parse(p.data))}catch{}},v=p=>{s&&clearTimeout(s);const x=Math.max(1e3,p*1e3-Tv);s=setTimeout(()=>{r||(l&&(l.close(),l=null),m())},x)},m=async()=>{if(r||typeof EventSource>"u")return;let p;try{p=await Pv()}catch{if(r)return;i=setTimeout(()=>void m(),o),o=Math.min(o*2,Ec);return}r||(l=new EventSource(u(p.token)),l.onopen=()=>{o=1e3},l.onmessage=c,l.onerror=x=>{l&&(l.close(),l=null),!r&&(i=setTimeout(()=>void m(),o),o=Math.min(o*2,Ec))},v(p.ttl_seconds))};return m(),{close(){r=!0,i&&clearTimeout(i),s&&clearTimeout(s),l&&(l.close(),l=null)}}}function Av(){const e=X(n=>n.activeProjectId),t=X(n=>n.applyEvent);U.useEffect(()=>{if(!e)return;const n=new Set,r=Lv(e,l=>{if(l.kind==="resync"){X.getState().loadProjects();const o=X.getState().activeProjectId;o&&X.getState().loadCells(o);return}if(!n.has(l.id)){if(n.add(l.id),n.size>200){const o=n.values().next().value;o&&n.delete(o)}t(l)}});return()=>r.close()},[e,t])}function Ov(e){if(!e)return null;const t=e.split(` +`);for(const n of t){const r=n.trimStart();if(r.trim())return r.startsWith("#### ")?4:r.startsWith("### ")?3:r.startsWith("## ")?2:r.startsWith("# ")?1:null}return null}function Mv(e){const t=e.split(` +`);for(const n of t){const r=n.trimStart();if(r.trim())return r.startsWith("#### ")?r.slice(5).trim():r.startsWith("### ")?r.slice(4).trim():r.startsWith("## ")?r.slice(3).trim():r.startsWith("# ")?r.slice(2).trim():""}return""}function Rv(e){const t=[],n=[],r=l=>{const o=n.length?n[n.length-1]:null;o?o.children.push(l):t.push(l)};return e.forEach(l=>{const o=l.id;if(l.kind==="markdown"){const i=Ov(l.body);if(i){for(;n.length&&(n[n.length-1].level??0)>=i;)n.pop();const s={kind:"section",level:i,heading:Mv(l.body||""),cell:l,key:o,children:[]};r(s),n.push(s);return}r({kind:"markdown",cell:l,key:o});return}r({kind:"cell",cell:l,key:o})}),t}function eo(e){return e.kind==="section"&&e.children&&e.children.length>0?eo(e.children[e.children.length-1]):e.cell.id}function Dv(){const[e,t]=U.useState("");return a.jsx("div",{className:"key-gate-page",children:a.jsxs("div",{className:"key-gate-card",children:[a.jsx("h2",{children:"Field Notes"}),a.jsx("p",{className:"mono",children:"Enter your Field Notes key to begin."}),a.jsx("input",{type:"password",autoFocus:!0,placeholder:"X-Field-Notes-Key",value:e,onChange:n=>t(n.target.value),onKeyDown:n=>{n.key==="Enter"&&e.trim()&&(kc(e.trim()),window.location.reload())}}),a.jsx("button",{type:"button",onClick:()=>{e.trim()&&(kc(e.trim()),window.location.reload())},children:"save & reload"})]})})}function jc(){const e=X(r=>r.error),t=X(r=>r.clearError);if(!e)return null;const n=/401|api[ -_]?key|invalid|unauthor/i.test(e);return a.jsxs("div",{className:"error-banner",role:"alert",children:[a.jsxs("div",{className:"error-banner-body",children:[a.jsx("span",{className:"error-banner-tag mono",children:"ERROR"}),a.jsx("span",{className:"error-banner-msg",children:e}),n&&a.jsx("span",{className:"error-banner-hint mono dim",children:'— your X-Field-Notes-Key is missing or wrong. Click "reset key" then re-enter it.'})]}),a.jsxs("div",{className:"error-banner-actions",children:[n&&a.jsx("button",{type:"button",className:"ghost-btn mono",onClick:()=>{uv(),window.location.reload()},children:"reset key"}),a.jsx("button",{type:"button",className:"ghost-btn mono",onClick:t,children:"dismiss"})]})]})}const Iv={open:0,verified:0,rejected:0};function zv({project:e,active:t,canClose:n,dragging:r,dragOver:l,onClick:o,onClose:i,onDragStart:s,onDragEnter:u,onDragEnd:c,onDrop:v}){const m=e.counts??Iv,p=e.subtitle?`${e.name} · ${e.subtitle}`:e.name;return a.jsxs("div",{className:`ptab ${t?"is-active":""} ${r?"is-dragging":""} ${l?"is-drag-over":""}`,role:"tab","aria-selected":t,tabIndex:0,title:p,draggable:!0,onClick:o,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),o())},onDragStart:x=>{x.dataTransfer&&(x.dataTransfer.effectAllowed="move"),s()},onDragEnter:u,onDragOver:x=>x.preventDefault(),onDrop:x=>{x.preventDefault(),v()},onDragEnd:c,children:[a.jsxs("div",{className:"ptab-body",children:[a.jsx("div",{className:"ptab-name",children:e.name}),a.jsx("div",{className:"ptab-meta",children:a.jsxs("span",{className:"ptab-counts mono",children:[m.open>0&&a.jsxs("span",{className:"ptab-pip",title:`${m.open} awaiting review`,children:[a.jsx("span",{className:"pip-dot pip-blue"}),m.open]}),m.verified>0&&a.jsxs("span",{className:"ptab-pip",title:`${m.verified} verified`,children:[a.jsx("span",{className:"pip-dot pip-green"}),m.verified]}),m.rejected>0&&a.jsxs("span",{className:"ptab-pip",title:`${m.rejected} rejected`,children:[a.jsx("span",{className:"pip-dot pip-red"}),m.rejected]}),m.open===0&&m.verified===0&&m.rejected===0&&a.jsxs("span",{className:"ptab-pip dim",children:[a.jsx("span",{className:"pip-dot pip-rest"}),"0"]})]})})]}),t&&n&&a.jsx("button",{className:"ptab-close","aria-label":`close ${e.name}`,onClick:x=>{x.stopPropagation(),i()},title:"close project",children:a.jsx("svg",{viewBox:"0 0 12 12",width:"10",height:"10",children:a.jsx("path",{d:"M3 3l6 6M9 3l-6 6",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})})]})}function Fv({projects:e,activeId:t,onSelect:n,onClose:r,onAdd:l,onReorder:o}){const[i,s]=U.useState(null),[u,c]=U.useState(null);return a.jsxs("div",{className:"ptab-strip",role:"tablist","aria-label":"projects",children:[a.jsxs("div",{className:"ptab-folder","aria-hidden":"true",children:[a.jsx("svg",{viewBox:"0 0 18 14",width:"14",height:"12",children:a.jsx("path",{d:"M1 3.5c0-.8.7-1.5 1.5-1.5h3.7c.5 0 1 .2 1.3.6L8.7 4H15.5c.8 0 1.5.7 1.5 1.5v6c0 .8-.7 1.5-1.5 1.5h-13C1.7 13 1 12.3 1 11.5v-8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})}),a.jsx("span",{className:"mono",children:"projects"})]}),a.jsx("div",{className:"ptab-list",children:e.map(v=>a.jsx(zv,{project:v,active:v.id===t,canClose:e.length>1,dragging:i===v.id,dragOver:u===v.id&&i!==null&&i!==v.id,onClick:()=>n(v.id),onClose:()=>r(v.id),onDragStart:()=>{s(v.id),c(v.id)},onDragEnter:()=>c(v.id),onDragEnd:()=>{s(null),c(null)},onDrop:()=>{if(i&&i!==v.id){const m=e.findIndex(p=>p.id===v.id);m>=0&&o(i,m)}s(null),c(null)}},v.id))}),a.jsx("button",{className:"ptab-add",onClick:l,"aria-label":"new project",title:"new project",children:a.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",children:a.jsx("path",{d:"M8 3v10M3 8h10",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})})})]})}function _c(e){if(!e)return"—";const t=new Date(e).getTime();if(Number.isNaN(t))return"—";const n=Math.max(1,Math.round((Date.now()-t)/6e4));if(n<60)return`${n}m ago`;const r=Math.round(n/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}const Ri={open:{label:"open",short:"needs review",color:"var(--c-blue)",bg:"var(--c-blue-bg)",rail:"var(--c-blue)",dotAnim:!1},verified:{label:"verified",short:"verified",color:"var(--c-green)",bg:"var(--c-green-bg)",rail:"var(--c-green)",dotAnim:!1},rejected:{label:"rejected",short:"rejected",color:"var(--c-red)",bg:"var(--c-red-bg)",rail:"var(--c-red)",dotAnim:!1}},Bv=["open","verified","rejected"];function Ta(e){return e&&Object.prototype.hasOwnProperty.call(Ri,e)?Ri[e]:Ri.open}function Nc({id:e,active:t,count:n,onClick:r}){const l=e==="all"?{label:"all",color:"var(--ink)"}:Ta(e);return a.jsxs("button",{className:`pill ${t?"is-active":""}`,style:{"--c":l.color},onClick:r,type:"button",children:[e!=="all"&&a.jsx("span",{className:"pill-dot"}),a.jsx("span",{className:"pill-label",children:l.label}),a.jsx("span",{className:"pill-count",children:n})]})}function Uv({title:e,filter:t,counts:n,onSetFilter:r}){return a.jsxs("div",{className:"filter-bar",children:[a.jsx("h1",{className:"filter-title",children:e}),a.jsxs("div",{className:"filter-pills",children:[a.jsx(Nc,{id:"all",active:t==="all",count:n.all,onClick:()=>r("all")}),a.jsx("span",{className:"pill-sep"}),Bv.map(l=>a.jsx(Nc,{id:l,active:t===l,count:n[l],onClick:()=>r(l)},l))]})]})}function $v({status:e,size:t="md"}){const n=Ta(e);return a.jsxs("span",{className:`status-badge size-${t}`,style:{"--c":n.color,"--bg":n.bg},"aria-label":`status: ${n.label}`,children:[a.jsx("span",{className:`status-dot ${n.dotAnim?"pulse":""}`}),n.label]})}function Wv({items:e}){return a.jsx("div",{className:"metrics",children:e.map((t,n)=>a.jsxs("div",{className:"metric",children:[a.jsx("div",{className:"metric-k",children:t.k}),a.jsx("div",{className:"metric-v",children:t.v}),t.d&&a.jsx("div",{className:"metric-d",children:t.d})]},`${t.k}-${n}`))})}const Hv="ffmpeg -i in.mp4 -c:v libx264 -pix_fmt yuv420p -movflags +faststart out.mp4";function Vv(e){return e.startsWith("/media")||e.includes("/media/")||e.startsWith("data:")}function Kv({video:e}){const[t,n]=U.useState(!1),r=!!(e.url&&e.url.length>0),l=r&&!Vv(e.url);return a.jsxs("div",{className:"video-slot",children:[r?a.jsx("video",{controls:!0,preload:"metadata",playsInline:!0,onError:()=>n(!0),style:{width:"100%",height:"auto",display:"block"},children:a.jsx("source",{src:e.url,type:e.mime||"video/mp4"})}):a.jsxs("div",{className:"video-placeholder","data-testid":"no-source-placeholder",children:[a.jsxs("svg",{viewBox:"0 0 100 56",preserveAspectRatio:"none",className:"video-bg",children:[a.jsx("defs",{children:a.jsxs("pattern",{id:"stripes",patternUnits:"userSpaceOnUse",width:"6",height:"6",patternTransform:"rotate(35)",children:[a.jsx("rect",{width:"6",height:"6",fill:"var(--paper-2)"}),a.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"6",stroke:"var(--rule)",strokeWidth:"1"})]})}),a.jsx("rect",{width:"100",height:"56",fill:"url(#stripes)"})]}),a.jsx("span",{className:"mono dim",children:"no source"})]}),t&&a.jsxs("div",{className:"video-error-banner",role:"alert",children:[a.jsx("span",{className:"mono dim",children:"Browser couldn't decode this video. Transcode with:"}),a.jsx("code",{children:Hv})]}),a.jsxs("div",{className:"video-meta",children:[a.jsx("span",{className:"mono",children:e.label}),a.jsx("span",{className:"mono dim",children:e.duration}),l&&a.jsx("span",{className:"video-external mono",title:e.url,children:"⚠ external — may drop"})]})]})}const Gv="modulepreload",Qv=function(e){return"/"+e},Cc={},Yv=function(t,n,r){let l=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),s=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));l=Promise.allSettled(n.map(u=>{if(u=Qv(u),u in Cc)return;Cc[u]=!0;const c=u.endsWith(".css"),v=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${v}`))return;const m=document.createElement("link");if(m.rel=c?"stylesheet":Gv,c||(m.as="script"),m.crossOrigin="",m.href=u,s&&m.setAttribute("nonce",s),document.head.appendChild(m),c)return new Promise((p,x)=>{m.addEventListener("load",p),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${u}`)))})}))}function o(i){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i}return l.then(i=>{for(const s of i||[])s.status==="rejected"&&o(s.reason);return t().catch(o)})};/*! @license DOMPurify 3.4.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.6/LICENSE */var Di,Tc;function Pc(){if(Tc)return Di;Tc=1;function e(_,T){(T==null||T>_.length)&&(T=_.length);for(var B=0,W=Array(T);B2?W-2:0),re=2;re1?B-1:0),Y=1;Y"u"?null:F(BigInt.prototype.toString),at=typeof Symbol>"u"?null:F(Symbol.prototype.toString),Q=F(Object.prototype.hasOwnProperty),L=F(Object.prototype.toString),R=F(RegExp.prototype.test),y=Z(TypeError);function F(_){return function(T){T instanceof RegExp&&(T.lastIndex=0);for(var B=arguments.length,W=new Array(B>1?B-1:0),Y=1;Y2&&arguments[2]!==void 0?arguments[2]:O;if(s&&s(_,null),!C(T))return _;let W=T.length;for(;W--;){let Y=T[W];if(typeof Y=="string"){const re=B(Y);re!==Y&&(u(T)||(T[W]=re),Y=re)}_[Y]=!0}return _}function fe(_){for(let T=0;T<_.length;T++)Q(_,T)||(_[T]=null);return _}function H(_){const T=x(null);for(const W of i(_)){var B=l(W,2);const Y=B[0],re=B[1];Q(_,Y)&&(C(re)?T[Y]=fe(re):re&&typeof re=="object"&&re.constructor===Object?T[Y]=H(re):T[Y]=re)}return T}function he(_){switch(typeof _){case"string":return _;case"number":return et(_);case"boolean":return Bt(_);case"bigint":return Nt?Nt(_):"0";case"symbol":return at?at(_):"Symbol()";case"undefined":return L(_);case"function":case"object":{if(_===null)return L(_);const T=_,B=ve(T,"toString");if(typeof B=="function"){const W=B(T);return typeof W=="string"?W:L(W)}return L(_)}default:return L(_)}}function ve(_,T){for(;_!==null;){const W=v(_,T);if(W){if(W.get)return F(W.get);if(typeof W.value=="function")return F(W.value)}_=c(_)}function B(){return null}return B}function Ge(_){try{return R(_,""),!0}catch{return!1}}const Ut=m(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Wo=m(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Ho=m(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),qf=m(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Vo=m(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),bf=m(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Aa=m(["#text"]),Oa=m(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),Ko=m(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Ma=m(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),sl=m(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ep=p(/{{[\w\W]*|^[\w\W]*}}/g),tp=p(/<%[\w\W]*|^[\w\W]*%>/g),np=p(/\${[\w\W]*/g),rp=p(/^data-[\-\w.\u00B7-\uFFFF]+$/),lp=p(/^aria-[\-\w]+$/),Ra=p(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),op=p(/^(?:\w+script|data):/i),ip=p(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sp=p(/^html$/i),ap=p(/^[a-z][.\w]*(-[.\w]+)+$/i),$t={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},up=function(){return typeof window>"u"?null:window},cp=function(T,B){if(typeof T!="object"||typeof T.createPolicy!="function")return null;let W=null;const Y="data-tt-policy-suffix";B&&B.hasAttribute(Y)&&(W=B.getAttribute(Y));const re="dompurify"+(W?"#"+W:"");try{return T.createPolicy(re,{createHTML(Te){return Te},createScriptURL(Te){return Te}})}catch{return console.warn("TrustedTypes policy "+re+" could not be created."),null}},Da=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ia(){let _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:up();const T=z=>Ia(z);if(T.version="3.4.6",T.removed=[],!_||!_.document||_.document.nodeType!==$t.document||!_.Element)return T.isSupported=!1,T;let B=_.document;const W=B,Y=W.currentScript;_.DocumentFragment;const re=_.HTMLTemplateElement,Te=_.Node,cr=_.Element,Qe=_.NodeFilter,dr=_.NamedNodeMap;dr===void 0&&(_.NamedNodeMap||_.MozNamedAttrMap),_.HTMLFormElement;const Go=_.DOMParser,al=_.trustedTypes,fn=cr.prototype,fp=ve(fn,"cloneNode"),pp=ve(fn,"remove"),mp=ve(fn,"nextSibling"),ul=ve(fn,"childNodes"),cl=ve(fn,"parentNode"),za=ve(fn,"shadowRoot"),hp=ve(fn,"attributes"),Wt=Te&&Te.prototype?ve(Te.prototype,"nodeType"):null,dl=Te&&Te.prototype?ve(Te.prototype,"nodeName"):null;if(typeof re=="function"){const z=B.createElement("template");z.content&&z.content.ownerDocument&&(B=z.content.ownerDocument)}let Me,fr="";const fl=B,Qo=fl.implementation,Fa=fl.createNodeIterator,vp=fl.createDocumentFragment,gp=fl.getElementsByTagName,yp=W.importNode;let Re=Da();T.isSupported=typeof i=="function"&&typeof cl=="function"&&Qo&&Qo.createHTMLDocument!==void 0;const pl=ep,ml=tp,hl=np,xp=rp,wp=lp,kp=op,Ba=ip,Sp=ap;let Ua=Ra,xe=null;const $a=D({},[...Ut,...Wo,...Ho,...Vo,...Aa]);let Ee=null;const Wa=D({},[...Oa,...Ko,...Ma,...sl]);let ce=Object.seal(x(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),pr=null,vl=null;const Ht=Object.seal(x(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ha=!0,Yo=!0,Va=!1,Ka=!0,Vt=!1,mr=!0,pn=!1,Xo=!1,Zo=!1,Ln=!1,gl=!1,yl=!1,Ga=!0,Qa=!1;const Ya="user-content-";let Jo=!0,hr=!1,An={},yt=null;const qo=D({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Xa=null;const Za=D({},["audio","video","img","source","image","track"]);let bo=null;const Ja=D({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),xl="http://www.w3.org/1998/Math/MathML",wl="http://www.w3.org/2000/svg",xt="http://www.w3.org/1999/xhtml";let On=xt,ei=!1,ti=null;const Ep=D({},[xl,wl,xt],I);let ni=D({},["mi","mo","mn","ms","mtext"]),ri=D({},["annotation-xml"]);const jp=D({},["title","style","font","a","script"]);let vr=null;const _p=["application/xhtml+xml","text/html"],Np="text/html";let pe=null,Mn=null;const Cp=B.createElement("form"),qa=function(d){return d instanceof RegExp||d instanceof Function},li=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Mn&&Mn===d)return;(!d||typeof d!="object")&&(d={}),d=H(d),vr=_p.indexOf(d.PARSER_MEDIA_TYPE)===-1?Np:d.PARSER_MEDIA_TYPE,pe=vr==="application/xhtml+xml"?I:O,xe=Q(d,"ALLOWED_TAGS")&&C(d.ALLOWED_TAGS)?D({},d.ALLOWED_TAGS,pe):$a,Ee=Q(d,"ALLOWED_ATTR")&&C(d.ALLOWED_ATTR)?D({},d.ALLOWED_ATTR,pe):Wa,ti=Q(d,"ALLOWED_NAMESPACES")&&C(d.ALLOWED_NAMESPACES)?D({},d.ALLOWED_NAMESPACES,I):Ep,bo=Q(d,"ADD_URI_SAFE_ATTR")&&C(d.ADD_URI_SAFE_ATTR)?D(H(Ja),d.ADD_URI_SAFE_ATTR,pe):Ja,Xa=Q(d,"ADD_DATA_URI_TAGS")&&C(d.ADD_DATA_URI_TAGS)?D(H(Za),d.ADD_DATA_URI_TAGS,pe):Za,yt=Q(d,"FORBID_CONTENTS")&&C(d.FORBID_CONTENTS)?D({},d.FORBID_CONTENTS,pe):qo,pr=Q(d,"FORBID_TAGS")&&C(d.FORBID_TAGS)?D({},d.FORBID_TAGS,pe):H({}),vl=Q(d,"FORBID_ATTR")&&C(d.FORBID_ATTR)?D({},d.FORBID_ATTR,pe):H({}),An=Q(d,"USE_PROFILES")?d.USE_PROFILES&&typeof d.USE_PROFILES=="object"?H(d.USE_PROFILES):d.USE_PROFILES:!1,Ha=d.ALLOW_ARIA_ATTR!==!1,Yo=d.ALLOW_DATA_ATTR!==!1,Va=d.ALLOW_UNKNOWN_PROTOCOLS||!1,Ka=d.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Vt=d.SAFE_FOR_TEMPLATES||!1,mr=d.SAFE_FOR_XML!==!1,pn=d.WHOLE_DOCUMENT||!1,Ln=d.RETURN_DOM||!1,gl=d.RETURN_DOM_FRAGMENT||!1,yl=d.RETURN_TRUSTED_TYPE||!1,Zo=d.FORCE_BODY||!1,Ga=d.SANITIZE_DOM!==!1,Qa=d.SANITIZE_NAMED_PROPS||!1,Jo=d.KEEP_CONTENT!==!1,hr=d.IN_PLACE||!1,Ua=Ge(d.ALLOWED_URI_REGEXP)?d.ALLOWED_URI_REGEXP:Ra,On=typeof d.NAMESPACE=="string"?d.NAMESPACE:xt,ni=Q(d,"MATHML_TEXT_INTEGRATION_POINTS")&&d.MATHML_TEXT_INTEGRATION_POINTS&&typeof d.MATHML_TEXT_INTEGRATION_POINTS=="object"?H(d.MATHML_TEXT_INTEGRATION_POINTS):D({},["mi","mo","mn","ms","mtext"]),ri=Q(d,"HTML_INTEGRATION_POINTS")&&d.HTML_INTEGRATION_POINTS&&typeof d.HTML_INTEGRATION_POINTS=="object"?H(d.HTML_INTEGRATION_POINTS):D({},["annotation-xml"]);const w=Q(d,"CUSTOM_ELEMENT_HANDLING")&&d.CUSTOM_ELEMENT_HANDLING&&typeof d.CUSTOM_ELEMENT_HANDLING=="object"?H(d.CUSTOM_ELEMENT_HANDLING):x(null);if(ce=x(null),Q(w,"tagNameCheck")&&qa(w.tagNameCheck)&&(ce.tagNameCheck=w.tagNameCheck),Q(w,"attributeNameCheck")&&qa(w.attributeNameCheck)&&(ce.attributeNameCheck=w.attributeNameCheck),Q(w,"allowCustomizedBuiltInElements")&&typeof w.allowCustomizedBuiltInElements=="boolean"&&(ce.allowCustomizedBuiltInElements=w.allowCustomizedBuiltInElements),Vt&&(Yo=!1),gl&&(Ln=!0),An&&(xe=D({},Aa),Ee=x(null),An.html===!0&&(D(xe,Ut),D(Ee,Oa)),An.svg===!0&&(D(xe,Wo),D(Ee,Ko),D(Ee,sl)),An.svgFilters===!0&&(D(xe,Ho),D(Ee,Ko),D(Ee,sl)),An.mathMl===!0&&(D(xe,Vo),D(Ee,Ma),D(Ee,sl))),Ht.tagCheck=null,Ht.attributeCheck=null,Q(d,"ADD_TAGS")&&(typeof d.ADD_TAGS=="function"?Ht.tagCheck=d.ADD_TAGS:C(d.ADD_TAGS)&&(xe===$a&&(xe=H(xe)),D(xe,d.ADD_TAGS,pe))),Q(d,"ADD_ATTR")&&(typeof d.ADD_ATTR=="function"?Ht.attributeCheck=d.ADD_ATTR:C(d.ADD_ATTR)&&(Ee===Wa&&(Ee=H(Ee)),D(Ee,d.ADD_ATTR,pe))),Q(d,"ADD_URI_SAFE_ATTR")&&C(d.ADD_URI_SAFE_ATTR)&&D(bo,d.ADD_URI_SAFE_ATTR,pe),Q(d,"FORBID_CONTENTS")&&C(d.FORBID_CONTENTS)&&(yt===qo&&(yt=H(yt)),D(yt,d.FORBID_CONTENTS,pe)),Q(d,"ADD_FORBID_CONTENTS")&&C(d.ADD_FORBID_CONTENTS)&&(yt===qo&&(yt=H(yt)),D(yt,d.ADD_FORBID_CONTENTS,pe)),Jo&&(xe["#text"]=!0),pn&&D(xe,["html","head","body"]),xe.table&&(D(xe,["tbody"]),delete pr.tbody),d.TRUSTED_TYPES_POLICY){if(typeof d.TRUSTED_TYPES_POLICY.createHTML!="function")throw y('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof d.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw y('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Me=d.TRUSTED_TYPES_POLICY,fr=Me.createHTML("")}else Me===void 0&&(Me=cp(al,Y)),Me!==null&&typeof fr=="string"&&(fr=Me.createHTML(""));m&&m(d),Mn=d},ba=D({},[...Wo,...Ho,...qf]),eu=D({},[...Vo,...bf]),Tp=function(d){let w=cl(d);(!w||!w.tagName)&&(w={namespaceURI:On,tagName:"template"});const A=O(d.tagName),J=O(w.tagName);return ti[d.namespaceURI]?d.namespaceURI===wl?w.namespaceURI===xt?A==="svg":w.namespaceURI===xl?A==="svg"&&(J==="annotation-xml"||ni[J]):!!ba[A]:d.namespaceURI===xl?w.namespaceURI===xt?A==="math":w.namespaceURI===wl?A==="math"&&ri[J]:!!eu[A]:d.namespaceURI===xt?w.namespaceURI===wl&&!ri[J]||w.namespaceURI===xl&&!ni[J]?!1:!eu[A]&&(jp[A]||!ba[A]):!!(vr==="application/xhtml+xml"&&ti[d.namespaceURI]):!1},ut=function(d){k(T.removed,{element:d});try{cl(d).removeChild(d)}catch{pp(d)}},mn=function(d,w){try{k(T.removed,{attribute:w.getAttributeNode(d),from:w})}catch{k(T.removed,{attribute:null,from:w})}if(w.removeAttribute(d),d==="is")if(Ln||gl)try{ut(w)}catch{}else try{w.setAttribute(d,"")}catch{}},tu=function(d){let w=null,A=null;if(Zo)d=""+d;else{const ae=K(d,/^[\r\n\t ]+/);A=ae&&ae[0]}vr==="application/xhtml+xml"&&On===xt&&(d=''+d+"");const J=Me?Me.createHTML(d):d;if(On===xt)try{w=new Go().parseFromString(J,vr)}catch{}if(!w||!w.documentElement){w=Qo.createDocument(On,"template",null);try{w.documentElement.innerHTML=ei?fr:J}catch{}}const q=w.body||w.documentElement;return d&&A&&q.insertBefore(B.createTextNode(A),q.childNodes[0]||null),On===xt?gp.call(w,pn?"html":"body")[0]:pn?w.documentElement:q},nu=function(d){return Fa.call(d.ownerDocument||d,d,Qe.SHOW_ELEMENT|Qe.SHOW_COMMENT|Qe.SHOW_TEXT|Qe.SHOW_PROCESSING_INSTRUCTION|Qe.SHOW_CDATA_SECTION,null)},ru=function(d){d.normalize();const w=Fa.call(d.ownerDocument||d,d,Qe.SHOW_TEXT|Qe.SHOW_COMMENT|Qe.SHOW_CDATA_SECTION|Qe.SHOW_PROCESSING_INSTRUCTION,null);let A=w.nextNode();for(;A;){let J=A.data;h([pl,ml,hl],q=>{J=$(J,q," ")}),A.data=J,A=w.nextNode()}},kl=function(d){const w=dl?dl(d):null;return typeof w!="string"||pe(w)!=="form"?!1:typeof d.nodeName!="string"||typeof d.textContent!="string"||typeof d.removeChild!="function"||d.attributes!==hp(d)||typeof d.removeAttribute!="function"||typeof d.setAttribute!="function"||typeof d.namespaceURI!="string"||typeof d.insertBefore!="function"||typeof d.hasChildNodes!="function"||d.childNodes!==ul(d)},oi=function(d){if(!Wt||typeof d!="object"||d===null)return!1;try{return Wt(d)===$t.documentFragment}catch{return!1}},Sl=function(d){if(!Wt||typeof d!="object"||d===null)return!1;try{return typeof Wt(d)=="number"}catch{return!1}};function Ct(z,d,w){h(z,A=>{A.call(T,d,w,Mn)})}const lu=function(d){let w=null;if(Ct(Re.beforeSanitizeElements,d,null),kl(d))return ut(d),!0;const A=pe(d.nodeName);if(Ct(Re.uponSanitizeElement,d,{tagName:A,allowedTags:xe}),mr&&d.hasChildNodes()&&!Sl(d.firstElementChild)&&R(/<[/\w!]/g,d.innerHTML)&&R(/<[/\w!]/g,d.textContent)||mr&&d.namespaceURI===xt&&A==="style"&&Sl(d.firstElementChild)||d.nodeType===$t.progressingInstruction||mr&&d.nodeType===$t.comment&&R(/<[/\w]/g,d.data))return ut(d),!0;if(pr[A]||!(Ht.tagCheck instanceof Function&&Ht.tagCheck(A))&&!xe[A]){if(!pr[A]&&iu(A)&&(ce.tagNameCheck instanceof RegExp&&R(ce.tagNameCheck,A)||ce.tagNameCheck instanceof Function&&ce.tagNameCheck(A)))return!1;if(Jo&&!yt[A]){const q=cl(d)||d.parentNode,ae=ul(d)||d.childNodes;if(ae&&q){const tt=ae.length;for(let wt=tt-1;wt>=0;--wt){const ct=fp(ae[wt],!0);q.insertBefore(ct,mp(d))}}}return ut(d),!0}return(Wt?Wt(d):d.nodeType)===$t.element&&!Tp(d)||(A==="noscript"||A==="noembed"||A==="noframes")&&R(/<\/no(script|embed|frames)/i,d.innerHTML)?(ut(d),!0):(Vt&&d.nodeType===$t.text&&(w=d.textContent,h([pl,ml,hl],q=>{w=$(w,q," ")}),d.textContent!==w&&(k(T.removed,{element:d.cloneNode()}),d.textContent=w)),Ct(Re.afterSanitizeElements,d,null),!1)},ou=function(d,w,A){if(vl[w]||Ga&&(w==="id"||w==="name")&&(A in B||A in Cp))return!1;const J=Ee[w]||Ht.attributeCheck instanceof Function&&Ht.attributeCheck(w,d);if(!(Yo&&!vl[w]&&R(xp,w))){if(!(Ha&&R(wp,w))){if(!J||vl[w]){if(!(iu(d)&&(ce.tagNameCheck instanceof RegExp&&R(ce.tagNameCheck,d)||ce.tagNameCheck instanceof Function&&ce.tagNameCheck(d))&&(ce.attributeNameCheck instanceof RegExp&&R(ce.attributeNameCheck,w)||ce.attributeNameCheck instanceof Function&&ce.attributeNameCheck(w,d))||w==="is"&&ce.allowCustomizedBuiltInElements&&(ce.tagNameCheck instanceof RegExp&&R(ce.tagNameCheck,A)||ce.tagNameCheck instanceof Function&&ce.tagNameCheck(A))))return!1}else if(!bo[w]){if(!R(Ua,$(A,Ba,""))){if(!((w==="src"||w==="xlink:href"||w==="href")&&d!=="script"&&Ce(A,"data:")===0&&Xa[d])){if(!(Va&&!R(kp,$(A,Ba,"")))){if(A)return!1}}}}}}return!0},Pp=D({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),iu=function(d){return!Pp[O(d)]&&R(Sp,d)},su=function(d){Ct(Re.beforeSanitizeAttributes,d,null);const w=d.attributes;if(!w||kl(d))return;const A={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ee,forceKeepAttr:void 0};let J=w.length;for(;J--;){const q=w[J],ae=q.name,tt=q.namespaceURI,wt=q.value,ct=pe(ae),si=wt;let we=ae==="value"?si:Be(si);if(A.attrName=ct,A.attrValue=we,A.keepAttr=!0,A.forceKeepAttr=void 0,Ct(Re.uponSanitizeAttribute,d,A),we=A.attrValue,Qa&&(ct==="id"||ct==="name")&&Ce(we,Ya)!==0&&(mn(ae,d),we=Ya+we),mr&&R(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,we)){mn(ae,d);continue}if(ct==="attributename"&&K(we,"href")){mn(ae,d);continue}if(A.forceKeepAttr)continue;if(!A.keepAttr){mn(ae,d);continue}if(!Ka&&R(/\/>/i,we)){mn(ae,d);continue}Vt&&h([pl,ml,hl],uu=>{we=$(we,uu," ")});const au=pe(d.nodeName);if(!ou(au,ct,we)){mn(ae,d);continue}if(Me&&typeof al=="object"&&typeof al.getAttributeType=="function"&&!tt)switch(al.getAttributeType(au,ct)){case"TrustedHTML":{we=Me.createHTML(we);break}case"TrustedScriptURL":{we=Me.createScriptURL(we);break}}if(we!==si)try{tt?d.setAttributeNS(tt,ae,we):d.setAttribute(ae,we),kl(d)?ut(d):g(T.removed)}catch{mn(ae,d)}}Ct(Re.afterSanitizeAttributes,d,null)},ii=function(d){let w=null;const A=nu(d);for(Ct(Re.beforeSanitizeShadowDOM,d,null);w=A.nextNode();)Ct(Re.uponSanitizeShadowNode,w,null),lu(w),su(w),oi(w.content)&&ii(w.content);Ct(Re.afterSanitizeShadowDOM,d,null)},El=function(d){if((Wt?Wt(d):d.nodeType)===$t.element){const q=za?za(d):d.shadowRoot;oi(q)&&(El(q),ii(q))}const A=ul?ul(d):d.childNodes;if(!A)return;const J=[];h(A,q=>{k(J,q)});for(const q of J)El(q)};return T.sanitize=function(z){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},w=null,A=null,J=null,q=null;if(ei=!z,ei&&(z=""),typeof z!="string"&&!Sl(z)&&(z=he(z),typeof z!="string"))throw y("dirty is not a string, aborting");if(!T.isSupported)return z;if(Xo||li(d),T.removed=[],typeof z=="string"&&(hr=!1),hr){const wt=dl?dl(z):z.nodeName;if(typeof wt=="string"){const ct=pe(wt);if(!xe[ct]||pr[ct])throw y("root node is forbidden and cannot be sanitized in-place")}if(kl(z))throw y("root node is clobbered and cannot be sanitized in-place");El(z)}else if(Sl(z))w=tu(""),A=w.ownerDocument.importNode(z,!0),A.nodeType===$t.element&&A.nodeName==="BODY"||A.nodeName==="HTML"?w=A:w.appendChild(A),El(A);else{if(!Ln&&!Vt&&!pn&&z.indexOf("<")===-1)return Me&&yl?Me.createHTML(z):z;if(w=tu(z),!w)return Ln?null:yl?fr:""}w&&Zo&&ut(w.firstChild);const ae=nu(hr?z:w);for(;J=ae.nextNode();)lu(J),su(J),oi(J.content)&&ii(J.content);if(hr)return Vt&&ru(z),z;if(Ln){if(Vt&&ru(w),gl)for(q=vp.call(w.ownerDocument);w.firstChild;)q.appendChild(w.firstChild);else q=w;return(Ee.shadowroot||Ee.shadowrootmode)&&(q=yp.call(W,q,!0)),q}let tt=pn?w.outerHTML:w.innerHTML;return pn&&xe["!doctype"]&&w.ownerDocument&&w.ownerDocument.doctype&&w.ownerDocument.doctype.name&&R(sp,w.ownerDocument.doctype.name)&&(tt=" +`+tt),Vt&&h([pl,ml,hl],wt=>{tt=$(tt,wt," ")}),Me&&yl?Me.createHTML(tt):tt},T.setConfig=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};li(z),Xo=!0},T.clearConfig=function(){Mn=null,Xo=!1},T.isValidAttribute=function(z,d,w){Mn||li({});const A=pe(z),J=pe(d);return ou(A,J,w)},T.addHook=function(z,d){typeof d=="function"&&k(Re[z],d)},T.removeHook=function(z,d){if(d!==void 0){const w=f(Re[z],d);return w===-1?void 0:S(Re[z],w,1)[0]}return g(Re[z])},T.removeHooks=function(z){Re[z]=[]},T.removeAllHooks=function(){Re=Da()},T}var dp=Ia();return Di=dp,Di}var Xv=self.DOMPurify||(self.DOMPurify=Pc().default||Pc());const Zv=Oc(Xv);function Jv(e){return e.replace(/&/g,"&").replace(//g,">")}function qv(e){const t=e.trim();return/^(https?:|mailto:|\/|#)/i.test(t)}function Tt(e){let t=Jv(e);return t=t.replace(/`([^`]+)`/g,"$1"),t=t.replace(/\*\*([^*]+)\*\*/g,"$1"),t=t.replace(/(^|\W)\*([^*\n]+)\*(?=\W|$)/g,"$1$2"),t=t.replace(/_([^_\n]+)_/g,"$1"),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(n,r,l)=>qv(l)?`${r}`:r),t}function Zf(e){const t=(e||"").split(` +`),n=[];let r=0;for(;r${Tt(l.slice(5))}`),r++;continue}if(l.startsWith("### ")){n.push(`

${Tt(l.slice(4))}

`),r++;continue}if(l.startsWith("## ")){n.push(`

${Tt(l.slice(3))}

`),r++;continue}if(l.startsWith("# ")){n.push(`

${Tt(l.slice(2))}

`),r++;continue}if(l.startsWith("#")){n.push(`

${Tt(l)}

`),r++;continue}if(l.trim()==="---"||l.trim()==="***"){n.push("
"),r++;continue}if(l.startsWith("> ")){const i=[];for(;r ");)i.push(Tt(t[r].slice(2))),r++;n.push(`
${i.join("
")}
`);continue}if(/^[-*]\s/.test(l)){const i=[];for(;r${Tt(t[r].replace(/^[-*]\s/,""))}`),r++;n.push(`
    ${i.join("")}
`);continue}if(/^\d+\.\s/.test(l)){const i=[];for(;r${Tt(t[r].replace(/^\d+\.\s/,""))}`),r++;n.push(`
    ${i.join("")}
`);continue}const o=[];for(;r ")&&!/^[-*]\s/.test(t[r])&&!/^\d+\.\s/.test(t[r]);)o.push(Tt(t[r])),r++;n.push(`

${o.join("
")}

`)}return n.join("")}function bv(e){return Zv.sanitize(e,{USE_PROFILES:{svg:!0,svgFilters:!0}})}function eg({visual:e}){return e.kind==="data"?a.jsx(tg,{visual:e}):e.kind==="vega"?a.jsx(og,{visual:e}):e.kind==="svg"?a.jsx(ig,{source:e.source}):a.jsx(ug,{visual:e})}function tg({visual:e}){return e.chart==="line"?a.jsx(ng,{series:e.series}):e.chart==="sweep"?a.jsx(rg,{series:e.series}):a.jsx(lg,{series:e.series})}function ng({series:e}){const t=Pa(e);if(t.length===0)return La();const n=t.map(m=>m.x),r=t.map(m=>m.y),l=Math.min(...n),o=Math.max(...n),i=Math.min(...r),s=Math.max(...r),u=m=>32+(m-l)/Math.max(1e-9,o-l)*280,c=m=>92-(m-i)/Math.max(1e-9,s-i)*78,v=t.map((m,p)=>`${p===0?"M":"L"} ${u(m.x)} ${c(m.y)}`).join(" ");return a.jsxs("svg",{viewBox:"0 0 320 110",className:"chart",children:[a.jsx("defs",{children:a.jsxs("linearGradient",{id:"gloss-line",x1:"0",y1:"0",x2:"0",y2:"1",children:[a.jsx("stop",{offset:"0%",stopColor:"var(--c-green)",stopOpacity:"0.18"}),a.jsx("stop",{offset:"100%",stopColor:"var(--c-green)",stopOpacity:"0"})]})}),a.jsx("line",{x1:"32",y1:"92",x2:"312",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("line",{x1:"32",y1:"14",x2:"32",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("path",{d:v,fill:"none",stroke:"var(--c-green)",strokeWidth:"2"}),a.jsx("path",{d:`${v} L 312 92 L 32 92 Z`,fill:"url(#gloss-line)"})]})}function rg({series:e}){const t=Pa(e);if(t.length===0)return La();const n=t.map(p=>p.x),r=t.map(p=>p.y),l=Math.min(...n),o=Math.max(...n),i=Math.min(...r),s=Math.max(...r),u=p=>32+(p-l)/Math.max(1e-9,o-l)*280,c=p=>92-(p-i)/Math.max(1e-9,s-i)*78,v=r.indexOf(Math.max(...r)),m=t.map(p=>`${u(p.x)} ${c(p.y)}`).map((p,x)=>x===0?`M ${p}`:`L ${p}`).join(" ");return a.jsxs("svg",{viewBox:"0 0 320 110",className:"chart",children:[a.jsx("line",{x1:"32",y1:"92",x2:"312",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("line",{x1:"32",y1:"14",x2:"32",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("path",{d:m,fill:"none",stroke:"var(--c-blue)",strokeWidth:"2"}),t.map((p,x)=>a.jsx("circle",{cx:u(p.x),cy:c(p.y),r:x===v?5:3.2,fill:x===v?"var(--c-blue)":"var(--paper)",stroke:"var(--c-blue)",strokeWidth:"2"},x))]})}function lg({series:e}){const t=Pa(e);if(t.length===0)return La();const n=t.map(o=>o.y),r=Math.max(...n,1),l=280/t.length;return a.jsxs("svg",{viewBox:"0 0 320 110",className:"chart",children:[a.jsx("line",{x1:"32",y1:"92",x2:"312",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("line",{x1:"32",y1:"14",x2:"32",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),t.map((o,i)=>{const s=o.y/r*78,u=32+i*l+2;return a.jsx("rect",{x:u,y:92-s,width:Math.max(2,l-4),height:s,fill:"var(--c-blue)",opacity:.7},i)})]})}function Pa(e){return!Array.isArray(e)||e.length===0?[]:e.map((t,n)=>{const r=hn(t.x)??hn(t.step)??hn(t.k)??n,l=hn(t.y)??hn(t.value)??hn(t.v)??hn(t.loss)??0;return{x:r,y:l}}).filter(t=>Number.isFinite(t.x)&&Number.isFinite(t.y))}function hn(e){if(typeof e=="number")return e;if(typeof e=="string"){const t=parseFloat(e);return Number.isFinite(t)?t:null}return null}function La(){return a.jsxs("svg",{viewBox:"0 0 320 110",className:"chart",children:[a.jsx("line",{x1:"32",y1:"92",x2:"312",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("line",{x1:"32",y1:"14",x2:"32",y2:"92",stroke:"var(--rule)",strokeWidth:"1"}),a.jsx("text",{x:"160",y:"60",textAnchor:"middle",className:"chart-tick",children:"no data"})]})}function og({visual:e}){const t=U.useRef(null),[n,r]=U.useState(null);return U.useEffect(()=>{let l=!1;return(async()=>{try{const o=await Yv(()=>import("./embed-S92vvM1_.js"),[]);if(l||!t.current)return;await o.default(t.current,e.spec,{actions:!1,theme:"dark"})}catch(o){r(o.message)}})(),()=>{l=!0}},[e.spec]),n?a.jsxs("div",{className:"dim mono",children:["vega error: ",n]}):a.jsx("div",{className:"vega-host",ref:t})}function ig({source:e}){const t=bv(e);return a.jsx("div",{className:"svg-visual",dangerouslySetInnerHTML:{__html:t}})}const sg=[' + + + +
+ + From f92fa3159f04cfb74e6458ce7a74d49a9517e484 Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:26:53 -0700 Subject: [PATCH 09/11] local: cron keepalive recipe for always-on field-notes serve deploy/local-keepalive.sh: relaunches a downed local server (crash/reboot/never -started), flock-guarded, crash output preserved in server.log. Wire via cron @reboot + every-2-min. Resolves the binary from FIELD_NOTES_BIN/PATH so it works for any self-hoster, not just this machine. --- deploy/local-keepalive.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 deploy/local-keepalive.sh diff --git a/deploy/local-keepalive.sh b/deploy/local-keepalive.sh new file mode 100755 index 0000000..2d64a10 --- /dev/null +++ b/deploy/local-keepalive.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# Keep a local `field-notes serve` up. Designed for cron: +# @reboot /path/to/local-keepalive.sh +# */2 * * * * /path/to/local-keepalive.sh +# If the server is down (crash, reboot, never started) it relaunches it detached. +# A lock prevents racing launches; crash output is kept in server.log so a real +# bug stays visible instead of being silently resurrected. +set -u +export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$HOME/.local/bin" + +PORT="${FIELD_NOTES_PORT:-8000}" +DATA_DIR="${FIELD_NOTES_DATA_DIR:-$HOME/.field-notes}" +# Resolve the field-notes binary: explicit override, else PATH, else fail loud. +BIN="${FIELD_NOTES_BIN:-$(command -v field-notes || true)}" + +LOCK="$DATA_DIR/.keepalive.lock"; KLOG="$DATA_DIR/keepalive.log"; SLOG="$DATA_DIR/server.log" +mkdir -p "$DATA_DIR" +exec 9>"$LOCK"; flock -n 9 || exit 0 +ts() { date '+%Y-%m-%d %H:%M:%S'; } + +if [ -z "$BIN" ]; then echo "[$(ts)] field-notes binary not found (set FIELD_NOTES_BIN)" >> "$KLOG"; exit 1; fi +if curl -fsS --max-time 5 "http://127.0.0.1:$PORT/healthz" >/dev/null 2>&1; then exit 0; fi + +echo "[$(ts)] server not healthy on :$PORT — relaunching" >> "$KLOG" +setsid nohup "$BIN" serve --host 127.0.0.1 --port "$PORT" --data-dir "$DATA_DIR" --no-browser >> "$SLOG" 2>&1 & +echo "[$(ts)] launched pid $! (logging to $SLOG)" >> "$KLOG" From 2c55f62f0acf03ddd044c3cadd74291444b3b190 Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:41:44 -0700 Subject: [PATCH 10/11] local: import-db connects to remote Postgres over TLS (Heroku/RDS) _engine_for() adds asyncpg ssl=require for non-loopback Postgres hosts so import-db can pull from a hosted DB (Heroku won't accept a non-TLS connection); loopback Postgres + SQLite stay plaintext. Verified against live Heroku: pulled 7 projects / 170 cells / 69 verdicts / 1751 events. --- apps/api/field_notes_api/transfer.py | 26 +++++++++++++++++++-- apps/api/tests/test_local_transfer.py | 33 +++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/apps/api/field_notes_api/transfer.py b/apps/api/field_notes_api/transfer.py index 59a6fc3..e391a4e 100644 --- a/apps/api/field_notes_api/transfer.py +++ b/apps/api/field_notes_api/transfer.py @@ -20,10 +20,14 @@ from sqlalchemy import func, select, text +from sqlalchemy.engine import make_url +from sqlalchemy.ext.asyncio import create_async_engine + from .db import _build_engine from .models import Base _TARBALL_URL = re.compile(r"https://\S+?\.tar\.gz") +_LOCAL_HOSTS = {"localhost", "127.0.0.1", "::1", "", None} def _to_async_url(url: str) -> str: @@ -37,6 +41,24 @@ def _to_async_url(url: str) -> str: return url +def _needs_ssl(async_url: str) -> bool: + """Remote Postgres (Heroku/RDS) requires TLS; loopback/SQLite does not.""" + if not async_url.startswith("postgresql"): + return False + return make_url(async_url).host not in _LOCAL_HOSTS + + +def _engine_for(url: str): + """Engine for a transfer endpoint. SQLite reuses the app's _build_engine + (WAL/FK pragmas); remote Postgres adds asyncpg TLS (Heroku won't connect + without it).""" + async_url = _to_async_url(url) + if async_url.startswith("sqlite"): + return _build_engine(async_url) + connect_args = {"ssl": "require"} if _needs_ssl(async_url) else {} + return create_async_engine(async_url, future=True, pool_pre_ping=True, connect_args=connect_args) + + async def _read_revision(conn) -> str | None: # noqa: ANN001 — AsyncConnection try: return (await conn.execute(text("SELECT version_num FROM alembic_version"))).scalar() @@ -50,8 +72,8 @@ async def import_db(source_url: str, dest_url: str, *, overwrite: bool = False) Raises if the two DBs are at different Alembic revisions (column drift would silently drop data) or if dest is non-empty and overwrite is False. """ - src = _build_engine(_to_async_url(source_url)) - dst = _build_engine(_to_async_url(dest_url)) + src = _engine_for(source_url) + dst = _engine_for(dest_url) try: async with src.connect() as sc: src_rev = await _read_revision(sc) diff --git a/apps/api/tests/test_local_transfer.py b/apps/api/tests/test_local_transfer.py index 919c43e..6f17e20 100644 --- a/apps/api/tests/test_local_transfer.py +++ b/apps/api/tests/test_local_transfer.py @@ -94,6 +94,39 @@ async def test_import_db_guards_nonempty_dest(tmp_path): assert counts["projects"] == 1 # overwrite replaces, not appends +# --- remote Postgres needs TLS (Heroku/RDS) ------------------------------- + + +def test_needs_ssl_true_for_remote_postgres(): + assert transfer._needs_ssl("postgresql+asyncpg://u:p@abc.rds.amazonaws.com:5432/db") is True + + +@pytest.mark.parametrize( + "url", + [ + "postgresql+asyncpg://u:p@localhost:5432/db", + "postgresql+asyncpg://u:p@127.0.0.1:5432/db", + "sqlite+aiosqlite:///x.db", + ], +) +def test_needs_ssl_false_for_local_or_sqlite(url): + assert transfer._needs_ssl(url) is False + + +def test_engine_for_remote_postgres_sets_ssl(monkeypatch): + captured = {} + + def fake_create(url, **kw): + captured["url"] = str(url) + captured["connect_args"] = kw.get("connect_args") + return "engine" + + monkeypatch.setattr(transfer, "create_async_engine", fake_create) + transfer._engine_for("postgres://u:p@host.rds.amazonaws.com:5432/db") + assert captured["connect_args"] == {"ssl": "require"} + assert captured["url"].startswith("postgresql+asyncpg://") + + # --- media tarball URL parsing -------------------------------------------- From e6deaa4f7cdd3561f33930b3131aa2b54419e5c1 Mon Sep 17 00:00:00 2001 From: themikulrai <152346781+themikulrai@users.noreply.github.com> Date: Fri, 26 Jun 2026 23:26:36 -0700 Subject: [PATCH 11/11] local: document AFS/cron HOME gotcha in keepalive recipe cron's getpwuid HOME can differ from interactive HOME (AFS) and be unreadable without a token, which breaks the lock/data-dir. Document setting HOME + FIELD_NOTES_DATA_DIR to an absolute path in the crontab. --- deploy/local-keepalive.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/deploy/local-keepalive.sh b/deploy/local-keepalive.sh index 2d64a10..64d5b63 100755 --- a/deploy/local-keepalive.sh +++ b/deploy/local-keepalive.sh @@ -5,6 +5,13 @@ # If the server is down (crash, reboot, never started) it relaunches it detached. # A lock prevents racing launches; crash output is kept in server.log so a real # bug stays visible instead of being silently resurrected. +# +# NOTE on networked-home machines (e.g. AFS): cron's $HOME comes from getpwuid +# and may differ from your interactive $HOME (and be unreadable without a token). +# Set FIELD_NOTES_DATA_DIR (and ideally HOME) to an absolute, always-readable +# path in the crontab so the lock/db/media don't land on an inaccessible home: +# HOME=/abs/home +# FIELD_NOTES_DATA_DIR=/abs/home/.field-notes set -u export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$HOME/.local/bin"